Class TBitmapFonts

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TBitmapFonts = class(TObject)

Description

The list that may contain one or more instances of TBitmapFont and provide facilities to search for fonts by their unique names, font loading and handling "device lost" scenario.

Hierarchy

  • TObject
  • TBitmapFonts

Overview

Methods

Public constructor Create(const ADevice: TCustomDevice);
Public function AddFromBinaryAsset(const AssetName: StdString; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;
Public function AddFromBinaryFile(const FileName: StdString; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;
Public function AddFromBinaryStream(const Stream: TStream; const FontName: StdString = ''; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;
Public function AddFromXMLAsset(const ImageAssetName: StdString; const XMLAssetName: StdString = ''; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;
Public function AddFromXMLFile(const ImageFileName: StdString; const XMLFileName: StdString = ''; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;
Public function AddFromXMLStream(const ImageExtension: StdString; const ImageStream, XMLStream: TStream; const FontName: StdString = ''; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;
Public function AddSystemFont(const FontImage: TSystemFontImage = TSystemFontImage.Font8x8; const FontName: StdString = ''; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;
Public function Include(const Element: TBitmapFont): Integer;
Public function IndexOf(const FontName: StdString): Integer; overload;
Public function IndexOf(const Element: TBitmapFont): Integer; overload;
Public function Insert(const Font: TBitmapFont): Integer;
Public procedure Clear;
Public procedure MarkSearchDirty;
Public procedure Remove(const Index: Integer);

Properties

Public property Canvas: TCustomCanvas read FCanvas write SetCanvas;
Public property Count: Integer read GetCount;
Public property Device: TCustomDevice read FDevice;
Public property Font[constName:StdString]: TBitmapFont read GetFont;
Public property Items[constIndex:Integer]: TBitmapFont read GetItem;
Public property StyleTags: TBitmapFont.TStyleTags read FStyleTags;

Description

Methods

Public constructor Create(const ADevice: TCustomDevice);

Creates new instance of TBitmapFonts class bound to the specified device. Elements inside this list will also be bound to this device.

Public function AddFromBinaryAsset(const AssetName: StdString; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;

Loads binary font from file in /assets sub-folder and adds its to the list with font name equal to file name (without extension). The given pixel format, if specified, will be used as a hint for initializing font letters image. Returns font index in the list when successful and -1 otherwise.

Public function AddFromBinaryFile(const FileName: StdString; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;

Loads binary font from external file and adds its to the list with font name equal to file name (without extension). The given pixel format, if specified, will be used as a hint for initializing font letters image. Returns font index in the list when successful and -1 otherwise.

Public function AddFromBinaryStream(const Stream: TStream; const FontName: StdString = ''; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;

Loads binary font from the given stream and adds its to the list with the given name. The given pixel format, if specified, will be used as a hint for initializing font letters image. Returns font index in the list when successful and -1 otherwise.

Public function AddFromXMLAsset(const ImageAssetName: StdString; const XMLAssetName: StdString = ''; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;

Loads font letter information and letter image from external files in /assets sub-folder and adds the resulting font to the list with the name equal to that of file name (without extension). This methods accepts that one of file names is left empty and will be guessed by either changing extension from ".xml" to ".png" or vice-versa. This uses image format manager reference from associated device. The given pixel format, if specified, will be used as a hint for initializing font letters image. Returns font index in the list when successful and -1 otherwise.

Public function AddFromXMLFile(const ImageFileName: StdString; const XMLFileName: StdString = ''; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;

Loads font letter information and letter image from external files on disk and adds the resulting font to the list with the name equal to that of file name (without extension). This methods accepts that one of file names is left empty and will be guessed by either changing extension from ".xml" to ".png" or vice-versa. This uses image format manager reference from associated device. The given pixel format, if specified, will be used as a hint for initializing font letters image. Returns font index in the list when successful and -1 otherwise.

Public function AddFromXMLStream(const ImageExtension: StdString; const ImageStream, XMLStream: TStream; const FontName: StdString = ''; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;

Loads font letter information and letter image from their corresponding streams and adds the resulting font to the list with the given name. This uses image format manager reference from associated device. The image extension indicates what image format for letters image is used. The given pixel format, if specified, will be used as a hint for initializing font letters image. Returns font index in the list when successful and -1 otherwise.

Public function AddSystemFont(const FontImage: TSystemFontImage = TSystemFontImage.Font8x8; const FontName: StdString = ''; const PixelFormat: TPixelFormat = TPixelFormat.Unknown): Integer;

Adds and initializes one of the predefined system fonts to the list with the given name. These are embedded within the final application and can be used at any time. The drawback of this is that these fonts don't look pretty as the pre-rendered ones and typically contain only ASCII characters. The given pixel format, if specified, will be used as a hint for initializing font letters image. Returns font index in the list when successful and -1 otherwise.

Public function Include(const Element: TBitmapFont): Integer;

Includes the specified font to the list, if it wasn't included previously. This implies searching the list before adding the element, which may impact performance.

Public function IndexOf(const FontName: StdString): Integer; overload;

Returns the index of font with given unique name (not case-sensitive) in the list. If no font with such name exists, returns -1.

Public function IndexOf(const Element: TBitmapFont): Integer; overload;

Returns the index of the given font element in the list. If such font is not found, -1 is returned.

Public function Insert(const Font: TBitmapFont): Integer;

Inserts the given font to the list and returns its index.

Public procedure Clear;

Removes all font entries from the list.

Public procedure MarkSearchDirty;

Indicates that one of the fonts had its name changed, so the list needs to be refreshed to make searching by name (IndexOf function and Font property) work properly.

Public procedure Remove(const Index: Integer);

Removes font with the specified index from the list.

Properties

Public property Canvas: TCustomCanvas read FCanvas write SetCanvas;

Destination canvas to which the text should be rendered to. This can be changed between different drawing calls to a different canvas, as long as such canvas is bound to the same device as the fonts. Note that setting this property changes Canvas value for all the fonts in the list to this same value.

Public property Count: Integer read GetCount;

Total number of elements in the list.

Public property Device: TCustomDevice read FDevice;

The device to which this list is bound to.

Public property Font[constName:StdString]: TBitmapFont read GetFont;

Provides access to individual fonts in the list by unique font name (not case-sensitive). If no font with such name is found, Nil is returned.

Public property Items[constIndex:Integer]: TBitmapFont read GetItem;

Provides access to individual fonts in the list by the corresponding index. If the index is outside of valid range, Nil is returned.

Public property StyleTags: TBitmapFont.TStyleTags read FStyleTags;

Global font style tags that can be shared among all fonts contained in this list.


Copyright © 2000 - 2017 Yuriy Kotsarenko. Help files generated by PasDoc.