ScummVM API documentation
gui_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 NUVIE_GUI_GUI_FONT_H
23 #define NUVIE_GUI_GUI_FONT_H
24 
25 #include "ultima/nuvie/core/nuvie_defs.h"
26 
27 namespace Ultima {
28 namespace Nuvie {
29 
30 enum GuiFont {
31  GUI_FONT_DEFAULT = 0,
32  GUI_FONT_6X8 = 1,
33  GUI_FONT_GUMP = 2
34 };
35 
36 class GUI_Font {
37 protected:
38  /* the font source surface */
39  Graphics::ManagedSurface *_fontStore;
40 
41  /* flags */
42  bool _transparent;
43  DisposeAfterUse::Flag _disposeFont;
44 
45  /* dimensions */
46  int _charH, _charW;
47 
48  byte *_wData;
49 public:
50  /* use default 8x8 font */
51  GUI_Font(uint8 fontType = GUI_FONT_DEFAULT);
52 
53  /* open named BMP file */
54  GUI_Font(const char *name);
55 
56  /* use given YxY surface */
58 
59  GUI_Font(const GUI_Font &font) = delete;
60 
61  virtual ~GUI_Font();
62 
63  /* determine drawing style */
64  virtual void setTransparency(bool on);
65 
66  /* determine foreground and background color values RGB*/
67  virtual void setColoring(uint8 fr, uint8 fg, uint8 fb, uint8 br = 255, uint8 bg = 255, uint8 bb = 255);
68  /* Two color font */
69  virtual void setColoring(uint8 fr, uint8 fg, uint8 fb, uint8 fr1, uint8 fg1, uint8 fb1, uint8 br, uint8 bg, uint8 bb);
70 
71  /* yields the pixel height of a single character */
72  inline virtual int charHeight() const {
73  return _charH - 1;
74  }
75 
76  /* yields the pixel width of a single character */
77  inline virtual int charWidth() const {
78  return _charW;
79  }
80 
81  /* put the text onto the given surface using the preset mode and colors */
82  virtual void textOut(Graphics::ManagedSurface *context, int x, int y, const char *text, int line_wrap = 0);
83 
84  /* yields pixel width and height of a string when printed with this font */
85  void textExtent(const char *text, int *w, int *h, int line_wrap = 0);
86 
87  /* yields the center (of width) where the text should be placed or 0 if larger than width */
88  uint16 getCenter(const char *text, uint16 width);
89 };
90 
91 } // End of namespace Nuvie
92 } // End of namespace Ultima
93 
94 #endif
Definition: managed_surface.h:51
Definition: gui_font.h:36
Definition: detection.h:27