Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
Font Class Reference

Font loading and storage: texture atlas, codepoints supported, dimensions of each glyph. More...

#include <Font.hpp>

Classes

struct  Glyph
 A font glyph bounding box, in UV space. More...
 

Public Types

enum class  Alignment { LEFT , CENTER , RIGHT }
 Text alignment.
 

Public Member Functions

 Font (std::istream &in)
 
void generateLabel (const std::string &text, float scale, Mesh &mesh, Alignment align=Alignment::LEFT) const
 
Fontoperator= (const Font &)=delete
 
 Font (const Font &)=delete
 
Fontoperator= (Font &&)=default
 
 Font (Font &&)=default
 
const Textureatlas () const
 

Private Attributes

const Texture_atlas
 The font texture atlas.
 
int _firstCodepoint
 The integer value of the first supported character.
 
int _lastCodepoint
 The integer value of the last supported character.
 
glm::vec2 _margins
 Margin to apply around each characters when generating the geometry.
 
std::vector< Glyph_glyphs
 The glyphs informations.
 

Detailed Description

Font loading and storage: texture atlas, codepoints supported, dimensions of each glyph.

Note
Assumes that the supported codepoints form a continuous range.

Constructor & Destructor Documentation

◆ Font() [1/3]

Font::Font ( std::istream &  in)
explicit

Load font from text stream.

Parameters
inthe input stream containing the metadata

◆ Font() [2/3]

Font::Font ( const Font )
delete

Copy constructor (disabled).

◆ Font() [3/3]

Font::Font ( Font &&  )
default

Move constructor.

Member Function Documentation

◆ atlas()

const Texture * Font::atlas ( ) const
inline

Obtain the font atlas.

Returns
the font atlas texture.

◆ generateLabel()

void Font::generateLabel ( const std::string &  text,
float  scale,
Mesh mesh,
Alignment  align = Alignment::LEFT 
) const

Generate the label mesh for a given text and font.

Parameters
textthe text do display
scalethe vertical height of the characters, in absolute units
meshthe mesh to populate
alignthe text alignment to apply, will influence the origin placement

◆ operator=() [1/2]

Font & Font::operator= ( const Font )
delete

Copy assignment operator (disabled).

Returns
a reference to the object assigned to

◆ operator=() [2/2]

Font & Font::operator= ( Font &&  )
default

Move assignment operator.

Returns
a reference to the object assigned to

The documentation for this class was generated from the following files: