Wiki copymirror

This is a mirror of the wiki at pascal.chat. Editing, history and sign-in are there.

TBGRABitmap text functions

Here are the text functions the TBGRABitmap class.

Font name and style

pascal
  
  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', ...

pascal
  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.

pascal
  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.

pascal
  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).

pascal
  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

pascal
  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.

pascal
  property FontAntialias: Boolean; read write;

Simplified version to specify the quality.

pascal
  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

pascal
  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.

pascal
  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.

pascal
  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.

pascal
  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.

pascal
  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.

pascal
  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

pascal
  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.

pascal
  property FontPixelMetric: TFontPixelMetric;

Returns measurement for the current font in pixels.


From the Free Pascal wiki, page "TBGRABitmap text functions", as it stood on 2020-02-29 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .