xoreos  0.0.5
nftrfont.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_NFTRFONT_H
26 #define GRAPHICS_AURORA_NFTRFONT_H
27 
28 #include <vector>
29 #include <map>
30 
31 #include "src/common/types.h"
32 
33 #include "src/aurora/nitrofile.h"
34 
35 #include "src/graphics/font.h"
36 
38 
39 namespace Graphics {
40 
41 class Surface;
42 
43 namespace Aurora {
44 
46 public:
47  NFTRFont(Common::SeekableReadStream *nftr, bool invertPalette = false);
48  NFTRFont(const Common::UString &name, bool invertPalette = false);
49  ~NFTRFont();
50 
51  float getWidth (uint32 c) const;
52  float getHeight() const;
53 
54  void draw(uint32 c) const;
55 
56 private:
57  struct Header {
61 
63 
67  };
68 
69  struct Glyph {
71 
73 
77 
79 
81 
82  Glyph();
83  ~Glyph();
84  };
85 
87  struct Char {
88  float width;
89 
90  float tX[4], tY[4];
91  float vX[4], vY[4];
92  };
93 
94 
96 
99 
100  std::map<uint32, Char> _chars;
101 
103 
105 
106 
108 
111  void readGlyphs (Common::SeekableSubReadStreamEndian &nftr, Header &header, std::vector<Glyph> &glyphs);
112  void readWidths (Common::SeekableSubReadStreamEndian &nftr, Header &header, std::vector<Glyph> &glyphs);
113  void readCharMaps(Common::SeekableSubReadStreamEndian &nftr, Header &header, std::vector<Glyph> &glyphs);
114 
115  void drawGlyphs(const std::vector<Glyph> &glyphs);
116  void drawGlyph(const Glyph &glyph, Surface &surface, uint32 x, uint32 y);
117 
118  void drawMissing() const;
119 
120  static uint32 convertToUTF32(uint16 codePoint, uint8 encoding);
121 };
122 
123 } // End of namespace Aurora
124 
125 } // End of namespace Graphics
126 
127 #endif // GRAPHICS_AURORA_NFTRFONT_H
void readHeader(Common::SeekableSubReadStreamEndian &nftr, Header &header)
Definition: nftrfont.cpp:132
void readCharMaps(Common::SeekableSubReadStreamEndian &nftr, Header &header, std::vector< Glyph > &glyphs)
Definition: nftrfont.cpp:276
void drawGlyphs(const std::vector< Glyph > &glyphs)
Definition: nftrfont.cpp:410
This is a wrapper around SeekableSubReadStream, but it adds non-endian read methods whose endianness ...
Definition: readstream.h:383
float getWidth(uint32 c) const
Return the width of a character.
Definition: nftrfont.cpp:364
A class holding an UTF-8 string.
Definition: ustring.h:48
uint8_t uint8
Definition: types.h:200
Common::SeekableReadStream * data
Definition: nftrfont.h:70
NFTRFont(Common::SeekableReadStream *nftr, bool invertPalette=false)
Definition: nftrfont.cpp:89
void readGlyphs(Common::SeekableSubReadStreamEndian &nftr, Header &header, std::vector< Glyph > &glyphs)
Definition: nftrfont.cpp:187
A font character.
Definition: nftrfont.h:87
float getHeight() const
Return the height of a character.
Definition: nftrfont.cpp:372
void draw(uint32 c) const
Draw this character.
Definition: nftrfont.cpp:391
A handle to an Aurora texture.
std::map< uint32, Char > _chars
Definition: nftrfont.h:100
uint16_t uint16
Definition: types.h:202
void drawGlyph(const Glyph &glyph, Surface &surface, uint32 x, uint32 y)
Definition: nftrfont.cpp:471
TextureHandle _texture
Definition: nftrfont.h:98
void readWidths(Common::SeekableSubReadStreamEndian &nftr, Header &header, std::vector< Glyph > &glyphs)
Definition: nftrfont.cpp:239
Low-level type definitions to handle fixed width types portably.
An abstract font.
Definition: font.h:39
void readInfo(Common::SeekableSubReadStreamEndian &nftr, Header &header)
Definition: nftrfont.cpp:157
uint32_t uint32
Definition: types.h:204
void load(Common::SeekableSubReadStreamEndian &nftr)
Definition: nftrfont.cpp:114
Base class for Nitro (Nintendo DS) files.
static uint32 convertToUTF32(uint16 codePoint, uint8 encoding)
Definition: nftrfont.cpp:521
A handle to a texture.
Definition: texturehandle.h:51
Interface for a seekable & readable data stream.
Definition: readstream.h:265
A font.