Allolib  1.0
C++ Components For Interactive Multimedia
al::Font Struct Reference

Interface for loading fonts and rendering text. More...

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/graphics/al_Font.hpp>

Inheritance diagram for al::Font:
al::FontRenderer

Public Member Functions

 Font (const Font &)=delete
 
Fontoperator= (const Font &)=delete
 
 Font (Font &&other) noexcept
 
Fontoperator= (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
 

Detailed Description

Interface for loading fonts and rendering text.

Definition at line 60 of file al_Font.hpp.

Member Function Documentation

◆ alignLeft()

void al::Font::alignLeft ( )
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

Parameters
[in]xfracFraction along text width to render at x=0; 0 is left-aligned, 0.5 is centered, 1 is right-aligned
[in]yfracFraction along text height to render at y=0

Definition at line 127 of file al_Font.hpp.

◆ load()

bool al::Font::load ( const char *  filename,
int  fontSize,
int  bitmapSize 
)

Load font from file

Parameters
[in]filenamepath to font file
[in]fontSizesize of font
[in]bitmapSizesize of font bitmap
Returns
whether font loaded successfully

◆ write()

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();

The documentation for this struct was generated from the following file: