video.fontmanager

Font manager and text drawing code abstracted from the video driver.

struct FontRenderer;

Used by VideoDriver implementations to draw a string.

const pure @property uint height();

Get height of the font we're drawing.

void start();

Start drawing a string.

const bool hasGlyph(const dchar c);

Determine if the glyph of a character is loaded.

Parameters:
dchar c Character to check.
Returns:
True if the glyph is loaded, false otherwise.
void loadGlyph(VideoDriver driver, const dchar c);

Load glyph for a character.

Will render the glyph and create a texture for it.

Parameters:
VideoDriver driver Video driver to use for texture creation.
dchar c Character to load glyph for.
Throws:
TextureException if the glyph texture could not be created.
const(Texture*) glyph(const dchar c, out Vector2u offset);

Get glyph texture and offset to draw a glyph at.

Parameters:
dchar c Character we're drawing.
Vector2u offset Offset to draw the glyph at will be written here (relative to string start).
Returns:
Pointer to the texture of the glyph.
Vector2u textSize(const string text);

Get size of text as it would be drawn in pixels.

Parameters:
string text Text to get size of.
Returns:
Size of the text in X and Y. Y might be slightly imprecise.
class FontManager;

Manages all font resources.

this(VFSDir gameDir);

Construct the font manager, load default font.

Parameters:
VFSDir gameDir Game data directory.
Throws:
FontException on failure.
void unloadTextures(VideoDriver driver);

Delete all glyph textures from the video driver.

Parameters:
VideoDriver driver VideoDriver to unload textures from.
void reloadTextures(VideoDriver driver);

Load glyph textures back to the video driver.

Parameters:
VideoDriver driver VideoDriver to load textures to.
Throws:
TextureException if the glyph textures could not be reloaded.
void font(string fontName, const bool forceLoad = false);

Set font to use.

Parameters:
string fontName Name of the font to set.
bool forceLoad Force the font to be set right now and loaded if it's not loaded yet.
void fontSize(uint size, const bool forceLoad = false);

Set font size to use.

Parameters:
uint size Font size to set.
bool forceLoad Force the font size to be set right now and font loaded if it's not loaded yet.
FontRenderer renderer();

Return a renderer to draw text with.

const pure @property bool antialiasing();

Is font antialiasing enabled?

const pure @property bool kerning();

Is kerning enabled?