ADTF_DISPLAY_TOOLBOX  3.8.0 (ADTF 3.14.3)
glfont.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #ifdef WIN32
10  #include <windows.h>
11  #include <gl/GL.h>
12 #else
13  #include <GL/gl.h>
14  #include <fontconfig/fontconfig.h>
15 #endif
16 
17 #include <ft2build.h>
18 #include FT_FREETYPE_H
19 
20 #include <adtf_base.h>
22 
23 
24 namespace adtf
25 {
26 
27 namespace disptb
28 {
29 
30 namespace graphicslib
31 {
32 
33 namespace dengar
34 {
35 
36 class cGLCanvas;
37 
43 class cGLFont : public IFont
44 {
45 protected:
46  FT_Face m_hFace;
47  GLuint* m_hTextures;
48  GLuint m_nTextureBase;
49  tInt m_nHeight;
50  tInt m_aCharWidth[256];
51 
52  static constexpr tInt m_nTextureScale = 8;
53 
55  tBool m_bOpposedYAxis;
56  tBool m_bScaleWithCoordinateSystem;
57  tBool m_bRotationWithCoordinateSystem;
58  tBool m_bTextBaselineOnTop;
60 
61 public:
67  static tResult Initialize();
68 
74  static tResult Uninitialize();
75 
76  cGLFont();
77 
78  ~cGLFont();
79 
90  tResult Create(const cGLCanvas* pCanvas, const char* strFilename, tInt nHeight, tStyle eFontStyle);
91 
97  tResult CleanUp();
98 
108  void Print(tInt x, tInt y, tFloat64 fAngle, const char* strFormat, va_list ArgList);
109 
119  void Print(tFloat32 x, tFloat32 y, tFloat64 fAngle, const char* strFormat, va_list ArgList);
120 
121 
129  tVoid FlipTextHorizontally(tBool bOpposedYAxis);
130 
137  tVoid TextScaleWithCoordinateSystem(tBool bScaleWithCoordinateSystem);
138 
145  tVoid TextRotateWithCoordinateSystem(tBool bRotateWithCoordinateSystem);
146 
153  tVoid TextBaselineOnTop(tBool bTextBaselineOnTop);
154 
155 public: // Implements IFont
156 
158  tResult Release();
159 
160  tInt GetHeight() const;
161 
162 
163  tBool MeasureText(const char* str, tInt& nWidth, tInt& nHeight) const;
165 
166 protected:
175  tResult BuildDisplayList(char ch, tStyle eFontStyle);
176 
187  void PrintImpl(tUInt32 ui32Flags, tFloat32 x, tFloat32 y, tFloat64 fAngle, const char* strFormat, va_list ArgList);
188 
189 
190 };
191 
192 }
193 
194 using dengar::cGLFont;
195 }
196 
197 }
198 
199 }
200 
Default Font handling interface for basic font support.
tStyle
The enumeration marks the style of the font.
virtual tResult Release()=0
Releases the font.
virtual tBool MeasureText(const tChar *str, tInt &nWidth, tInt &nHeight) const =0
The methods returns the measurement of the text in nWidth and nHeight.
virtual tInt GetHeight() const =0
This function returns the height of the font in point.
tResult Create(const cGLCanvas *pCanvas, const char *strFilename, tInt nHeight, tStyle eFontStyle)
Creates a font based on the given parameters.
static tResult Uninitialize()
Uninitialize the font.
GLuint m_nTextureBase
Base address of texture array.
Definition: glfont.h:48
tVoid FlipTextHorizontally(tBool bOpposedYAxis)
Set the text direction with or opposed the x-axis direction.
tInt m_aCharWidth[256]
Character width.
Definition: glfont.h:50
tVoid TextScaleWithCoordinateSystem(tBool bScaleWithCoordinateSystem)
Set the text to scale with the coordinatesystem.
GLuint * m_hTextures
Texture array.
Definition: glfont.h:47
tResult BuildDisplayList(char ch, tStyle eFontStyle)
Creates a display list for the given character.
static tResult Initialize()
Initialize the font.
tVoid TextRotateWithCoordinateSystem(tBool bRotateWithCoordinateSystem)
Set the text to rotate with the coordinatesystem.
void Print(tInt x, tInt y, tFloat64 fAngle, const char *strFormat, va_list ArgList)
Print a string onto the screen.
tResult CleanUp()
Clean up the font.
void Print(tFloat32 x, tFloat32 y, tFloat64 fAngle, const char *strFormat, va_list ArgList)
Print a string onto the screen.
tVoid TextBaselineOnTop(tBool bTextBaselineOnTop)
Set the text baseline on the top of the text.
static constexpr tInt m_nTextureScale
Super sampling of internal texture.
Definition: glfont.h:52
void PrintImpl(tUInt32 ui32Flags, tFloat32 x, tFloat32 y, tFloat64 fAngle, const char *strFormat, va_list ArgList)
Internal print implementation.
Copyright © Audi Electronics Venture GmbH.
Main namespace.