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;

This item has no description.

Public destructor Destroy; override;

This item has no description.

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

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;

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 PrepareResources (although it is never needed, resources will be automatically created if needed). There's no public method to explicitly destroy them, they are always destroyed automatically.

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

Public function TextWidth(const S: string): Single; override;

This item has no description.

Public function TextHeight(const S: string): Single; override;

This item has no description.

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

Public function TextMove(const S: string): TVector2; override;

This item has no description.

Public 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

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.