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:

Hierarchy

Overview

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;
Public 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';
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;
Public function FontLoaded: Boolean; override;

Properties

Published property ImageUrl: String read FImageUrl write SetImageUrl;
Published property ImageColumns: Cardinal read FImageColumns write SetImageColumns default 8;
Published property ImageRows: Cardinal read FImageRows write SetImageRows default 8;
Published property ImageMargin: Cardinal read FImageMargin write SetImageMargin default 0;
Published property DisplayMargin: Single read FDisplayMargin write SetDisplayMargin default 2;

Description

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public function PropertySections(const PropertyName: String): TPropertySections; override;
 
Public 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
AImage
Image data, becomes owned by this class.
AImageMargin
There is a margin in the image between rows and cols.
ADisplayMargin
We can display some spacing between characters. This is independent from ImageMargin and image contents.
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;
 
Public function FontLoaded: Boolean; override;
 

Properties

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

Published property ImageColumns: Cardinal read FImageColumns write SetImageColumns default 8;

Columns of the characters in the image ImageUrl.

Published property ImageRows: Cardinal read FImageRows write SetImageRows default 8;

Rows of the characters in the image ImageUrl.

Published property ImageMargin: Cardinal read FImageMargin write SetImageMargin default 0;

Margin between characters in the image ImageUrl.

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