Class TTextureFontData

Unit

Declaration

type TTextureFontData = class(TObject)

Description

Data for a 2D font initialized from a FreeType font file, like ttf.

Hierarchy

  • TObject
  • TTextureFontData

Overview

Nested Classes and Records

Public TGlyph = class(TObject)
Public TGlyphDictionary = class(specialize TDictionary<TUnicodeChar,TGlyph>)

Methods

Public constructor Create(const AUrl: String; const ASize: Cardinal; const AnAntiAliased: Boolean; ACharacters: TUnicodeCharList = nil; const ADistanceField: Boolean = false);
Public constructor CreateFromData(const AGlyphs: TGlyphDictionary; const AImage: TGrayscaleImage; const ASize: Cardinal; const AnAntiAliased: Boolean);
Public destructor Destroy; override;
Public function Glyph(const C: TUnicodeChar; const AllowUsingFallbackGlyph: Boolean = true): TGlyph;
Public function LoadedGlyphs: TUnicodeCharList;
Public function TextWidth(const S: string): Integer;
Public function TextHeight(const S: string): Integer;
Public function TextHeightBase(const S: string): Integer;
Public function TextMove(const S: string): TVector2Integer;
Public function GlyphDrawImageRect(const G: TTextureFontData.TGlyph): TRectangle;

Properties

Public property Url: String read FUrl;
Public property Size: Cardinal read FSize;
Public property AntiAliased: Boolean read FAntiAliased;
Public property UseFallbackGlyph: Boolean read FUseFallbackGlyph write FUseFallbackGlyph default true;
Public property Image: TGrayscaleImage read FImage;
Public property DistanceField: Boolean read FDistanceField;

Description

Methods

Public constructor Create(const AUrl: String; const ASize: Cardinal; const AnAntiAliased: Boolean; ACharacters: TUnicodeCharList = nil; const ADistanceField: Boolean = false);

Create by reading a FreeType font file, like ttf.

Providing charaters list as Nil means that we only create glyphs for SimpleAsciiCharacters, which includes only the basic ASCII characters. The ACharacters instance does not become owned by this object, so remember to free it after calling this constructor.

Exceptions raised
EFreeTypeLibraryNotFound
If the freetype library is not installed.
Public constructor CreateFromData(const AGlyphs: TGlyphDictionary; const AImage: TGrayscaleImage; const ASize: Cardinal; const AnAntiAliased: Boolean);

Create from a ready data for glyphs and image. Useful when font data is embedded inside the Pascal source code. AGlyphs instance, and AImage instance, become owned by this class.

Public destructor Destroy; override;

This item has no description.

Public function Glyph(const C: TUnicodeChar; const AllowUsingFallbackGlyph: Boolean = true): TGlyph;

Read-only information about a glyph for given character.

When AllowUsingFallbackGlyph and UseFallbackGlyph (both are True by default) then we always return non-nil glyph. If the desired glyph was not really present, we make a warning (using WritelnWarning) and return a fallback glyph.

When not (AllowUsingFallbackGlyph and UseFallbackGlyph) then we return Nil for a missing glyph. Glyph may be missing because it was not requested at constructor, or because it doesn't exist in the font data.

Public function LoadedGlyphs: TUnicodeCharList;

List all characters for which glyphs are actually loaded. Glyph will answer non-nil exactly for these characters. The resulting list instance is owned by caller, so take care to free it.

Public function TextWidth(const S: string): Integer;

This item has no description.

Public function TextHeight(const S: string): Integer;

This item has no description.

Public function TextHeightBase(const S: string): Integer;

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

Public function TextMove(const S: string): TVector2Integer;

This item has no description.

Public function GlyphDrawImageRect(const G: TTextureFontData.TGlyph): TRectangle;

Rect of the glyph in the image, without the additional padding added when rendering with distance field fonts.

To get the full rect of the glyph in the image, with padding, use G.ImageX, G.ImageY, G.Width, G.Height.

Properties

Public property Url: String read FUrl;

This item has no description.

Public property Size: Cardinal read FSize;

This item has no description.

Public property AntiAliased: Boolean read FAntiAliased;

This item has no description.

Public property UseFallbackGlyph: Boolean read FUseFallbackGlyph write FUseFallbackGlyph default true;

When a glyph (picture of a particular character) in a font doesn't exist, by default we make a warning (using WritelnWarning) and use a fallback glyph, like "?". This lets user know that some character is there.

Set this to False to just silently omit a missing glyph. The Glyph method will just return (silently) Nil in this case.

Public property Image: TGrayscaleImage read FImage;

This item has no description.

Public property DistanceField: Boolean read FDistanceField;

Is the font prepared for distance field rendering.


Generated by PasDoc 0.16.0-snapshot.