Class TSimpleTextureFont

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TSimpleTextureFont = class(TCastleFont)

Description

2D font using a texture to define character images with constant width and height.

This class has some assumptions about how the font image looks like: the characters are drawn in ASCII order, starting from space, on an image. Derive your own descendants of TCastleFont to have more flexibility, see the implementation of this class — it is quite simple. Or use TTextureFont that can read data from a FreeType (like ttf) font file.

See e.g. castle_game_engine/examples/fonts/data/sonic_asalga_0.png how to prepare an image for use with such font. You can find more such fonts on the Internet, see e.g. http://opengameart.org/content/sonic-font and http://opengameart.org/content/null-terminator.

Hierarchy

Overview

Methods

Public constructor Create(AImage: TCastleImage; const AImageCols, AImageRows, ACharMargin, ACharDisplayMargin: Integer);
Public destructor Destroy; override;
Public procedure GLContextOpen; override;
Public procedure GLContextClose; override;
Public procedure Print(const X, Y: Integer; const Color: TCastleColor; const S: string); override;
Public function TextWidth(const S: string): Integer; override;
Public function TextHeight(const S: string): Integer; override;
Public function TextHeightBase(const S: string): Integer; override;
Public function TextMove(const S: string): TVector2Integer; override;

Description

Methods

Public constructor Create(AImage: TCastleImage; const AImageCols, AImageRows, ACharMargin, ACharDisplayMargin: Integer);

Load font from given image.

Parameters
AImage
Image data, becomes owned by this class.
ACharMargin
There is a margin in the image between rows and cols.
ACharDisplayMargin
We can display some spacing between characters. This is independent from CharMargin and image contents.
Public destructor Destroy; override;
 
Public procedure GLContextOpen; override;
 
Public procedure GLContextClose; override;
 
Public procedure Print(const X, Y: Integer; const Color: TCastleColor; const S: string); override;
 
Public function TextWidth(const S: string): Integer; override;
 
Public function TextHeight(const S: string): Integer; override;
 
Public function TextHeightBase(const S: string): Integer; override;
 
Public function TextMove(const S: string): TVector2Integer; override;
 

Generated by PasDoc 0.14.0.