Class TCastleFont

Unit

Declaration

type TCastleFont = class(TCastleAbstractFont)

Description

Font loaded from a font file, like ttf or otf. This class is typically used for outline (scalable, vector) fonts in ttf or otf formats. But it can really deal with any font supported by the FreeType library, even bitmap fonts, see the summary of font formats supported by FreeType.

This can load a font file, or it can use ready data in TTextureFontData. The latter allows to use this for fonts embedded in a Pascal source code, since our texture-font-to-pascal can convert a font file to a unit that defines ready TTextureFontData instance.

Hierarchy

Overview

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public constructor Create(const URL: string; const ASize: Integer; const AnAntiAliased: boolean; const ACharacters: TUnicodeCharList = nil); reintroduce; deprecated 'use Create(Owner: TComponent), then Load';
Public constructor Create(const URL: string; const ASize: Integer; const AnAntiAliased: boolean; const ACharacters: TSetOfChars); deprecated 'use Create(Owner: TComponent), then Load';
Public procedure Load(const URL: string; const ASize: Integer; const AnAntiAliased: boolean; const ACharacters: TUnicodeCharList = nil);
Public procedure Load(const Data: TTextureFontData; const OwnsData: boolean = false);
Public procedure PrepareResources; override;
Public procedure Print(const X, Y: Single; const Color: TCastleColor; const S: string); override;
Public function TextWidth(const S: string): Single; override;
Public function TextHeight(const S: string): Single; override;
Public function TextHeightBase(const S: string): Single; override;
Public function TextMove(const S: string): TVector2; override;

Properties

Public property FontData: TTextureFontData read FFont;
Public property Scale: Single read GetScale write SetScale;

Description

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public constructor Create(const URL: string; const ASize: Integer; const AnAntiAliased: boolean; const ACharacters: TUnicodeCharList = nil); reintroduce; deprecated 'use Create(Owner: TComponent), then Load';

Warning: this symbol is deprecated: use Create(Owner: TComponent), then Load

 
Public constructor Create(const URL: string; const ASize: Integer; const AnAntiAliased: boolean; const ACharacters: TSetOfChars); deprecated 'use Create(Owner: TComponent), then Load';

Warning: this symbol is deprecated: use Create(Owner: TComponent), then Load

 
Public procedure Load(const URL: string; const ASize: Integer; const AnAntiAliased: boolean; const ACharacters: TUnicodeCharList = nil);

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

Loading a font data also changes Size to the underlying (optimal to render) font data size.

Public procedure Load(const Data: TTextureFontData; const OwnsData: boolean = false);

Load from a ready TTextureFontData instance.

Parameters
Data
TTextureFontData instance containing loaded image and glyphs parameters.
OwnsData
If True, the Data instance becomes owned by this class (will be freed in our constructor). Usually you do not want this, since usually you pass Data from a unit generated by texture-font-to-pascal. In this case, the finalization of CastleTextureFont_Xxx unit will already free the TTextureFontData instance.
Public procedure PrepareResources; override;
 
Public procedure Print(const X, Y: Single; const Color: TCastleColor; const S: string); override;
 
Public function TextWidth(const S: string): Single; override;
 
Public function TextHeight(const S: string): Single; override;
 
Public function TextHeightBase(const S: string): Single; override;
 
Public function TextMove(const S: string): TVector2; override;
 

Properties

Public property FontData: TTextureFontData read FFont;

Underlying font data.

Public property Scale: Single read GetScale write SetScale;

Scale applied to the rendered font, compared to FontData.Size. Changing this is equivalent to changing the Size property.


Generated by PasDoc 0.16.0.