xoreos  0.0.5
ttf.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_TTF_H
26 #define GRAPHICS_TTF_H
27 
28 #include <ft2build.h>
29 #include FT_FREETYPE_H
30 #include FT_GLYPH_H
31 
32 #include "src/common/types.h"
33 #include "src/common/scopedptr.h"
34 #include "src/common/readstream.h"
35 
36 namespace Graphics {
37 
38 class Surface;
39 
40 class TTFRenderer {
41 public:
43  TTFRenderer(Common::SeekableReadStream &ttfFile, int height);
44  ~TTFRenderer();
45 
47  int getHeight() const;
49  int getMaxWidth() const;
50 
52  bool hasChar(uint32 ch) const;
53 
55  int getCharWidth(uint32 ch) const;
56 
58  void drawCharacter(uint32 ch, Surface &surface, int x, int y);
59 
60 private:
61  FT_Library _library;
62  FT_Face _face;
63 
65 
68 
69  void getFaceMetrics(int &advance, int &yOffset, int &xMin) const;
70 };
71 
72 } // End of namespace Graphics
73 
74 #endif // GRAPHICS_TTF_H
bool hasChar(uint32 ch) const
Does the font have the specified character?
Definition: ttf.cpp:115
A simple scoped smart pointer template.
FT_Library _library
Definition: ttf.h:61
int getMaxWidth() const
Return the max width of a character in pixels.
Definition: ttf.cpp:103
int getCharWidth(uint32 ch) const
Return the width of a specific character in pixels.
Definition: ttf.cpp:119
Low-level type definitions to handle fixed width types portably.
void getFaceMetrics(int &advance, int &yOffset, int &xMin) const
Definition: ttf.cpp:107
Basic reading stream interfaces.
uint32_t uint32
Definition: types.h:204
Common::ScopedArray< byte > _fileBuffer
Definition: ttf.h:64
TTFRenderer(Common::SeekableReadStream &ttfFile, int height)
Create a TTF renderer with this TTF in the specified line height in pixels.
Definition: ttf.cpp:48
int getHeight() const
Return the height of a character in pixels.
Definition: ttf.cpp:99
Interface for a seekable & readable data stream.
Definition: readstream.h:265
void drawCharacter(uint32 ch, Surface &surface, int x, int y)
Draw a specific character onto a BGRA surface.
Definition: ttf.cpp:134
FT_Face _face
Definition: ttf.h:62