ScummVM API documentation
fontresource.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 ILLUSIONS_FONTRESOURCE_H
23 #define ILLUSIONS_FONTRESOURCE_H
24 
25 #include "illusions/graphics.h"
26 #include "illusions/resourcesystem.h"
27 
28 namespace Illusions {
29 
30 class IllusionsEngine;
31 
33 public:
34  FontResourceLoader(IllusionsEngine *vm) : _vm(vm) {}
35  ~FontResourceLoader() override {}
36  void load(Resource *resource) override;
37  bool isFlag(int flag) override;
38 protected:
39  IllusionsEngine *_vm;
40 };
41 
42 struct CharInfo {
43  int16 _width;
44  int16 _field_2;
45  byte *_pixels;
46  void load(byte *dataStart, Common::SeekableReadStream &stream);
47 };
48 
49 struct CharRange {
50  CharRange();
51  ~CharRange();
52  uint16 _firstChar;
53  uint16 _lastChar;
54  CharInfo *_charInfos;
55  void load(byte *dataStart, Common::SeekableReadStream &stream);
56  CharInfo *getCharInfo(uint16 c);
57  bool containsChar(uint16 c);
58 };
59 
60 class FontResource {
61 public:
62  FontResource();
63  ~FontResource();
64  void load(Resource *resource);
65  CharInfo *getCharInfo(uint16 c);
66  int16 getColorIndex() const { return _colorIndex; }
67  int16 getCharHeight() const { return _charHeight; }
68  int16 getLineIncr() const { return _lineIncr; }
69  const Common::Rect calculateRectForText(uint16 *text, uint textLength);
70 public:
71  uint32 _totalSize;
72  int16 _charHeight;
73  int16 _defaultChar;
74  int16 _colorIndex;
75  int16 _lineIncr;
76  int16 _widthC;
77  uint _charRangesCount;
78  CharRange *_charRanges;
79  CharRange *getCharRange(uint16 c);
80 };
81 
83 public:
85  void load(Resource *resource) override;
86  void unload() override;
87 public:
88  IllusionsEngine *_vm;
89  FontResource *_fontResource;
90  uint32 _resId;
91 };
92 
93 } // End of namespace Illusions
94 
95 #endif // ILLUSIONS_FONTRESOURCE_H
Definition: fontresource.h:42
Definition: fontresource.h:60
Definition: fontresource.h:82
Definition: fontresource.h:32
Definition: fontresource.h:49
Definition: rect.h:144
Definition: actor.h:34
Definition: stream.h:745
Definition: resourcesystem.h:51
Definition: resourcesystem.h:42
Definition: resourcesystem.h:78
Definition: illusions.h:92