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  uint16 _firstChar;
51  uint16 _lastChar;
52  CharInfo *_charInfos;
53  void load(byte *dataStart, Common::SeekableReadStream &stream);
54  CharInfo *getCharInfo(uint16 c);
55  bool containsChar(uint16 c);
56 };
57 
58 class FontResource {
59 public:
60  FontResource();
61  ~FontResource();
62  void load(Resource *resource);
63  CharInfo *getCharInfo(uint16 c);
64  int16 getColorIndex() const { return _colorIndex; }
65  int16 getCharHeight() const { return _charHeight; }
66  int16 getLineIncr() const { return _lineIncr; }
67  const Common::Rect calculateRectForText(uint16 *text, uint textLength);
68 public:
69  uint32 _totalSize;
70  int16 _charHeight;
71  int16 _defaultChar;
72  int16 _colorIndex;
73  int16 _lineIncr;
74  int16 _widthC;
75  uint _charRangesCount;
76  CharRange *_charRanges;
77  CharRange *getCharRange(uint16 c);
78 };
79 
81 public:
83  void load(Resource *resource) override;
84  void unload() override;
85 public:
86  IllusionsEngine *_vm;
87  FontResource *_fontResource;
88  uint32 _resId;
89 };
90 
91 } // End of namespace Illusions
92 
93 #endif // ILLUSIONS_FONTRESOURCE_H
Definition: fontresource.h:42
Definition: fontresource.h:58
Definition: fontresource.h:80
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