OpenPolygon  1.0.0
OpenPolygon is a Rendering Engine
fontmanager.h
1 /*
2  Copyright (C) 2014 - 2016 Mutzii
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
18 #ifndef FONTMANAGER_H
19 #define FONTMANAGER_H
20 
21 #include "index.h"
22 #include "logmanager.h"
23 #include "texturemanager.h"
24 
25 namespace Engine
26 {
27 
29  {
30  float u;
31  float v;
32  };
33 
35  {
36  char c;
37 
38  int x,y;
39  int width;
40  int height;
41 
42  FontAtlasCharUV uvs[6];
43  };
44 
45  struct FontAtlas
46  {
47  FontAtlasChar chars[128];
48 
49  int atlas_width;
50  int atlas_height;
51 
52  Texture * texture;
53  };
54 
55 
65 {
66  public:
67 
71  using CharMapping = std::map< char , Texture * >;
72 
73  private:
74 
75  static FontManager * ptrInstance;
77  FontManager(void);
78  FontManager(const FontManager & ){}
79  void operator=(const FontManager &){}
80 
81  public:
82 
88  static FontManager * getSingletonPtr(void);
89  void finish(void);
90 
91  /*NEW*/
92  FontAtlas createFontAtlas(const std::string & ttf_file );
93 
94 
101  FT_Face createFontFace( const std::string & ttf_file );
102 
110  void load( FT_Face face , const std::string & asci );
111  void unload(void);
112 
119  Texture * getCharTexture( char c ) throw( std::runtime_error );
120 
127  void CharRegister( char c , Texture * buffer );
128 
129 
130  protected:
131 
132  /*New*/
133  Vector2f getAtlasVector( FT_Face font );
134 
135  private:
136 
137  FT_Library mFreeType;
138  CharMapping mCharMapping;
140 };
141 
142 }
143 
144 #endif // FONTMANAGER_H
The Texture class.
Definition: texture.h:37
FT_Face createFontFace(const std::string &ttf_file)
createFontFace
Definition: FontManager.cpp:150
Texture * getCharTexture(char c)
getCharTexture
Definition: FontManager.cpp:226
std::map< char, Texture * > CharMapping
Definition: fontmanager.h:71
static FontManager * getSingletonPtr(void)
getSingletonPtr
Definition: FontManager.cpp:32
Definition: fontmanager.h:28
void CharRegister(char c, Texture *buffer)
CharRegister.
Definition: FontManager.cpp:238
Definition: element.h:23
Definition: fontmanager.h:34
The FontManager managed the Fonts.
Definition: fontmanager.h:64
void load(FT_Face face, const std::string &asci)
load
Definition: FontManager.cpp:182
Definition: fontmanager.h:45