video.font
Font class.
- class FontException: object.Exception;
Exception thrown at font related errors.
- struct Glyph;
Immutable font glyph structure.
- class Font;
Stores one font with one size (e.g. Inconsolata size 16 and 18 will be two Font objects).
- this(FT_LibraryRec* freetypeLib, ubyte[] fontData, const(immutable(char)[]) name, const(uint) size, const(uint) fastGlyphs, const(bool) antialiasing);
Construct a font.
Parameters:Throws:FT_LibraryRec* freetypeLib Handle to the freetype library used to work with fonts. ubyte[] fontData Font data (loaded from a font file). const(immutable(char)[]) name Name of the font. const(uint) size Size of the font in points. const(uint) fastGlyphs Number of glyphs to store in fast access array, from glyph 0. E.g. 128 means 0-127, i.e. ASCII. const(bool) antialiasing Should the font be antialiased? FontException if the font could not be loaded.- const pure @property uint size();
- const pure @property uint height();
Get height of the font in pixels (currently the same as size).
- const pure @property string name();
- const pure @property bool kerning();
- pure @property FT_Face fontFace();
Get FreeType font face of the font.
- void unloadTextures(VideoDriver driver);
Delete glyph textures.
Textures have to be reloaded before any further glyph rendering with the font.
Parameters:VideoDriver driver Video driver to delete textures from. - void reloadTextures(VideoDriver driver);
Load glyph textures back to video driver.
Can only be used after textures were unloaded.
Parameters:Throws:VideoDriver driver Video driver to load textures to. TextureException if the glyph textures could not be reloaded.- package uint textWidth(const string str, const bool useKerning);
Returns width of text as it would be drawn.
Parameters:Returns:string str Text to measure. bool useKerning Should kerning be used? Should only be true if the font supports kerning. Width of the text in pixels.- package const const(Glyph*) getGlyph(const dchar c);
Access glyph of a (UTF-32) character.
The glyph has to be loaded, otherwise a call to getGlyph() will result in undefined behavior.
Parameters:Returns:dchar c Character to get glyph for. Pointer to glyph corresponding to the character.- package const bool hasGlyph(const dchar c);
Determines if the glyph of a character is loaded.
Parameters:Returns:dchar c Character to check for. True if the glyph is loaded, false otherwise.- package void loadGlyph(VideoDriver driver, const dchar c);
Load glyph of a character.
Parameters:Throws:VideoDriver driver Video driver to use for texture creation. dchar c Character to load glyph for. TextureException if the glyph texture could not be created.