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 /*
23  * This code is based on Broken Sword 2.5 engine
24  *
25  * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
26  *
27  * Licensed under GNU GPL v2
28  *
29  */
30 
31 #ifndef SWORD25_FONTRESOURCE_H
32 #define SWORD25_FONTRESOURCE_H
33 
34 #include "common/scummsys.h"
35 #include "common/rect.h"
36 #include "common/formats/xmlparser.h"
37 #include "sword25/kernel/common.h"
38 #include "sword25/kernel/resource.h"
39 
40 namespace Sword25 {
41 
42 class Kernel;
43 
45 public:
52  FontResource(Kernel *pKernel, const Common::String &fileName);
53 
59  bool isValid() const {
60  return _valid;
61  }
62 
68  int getLineHeight() const {
69  return _lineHeight;
70  }
71 
77  int getGapWidth() const {
78  return _gapWidth;
79  }
80 
86  const Common::Rect &getCharacterRect(int character) const {
87  assert(character >= 0 && character < 256);
88  return _characterRects[character];
89  }
90 
95  return _bitmapFileName;
96  }
97 
98 private:
99  Kernel *_pKernel;
100  bool _valid;
101  Common::String _bitmapFileName;
102  int _lineHeight;
103  int _gapWidth;
104  Common::Rect _characterRects[256];
105 
106  // Parser
107  CUSTOM_XML_PARSER(FontResource) {
108  XML_KEY(font)
109  XML_PROP(bitmap, true)
110  XML_PROP(lineheight, false)
111  XML_PROP(gap, false)
112 
113  XML_KEY(character)
114  XML_PROP(code, true)
115  XML_PROP(left, true)
116  XML_PROP(top, true)
117  XML_PROP(right, true)
118  XML_PROP(bottom, true)
119  KEY_END()
120  KEY_END()
121  } PARSER_END()
122 
123  // Parser callback methods
124  bool parserCallback_font(ParserNode *node);
125  bool parserCallback_character(ParserNode *node);
126 };
127 
128 } // End of namespace Sword25
129 
130 #endif
Definition: fontresource.h:44
Definition: str.h:59
bool isValid() const
Gibt true zurück, wenn das Objekt korrekt initialisiert wurde.
Definition: fontresource.h:59
Definition: rect.h:144
int getLineHeight() const
Gibt die Zeilenhöhe des Fonts in Pixeln zurück.
Definition: fontresource.h:68
Definition: xmlparser.h:145
Definition: resource.h:43
int getGapWidth() const
Gibt den Buchstabenabstand der Fonts in Pixeln zurück.
Definition: fontresource.h:77
Definition: xmlparser.h:98
Definition: console.h:27
Definition: kernel.h:72
const Common::String & getCharactermapFileName() const
Gibt den Dateinamen der Charactermap zurück.
Definition: fontresource.h:94
const Common::Rect & getCharacterRect(int character) const
Gibt das Bounding-Rect eines Zeichens auf der Charactermap zurück.
Definition: fontresource.h:86
FontResource(Kernel *pKernel, const Common::String &fileName)
Erzeugt eine neues Exemplar von BS_FontResource.