ScummVM API documentation
truetype_font.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22// This file is based on engines/wintermute/base/fonts/base_font_truetype.h/.cpp
23
24#ifndef ZVISION_TRUETYPE_FONT_H
25#define ZVISION_TRUETYPE_FONT_H
26
27#include "graphics/font.h"
28#include "graphics/pixelformat.h"
29
30namespace Graphics {
31struct Surface;
32}
33
34namespace ZVision {
35
36struct FontStyle {
37 const char *zorkFont;
38 const char *fontBase;
39 const char *liberationFontBase;
40};
41
42#define FONT_COUNT 9
43
44class ZVision;
45
46// Styled TTF
48public:
49 StyledTTFont(ZVision *engine);
51
52 enum {
53 TTF_STYLE_BOLD = 0x01,
54 TTF_STYLE_ITALIC = 0x02,
55 TTF_STYLE_UNDERLINE = 0x04,
56 TTF_STYLE_STRIKETHROUGH = 0x08,
57 TTF_STYLE_SHARP = 0x10
58 };
59
60private:
61 ZVision *_engine;
62 Graphics::Font *_font;
63 int _lineHeight;
64 uint _style;
65 Common::String _fontName;
66
67public:
68 bool loadFont(const Common::String &fontName, int32 point, uint style);
69
70 int getFontHeight();
71 int getMaxCharWidth();
72 int getCharWidth(uint32 chr);
73 int getKerningOffset(byte left, byte right);
74
75 void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color);
76
77 void drawString(Graphics::Surface *dst, const Common::U32String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft);
78 int getStringWidth(const Common::U32String &str);
79
80 Graphics::Surface *renderSolidText(const Common::U32String &str, uint32 color);
81
82 bool isLoaded() {
83 return _font != NULL;
84 };
85};
86
87} // End of namespace ZVision
88
89#endif
Definition: str.h:59
Definition: ustr.h:57
Definition: font.h:83
Definition: truetype_font.h:47
TextAlign
Definition: font.h:48
@ kTextAlignLeft
Align the text to the left.
Definition: font.h:51
Definition: formatinfo.h:28
Definition: focus_list.h:27
Definition: surface.h:67
Definition: truetype_font.h:36