Allolib
1.0
C++ Components For Interactive Multimedia
|
Interface for loading fonts and rendering text. More...
Public Member Functions | |
Font (const Font &)=delete | |
Font & | operator= (const Font &)=delete |
Font (Font &&other) noexcept | |
Font & | operator= (Font &&other) noexcept |
bool | load (const char *filename, int fontSize, int bitmapSize) |
void | write (Mesh &mesh, const char *text, float worldHeight) |
void | alignLeft () |
Returns the width of a text string, in pixels. More... | |
void | alignCenter () |
void | alignRight () |
Static Public Member Functions | |
static std::string | defaultFont () |
Public Attributes | |
Impl * | impl |
Texture | tex |
float | alignFactorX = 0.0f |
Interface for loading fonts and rendering text.
Definition at line 60 of file al_Font.hpp.
|
inline |
Returns the width of a text string, in pixels.
Returns the width of a character, in pixels Returns the "above-line" height of the font, in pixels Returns the "below-line" height of the font, in pixels Returns the total height of the font, in pixels Set alignment of rendered text strings
[in] | xfrac | Fraction along text width to render at x=0; 0 is left-aligned, 0.5 is centered, 1 is right-aligned |
[in] | yfrac | Fraction along text height to render at y=0 |
Definition at line 127 of file al_Font.hpp.
bool al::Font::load | ( | const char * | filename, |
int | fontSize, | ||
int | bitmapSize | ||
) |
Load font from file
[in] | filename | path to font file |
[in] | fontSize | size of font |
[in] | bitmapSize | size of font bitmap |
void al::Font::write | ( | Mesh & | mesh, |
const char * | text, | ||
float | worldHeight | ||
) |
Render text geometry Render text into geometry for drawing a string of text using the bitmap returned by ascii_chars. Render expects the vertex and texcoord buffers to be at least as big as the text length * 4 since each character is rendered by a quad.
Example usage:
Mesh mesh; font.write(mesh, "allocore"); font.texture().bind(); g.draw(mesh); font.texture().unbind();