ScummVM API documentation
fonts.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#ifndef SHERLOCK_FONTS_H
23#define SHERLOCK_FONTS_H
24
25#include "common/rect.h"
26#include "common/platform.h"
27#include "graphics/big5.h"
28#include "graphics/surface.h"
29
30namespace Sherlock {
31
32class SherlockEngine;
33class ImageFile;
34class BaseSurface;
35
36class Fonts {
37private:
38 struct ChinaFontCodElement {
39 uint16 a;
40 uint16 b;
41 uint8 c;
42 };
43 static ImageFile *_font;
44 static byte *_chineseFont;
45 static Graphics::Big5Font *_big5Font;
46 static byte _yOffsets[255];
47 static int _fontNumber;
48 static int _fontHeight;
49 static int _widestChar;
50 static uint16 _charCount;
51 static bool _isModifiedEucCn;
52 static bool _isBig5;
53
54 static inline byte translateChar(byte c);
55protected:
56 static SherlockEngine *_vm;
57
58 static void writeString(BaseSurface *surface, const Common::String &str,
59 const Common::Point &pt, int overrideColor = 0);
60
61public:
62 static const int kChineseWidth = 16;
63 static const int kChineseHeight = 16;
64
68 static void setVm(SherlockEngine *vm);
69
73 static void freeFont();
74
75 static bool isModifiedEucCn() { return _isModifiedEucCn; }
76 static bool isBig5() { return _isBig5; }
77
81 void setFont(int fontNum);
82
86 int stringWidth(const Common::String &str);
87
92
93 static Common::String unescape(const Common::String& in);
94
98 int charWidth(const char *str, int &idx);
99
103 int charWidth(char ch);
104
108 int charHeight(unsigned char c);
109
113 int fontHeight() const { return _chineseFont || _isBig5 ? MAX(_fontHeight, 16) : _fontHeight; }
114
118 int widestChar() const { return _widestChar; }
119
123 int fontNumber() const { return _fontNumber; }
124
125 Common::Array<Common::String> wordWrap(const Common::String &str, uint maxWidth, Common::String &rem,
126 uint maxChars = Common::String::npos, uint maxLines = Common::String::npos, bool skipHeadAt = false);
127 Common::Array<Common::String> wordWrap(const Common::String &str, uint maxWidth,
128 uint maxChars = Common::String::npos, uint maxLines = Common::String::npos, bool skipHeadAt = false);
129};
130
131} // End of namespace Sherlock
132
133#endif
Definition: str.h:59
Definition: big5.h:32
Definition: surface.h:41
Definition: fonts.h:36
static void setVm(SherlockEngine *vm)
int charWidth(char ch)
int fontHeight() const
Definition: fonts.h:113
int stringWidth(const Common::String &str)
int stringHeight(const Common::String &str)
static void freeFont()
int fontNumber() const
Definition: fonts.h:123
int widestChar() const
Definition: fonts.h:118
void setFont(int fontNum)
int charHeight(unsigned char c)
int charWidth(const char *str, int &idx)
Definition: image_file.h:78
Definition: sherlock.h:206
T MAX(T a, T b)
Definition: util.h:66
Definition: rect.h:144