ScummVM API documentation
cryoextfont.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 CRYOMNI3D_FONTS_CRYOEXTFONT_H
23 #define CRYOMNI3D_FONTS_CRYOEXTFONT_H
24 
25 #include "common/array.h"
26 #include "common/hashmap.h"
27 #include "common/str.h"
28 #include "graphics/font.h"
29 
30 namespace Common {
31 class SeekableReadStream;
32 }
33 
34 namespace CryOmni3D {
35 
36 class CryoExtFont : public Graphics::Font {
37 public:
38  CryoExtFont() : _height(0), _maxAdvance(0), _crf(nullptr), _codepage(Common::kCodePageInvalid) { }
39  virtual ~CryoExtFont();
40 
41  void load(const Common::Path &fontFile, Common::CodePage encoding);
42 
43  virtual int getFontHeight() const { return _height; }
44  virtual int getMaxCharWidth() const { return _maxAdvance; }
45 
46  virtual int getCharWidth(uint32 chr) const;
47 
48  virtual Common::Rect getBoundingBox(uint32 chr) const;
49 
50  virtual void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const;
51 
52 private:
53  void loadOffsets(const Common::Path &offsetsFile);
54  void assureCached(uint32 chr) const;
55  uint32 mapGlyph(uint32 chr) const;
56 
57  struct Glyph {
58  uint16 h;
59  uint16 w;
60  int16 offX;
61  int16 offY;
62  uint16 advance;
63 
64  byte *bitmap;
65 
66  Glyph();
67  ~Glyph();
68 
69  uint setup(uint16 width, uint16 height);
70  };
71 
72  uint16 _height;
73  uint16 _maxAdvance;
74  byte _comment[32];
75 
76  Common::CodePage _codepage;
77 
78  mutable Common::SeekableReadStream *_crf;
79  Common::Array<uint32> _offsets;
80 
82  mutable GlyphCache _cache;
83 };
84 
85 } // End of namespace CryOmni3D
86 
87 #endif
Definition: cryomni3d.h:62
Definition: font.h:83
Definition: surface.h:67
virtual int getMaxCharWidth() const
Definition: cryoextfont.h:44
Definition: rect.h:144
Definition: path.h:52
Definition: stream.h:745
Definition: cryoextfont.h:36
Definition: algorithm.h:29
virtual int getFontHeight() const
Definition: cryoextfont.h:43