TBGRABitmap text functions: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: TBGRABitmap text functions
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Here are the text functions the [[TBGRABitmap class|TBGRABitmap]] class. | |
| 2 | + | ||
| 3 | + | ### Font name and style | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 6 | + | ||
| 7 | + | property FontName: string; read write; | |
| 8 | + | ``` | |
| 9 | + | ||
| 10 | + | Specifies the font to use. Unless the font renderer accept otherwise, the name is in human readable form, like 'Arial', 'Times New Roman', ... | |
| 11 | + | ||
| 12 | + | ``` pascal | |
| 13 | + | property FontStyle: TFontStyles; read write; | |
| 14 | + | ``` | |
| 15 | + | ||
| 16 | + | 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. | |
| 17 | + | ||
| 18 | + | ``` pascal | |
| 19 | + | property FontOrientation: integer; read write; | |
| 20 | + | ``` | |
| 21 | + | ||
| 22 | + | Specifies the rotation of the text, for functions that support text rotation. It is expressed in tenth of degrees, positive values going counter-clockwise. | |
| 23 | + | ||
| 24 | + | ``` pascal | |
| 25 | + | property FontHeight: integer; read write; | |
| 26 | + | ``` | |
| 27 | + | ||
| 28 | + | 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). | |
| 29 | + | ||
| 30 | + | ``` pascal | |
| 31 | + | property FontFullHeight: integer; read write; | |
| 32 | + | ``` | |
| 33 | + | ||
| 34 | + | Specifies the height of the font, taking into account the additional line spacing defined for the font. | |
| 35 | + | ||
| 36 | + | Note: additional styles may be specified with the font renderer (see below). | |
| 37 | + | ||
| 38 | + | ### Font quality | |
| 39 | + | ||
| 40 | + | ``` pascal | |
| 41 | + | property FontQuality : TBGRAFontQuality; read write; | |
| 42 | + | ``` | |
| 43 | + | ||
| 44 | + | Specifies the quality of rendering. The following values are possible : | |
| 45 | + | ||
| 46 | + | \- *fqSystem*: use system rendering. It is fast however it may be not be smoothed. | |
| 47 | + | ||
| 48 | + | \- *fqSystemClearType*: use system rendering with ClearType. This quality is of course better than *fqSystem* however it may not be much smoother. | |
| 49 | + | ||
| 50 | + | \- *fqFineAntialiasing*: garanties a high quality antialiasing. This is slower. | |
| 51 | + | ||
| 52 | + | \- *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. | |
| 53 | + | ||
| 54 | + | \- *fqFineClearTypeBGR*: same as above, except the color of the LCD screen is supposed to be in blue/green/red order. | |
| 55 | + | ||
| 56 | + | ``` pascal | |
| 57 | + | property FontAntialias: Boolean; read write; | |
| 58 | + | ``` | |
| 59 | + | ||
| 60 | + | Simplified version to specify the quality. | |
| 61 | + | ||
| 62 | + | ``` pascal | |
| 63 | + | property FontRenderer: TBGRACustomFontRenderer; read write; | |
| 64 | + | ``` | |
| 65 | + | ||
| 66 | + | 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]]**. | |
| 67 | + | ||
| 68 | + | ### Drawing | |
| 69 | + | ||
| 70 | + | ``` pascal | |
| 71 | + | procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel; align: TAlignment); | |
| 72 | + | ``` | |
| 73 | + | ||
| 74 | + | 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. | |
| 75 | + | ||
| 76 | + | ``` pascal | |
| 77 | + | procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner; align: TAlignment); | |
| 78 | + | ``` | |
| 79 | + | ||
| 80 | + | 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. | |
| 81 | + | ||
| 82 | + | ``` pascal | |
| 83 | + | procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; c: TBGRAPixel; align: TAlignment); | |
| 84 | + | procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; texture: IBGRAScanner; align: TAlignment); | |
| 85 | + | ``` | |
| 86 | + | ||
| 87 | + | Same as above, except that the orientation is specified, overriding the value of the property *FontOrientation*. | |
| 88 | + | ||
| 89 | + | ``` pascal | |
| 90 | + | procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel); | |
| 91 | + | procedure TextOut(x, y: single; sUTF8: string; c: TColor); | |
| 92 | + | procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner); | |
| 93 | + | ``` | |
| 94 | + | ||
| 95 | + | 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. | |
| 96 | + | ||
| 97 | + | ``` pascal | |
| 98 | + | procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; c: TBGRAPixel); | |
| 99 | + | procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; texture: IBGRAScanner); | |
| 100 | + | ``` | |
| 101 | + | ||
| 102 | + | 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. | |
| 103 | + | ||
| 104 | + | ``` pascal | |
| 105 | + | procedure TextRect(ARect: TRect; sUTF8: string; halign: TAlignment; valign: TTextLayout; c: TBGRAPixel); | |
| 106 | + | procedure TextRect(ARect: TRect; sUTF8: string; halign: TAlignment; valign: TTextLayout; texture: IBGRAScanner); | |
| 107 | + | ``` | |
| 108 | + | ||
| 109 | + | 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. | |
| 110 | + | ||
| 111 | + | See **[[BGRABitmap tutorial 12|text functions tutorial]]**. | |
| 112 | + | ||
| 113 | + | ### Measuring | |
| 114 | + | ||
| 115 | + | ``` pascal | |
| 116 | + | function TextSize(sUTF8: string): TSize; | |
| 117 | + | ``` | |
| 118 | + | ||
| 119 | + | 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. | |
| 120 | + | ||
| 121 | + | ``` pascal | |
| 122 | + | property FontPixelMetric: TFontPixelMetric; | |
| 123 | + | ``` | |
| 124 | + | ||
| 125 | + | Returns measurement for the current font in pixels. | |
| 126 | + | ||
| 127 | + | --- | |
| 128 | + | *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](/wiki-contact).* |
