Castle Game Engine: CastleGLBitmapFonts: Class TGLBitmapFontAbstract

# Class TGLBitmapFontAbstract
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleGLBitmapFonts ## Declaration `type TGLBitmapFontAbstract = class(TObject)` ## Description Abstract class for all OpenGL bitmap fonts. ## Hierarchy TObject TGLBitmapFontAbstract ## Overview ### Methods
| `procedure PrintAndMove(const s: string); virtual; abstract;`
| `procedure Print(const s: string);`
| `function TextWidth(const s: string): integer; virtual; abstract;`
| `function TextHeight(const s: string): integer; virtual; abstract;`
| `function TextHeightBase(const s: string): integer; virtual; abstract;`
| `function Descend: integer; virtual;`
| `procedure BreakLines(const unbroken: string; broken: TStrings; maxLineWidth: integer); overload;`
| `procedure BreakLines(unbroken, broken: TStrings; maxLineWidth: integer); overload;`
| `procedure BreakLines(broken: TStrings; maxLineWidth: integer; FirstToBreak: integer); overload;`
| `function MaxTextWidth(SList: TStringList; const Tags: boolean = false): integer;`
| `procedure PrintStrings(strs: TStrings; const Tags: boolean; BonusVerticalSpace: TGLint; const X0: Integer = 0; const Y0: Integer = 0; const PositionAsRaster: boolean = true); overload;`
| `procedure PrintStrings(const Strs: array of string; const Tags: boolean; BonusVerticalSpace: TGLint; const X0: Integer = 0; const Y0: Integer = 0; const PositionAsRaster: boolean = true); overload;`
| `function PrintBrokenString(const s: string; MaxLineWidth, X0, Y0: Integer; PositionsFirst: boolean; BonusVerticalSpace: Integer; const PositionAsRaster: boolean = true): Integer;`
| `procedure PrintStringsBox(const Strs: array of string; const Tags: boolean; BonusVerticalSpace: TGLint; const InsideCol, BorderCol, TextCol: TVector4f; BoxPixelMargin: integer) overload; deprecated;`
| `procedure PrintStringsBox(Strs: TStringList; const Tags: boolean; BonusVerticalSpace: TGLint; const InsideCol, BorderCol, TextCol: TVector4f; BoxPixelMargin: integer) overload; deprecated;`
| `procedure PrintStringsBox(const Strs: array of string; const Tags: boolean; const X0, Y0: Integer; BonusVerticalSpace: TGLint; const InsideCol, BorderCol, TextCol: TVector4f; BoxPixelMargin: integer); overload;`
| `procedure PrintStringsBox(Strs: TStringList; const Tags: boolean; const X0, Y0: Integer; BonusVerticalSpace: TGLint; const InsideCol, BorderCol, TextCol: TVector4f; BoxPixelMargin: integer); overload;`
### Properties
| `property RowHeight: integer read FRowHeight;`
| `property RowHeightBase: Integer read FRowHeightBase;`
## Description ### Methods
| `procedure PrintAndMove(const s: string); virtual; abstract;`
Draw text at the current OpenGL raster position, and move the raster position at the end. This way you can immediately call another `PrintAndMove` again, to add something at the end. May require 1 free slot on the attributes stack. May only be called when current matrix is modelview. Doesn't modify any OpenGL state or matrix, except it moves raster position.
| `procedure Print(const s: string);`
Draw text at the current OpenGL raster position. In contrast to PrintAndMove, raster position is not changed. May require 1 free slot on the attributes stack. May only be called when current matrix is modelview. Doesn't modify any OpenGL state or matrix.
| `function TextWidth(const s: string): integer; virtual; abstract;`
| `function TextHeight(const s: string): integer; virtual; abstract;`
| `function TextHeightBase(const s: string): integer; virtual; abstract;`
The height (above the baseline) of the text. This doesn't take into account height of the text below the baseline (for example letter "y" has the tail below the baseline in most fonts).
| `function Descend: integer; virtual;`
How low the text may go below the baseline. By default this returns `TextHeight('y')-TextHeight('a')`, which is suitable for normal fonts.
| `procedure BreakLines(const unbroken: string; broken: TStrings; maxLineWidth: integer); overload;`
Break lines (possibly break one long string into more strings) to fit the text with given MaxLineWidth. This takes into account current font information (works also for non-monospace fonts, of course), and converts your Unbroken text into Broken text, such that TextWidth of the longest Broken line fits within MaxLineWidth. Tries to break on white characters. If not possible (there's a long stream of non-white characters that really has to be broken), it will break in the middle of normal (non-white) characters. The only situation when we have to fail, and the resulting Broken text is wider than required MaxLineWidth, is when a single character in your font is wider than MaxLineWidth. In such case, there's really no solution, and we'll just let such character stay. If you use the overloaded version where Unbroken is just a string, then note that already existing newlines (NL) inside Unbroken will be correctly preserved. If you use the overloaded version with separate Unbroken and Broken parameters, then the previous Broken contents are not modified. We only append to Broken new strings, coming from Unbroken text. The overloaded version that takes only Broken parameter (no Unbroken parameter) simply modifies it's Broken parameter (from the line FirstToBreak).
| `procedure BreakLines(unbroken, broken: TStrings; maxLineWidth: integer); overload;`
| `procedure BreakLines(broken: TStrings; maxLineWidth: integer; FirstToBreak: integer); overload;`
| `function MaxTextWidth(SList: TStringList; const Tags: boolean = false): integer;`
Largest width of the line of text in given list. ###### Parameters Tags Indicates that strings inside SList use HTML-like tags, the same as interpreted by PrintStrings. If your SList uses these tags (for example, you plan to call later PrintStrings with the same SList and Tags = `True`) then make sure you pass Tags = `True` to this method. Otherwise, `MaxTextWidth` will treat tags text (like `<font ...>`) like a normal text, usually making the width incorrectly large.
| `procedure PrintStrings(strs: TStrings; const Tags: boolean; BonusVerticalSpace: TGLint; const X0: Integer = 0; const Y0: Integer = 0; const PositionAsRaster: boolean = true); overload;`
Print all strings from the list. X0, Y0 is the bottom-left position of the whole text block (that is, it is the bottom-left position of the last string). Distance between each line is (RowHeight + BonusVerticalSpace) pixels. If PositionAsRaster is `True` (this is default, for backwards compatibility) then the (X0, Y0) position is interpreted as OpenGL raster 2D position (so it is transformed by modelview matrix and such). For new code, we advice using PositionAsRaster = `False`, as this will ease future transitions to OpenGL versions >= 3. Note that BonusVerticalSpace can be < 0 (as well as > 0), this may be sometimes useful if you really want to squeeze more text into some size. Still, make sure that (RowHeight + BonusVerticalSpace) is > 0. Previous OpenGL raster position value will be ignored and then modified by this method. May require 1 free slot on the attributes stack. May only be called when current matrix is modelview. Doesn't modify any OpenGL state or matrix, except it moves raster position. ###### Parameters Tags Enable some HTML-like tags to mark font changes inside the text. For now, these can only be used to surround whole lines (so you have to place opening tag at the beginnig of line, and closing tag at the end of line). For now, the only tag handled is `<font color="#rrggbb">` that changes line color to specified RGB. Also, we handle `<font color="#rrggbbaa">` where the last component is alpha (opacity), and when it's < 1 then we render using blending. Close with `</font>`. This functionality may be enhanced in the future (feature requests and patches welcome). Don't expect full HTML implementation inside, but some small set of useful tags may be doable and comfortable to use. Not necessarily replicating some (old version of) HTML standard.
| `procedure PrintStrings(const Strs: array of string; const Tags: boolean; BonusVerticalSpace: TGLint; const X0: Integer = 0; const Y0: Integer = 0; const PositionAsRaster: boolean = true); overload;`
| `function PrintBrokenString(const s: string; MaxLineWidth, X0, Y0: Integer; PositionsFirst: boolean; BonusVerticalSpace: Integer; const PositionAsRaster: boolean = true): Integer;`
Print the string, broken such that it fits within MaxLineWidth. The string is broken into many lines using BreakLines, so the original newlines insides are correctly used, and the length of lines fits inside MaxLineWidth. The strings are printed on the screen, just like by PrintStrings (with Tags = always false for now, since our string breaking cannot omit tags). If PositionsFirst then the X0, Y0 determine the position of the first (top) line, otherwise they determine the position of the last (bottom) line. BonusVerticalSpace has the same meaning as for PrintStrings: it adds an additional space between lines (if positive) or forces the lines to be more tightly squeezed (if negative). Always make sure that (RowHeight + BonusVerticalSpace) > 0. Returns the number of lines printed, that is the number of lines after breaking the text into lines. This may be useful e.g. to calculate the height of the printed text. May require 1 free slot on the attributes stack. May only be called when current matrix is modelview. Doesn't modify any OpenGL state or matrix.
| `procedure PrintStringsBox(const Strs: array of string; const Tags: boolean; BonusVerticalSpace: TGLint; const InsideCol, BorderCol, TextCol: TVector4f; BoxPixelMargin: integer) overload; deprecated;`
Warning: this symbol is deprecated. Print all strings from the list, and draw a box with frames around it. The text is printed like by PrintStrings. For the deprecated overloaded versions without X0, Y0: the position of the text and box is determined by the current modelview matrix. The left-bottom box corner is at raster position 0, 0. The current raster position when this method is called doesn't matter. So your only way to move this box is to modify modelview matrix. For the new overloaded versions with X0, Y0: the X0, Y0 give explicitly the left-bottom box corner (in window coordinates, i.e. applied with SetWindowPos). BonusVerticalSpace has the same interpretation as for PrintStrings: additional space between lines (if positive) or forces the lines to be more tightly squeezed (if negative). Always make sure that (RowHeight + BonusVerticalSpace) > 0. The box background inside has color InsideCol. The box frame has color BorderCol. The text has color TextCol. BoxPixelMargin is the distance (in pixels) between text and the box frame. We assume that moving by 1 in modelview matrix is equal to moving 1 pixel. In other words, we assume you have normal 2D orthographic projection with the dimensions equal to pixel dimensions. May require 1 free slot on the attributes stack. May only be called when current matrix is modelview. Doesn't modify any OpenGL state or matrix, except it modifies the raster position.
| `procedure PrintStringsBox(Strs: TStringList; const Tags: boolean; BonusVerticalSpace: TGLint; const InsideCol, BorderCol, TextCol: TVector4f; BoxPixelMargin: integer) overload; deprecated;`
Warning: this symbol is deprecated.
| `procedure PrintStringsBox(const Strs: array of string; const Tags: boolean; const X0, Y0: Integer; BonusVerticalSpace: TGLint; const InsideCol, BorderCol, TextCol: TVector4f; BoxPixelMargin: integer); overload;`
| `procedure PrintStringsBox(Strs: TStringList; const Tags: boolean; const X0, Y0: Integer; BonusVerticalSpace: TGLint; const InsideCol, BorderCol, TextCol: TVector4f; BoxPixelMargin: integer); overload;`
### Properties
| `property RowHeight: integer read FRowHeight;`
Height of a row of text in this font. This may be calculated as simply `TextHeight('Wy')` for most normal fonts.
| `property RowHeightBase: Integer read FRowHeightBase;`
Height (above the baseline) of a row of text in this font. Similar to TextHeightBase and TextHeight, note that `RowHeightBase` is generally smaller than RowHeight, because `RowHeightBase` doesn't care how low the letter may go below the baseline.
Generated by PasDoc 0.13.0 on 2013-08-17 21:27:12