ScummVM API documentation
gr_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 QDENGINE_SYSTEM_GRAPHICS_GR_FONT_H
23 #define QDENGINE_SYSTEM_GRAPHICS_GR_FONT_H
24 
25 #include "common/path.h"
26 #include "qdengine/system/graphics/gr_screen_region.h"
27 
28 namespace Common {
29 class SeekableReadStream;
30 }
31 
32 namespace QDEngine {
33 
34 class grFont {
35 public:
36  grFont();
37  ~grFont();
38 
39  bool load(const Common::Path fname);
40 
41  bool load_index(Common::SeekableReadStream *fh);
42  bool load_alpha(Common::SeekableReadStream *fh);
43 
44  int size_x() const {
45  return _size_x;
46  }
47  int size_y() const {
48  return _size_y;
49  }
50 
51  int alpha_buffer_size_x() const {
52  return _alpha_buffer_sx;
53  }
54  int alpha_buffer_size_y() const {
55  return _alpha_buffer_sy;
56  }
57 
58  const byte *alpha_buffer() const {
59  return _alpha_buffer;
60  }
61 
62  const grScreenRegion find_char(int code) const {
63  grFontCharVector::const_iterator it = Common::find(_chars.begin(), _chars.end(), code);
64  if (it != _chars.end()) return it->_region;
65 
66  return grScreenRegion_EMPTY;
67  }
68 
69  int char_width(int code) const {
70  return code == ' ' ? size_x() / 2 : find_char(code).size_x();
71  }
72 
73 private:
74 
75  int _size_x;
76  int _size_y;
77 
78  int _alpha_buffer_sx;
79  int _alpha_buffer_sy;
80  byte *_alpha_buffer;
81 
82  struct grFontChar {
83  grFontChar() : _code(-1) { }
84 
85  int _code;
86  grScreenRegion _region;
87 
88  bool operator == (int code) const {
89  return (_code == code);
90  }
91  };
92 
94  grFontCharVector _chars;
95 };
96 
97 } // namespace QDEngine
98 
99 #endif // QDENGINE_SYSTEM_GRAPHICS_GR_FONT_H
In find(In first, In last, const T &v)
Definition: algorithm.h:225
Definition: path.h:52
Definition: stream.h:745
Базовый класс для игровых ресурсов.
Definition: console.h:28
Definition: algorithm.h:29
Прямоугольная область на экране.
Definition: gr_screen_region.h:31
Definition: gr_font.h:34