27 #include "common/list.h" 36 #define FONT_SHOWUNDEFINED 1 // Define to draw undefined characters * as ?'s 40 #define FONT_FIRSTCHAR 33 43 #define FONT_CH_SPACE 32 44 #define FONT_CH_QMARK 63 48 #define FONT_DESCSIZE 1286 50 #define FONT_CHARCOUNT 256 51 #define FONT_CHARMASK 0xFFU 53 #define SAGA_FONT_HEADER_LEN 6 55 #define TEXT_CENTERLIMIT 50 56 #define TEXT_MARGIN 10 57 #define TEXT_LINESPACING 2 59 enum FontEffectFlags {
61 kFontOutline = 1 << 0,
64 kFontCentered = 1 << 3,
83 KnownColor knownColor;
84 KnownColor effectKnownColor;
85 FontEffectFlags flags;
94 knownColor = kKnownColorTransparent;
95 effectKnownColor = kKnownColorTransparent;
97 font = kKnownFontSmall;
102 return 0 == memcmp(
this, &e,
sizeof(*
this));
149 int getStringWidth(KnownFont font,
const char *text,
size_t count, FontEffectFlags flags) {
150 return getStringWidth(knownFont2FontIdx(font), text, count, flags);
153 int getHeight(KnownFont font) {
154 return getHeight(knownFont2FontIdx(font));
157 int getHeight(KnownFont font,
const char *text,
int width, FontEffectFlags flags) {
158 return getHeight(knownFont2FontIdx(font), text, width, flags);
161 void textDraw(KnownFont font,
const char *
string,
const Common::Point &point,
int color,
int effectColor, FontEffectFlags flags) {
162 textDraw(knownFont2FontIdx(font),
string, point, color, effectColor, flags);
165 void textDrawRect(KnownFont font,
const char *text,
const Common::Rect &rect,
int color,
int effectColor, FontEffectFlags flags) {
166 textDrawRect(knownFont2FontIdx(font), text, rect, color, effectColor, flags);
169 virtual void setFontMapping(
int) {}
185 FontId knownFont2FontIdx(KnownFont font);
186 void textDraw(FontId fontId,
const char *
string,
const Common::Point &point,
int color,
int effectColor, FontEffectFlags flags);
188 virtual void textDrawRect(FontId fontId,
const char *text,
const Common::Rect &rect,
int color,
int effectColor, FontEffectFlags flags) = 0;
189 virtual int translateChar(
int charId) = 0;
190 virtual int getStringLength(
const char *text) = 0;
191 virtual int getStringWidth(FontId fontId,
const char *text,
size_t count, FontEffectFlags flags) = 0;
192 virtual int getHeight(FontId fontId,
const char *text,
int width, FontEffectFlags flags) = 0;
193 virtual int getHeight(FontId fontId) = 0;
194 virtual bool valid(FontId) = 0;
195 virtual void draw(FontId fontId,
const char *text,
size_t count,
const Common::Point &point,
int color,
int effectColor, FontEffectFlags flags) = 0;
203 void setFontMapping(
int mapping)
override {
204 _fontMapping = mapping;
208 void textDrawRect(FontId fontId,
const char *text,
const Common::Rect &rect,
int color,
int effectColor, FontEffectFlags flags)
override;
209 int translateChar(
int charId)
override;
210 int getStringLength(
const char *text)
override {
214 int getStringWidth(FontId fontId,
const char *text,
size_t count, FontEffectFlags flags)
override;
215 int getHeight(FontId fontId,
const char *text,
int width, FontEffectFlags flags)
override;
216 int getHeight(FontId fontId)
override {
217 return getFont(fontId)->normal.header.charHeight;
220 int getHeight(FontId fontId,
const char *text);
222 void validate(FontId fontId) {
223 if (!valid(fontId)) {
224 error(
"Font::validate: Invalid font id");
228 bool valid(FontId fontId)
override {
229 return (uint(fontId) < _fonts.size());
234 return &_fonts[fontId];
237 void draw(FontId fontId,
const char *text,
size_t count,
const Common::Point &point,
int color,
int effectColor, FontEffectFlags flags)
override;
238 void outFont(
const FontStyle &drawFont,
const char *text,
size_t count,
const Common::Point &point,
int color, FontEffectFlags flags);
239 void loadFont(
FontData *font, uint32 fontResourceId);
240 void loadFont(
FontData *font,
const ByteArray& fontResourceData,
bool isBigEndian);
241 void loadChineseFontIHNM(
FontData *font, uint32 fontResourceId);
244 void saveBig5Index(byte head, byte tail, uint curIdx);
246 void blitGlyph(
const Common::Point &textPoint,
const byte* bitmap,
int charWidth,
int charHeight,
int rowLength, byte color);
248 int getByteLen(
int numBits)
const {
249 int byteLength = numBits / 8;
258 static const int _charMap[128];
270 static const int kIHNMKoreanGlyphBytes = 32;
271 static const int kIHNMKoreanInitials = 20;
272 static const int kIHNMKoreanInitialVariants = 8;
273 static const int kIHNMKoreanMidOffset = kIHNMKoreanInitialVariants * kIHNMKoreanInitials;
274 static const int kIHNMKoreanMids = 22;
275 static const int kIHNMKoreanMidVariants = 4;
276 static const int kIHNMKoreanFinalsOffset = kIHNMKoreanMidOffset + kIHNMKoreanMids * kIHNMKoreanMidVariants;
277 static const int kIHNMKoreanFinals = 28;
278 static const int kIHNMKoreanFinalVariants = 4;
279 static const int kIHNMKoreanNonJamoOffset = kIHNMKoreanFinalsOffset + kIHNMKoreanFinals * kIHNMKoreanFinalVariants;
280 static const int kIHNMKoreanNonJamo = 126;
289 void textDrawRect(FontId fontId,
const char *text,
const Common::Rect &rect,
int color,
int effectColor, FontEffectFlags flags)
override;
290 int translateChar(
int charId)
override {
return charId; }
291 int getStringLength(
const char *text)
override;
292 int getStringWidth(FontId fontId,
const char *text,
size_t count, FontEffectFlags flags)
override;
293 int getHeight(FontId fontId,
const char *text,
int width, FontEffectFlags flags)
override;
294 int getHeight(FontId fontId)
override;
295 bool valid(FontId fontId)
override {
return fontId != kBigFont; }
297 void draw(FontId fontId,
const char *text,
size_t count,
const Common::Point &point,
int color,
int effectColor, FontEffectFlags flags)
override;
299 uint16 fetchChar(
const char *&s)
const;
300 bool preventLineBreakForCharacter(uint16 ch)
const;
302 Graphics::FontSJIS *_font;
iterator end()
Definition: list.h:240
Definition: formatinfo.h:28
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
void push_back(const t_T &element)
Definition: list.h:140