Reference TFont
Declared in Codebot.Render.Fonts.pas on line 36
TFont loads a TrueType font and renders its glyphs at a fixed pixel size into a texture atlas. The atlas contains the printable ASCII and Latin-1 characters. Glyphs are white with coverage stored in alpha, so they can be tinted by vertex color.
TFont = class(TContextManagedObject)
public
{ Create a font from a TrueType file rendered at a size in pixels }
constructor Create(const FileName: string; Size: Float = 48);
{ Create a font from a stream containing a TrueType file }
constructor CreateFromStream(Stream: TStream; Size: Float = 48);
destructor Destroy; override;
{ Find the glyph for a unicode codepoint, returning a fallback glyph when
the font atlas does not contain it }
function FindGlyph(Codepoint: Integer): PFontGlyph;
{ The kerning adjustment in font pixels between two glyphs }
function Kerning(A, B: PFontGlyph): Float;
{ Measure the width of the widest line and the height of all lines of text
in font pixels }
function Measure(const Text: string): TVec2;
{ Add the glyph quads for text to a buffer which was started with
BeginBuffer(vertQuads). The text is laid out with y pointing up, X and Y
being the top left of the first line, and one font pixel being Scale
units. Line breaks start a new line. }
procedure AddText(Buffer: TColorTexVertexBuffer; const Text: string; X, Y, Scale: Float; const Color: TVec4);
{ The pixel height the font was rendered at }
property Size: Float read FSize;
{ The distance in font pixels from the baseline to the top of the font }
property Ascent: Float read FAscent;
{ The distance in font pixels from the baseline to the bottom of the font }
property Descent: Float read FDescent;
{ The distance in font pixels between baselines of lines of text }
property LineHeight: Float read FLineHeight;
{ The texture atlas holding the font glyphs }
property Texture: TTexture read FTexture;
end;See also
Float in Codebot.System.pas
TColorTexVertexBuffer in Codebot.Render.Buffers.pas
TContextManagedObject in Codebot.Render.Contexts.pas
TTexture in Codebot.Render.Textures.pas
TVec2 in Codebot.Geometry.pas
TVec4 in Codebot.Geometry.pas