Class TCastleFont
Unit
CastleFonts
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
Fields
Methods
 |
constructor Create(AOwner: TComponent); overload; override; |
 |
destructor Destroy; override; |
 |
function PropertySections(const PropertyName: String): TPropertySections; override; |
 |
function FontLoaded: Boolean; overload; override; |
 |
constructor Create(const URL: String; const ASize: Cardinal; const AnAntiAliased: Boolean; const ACharacters: TUnicodeCharList = nil); reintroduce; overload; deprecated 'use Create(Owner: TComponent), then assign properties to load font: OptimalSize, LoadCharacters, AntiAliased, URL'; |
 |
constructor Create(const URL: String; const ASize: Cardinal; const AnAntiAliased: Boolean; const ACharacters: TSetOfChars); reintroduce; overload; deprecated 'use Create(Owner: TComponent), then assign properties to load font: OptimalSize, LoadCharacters, AntiAliased, URL'; |
 |
procedure Load(const URL: String; const ASize: Cardinal; const AnAntiAliased: Boolean; const ACharacters: TUnicodeCharList = nil; const AdjustProperties: Boolean = true); overload; deprecated 'assign properties to load font: OptimalSize, LoadCharacters, AntiAliased, URL'; |
 |
procedure Load(const Data: TTextureFontData; const OwnsData: Boolean = false; const AdjustProperties: Boolean = true); overload; |
 |
procedure PrepareResources; override; |
 |
procedure Print(const X, Y: Single; const Color: TCastleColor; const S: string); override; |
 |
function TextWidth(const S: string): Single; override; |
 |
function TextHeight(const S: string): Single; override; |
 |
function TextHeightBase(const S: string): Single; override; |
 |
function TextMove(const S: string): TVector2; override; |
Properties
 |
property FontData: TTextureFontData read FFont; deprecated 'you should not need to use this directly'; |
 |
property Scale: Single read GetScale write SetScale; |
 |
property URL: String read FURL write SetURL; |
 |
property OptimalSize: Cardinal read FOptimalSize write SetOptimalSize default DefaultOptimalSize; |
 |
property AntiAliased: Boolean read FAntiAliased write SetAntiAliased default true; |
 |
property LoadBasicCharacters: Boolean read FLoadBasicCharacters write SetLoadBasicCharacters default true; |
 |
property LoadCharacters: String read FLoadCharacters write SetLoadCharacters; |
Description
Fields
 |
nested const DefaultOptimalSize = 20; |
|
Methods
 |
constructor Create(AOwner: TComponent); overload; override; |
|
 |
destructor Destroy; override; |
|
 |
function FontLoaded: Boolean; overload; override; |
|
 |
constructor Create(const URL: String; const ASize: Cardinal; const AnAntiAliased: Boolean; const ACharacters: TUnicodeCharList = nil); reintroduce; overload; deprecated 'use Create(Owner: TComponent), then assign properties to load font: OptimalSize, LoadCharacters, AntiAliased, URL'; |
Warning: this symbol is deprecated: use Create(Owner: TComponent), then assign properties to load font: OptimalSize, LoadCharacters, AntiAliased, URL |
 |
constructor Create(const URL: String; const ASize: Cardinal; const AnAntiAliased: Boolean; const ACharacters: TSetOfChars); reintroduce; overload; deprecated 'use Create(Owner: TComponent), then assign properties to load font: OptimalSize, LoadCharacters, AntiAliased, URL'; |
Warning: this symbol is deprecated: use Create(Owner: TComponent), then assign properties to load font: OptimalSize, LoadCharacters, AntiAliased, URL |
 |
procedure Load(const URL: String; const ASize: Cardinal; const AnAntiAliased: Boolean; const ACharacters: TUnicodeCharList = nil; const AdjustProperties: Boolean = true); overload; deprecated 'assign properties to load font: OptimalSize, LoadCharacters, AntiAliased, URL'; |
Warning: this symbol is deprecated: assign properties to load font: OptimalSize, LoadCharacters, AntiAliased, URL
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.
|
 |
procedure Load(const Data: TTextureFontData; const OwnsData: Boolean = false; const AdjustProperties: Boolean = true); overload; |
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.
- AdjustProperties
- Adjust URL, OptimalSize, Size, AntiAliased to reflect loaded Data. Or reset them to reflect empty URL (and the rest at defaults) when Data = nil.
|
 |
procedure PrepareResources; override; |
|
 |
procedure Print(const X, Y: Single; const Color: TCastleColor; const S: string); override; |
|
 |
function TextWidth(const S: string): Single; override; |
|
 |
function TextHeight(const S: string): Single; override; |
|
 |
function TextHeightBase(const S: string): Single; override; |
|
 |
function TextMove(const S: string): TVector2; override; |
|
Properties
 |
property FontData: TTextureFontData read FFont; deprecated 'you should not need to use this directly'; |
Warning: this symbol is deprecated: you should not need to use this directly
Underlying font data.
|
 |
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.
|
 |
property OptimalSize: Cardinal read FOptimalSize write SetOptimalSize default DefaultOptimalSize; |
Optimal font size (in real device pixels), the font will be scaled when other size is actually needed. This also sets default Size used for rendering this font.
|
 |
property AntiAliased: Boolean read FAntiAliased write SetAntiAliased default true; |
Anti-aliased font has smooth edges and is rendered using blending. Usually this is much better for quality. Non-anti-aliased means that font uses simple yes/no transparency and is rendered using alpha testing.
|
 |
property LoadBasicCharacters: Boolean read FLoadBasicCharacters write SetLoadBasicCharacters default true; |
Load from font all "basic" characters, which include digits, English letters and standard ASCII symbols. See SimpleAsciiCharacters for exact definition. These are loaded in addition to characters listed on LoadCharacters.
|
 |
property LoadCharacters: String read FLoadCharacters write SetLoadCharacters; |
Load from font all characters listed here. As everywhere in CGE (same as in Lazarus LCL), this is an string composed from UTF-8 characters.
|
Generated by PasDoc 0.16.0.