TBGRABitmap text functions

From Free Pascal wiki
Jump to navigationJump to search

English (en)


Here are the text functions the TBGRABitmap class.


Font name and style

  
  property FontName: string; read write;

Specifies the font to use. Unless the font renderer accept otherwise, the name is in human readable form, like 'Arial', 'Times New Roman', ...

  property FontStyle: TFontStyles; read write;

Specifies the set of styles to be applied to the font. These can be fsBold, fsItalic, fsStrikeOut, fsUnderline. So the value [fsBold,fsItalic] means that the font must be bold and italic.

  property FontOrientation: integer; read write;

Specifies the rotation of the text, for functions that support text rotation. It is expressed in tenth of degrees, positive values going counter-clockwise.

  property FontHeight: integer; read write;

Specifies the height of the font without taking into account additional line spacing. A negative value means that it is the full height instead (see below).

  property FontFullHeight: integer; read write;

Specifies the height of the font, taking into account the additional line spacing defined for the font.

Note: additional styles may be specified with the font renderer (see below).

Font quality

  property FontQuality : TBGRAFontQuality; read write;

Specifies the quality of rendering. The following values are possible :

- fqSystem: use system rendering. It is fast however it may be not be smoothed.

- fqSystemClearType: use system rendering with ClearType. This quality is of course better than fqSystem however it may not be much smoother.

- fqFineAntialiasing: garanties a high quality antialiasing. This is slower.

- fqFineClearTypeRGB: garanties a high quality antialiasing with ClearType. The order of the color in the LCD screen is supposed to be un red/green/blue order.

- fqFineClearTypeBGR: same as above, except the color of the LCD screen is supposed to be in blue/green/red order.

  property FontAntialias: Boolean; read write;

Simplified version to specify the quality.

  property FontRenderer: TBGRACustomFontRenderer; read write;

Specifies the font renderer. By default it is an instance of TLCLFontRenderer of unit BGRAText. Other renderers are provided in BGRATextFX unit and BGRAVectorize unit. Once you assign a renderer, it will automatically be freed. The renderers may provide additional styling for the font. See font rendering.

Drawing

  procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel; align: TAlignment);

Draws the UTF8 encoded string, with color c. If align is taLeftJustify, (x,y) is the top-left corner. If align is taCenter, (x,y) is at the top and middle of the text. If align is taRightJustify, (x,y) is the top-right corner. The value of FontOrientation is taken into account, so that the text may be rotated.

  procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner; align: TAlignment);

Same as above functions, except that the text is filled using texture. The value of FontOrientation is taken into account, so that the text may be rotated.

  procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; c: TBGRAPixel; align: TAlignment);
  procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; texture: IBGRAScanner; align: TAlignment);

Same as above, except that the orientation is specified, overriding the value of the property FontOrientation.

  procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel);
  procedure TextOut(x, y: single; sUTF8: string; c: TColor);
  procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner);

Draw the UTF8 encoded string, (x,y) being the top-left corner. The color c or texture is used to fill the text. The value of FontOrientation is taken into account, so that the text may be rotated.

  procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; c: TBGRAPixel);
  procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; texture: IBGRAScanner);

Draw the UTF8 encoded string at the coordinate (x,y), clipped inside the rectangle ARect. Additional style information is provided by the style parameter. The color c or texture is used to fill the text. No rotation is applied.

  procedure TextRect(ARect: TRect; sUTF8: string; halign: TAlignment; valign: TTextLayout; c: TBGRAPixel);
  procedure TextRect(ARect: TRect; sUTF8: string; halign: TAlignment; valign: TTextLayout; texture: IBGRAScanner);

Draw the UTF8 encoded string in the rectangle ARect. Text is wrapped if necessary. The position depends on the specified horizontal alignment halign and vertical alignement valign. The color c or texture is used to fill the text. No rotation is applied.

See text functions tutorial.

Measuring

  function TextSize(sUTF8: string): TSize;

Returns the total size of the string provided using the current font. Orientation is not taken into account, so that the width is along the text.

  property FontPixelMetric: TFontPixelMetric;

Returns measurement for the current font in pixels.