Class TCastleBitmapFont
Unit
Declaration
type TCastleBitmapFont = class(TCastleAbstractFont)
Description
Bitmap font, where each character is just drawn (and may be multi-color) on a raster image. See https://en.wikipedia.org/wiki/Computer_font about "bitmap font" or (less common name, but more valid) "raster font".
By default this class makes some assumptions about how the font image looks like: the characters are placed on the image in their Unicode order, starting from space in the upper-left corner. TODO: Use OnGlyph event to customize it.
Examples of such fonts:
See examples/fonts/data/sonic_asalga_0.png in CGE examples.
From OpenGameArt: http://opengameart.org/content/sonic-font, http://opengameart.org/content/null-terminator .
From itch.io: https://itch.io/game-assets/tag-bitmap-font .
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleAbstractFont
- TCastleBitmapFont
Overview
Methods
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
procedure Load(const AImage: TCastleImage; const AImageColumns, AImageRows, AImageMargin: Cardinal; const ADisplayMargin: Single); deprecated 'assign properties to load font: ImageUrl, ImageColumns, ImageRows, ImageMargin and (only for display) DisplayMargin'; |
|
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; |
|
function FontLoaded: Boolean; override; |
Properties
property ImageUrl: String read FImageUrl write SetImageUrl; |
|
property ImageColumns: Cardinal read FImageColumns write SetImageColumns default 8; |
|
property ImageRows: Cardinal read FImageRows write SetImageRows default 8; |
|
property ImageMargin: Cardinal read FImageMargin write SetImageMargin default 0; |
|
property DisplayMargin: Single read FDisplayMargin write SetDisplayMargin default 2; |
Description
Methods
constructor Create(AOwner: TComponent); override; |
|
This item has no description. |
destructor Destroy; override; |
|
This item has no description. |
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. |
procedure Load(const AImage: TCastleImage; const AImageColumns, AImageRows, AImageMargin: Cardinal; const ADisplayMargin: Single); deprecated 'assign properties to load font: ImageUrl, ImageColumns, ImageRows, ImageMargin and (only for display) DisplayMargin'; |
|
Warning: this symbol is deprecated: assign properties to load font: ImageUrl, ImageColumns, ImageRows, ImageMargin and (only for display) DisplayMargin Load font from given image. Parameters
|
procedure PrepareResources; override; |
|
This item has no description. Showing description inherited from TCastleAbstractFont.PrepareResources.
The font may require some OpenGL resources for drawing. You can explicitly create them using |
procedure Print(const X, Y: Single; const Color: TCastleColor; const S: string); override; |
|
This item has no description. Showing description inherited from TCastleAbstractFont.Print. Draw text at the given position with given color. If the last Color component is not 1, the text is rendered with blending. Overloaded version without X, Y uses WindowPos (but doesn't modify it, in contrast to PrintAndMove). Overloaded version without Color uses CurrentColor, last color set by glColorv. It is not adviced to use overloaded versions without X, Y or Color — using global state leads to messy code. You should upgrade your code to use the version that gets X,Y,Color explicitly. 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. |
function TextWidth(const S: string): Single; override; |
|
This item has no description. |
function TextHeight(const S: string): Single; override; |
|
This item has no description. |
function TextHeightBase(const S: string): Single; override; |
|
This item has no description. Showing description inherited from TCastleAbstractFont.TextHeightBase. 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 TextMove(const S: string): TVector2; override; |
|
This item has no description. |
function FontLoaded: Boolean; override; |
|
This item has no description. Showing description inherited from TCastleAbstractFont.FontLoaded. If the font is loaded, it can actually display and measure some characters. |
Properties
property ImageUrl: String read FImageUrl write SetImageUrl; |
|
Image that contains the characters. The characters are placed on the image in their Unicode order, starting from space in the upper-left corner. The characters are organized in ImageColumns columns and ImageRows rows, and have ImageMargin space between them. |
property ImageColumns: Cardinal read FImageColumns write SetImageColumns default 8; |
|
Columns of the characters in the image ImageUrl. |
property ImageRows: Cardinal read FImageRows write SetImageRows default 8; |
|
Rows of the characters in the image ImageUrl. |
property ImageMargin: Cardinal read FImageMargin write SetImageMargin default 0; |
|
Margin between characters in the image ImageUrl. |
property DisplayMargin: Single read FDisplayMargin write SetDisplayMargin default 2; |
|
Spacing between characters when rendering the font. This is independent from ImageMargin. |
Generated by PasDoc 0.16.0-snapshot.