Difference between revisions of "TBGRABitmap text functions"

From Free Pascal wiki
Jump to navigationJump to search
(Categorization)
m (Fixed syntax highlighting; deleted category included in page template)
 
Line 1: Line 1:
 +
{{TBGRABitmap_text_functions}}
 +
 +
 
Here are the text functions the [[TBGRABitmap class|TBGRABitmap]] class.
 
Here are the text functions the [[TBGRABitmap class|TBGRABitmap]] class.
 +
  
 
=== Font name and style ===
 
=== Font name and style ===
<syntaxhighlight>  property FontName: string; read write;</syntaxhighlight>
+
 
 +
<syntaxhighlight lang=pascal>   
 +
  property FontName: string; read write;
 +
</syntaxhighlight>
 +
 
 
Specifies the font to use. Unless the font renderer accept otherwise, the name is in human readable form, like 'Arial', 'Times New Roman', ...
 
Specifies the font to use. Unless the font renderer accept otherwise, the name is in human readable form, like 'Arial', 'Times New Roman', ...
<syntaxhighlight> property FontStyle: TFontStyles; read write;</syntaxhighlight>
+
 
 +
<syntaxhighlight lang=pascal>
 +
  property FontStyle: TFontStyles; read write;</syntaxhighlight>
 
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.
 
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.
<syntaxhighlight> property FontOrientation: integer; read write;</syntaxhighlight>
+
 
 +
<syntaxhighlight lang=pascal>
 +
  property FontOrientation: integer; read write;
 +
</syntaxhighlight>
 +
 
 
Specifies the rotation of the text, for functions that support text rotation. It is expressed in tenth of degrees, positive values going counter-clockwise.
 
Specifies the rotation of the text, for functions that support text rotation. It is expressed in tenth of degrees, positive values going counter-clockwise.
<syntaxhighlight> property FontHeight: integer; read write;</syntaxhighlight>
+
 
 +
<syntaxhighlight lang=pascal>
 +
  property FontHeight: integer; read write;
 +
</syntaxhighlight>
 +
 
 
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).
 
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).
<syntaxhighlight> property FontFullHeight: integer; read write;</syntaxhighlight>
+
 
 +
<syntaxhighlight lang=pascal>
 +
  property FontFullHeight: integer; read write;
 +
</syntaxhighlight>
 +
 
 
Specifies the height of the font, taking into account the additional line spacing defined for the font.
 
Specifies the height of the font, taking into account the additional line spacing defined for the font.
  
Line 16: Line 38:
  
 
=== Font quality ===
 
=== Font quality ===
<syntaxhighlight> property FontQuality : TBGRAFontQuality; read write;</syntaxhighlight>
+
 
 +
<syntaxhighlight lang=pascal>
 +
  property FontQuality : TBGRAFontQuality; read write;
 +
</syntaxhighlight>
 +
 
 
Specifies the quality of rendering. The following values are possible :
 
Specifies the quality of rendering. The following values are possible :
  
Line 29: Line 55:
 
- ''fqFineClearTypeBGR'': same as above, except the color of the LCD screen is supposed to be in blue/green/red order.
 
- ''fqFineClearTypeBGR'': same as above, except the color of the LCD screen is supposed to be in blue/green/red order.
  
<syntaxhighlight> property FontAntialias: Boolean; read write;</syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 +
  property FontAntialias: Boolean; read write;
 +
</syntaxhighlight>
 +
 
 
Simplified version to specify the quality.
 
Simplified version to specify the quality.
  
<syntaxhighlight> property FontRenderer: TBGRACustomFontRenderer; read write;</syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 +
  property FontRenderer: TBGRACustomFontRenderer; read write;
 +
</syntaxhighlight>
 +
 
 
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 '''[[BGRABitmap tutorial Font rendering|font rendering]]'''.
 
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 '''[[BGRABitmap tutorial Font rendering|font rendering]]'''.
  
 
=== Drawing ===
 
=== Drawing ===
  
<syntaxhighlight> procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel; align: TAlignment);</syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 +
  procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel; align: TAlignment);
 +
</syntaxhighlight>
 +
 
 
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.
 
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.
<syntaxhighlight> procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner; align: TAlignment);</syntaxhighlight>
+
 
 +
<syntaxhighlight lang=pascal>
 +
  procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner; align: TAlignment);
 +
</syntaxhighlight>
 +
 
 
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.
 
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.
<syntaxhighlight> 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);</syntaxhighlight>
+
<syntaxhighlight lang=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);
 +
</syntaxhighlight>
 +
 
 
Same as above, except that the orientation is specified, overriding the value of the property ''FontOrientation''.
 
Same as above, except that the orientation is specified, overriding the value of the property ''FontOrientation''.
<syntaxhighlight> procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel);
+
 
 +
<syntaxhighlight lang=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; c: TColor);
   procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner);</syntaxhighlight>
+
   procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner);
 +
</syntaxhighlight>
 +
 
 
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.
 
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.
<syntaxhighlight> 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);</syntaxhighlight>
+
<syntaxhighlight lang=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);
 +
</syntaxhighlight>
 +
 
 
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.
 
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.
<syntaxhighlight>   procedure TextRect(ARect: TRect; sUTF8: string; halign: TAlignment; valign: TTextLayout; c: TBGRAPixel);
+
 
 +
<syntaxhighlight lang=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);</syntaxhighlight>
 
   procedure TextRect(ARect: TRect; sUTF8: string; halign: TAlignment; valign: TTextLayout; texture: IBGRAScanner);</syntaxhighlight>
 +
 
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.
 
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.
  
Line 59: Line 113:
 
=== Measuring ===
 
=== Measuring ===
  
<syntaxhighlight> function TextSize(sUTF8: string): TSize;</syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 +
  function TextSize(sUTF8: string): TSize;
 +
</syntaxhighlight>
 +
 
 
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.
 
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.
<syntaxhighlight> property FontPixelMetric: TFontPixelMetric;</syntaxhighlight>
+
 
 +
<syntaxhighlight lang=pascal>
 +
  property FontPixelMetric: TFontPixelMetric;
 +
</syntaxhighlight>
 +
 
 
Returns measurement for the current font in pixels.
 
Returns measurement for the current font in pixels.
 
[[Category: BGRABitmap]]
 

Latest revision as of 05:47, 29 February 2020

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.