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 
30 namespace Graphics {
31 struct Surface;
32 }
33 
34 namespace ZVision {
35 
36 struct FontStyle {
37  const char *zorkFont;
38  const char *fontBase;
39  const char *freeFontBase;
40  const char *freeFontItalicName;
41  const char *liberationFontBase;
42 };
43 
44 #define FONT_COUNT 9
45 
46 class ZVision;
47 
48 // Styled TTF
49 class StyledTTFont {
50 public:
51  StyledTTFont(ZVision *engine);
52  ~StyledTTFont();
53 
54  enum {
55  TTF_STYLE_BOLD = 0x01,
56  TTF_STYLE_ITALIC = 0x02,
57  TTF_STYLE_UNDERLINE = 0x04,
58  TTF_STYLE_STRIKETHROUGH = 0x08,
59  TTF_STYLE_SHARP = 0x10
60  };
61 
62 private:
63  ZVision *_engine;
64  Graphics::Font *_font;
65  int _lineHeight;
66  uint _style;
67  Common::String _fontName;
68 
69 public:
70  bool loadFont(const Common::String &fontName, int32 point, uint style);
71 
72  int getFontHeight();
73  int getMaxCharWidth();
74  int getCharWidth(uint16 chr);
75  int getKerningOffset(byte left, byte right);
76 
77  void drawChar(Graphics::Surface *dst, uint16 chr, int x, int y, uint32 color);
78 
79  void drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft);
80  int getStringWidth(const Common::String &str);
81 
82  Graphics::Surface *renderSolidText(const Common::String &str, uint32 color);
83 
84  bool isLoaded() {
85  return _font != NULL;
86  };
87 };
88 
89 } // End of namespace ZVision
90 
91 #endif
Definition: str.h:59
Definition: font.h:83
TextAlign
Definition: font.h:48
Definition: surface.h:67
Definition: truetype_font.h:49
Align the text to the left.
Definition: font.h:51
Definition: clock.h:29
Definition: formatinfo.h:28
Definition: truetype_font.h:36