ScummVM API documentation
font.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 MEDIASTATION_FONT_H
23 #define MEDIASTATION_FONT_H
24 
25 #include "mediastation/actor.h"
26 #include "mediastation/bitmap.h"
27 #include "mediastation/datafile.h"
28 #include "mediastation/mediascript/scriptvalue.h"
29 #include "mediastation/mediascript/scriptconstants.h"
30 
31 namespace MediaStation {
32 
33 class FontCharacter : public PixMapImage {
34 public:
35  FontCharacter(Chunk &chunk, uint charCode, int horizontalSpacing, int baselineOffset, const ImageInfo &header);
36 
37  // Returns the ascent (baseline position). Falls back to full height if baseline offset is not specified.
38  int16 ascent() const { return (_baselineOffset != 0) ? _baselineOffset : height(); }
39  uint _charCode = 0;
40  int16 _horizontalSpacing = 0; // Additional horizontal spacing added after the glyph width to get total advance
41 
42 private:
43  int16 _baselineOffset = 0; // Baseline position within the glyph bitmap (ascent - distance from top edge to baseline)
44 };
45 
46 class FontActor : public Actor, public ChannelClient {
47 public:
48  FontActor() : Actor(kActorTypeFont) {};
49  ~FontActor();
50 
51  virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
52  virtual void readChunk(Chunk &chunk) override;
53  virtual void loadIsComplete() override;
54 
55  FontCharacter *lookupCharacter(uint charCode) { return _characters.getValOrDefault(charCode); }
56 
57  int16 _totalWidthOfAllChars = 0;
58  int16 _totalHeightOfAllChars = 0;
59  int16 _averageCharWidth = 0;
60  int16 _averageCharHeight = 0;
61  int16 _maxAscent = 0; // Maximum ascent (distance from top to baseline) across all glyphs.
62  int16 _maxDescent = 0; // Maximum descent (distance from baseline to bottom) across all glyphs.
63 
64 private:
66 };
67 
68 } // End of namespace MediaStation
69 
70 #endif
Definition: actor.h:33
Definition: font.h:33
Definition: datafile.h:102
Definition: datafile.h:163
Definition: hashmap.h:85
Definition: bitmap.h:41
Definition: bitmap.h:52
Definition: font.h:46
Definition: actor.h:187