1 /* ScummVM - Graphic Adventure Engine
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.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 // The code in this file is currently only used in KYRA and SCI.
26 // So if neither of those is enabled, we will skip compiling it.
27 // If you plan to use this code in another engine, you will have
28 // to add the proper define check here.
29 // Also please add the define check at the comment after the
30 // matching #endif further down this file.
31 #if defined(ENABLE_KYRA) || defined(ENABLE_SCI)
33 #ifndef GRAPHICS_SJIS_H
34 #define GRAPHICS_SJIS_H
36 #include "common/scummsys.h"
37 #include "common/stream.h"
38 #include "common/util.h"
40 #include "graphics/surface.h"
45 * A font that is able to draw SJIS encoded characters.
47 * The font is always monospaced.
51 virtual ~FontSJIS() {}
54 * Creates the first SJIS font, which ROM/font file is present.
55 * It will also call loadData, so the user can just start
58 * It'll prefer the platform specific ROM file, when platform
59 * is set to a value, which's font ROM is supported.
60 * So far that is only kPlatformFMTowns.
62 * The last file tried is ScummVM's SJIS.FNT file.
64 static FontSJIS
*createFont(const Common::Platform platform
= Common::kPlatformUnknown
);
69 virtual bool loadData() = 0;
72 * Enable outline drawing.
74 * After changing outline state, getFontHeight and getFontWidth might return
77 virtual void enableOutline(bool enable
) {}
80 * Returns the height of the font.
82 virtual uint
getFontHeight() const = 0;
85 * Returns the width of the font.
87 virtual uint
getFontWidth() const = 0;
90 * Draws a SJIS encoded character on the given surface.
92 * TODO: Currently there is no assurance, that this method will only draw within
93 * the surface boundaries. Thus the caller has to assure the glyph will fit at
94 * the specified position.
96 void drawChar(Graphics::Surface
&dst
, uint16 ch
, int x
, int y
, uint32 c1
, uint32 c2
) const {
97 drawChar(dst
.getBasePtr(x
, y
), ch
, c1
, c2
, dst
.pitch
, dst
.bytesPerPixel
);
101 * Draws a SJIS char on the given raw buffer.
103 * @param dst pointer to the destination
104 * @param ch character to draw (in little endian)
105 * @param pitch pitch of the destination buffer (size in *bytes*)
106 * @param bpp bytes per pixel of the destination buffer
107 * @param c1 forground color
108 * @param c2 outline color
110 virtual void drawChar(void *dst
, uint16 ch
, int pitch
, int bpp
, uint32 c1
, uint32 c2
) const = 0;
114 * A base class to render 16x16 monochrome SJIS fonts.
116 class FontSJIS16x16
: public FontSJIS
{
118 FontSJIS16x16() : _outlineEnabled(false) {}
120 void enableOutline(bool enable
) { _outlineEnabled
= enable
; }
122 uint
getFontHeight() const { return _outlineEnabled
? 18 : 16; }
123 uint
getFontWidth() const { return _outlineEnabled
? 18 : 16; }
125 void drawChar(void *dst
, uint16 ch
, int pitch
, int bpp
, uint32 c1
, uint32 c2
) const;
128 template<typename Color
>
129 void drawCharInternOutline(const uint16
*glyph
, uint8
*dst
, int pitch
, Color c1
, Color c2
) const;
131 template<typename Color
>
132 void drawCharIntern(const uint16
*glyph
, uint8
*dst
, int pitch
, Color c1
) const;
134 bool _outlineEnabled
;
137 virtual const uint16
*getCharData(uint16 c
) const = 0;
141 * FM-TOWNS ROM based SJIS compatible font.
143 * This is used in KYRA and SCI.
145 class FontTowns
: public FontSJIS16x16
{
148 * Loads the ROM data from "FMT_FNT.ROM".
154 kFontRomSize
= 262144
157 uint16 _fontData
[kFontRomSize
/ 2];
159 const uint16
*getCharData(uint16 c
) const;
163 * Our custom SJIS FNT.
165 class FontSjisSVM
: public FontSJIS16x16
{
167 FontSjisSVM() : _fontData(0) {}
168 ~FontSjisSVM() { delete[] _fontData
; }
171 * Load the font data from "SJIS.FNT".
178 const uint16
*getCharData(uint16 c
) const;
181 // TODO: Consider adding support for PC98 ROM
183 } // end of namespace Graphics
187 #endif // defined(ENABLE_KYRA) || defined(ENABLE_SCI)