xoreos  0.0.5
texturefont.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_AURORA_TEXTUREFONT_H
26 #define GRAPHICS_AURORA_TEXTUREFONT_H
27 
28 #include <map>
29 
30 #include "src/common/types.h"
31 
32 #include "src/graphics/font.h"
33 
35 
37 
39 
40 namespace Common {
41  class UString;
42 }
43 
44 namespace Graphics {
45 
46 namespace Aurora {
47 
48 class Texture;
49 
51 class TextureFont : public Graphics::Font {
52 public:
53  TextureFont(const Common::UString &name);
54  ~TextureFont();
55 
56  float getWidth (uint32 c) const;
57  float getHeight() const;
58 
59  float getLineSpacing() const;
60 
61  void draw(uint32 c) const;
62 
67  virtual void renderBind(const glm::mat4 &transform) const;
68  virtual void render(uint32 c, float &x, float &y, float *rgba) const;
69  virtual void renderUnbind() const;
70 
71 
72 private:
74  struct Char {
75  float width;
76  float tX[4], tY[4];
77  float vX[4], vY[4];
78  };
79 
81 
82  std::map<uint32, Char> _chars;
83 
84  float _height;
85  float _spaceR;
86  float _spaceB;
87 
91 
92  void load();
93 
94  void drawMissing() const;
95 };
96 
97 } // End of namespace Aurora
98 
99 } // End of namespace Graphics
100 
101 #endif // GRAPHICS_AURORA_TEXTUREFONT_H
Shader renderable, a class for easier managing of a collection of items (surface, material...
Definition: 2dafile.h:39
A class holding an UTF-8 string.
Definition: ustring.h:48
Dedicated mesh used for dynamic font rendering.
virtual void renderUnbind() const
virtual void render(uint32 c, float &x, float &y, float *rgba) const
A texture font, as used by NWN and KotOR/KotOR2.
Definition: texturefont.h:51
A handle to an Aurora texture.
Shader::ShaderRenderable * _renderable
Definition: texturefont.h:90
float getHeight() const
Return the height of a character.
Definition: texturefont.cpp:93
float getWidth(uint32 c) const
Return the width of a character.
Definition: texturefont.cpp:82
Low-level type definitions to handle fixed width types portably.
An abstract font.
Definition: font.h:39
Shader::ShaderMaterial * _material
Definition: texturefont.h:89
uint32_t uint32
Definition: types.h:204
float getLineSpacing() const
Return the size of space between lines.
Definition: texturefont.cpp:97
A handle to a texture.
Definition: texturehandle.h:51
virtual void renderBind(const glm::mat4 &transform) const
Bind the font for rendering.
A font.
std::map< uint32, Char > _chars
Definition: texturefont.h:82
TextureFont(const Common::UString &name)
Definition: texturefont.cpp:64
void draw(uint32 c) const
Draw this character.