Debian Codegraph @

utils/fgpanel/FGFontCache.hxx

raw symbols SCIP
1 // SPDX-FileCopyrightText: 2011 Torsten Dreyer
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <string>
7 #include <map>
8 #include <ft2build.h>
9 #include FT_FREETYPE_H
10
11 #if defined (SG_MAC)
12 #include <OpenGL/gl.h>
13 #include <GLUT/glut.h>
14 #elif defined (_GLES2)
15 #include <GLES2/gl2.h>
16 #else
17 #include <GL/glew.h> // Must be included before <GL/gl.h>
18 #include <GL/gl.h>
19 #include <GL/glut.h>
20 #endif
21
22
23 /**
24 * A class to keep all fonts available for future use.
25 * This also assures a font isn't resident more than once.
26 */
27 class FGFontCache {
28 public:
29 FGFontCache ();
30 ~FGFontCache ();
31 bool Set_Font (const std::string& Font_Name,
32 const float Size,
33 GLuint &Glyph_Texture);
34 bool Get_Char (const char Char,
35 int &X, int &Y,
36 int &Left, int &Bottom,
37 int &W, int &H,
38 double &X1, double &Y1, // Top (Y1) left (X1)
39 double &X2, double &Y2) const; // Bottom (Y2) right (X2)
40 private:
41 void Get_Pos (const unsigned short ASCII_Code,
42 const unsigned short Row,
43 const unsigned short Width,
44 unsigned int &Line,
45 unsigned int &Column) const;
46 void Get_Relative_Pos (const unsigned short ASCII_Code,
47 const unsigned short Row,
48 const unsigned short Width,
49 double &X,
50 double &Y) const;
51 static std::string Get_Size (const float Size);
52 static const unsigned short First_Printable_Char;
53 static const unsigned short Last_Printable_Char;
54 static const unsigned int Texture_Size = 1024;
55 FT_Library m_Ft;
56 typedef std::map <std::string, FT_Face *> Face_Map_Type;
57 Face_Map_Type m_Face_Map;
58 FT_Face *m_Current_Face_Ptr;
59 char m_Texture[Texture_Size * Texture_Size];
60 typedef std::map <std::string, unsigned int> Pos_Map_Type;
61 Pos_Map_Type m_Pos_Map;
62 unsigned int m_Current_Pos;
63 GLuint m_Glyph_Texture;
64 };