ScummVM API documentation
font_he.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 SCUMM_HE_FONT_HE_H
23 #define SCUMM_HE_FONT_HE_H
24 
25 #include "common/array.h"
26 #include "common/list.h"
27 #include "common/scummsys.h"
28 #include "common/str.h"
29 
30 #include "graphics/font.h"
31 
32 namespace Scumm {
33 
34 class ScummEngine_v99he;
35 
36 // Font style flags, taken from the original
37 enum HEFontStyle {
38  kHEFontStyleItalic = 0x01,
39  kHEFontStyleUnderline = 0x02,
40  kHEFontStyleBold = 0x04,
41  kHEFontStyleCenter = 0x08,
42  kHEFontStyleLeft = 0x10,
43  kHEFontStyleRight = 0x20
44 };
45 
47  HEFontContextElement() : imageNumber(0),
48  font(nullptr),
49  fgColor(0),
50  bgColor(0),
51  transparentBg(false),
53 
55  delete font;
56  font = nullptr;
57  }
58 
59  int imageNumber;
60  Graphics::Font *font;
61  int fgColor;
62  int bgColor;
63  bool transparentBg;
64  Graphics::TextAlign align;
65 };
66 
67 struct HEFontEntry {
68  Common::String fileName; // Filename without extension (e.g., "LiberationSans-Bold")
69  Common::String fontName; // Actual font name from metadata (e.g., "Liberation Sans")
70 };
71 
72 class HEFont {
73 public:
74  HEFont(ScummEngine_v99he *vm);
75  ~HEFont();
76 
77  bool startFont(int imageNum);
78  bool endFont(int imageNum);
79  bool createFont(int imageNum, const char *fontName, int fgColor, int bgColor, int style, int size);
80  bool renderString(int imageNum, int imageState, int xPos, int yPos, const char *string);
81  int getStringWidth(int imageNum, const char *string);
82  int getStringHeight(int imageNum, const char *string);
83  int enumInit();
84  void enumDestroy();
85  const char *enumGet(int index);
86  int enumFind(const char *fontName);
87 
88 private:
89  ScummEngine_v99he *_vm;
90 
91  Common::List<HEFontContextElement *> _fontContextList;
92 
93  Common::Array<HEFontEntry> _fontEntries;
94  bool _fontsEnumerated;
95 
96  HEFontContextElement *findFontContext(int imageNum);
97  void enumerateFonts();
98 };
99 
100 } // End of namespace Scumm
101 
102 #endif // SCUMM_HE_FONT_HE_H
Center the text.
Definition: font.h:52
Definition: str.h:59
Definition: font_he.h:72
Definition: font.h:83
TextAlign
Definition: font.h:48
Definition: font_he.h:46
Definition: array.h:52
Definition: list.h:44
Definition: font_he.h:67
Definition: actor.h:30