ScummVM API documentation
smush_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 #ifndef SCUMM_SMUSH_FONT_H
23 #define SCUMM_SMUSH_FONT_H
24 
25 #include "common/scummsys.h"
26 #include "scumm/nut_renderer.h"
27 #include "scumm/scumm.h"
28 #include "scumm/string_v7.h"
29 
30 namespace Scumm {
31 
32 class SmushFont : public NutRenderer, public GlyphRenderer_v7 {
33 public:
34  SmushFont(ScummEngine *vm, const char *filename, bool useOriginalColors) :
35  NutRenderer(vm, filename), _hardcodedFontColors(useOriginalColors) {
36  _r = new TextRenderer_v7(vm, this);
37  }
38 
39  ~SmushFont() override { delete _r;}
40 
41  void drawString(const char *str, byte *buffer, Common::Rect &clipRect, int x, int y, int16 col, TextStyleFlags flags) {
42  _r->drawString(str, buffer, clipRect, x, y, _vm->_screenWidth, col, flags);
43  }
44 
45  void drawStringWrap(const char *str, byte *buffer, Common::Rect &clipRect, int x, int y, int16 col, TextStyleFlags flags) {
46  _r->drawStringWrap(str, buffer, clipRect, x, y, _vm->_screenWidth, col, flags);
47  }
48 
49 private:
50  int draw2byte(byte *buffer, Common::Rect &clipRect, int x, int y, int pitch, int16 col, uint16 chr) override {
51  return NutRenderer::draw2byte(buffer, clipRect, x, y, pitch, _vm->_game.id == GID_CMI ? 255 : (_vm->_game.id == GID_DIG && col == -1 ? 1 : col), chr);
52  }
53 
54  int drawCharV7(byte *buffer, Common::Rect &clipRect, int x, int y, int pitch, int16 col, TextStyleFlags flags, byte chr) override {
55  return NutRenderer::drawCharV7(buffer, clipRect, x, y, pitch, col, flags, chr, _hardcodedFontColors, true);
56  }
57 
58  int getCharWidth(uint16 chr) const override { return NutRenderer::getCharWidth(chr & 0xFF); }
59  int getCharHeight(uint16 chr) const override { return NutRenderer::getCharHeight(chr & 0xFF); }
60  int getFontHeight() const override { return NutRenderer::getFontHeight(); }
61  int setFont(int) override { return 0; }
62  bool newStyleWrapping() const override { return true; }
63 
64  TextRenderer_v7 *_r;
65  const bool _hardcodedFontColors;
66 };
67 
68 } // End of namespace Scumm
69 
70 #endif
Definition: rect.h:144
Definition: scumm.h:518
Definition: smush_font.h:32
Definition: actor.h:30