ScummVM API documentation
text.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 #ifndef ZVISION_TEXT_H
24 #define ZVISION_TEXT_H
25 
26 #include "zvision/text/truetype_font.h"
27 #include "zvision/zvision.h"
28 
29 namespace ZVision {
30 
31 class ZVision;
32 
33 enum TextJustification {
34  TEXT_JUSTIFY_CENTER = 0,
35  TEXT_JUSTIFY_LEFT = 1,
36  TEXT_JUSTIFY_RIGHT = 2
37 };
38 
39 enum TextChange {
40  TEXT_CHANGE_NONE = 0x0,
41  TEXT_CHANGE_FONT_TYPE = 0x1,
42  TEXT_CHANGE_FONT_STYLE = 0x2,
43  TEXT_CHANGE_NEWLINE = 0x4,
44  TEXT_CHANGE_HAS_STATE_BOX = 0x8
45 };
46 
48 public:
50  TextChange parseStyle(const Common::String &str, int16 len);
51  void readAllStyles(const Common::String &txt);
52  void updateFontWithTextState(StyledTTFont &font);
53 
54  uint32 getTextColor(ZVision *engine) {
55  return engine->_resourcePixelFormat.RGBToColor(_red, _green, _blue);
56  }
57 
58 public:
59  Common::String _fontname;
60  TextJustification _justification;
61  int16 _size;
62  uint8 _red; // 0-255
63  uint8 _green; // 0-255
64  uint8 _blue; // 0-255
65  bool _italic;
66  bool _bold;
67  bool _underline;
68  bool _strikeout;
69  int32 _statebox;
70  bool _sharp;
71 };
72 
73 class TextRenderer {
74 public:
75  TextRenderer(ZVision *engine): _engine(engine) {};
76 
77  void drawTextWithJustification(const Common::String &text, StyledTTFont &font, uint32 color, Graphics::Surface &dest, int lineY, TextJustification jusification);
78  int32 drawText(const Common::String &text, TextStyleState &state, Graphics::Surface &dest);
79  void drawTextWithWordWrapping(const Common::String &text, Graphics::Surface &dest);
80 
81 private:
82  ZVision *_engine;
83 };
84 
85 Common::String readWideLine(Common::SeekableReadStream &stream);
86 int8 getUtf8CharSize(char chr);
87 uint16 readUtf8Char(const char *chr);
88 
89 } // End of namespace ZVision
90 
91 #endif
Definition: str.h:59
Definition: surface.h:66
Definition: truetype_font.h:49
Definition: text.h:47
Definition: stream.h:745
Definition: clock.h:29
Definition: text.h:73