xoreos  0.0.5
abcfont.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_ABCFONT_H
26 #define GRAPHICS_AURORA_ABCFONT_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  class SeekableReadStream;
43 }
44 
45 namespace Graphics {
46 
47 namespace Aurora {
48 
50 class ABCFont : public Graphics::Font {
51 public:
52  ABCFont(const Common::UString &name);
53  ~ABCFont();
54 
55  float getWidth (uint32 c) const;
56  float getHeight() const;
57 
58  void draw(uint32 c) const;
59 
64  virtual void renderBind(const glm::mat4 &transform) const;
65 
66  virtual void render(uint32 c, float &x, float &y, float *rgba) const;
67  virtual void renderUnbind() const;
68 
69 private:
71  struct Char {
77 
78  float tX[4], tY[4];
79  float vX[4], vY[4];
80  };
81 
86 
88 
90  Char _ascii[128];
91  std::map<uint32, Char> _extended;
92 
93  void load(const Common::UString &name);
94 
96  void calcCharVertices(Char &c);
97 
98  const Char &findChar(uint32 c) const;
99 };
100 
101 } // End of namespace Aurora
102 
103 } // End of namespace Graphics
104 
105 #endif // GRAPHICS_AURORA_ABCFONT_H
virtual void render(uint32 c, float &x, float &y, float *rgba) const
Definition: abcfont.cpp:97
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.
uint8_t uint8
Definition: types.h:200
std::map< uint32, Char > _extended
Definition: abcfont.h:91
A handle to an Aurora texture.
void calcCharVertices(Char &c)
Definition: abcfont.cpp:210
ABCFont(const Common::UString &name)
Definition: abcfont.cpp:43
Shader::ShaderRenderable * _renderable
Definition: abcfont.h:85
void readCharDesc(Char &c, Common::SeekableReadStream &abc)
Definition: abcfont.cpp:195
void load(const Common::UString &name)
Definition: abcfont.cpp:129
Mesh::MeshFont * _mesh
Definition: abcfont.h:83
Low-level type definitions to handle fixed width types portably.
An abstract font.
Definition: font.h:39
const Char & findChar(uint32 c) const
Definition: abcfont.cpp:233
Shader::ShaderMaterial * _material
Definition: abcfont.h:84
virtual void renderUnbind() const
Definition: abcfont.cpp:121
int8_t int8
Definition: types.h:199
A font character.
Definition: abcfont.h:71
uint32_t uint32
Definition: types.h:204
float getHeight() const
Return the height of a character.
Definition: abcfont.cpp:61
virtual void renderBind(const glm::mat4 &transform) const
Bind the font for rendering.
Definition: abcfont.cpp:88
void draw(uint32 c) const
Draw this character.
Definition: abcfont.cpp:71
A handle to a texture.
Definition: texturehandle.h:51
Interface for a seekable & readable data stream.
Definition: readstream.h:265
A font.
An ABC/SBM font, as used by Jade Empire.
Definition: abcfont.h:50
float getWidth(uint32 c) const
Return the width of a character.
Definition: abcfont.cpp:65
TextureHandle _texture
Definition: abcfont.h:82