ScummVM API documentation
scifont.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 SCI_GRAPHICS_SCIFONT_H
23 #define SCI_GRAPHICS_SCIFONT_H
24 
25 #include "sci/resource/resource.h"
26 #include "sci/graphics/helpers.h"
27 #include "sci/util.h"
28 
29 namespace Sci {
30 
31 #ifdef ENABLE_SCI32
32 enum {
33  kSci32SystemFont = -1
34 };
35 #endif
36 
37 class GfxFont {
38 public:
39  GfxFont() {}
40  virtual ~GfxFont() {}
41 
42  virtual GuiResourceId getResourceId() { return 0; }
43  virtual byte getHeight() { return 0; }
44  virtual bool isDoubleByte(uint16 chr) { return false; }
45  virtual byte getCharWidth(uint16 chr) { return 0; }
46  virtual byte getCharHeight(uint16 chr) { return 0; }
47  virtual void draw(uint16 chr, int16 top, int16 left, byte color, bool greyedOutput) {}
48  virtual void drawToBuffer(uint16 chr, int16 top, int16 left, byte color, bool greyedOutput, byte *buffer, int16 width, int16 height) {}
49 };
50 
51 
56 class GfxFontFromResource : public GfxFont {
57 public:
58  GfxFontFromResource(ResourceManager *resMan, GfxScreen *screen, GuiResourceId resourceId);
59  ~GfxFontFromResource() override;
60 
61  GuiResourceId getResourceId() override;
62  uint8 getHeight() override;
63  uint8 getCharWidth(uint16 chr) override;
64  void draw(uint16 chr, int16 top, int16 left, byte color, bool greyedOutput) override;
65 #ifdef ENABLE_SCI32
66  // SCI2/2.1 equivalent
67  void drawToBuffer(uint16 chr, int16 top, int16 left, byte color, bool greyedOutput, byte *buffer, int16 width, int16 height) override;
68 #endif
69 
70 private:
71  uint8 getCharHeight(uint16 chr) override;
72  SciSpan<const byte> getCharData(uint16 chr);
73 
74  ResourceManager *_resMan;
75  GfxScreen *_screen;
76 
77  Resource *_resource;
78  SciSpan<const byte> _resourceData;
79  GuiResourceId _resourceId;
80 
81  struct Charinfo {
82  uint8 width, height;
83  int16 offset;
84  };
85 
86  uint8 _fontHeight;
87  uint16 _numChars;
88  Charinfo *_chars;
89 };
90 
91 } // End of namespace Sci
92 
93 #endif // SCI_GRAPHICS_SCIFONT_H
Definition: scifont.h:56
Definition: resource.h:327
Definition: scifont.h:37
Definition: resource.h:256
Definition: console.h:28
Definition: screen.h:70