ScummVM API documentation
korfont.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 GRAPHICS_KORFONT_H
23 #define GRAPHICS_KORFONT_H
24 
25 #include "common/str.h"
26 #include "graphics/surface.h"
27 
28 namespace Graphics {
29 
42 class FontKorean {
43 public:
44  virtual ~FontKorean() {}
45 
53  static FontKorean *createFont(const char * fontFile);
54 
58  virtual bool loadData(const char *fontFile) = 0;
59 
66  enum DrawingMode {
67  kDefaultMode,
68  kOutlineMode,
69  kShadowMode
70  };
71 
72  virtual void setDrawingMode(DrawingMode mode) {}
73 
77  virtual void toggleFlippedMode(bool enable) {}
78 
82  virtual void setCharSpacing(int spacing) {}
83  virtual void setLineSpacing(int spacing) {}
84 
88  virtual uint getFontHeight() const = 0;
89 
93  virtual uint getMaxFontWidth() const = 0;
94 
98  virtual uint getCharWidth(uint16 ch) const = 0;
99 
103  void drawChar(Graphics::Surface &dst, uint16 ch, int x, int y, uint32 c1, uint32 c2) const;
104 
117  virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const = 0;
118 };
119 
123 class FontKoreanBase : public FontKorean {
124 public:
125  FontKoreanBase();
126 
127  virtual void setDrawingMode(DrawingMode mode);
128 
129  virtual void toggleFlippedMode(bool enable);
130 
131  virtual uint getFontHeight() const;
132 
133  virtual uint getMaxFontWidth() const;
134 
135  virtual uint getCharWidth(uint16 ch) const;
136 
137  virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW, int maxH) const;
138 private:
139  template<typename Color>
140  void blitCharacter(const uint8 *glyph, const int w, const int h, uint8 *dst, int pitch, Color c) const;
141  void createOutline(uint8 *outline, const uint8 *glyph, const int w, const int h) const;
142 
143 protected:
144  DrawingMode _drawMode;
145  bool _flippedMode;
146  int _fontWidth, _fontHeight;
147  uint8 _bitPosNewLineMask;
148 
149  bool isASCII(uint16 ch) const;
150 
151  virtual const uint8 *getCharData(uint16 c) const = 0;
152 
153  enum DrawingFeature {
154  kFeatDefault = 1 << 0,
155  kFeatOutline = 1 << 1,
156  kFeatShadow = 1 << 2,
157  kFeatFMTownsShadow = 1 << 3,
158  kFeatFlipped = 1 << 4
159  };
160 
161  virtual bool hasFeature(int feat) const = 0;
162 };
163 
168 public:
169  FontKoreanSVM();
170  ~FontKoreanSVM();
174  bool loadData(const char *fontFile);
175 private:
176  uint8 *_fontData16x16;
177  uint _fontData16x16Size;
178 
179  uint8 *_fontData8x16;
180  uint _fontData8x16Size;
181 
182  uint8 *_fontData8x8;
183  uint _fontData8x8Size;
184 
185  virtual const uint8 *getCharData(uint16 c) const;
186 
187  bool hasFeature(int feat) const;
188 
189  const uint8 *getCharDataPCE(uint16 c) const;
190  const uint8 *getCharDataDefault(uint16 c) const;
191 
192  enum {
193  kKoreanFontVersion = 3
194  };
195 };
196 
201 public:
207  bool loadData(const char *fontFile);
208 private:
209  enum {
210  eFontNumChars = 256,
211  kFontNumChars = 2530
212  };
213 
214  int _fontShadow;
215  uint8 *_fontData;
216  uint _fontDataSize;
217 
218  int _englishFontWidth;
219  int _englishFontHeight;
220  uint8 *_englishFontData;
221  uint _englishFontDataSize;
222 
223 
224  virtual const uint8 *getCharData(uint16 c) const;
225 
226  bool hasFeature(int feat) const;
227 
228  bool englishLoadData(const char *fontFile);
229 };
231 } // End of namespace Graphics
232 
233 #endif
virtual uint getMaxFontWidth() const =0
virtual bool loadData(const char *fontFile)=0
Definition: surface.h:67
DrawingMode
Definition: korfont.h:66
Definition: korfont.h:42
virtual void setCharSpacing(int spacing)
Definition: korfont.h:82
Definition: korfont.h:123
static FontKorean * createFont(const char *fontFile)
Definition: korfont.h:200
virtual uint getCharWidth(uint16 ch) const =0
Definition: korfont.h:167
virtual void toggleFlippedMode(bool enable)
Definition: korfont.h:77
Definition: formatinfo.h:28
void drawChar(Graphics::Surface &dst, uint16 ch, int x, int y, uint32 c1, uint32 c2) const
virtual uint getFontHeight() const =0