ScummVM API documentation
bgifont.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 #ifndef GRAPHICS_FONTS_BGIFONT_H
22 #define GRAPHICS_FONTS_BGIFONT_H
23 
24 #include "common/file.h"
25 #include "common/array.h"
26 #include "graphics/font.h"
27 #include "graphics/surface.h"
28 
29 namespace Graphics {
30 
31 const int OPCODE_END = 0;
32 const int OPCODE_DOSCAN = 1;
33 const int OPCODE_MOVE = 2;
34 const int OPCODE_DRAW = 3;
35 
36 class BgiFont : public Font {
37 public:
38  BgiFont();
39  ~BgiFont();
40 
41  bool loadChr(const Common::Path &fileName);
42  bool loadChr(Common::SeekableReadStream &stream);
43 
44  void close();
45 
46  int getFontHeight() const { return _totalHeight; }
47  int getCharWidth(uint32 chr) const;
48  int getMaxCharWidth() const { return _maxWidth; }
49  void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
50 
51 private:
52  struct DrawingInstruction {
53  int opCode;
54  int8 xCoord;
55  int8 yCoord;
56  };
57 
58  struct GlyphEntry {
59  GlyphEntry() {
60  charWidth = 0;
61  offset = 0;
62  }
63  ~GlyphEntry() {}
64 
65  uint16 charWidth;
66  uint32 offset;
68  } *_glyphs;
69 
70  struct CachedFont {
71  int widths[256];
72  int offsets[256];
73  Graphics::Surface *surface;
74  ~CachedFont() {
75  delete surface;
76  }
77  };
78 
79  uint16 _charCount;
80  byte _firstChar;
81  // uint16 _pixHeight;
82  uint16 _maxWidth = 10;
83  uint32 _totalWidth = 0;
84  int16 _totalHeight = 0;
85  int8 _originToAscender = 0;
86  int8 _originToDescender = 0;
87  Common::Array<CachedFont *> _fontCache;
88 
89  uint16 characterToIndex(uint32 character) const;
90  byte fixSign(byte original);
91  CachedFont *drawCachedFont(int size);
92 };
93 
94 } // namespace Graphics
95 
96 #endif
int getCharWidth(uint32 chr) const
Definition: bgifont.h:36
int getFontHeight() const
Definition: bgifont.h:46
Definition: font.h:83
Definition: surface.h:67
int getMaxCharWidth() const
Definition: bgifont.h:48
Definition: array.h:52
Definition: path.h:52
Definition: stream.h:745
void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const
Definition: formatinfo.h:28