ADTF Display Toolbox
Loading...
Searching...
No Matches
cGLFont

OpenGL font. More...

#include <glfont.h>

Inheritance diagram for cGLFont:
[legend]

Public Member Functions

 cGLFont ()
 Constructor.
 
 ~cGLFont ()
 Destructor.
 
tResult Create (const cGLCanvas *, const char *strFilename, tInt nHeight, tStyle eFontStyle)
 Creates a font based on the given parameters.
 
tResult CleanUp ()
 Clean up the font.
 
void Print (tInt x, tInt y, tFloat64 fAngle, const char *strFormat, va_list ArgList)
 Print a string onto the screen.
 
void Print (tFloat32 x, tFloat32 y, tFloat64 fAngle, const char *strFormat, va_list ArgList)
 Print a string onto the screen.
 
tVoid FlipTextHorizontally (tBool bOpposedYAxis)
 Set the text direction with or opposed the x-axis direction.
 
tVoid TextScaleWithCoordinateSystem (tBool bScaleWithCoordinateSystem)
 Set the text to scale with the coordinatesystem.
 
tVoid TextRotateWithCoordinateSystem (tBool bRotateWithCoordinateSystem)
 Set the text to rotate with the coordinatesystem.
 
tVoid TextBaselineOnTop (tBool bTextBaselineOnTop)
 Set the text baseline on the top of the text.
 
- Public Member Functions inherited from IFont
virtual ~IFont ()
 virtual destructor to ensure proper cleanup.
 
virtual tResult Release ()=0
 Releases the font.
 
virtual tInt GetHeight () const =0
 This function returns the height of the font in point.
 
virtual tBool MeasureText (const tChar *str, tInt &nWidth, tInt &nHeight) const =0
 The methods returns the measurement of the text in nWidth and nHeight.
 

Static Public Member Functions

static tResult Initialize ()
 Initialize the font.
 
static tResult Uninitialize ()
 Uninitialize the font.
 

Protected Member Functions

tResult BuildDisplayList (char ch, tStyle eFontStyle)
 Creates a display list for the given character.
 
void PrintImpl (tUInt32 ui32Flags, tFloat32 x, tFloat32 y, tFloat64 fAngle, const char *strFormat, va_list ArgList)
 Internal print implementation.
 

Static Protected Member Functions

static bool _fnLookupFontFile (const char *strFamily, char *strFilenameBuffer)
 
static int _fnGetNextPowerOfTwo (int a)
 

Protected Attributes

FT_Face m_hFace
 FreeType face.
 
GLuint * m_hTextures
 Texture array.
 
GLuint m_nTextureBase
 Base address of texture array.
 
tInt m_nHeight
 Font height.
 
tInt m_aCharWidth [256]
 Character width.
 

Static Protected Attributes

static FT_Library g_hFreeTypeLibrary = NULL
 
static tInt g_nLibraryRefCount = 0
 
static const tInt g_nCharsetSize = 128
 
static constexpr tInt m_nTextureScale = 8
 Super sampling of internal texture.
 

Additional Inherited Members

- Public Types inherited from IFont
enum  tStyle { STYLE_Default , STYLE_Antialiased , STYLE_Mono }
 The enumeration marks the style of the font. More...
 

Detailed Description

OpenGL font.

Definition at line 61 of file glfont.h.

Constructor & Destructor Documentation

◆ cGLFont()

cGLFont ( )
inline

Constructor.

Definition at line 89 of file glfont.h.

◆ ~cGLFont()

~cGLFont ( )
inline

Destructor.

Definition at line 106 of file glfont.h.

Member Function Documentation

◆ _fnGetNextPowerOfTwo()

static int _fnGetNextPowerOfTwo ( int a)
inlinestaticprotected

Definition at line 806 of file glfont.h.

◆ _fnLookupFontFile()

static bool _fnLookupFontFile ( const char * strFamily,
char * strFilenameBuffer )
inlinestaticprotected

Definition at line 748 of file glfont.h.

◆ BuildDisplayList()

tResult BuildDisplayList ( char ch,
tStyle eFontStyle )
inlineprotected

Creates a display list for the given character.

Parameters
ch[in] Character for which the display list should be generated.
eFontStyle[in] Fontstyle.
Returns
Standard result code

Definition at line 412 of file glfont.h.

◆ CleanUp()

tResult CleanUp ( )
inline

Clean up the font.

Returns
Standard result code

Definition at line 263 of file glfont.h.

◆ Create()

tResult Create ( const cGLCanvas * ,
const char * strFilename,
tInt nHeight,
tStyle eFontStyle )
inline

Creates a font based on the given parameters.

Parameters
pCanvas[in] The drawing canvas.
strFilename[in] Filename of font.
nHeight[in] Desired height for the font.
eFontStyle[in] Fontstyle.
Returns
Standard result code

Definition at line 169 of file glfont.h.

◆ FlipTextHorizontally()

tVoid FlipTextHorizontally ( tBool bOpposedYAxis)
inline

Set the text direction with or opposed the x-axis direction.

Parameters
[in]bOpposedYAxistFalse: with the x-axis direction tTrue: opposed the x-axis direction
Returns
void

Definition at line 317 of file glfont.h.

◆ Initialize()

static tResult Initialize ( )
inlinestatic

Initialize the font.

Returns
Standard result code

Definition at line 118 of file glfont.h.

◆ Print() [1/2]

void Print ( tFloat32 x,
tFloat32 y,
tFloat64 fAngle,
const char * strFormat,
va_list ArgList )
inline

Print a string onto the screen.

Parameters
x[in] Drawing position x coordinate (floating-point).
y[in] Drawing position y coordinate (floating-point).
fAngle[in] Drawing angle.
strFormat[in] Formatted string.
ArgList[in] Arguments for formatted string.

Definition at line 305 of file glfont.h.

◆ Print() [2/2]

void Print ( tInt x,
tInt y,
tFloat64 fAngle,
const char * strFormat,
va_list ArgList )
inline

Print a string onto the screen.

Parameters
x[in] Drawing position x coordinate (integer).
y[in] Drawing position y coordinate (integer).
fAngle[in] Drawing angle.
strFormat[in] Formatted string.
ArgList[in] Arguments for formatted string.

Definition at line 291 of file glfont.h.

◆ PrintImpl()

void PrintImpl ( tUInt32 ui32Flags,
tFloat32 x,
tFloat32 y,
tFloat64 fAngle,
const char * strFormat,
va_list ArgList )
inlineprotected

Internal print implementation.

Parameters
ui32Flags[in] Flags.
x[in] Drawing position x coordinate (floating-point).
y[in] Drawing position y coordinate (floating-point).
fAngle[in] Drawing angle.
strFormat[in] Formatted string.
ArgList[in] Arguments for formatted string.

Definition at line 605 of file glfont.h.

◆ TextBaselineOnTop()

tVoid TextBaselineOnTop ( tBool bTextBaselineOnTop)
inline

Set the text baseline on the top of the text.

Parameters
[in]bTextBaselineOnTopif true = top otherwise false = bottom
Returns
void

Definition at line 350 of file glfont.h.

◆ TextRotateWithCoordinateSystem()

tVoid TextRotateWithCoordinateSystem ( tBool bRotateWithCoordinateSystem)
inline

Set the text to rotate with the coordinatesystem.

Parameters
[in]bRotateWithCoordinateSystemthe value to be set
Returns
void

Definition at line 339 of file glfont.h.

◆ TextScaleWithCoordinateSystem()

tVoid TextScaleWithCoordinateSystem ( tBool bScaleWithCoordinateSystem)
inline

Set the text to scale with the coordinatesystem.

Parameters
[in]bScaleWithCoordinateSystemthe value to be set
Returns
void

Definition at line 328 of file glfont.h.

◆ Uninitialize()

static tResult Uninitialize ( )
inlinestatic

Uninitialize the font.

Returns
Standard result code

Definition at line 140 of file glfont.h.

Member Data Documentation

◆ g_hFreeTypeLibrary

FT_Library g_hFreeTypeLibrary = NULL
inlinestaticprotected

Definition at line 64 of file glfont.h.

◆ g_nCharsetSize

const tInt g_nCharsetSize = 128
staticprotected

Definition at line 66 of file glfont.h.

◆ g_nLibraryRefCount

tInt g_nLibraryRefCount = 0
inlinestaticprotected

Definition at line 65 of file glfont.h.

◆ m_aCharWidth

tInt m_aCharWidth[256]
protected

Character width.

Definition at line 73 of file glfont.h.

◆ m_hFace

FT_Face m_hFace
protected

FreeType face.

Definition at line 69 of file glfont.h.

◆ m_hTextures

GLuint* m_hTextures
protected

Texture array.

Definition at line 70 of file glfont.h.

◆ m_nHeight

tInt m_nHeight
protected

Font height.

Definition at line 72 of file glfont.h.

◆ m_nTextureBase

GLuint m_nTextureBase
protected

Base address of texture array.

Definition at line 71 of file glfont.h.

◆ m_nTextureScale

tInt m_nTextureScale = 8
staticconstexprprotected

Super sampling of internal texture.

Definition at line 75 of file glfont.h.