GL Studio C++ Runtime API
GlsFontBase Class Reference

#include <gls_font_base.h>

Inheritance diagram for GlsFontBase:
GlsArialRegular12 GlsRobotoRegular12 GlsRuntimeFontBase GlsUnicodeFontBase

Classes

struct  CharAttr_t
 Character attributes. One item for each character in the set. More...
 
struct  FontAttr_t
 Attributes of the specific font. More...
 

Public Types

typedef GLuint Char_t
 Define the character type to use.
 
typedef std::vector< CharAttr_tAttrCont_t
 Typedef for a list of character attributes.
 

Public Member Functions

 GlsFontBase (const FontAttr_t &fontAttr, const AttrCont_t &charAttributes, Image *texture)
 
const FontAttr_tAttributes () const
 
const CharAttr_tCharAttr (Char_t c) const
 
GLuint CharAttrIndex (Char_t c) const
 
const AttrCont_tCharAttributes () const
 
std::string Family () const
 
std::string Key () const
 
GLfloat MaxCharHeight () const
 
GLfloat MaxCharWidth () const
 
GLuint PtSize () const
 
std::string Style () const
 
ImageTexture () const
 

Static Public Member Functions

static std::string Key (const std::string &name, const std::string &style, GLuint ptSize)
 

Protected Member Functions

 ~GlsFontBase ()
 

Protected Attributes

FontAttr_t _attr
 
AttrCont_t _charAttr
 
std::string _key
 
Image_texture
 

Friends

class GlsFontMan
 

Detailed Description

The GlsFontBase class provides a specific font face for use within the GL Studio. The font face is determined at construction time by the parameters passed in by the creator of the GlsFontBase instance. Specific instances should be wrapped in a singelton object wrapper, as there is no reason to have more than one instance of the exact same face (meaning font family, style, and point size.)

Once instanced, a GlsFontRenderer object can be used to render characters in Open GL at specific locations and with several different text effects.

See also
GlsFontRenderer

Constructor & Destructor Documentation

◆ GlsFontBase()

GlsFontBase ( const FontAttr_t fontAttr,
const AttrCont_t charAttributes,
Image texture 
)

Class Constructor.

Parameters
fontAttrFont attributes for this font.
charAttributesAttributes for each glyph of this font.
textureThe generated texture atlas associated with this font.

◆ ~GlsFontBase()

~GlsFontBase ( )
protected

Class Destructor. This is protected so that no one can delete a font except via the font manager GlsFontMan. It is not vitual because we want to avoid calling destructors on unloaded font code, and it is not needed.

Member Function Documentation

◆ Attributes()

const FontAttr_t & Attributes ( ) const
inline

Access the attributes of the font.

Returns
all the attributes of the font.

◆ CharAttr()

const CharAttr_t & CharAttr ( Char_t  c) const
inline

NOTE: This function will only return char attributes for pre-generated ASCII fonts. Users should call CharAttrUnicode for GlsUnicodeFontBase fonts or CharAttrRuntime for GlsRuntimeFontBase fonts.

Parameters
cThe character to retrieve attributes for.
Returns
The attributes for the character.

◆ CharAttributes()

const AttrCont_t & CharAttributes ( ) const
inline

Access the character attributes of the font.

Returns
the attributes of all the characters in the font.

◆ CharAttrIndex()

GLuint CharAttrIndex ( Char_t  c) const
inline

Calculates an index for the specified character depending on the set of characters the texture map was generated for. NOTE: This function will only return char attributes for pre-generated ASCII fonts. Users should call CharAttrUnicode for GlsUnicodeFontBase fonts or CharAttrRuntime for GlsRuntimeFontBase fonts.

Parameters
cspecifies for which character the index is calculated for
Returns
the index of the specified character

◆ Family()

std::string Family ( ) const
inline
Returns
The font family string

◆ Key() [1/2]

std::string Key ( ) const
inline
Returns
The unique lookup key for this font.

◆ Key() [2/2]

static std::string Key ( const std::string &  name,
const std::string &  style,
GLuint  ptSize 
)
static

Builds a unique lookup key for a specific font, style, and size.

Parameters
nameName of the font.
styleStyle of the font.
ptSizePoint size of the font.
Returns
The associated unique key for this combination.

◆ MaxCharHeight()

GLfloat MaxCharHeight ( ) const
inline
Returns
maximum height in pixels of the characters in the set

◆ MaxCharWidth()

GLfloat MaxCharWidth ( ) const
inline
Returns
maximum width in pixels of the characters in the set

◆ PtSize()

GLuint PtSize ( ) const
inline
Returns
maximum height in pixels of the characters in the set

◆ Style()

std::string Style ( ) const
inline
Returns
The style description for this font.

◆ Texture()

Image * Texture ( ) const
inline
Returns
a pointer to the font's texture image.

Member Data Documentation

◆ _attr

FontAttr_t _attr
protected

Attributes of the font.

◆ _charAttr

AttrCont_t _charAttr
protected

Proportional character attributes used when proportional character spacing is turned on.

◆ _key

std::string _key
protected

Unique key used as a lookup key to find fonts within maps.

◆ _texture

Image* _texture
protected

Texture of all characters in the set.


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