104 FONT_TITLE_BIG = 0x01 << 4,
105 FONT_TITLE_NORM = 0x02 << 4,
106 FONT_TITLE_LITTLE = 0x03 << 4,
117 FONT_HIGHLIGHT_NONE = 0x00 << 6,
118 FONT_HIGHLIGHT_LINK = 0x01 << 6,
119 FONT_HIGHLIGHT_TOKEN = 0x02 << 6,
120 FONT_HIGHLIGHT_TYPE = 0x03 << 6,
121 FONT_HIGHLIGHT_CONST = 0x04 << 6,
122 FONT_HIGHLIGHT_REM = 0x05 << 6,
123 FONT_HIGHLIGHT_KEY = 0x06 << 6,
124 FONT_HIGHLIGHT_TABLE = 0x07 << 6,
157 explicit UTF8Char(
char ch1 =
'\0',
char ch2 =
'\0',
char ch3 =
'\0')
158 : c1(ch1), c2(ch2), c3(ch3), pad(
'\0') {}
160 inline bool operator<(
const UTF8Char &other)
const
164 else if (c1 > other.c1)
169 else if (c2 > other.c2)
172 return c3 < other.c3;
175 inline bool operator==(
const UTF8Char &other)
const
177 return c1 == other.c1 && c2 == other.c2 && c3 == other.c3;
203 std::string fileName;
204 std::map<int, CachedFont*> fonts;
266 void DrawText(
const std::string &text, std::vector<FontMetaChar>::iterator format,
267 std::vector<FontMetaChar>::iterator end,
269 int eol,
Color color =
Color(0.0f, 0.0f, 0.0f, 1.0f));
273 int eol,
Color color =
Color(0.0f, 0.0f, 0.0f, 1.0f));
276 void SizeText(
const std::string &text, std::vector<FontMetaChar>::iterator format,
277 std::vector<FontMetaChar>::iterator endFormat,
294 std::vector<FontMetaChar>::iterator format,
295 std::vector<FontMetaChar>::iterator end,
float size);
302 int Justify(
const std::string &text, std::vector<FontMetaChar>::iterator format,
303 std::vector<FontMetaChar>::iterator end,
304 float size,
float width);
306 int Justify(
const std::string &text,
FontType font,
float size,
float width);
309 int Detect(
const std::string &text, std::vector<FontMetaChar>::iterator format,
310 std::vector<FontMetaChar>::iterator end,
311 float size,
float offset);
313 int Detect(
const std::string &text,
FontType font,
float size,
float offset);
315 UTF8Char TranslateSpecialChar(
int specialChar);
321 void DrawString(
const std::string &text, std::vector<FontMetaChar>::iterator format,
322 std::vector<FontMetaChar>::iterator end,
324 void DrawString(
const std::string &text,
FontType font,
328 void StringToUTFCharList(
const std::string &text, std::vector<UTF8Char> &chars);
329 void StringToUTFCharList(
const std::string &text, std::vector<UTF8Char> &chars, std::vector<FontMetaChar>::iterator format, std::vector<FontMetaChar>::iterator end);
339 std::map<FontType, MultisizeFont*> m_fonts;
TEST_VIRTUAL float GetStringWidth(const std::string &text, std::vector< FontMetaChar >::iterator format, std::vector< FontMetaChar >::iterator end, float size)
Returns width of string (multi-format)
Definition: text.cpp:300
Font with multiple possible sizes.
Definition: text.h:201
void SetDevice(CDevice *device)
Sets the device to be used.
Definition: text.cpp:128
Base TTF font with UTF-8 char cache.
Definition: text.cpp:44
Flag for bold font subtype.
Definition: text.h:72
Mask for FontType.
Definition: text.h:134
FontMask
Masks in FontMetaChar for different attributes.
Definition: text.h:131
TEST_VIRTUAL float GetCharWidth(UTF8Char ch, FontType font, float size, float offset)
Returns width of single character.
Definition: text.cpp:351
Texture of font character.
Definition: text.h:185
Point struct and related functions.
SpecialChar
Special codes for certain characters.
Definition: text.h:214
void Destroy()
Frees resources before exit.
Definition: text.cpp:101
Newline character - arrow pointing down and left.
Definition: text.h:218
FontHighlight
Type of color highlight for text.
Definition: text.h:115
Alias for bold courier font.
Definition: text.h:86
Tab character - :
Definition: text.h:217
short FontMetaChar
Type used for font character metainfo.
Definition: text.h:61
float GetDescent(FontType font, float size)
Returns the descent font metric.
Definition: text.cpp:275
Courier (monospace) font used mainly in code editor (only regular & bold)
Definition: text.h:84
Flag for italic font subtype.
Definition: text.h:74
const float FONT_SIZE_BIG
Standard big font size.
Definition: text.h:45
Square.
Definition: text.h:220
float GetAscent(FontType font, float size)
Returns the ascent font metric.
Definition: text.cpp:263
bool Create()
Initializes the font engine; must be called after SetDevice()
Definition: text.cpp:75
Alias for bold colobot font.
Definition: text.h:79
Color structs and related functions.
Mask for FontHighlight.
Definition: text.h:138
UTF-8 character in font cache.
Definition: text.h:150
Pseudo-font loaded from textures for buttons, icons, etc.
Definition: text.h:91
int Detect(const std::string &text, std::vector< FontMetaChar >::iterator format, std::vector< FontMetaChar >::iterator end, float size, float offset)
Returns the most suitable position to a given offset (multi-format)
Definition: text.cpp:478
2D point
Definition: point.h:49
Namespace for (new) graphics code.
Definition: app.h:49
Filled triangle pointing right.
Definition: text.h:221
The graphics engine.
Definition: engine.h:684
Single dot in the middle.
Definition: text.h:219
float GetHeight(FontType font, float size)
Returns the height font metric.
Definition: text.cpp:287
void DrawText(const std::string &text, std::vector< FontMetaChar >::iterator format, std::vector< FontMetaChar >::iterator end, float size, Math::Point pos, float width, TextAlign align, int eol, Color color=Color(0.0f, 0.0f, 0.0f, 1.0f))
Draws text (multi-format)
Definition: text.cpp:171
TextAlign
Type of text alignment.
Definition: text.h:51
Text rendering engine.
Definition: text.h:239
int Justify(const std::string &text, std::vector< FontMetaChar >::iterator format, std::vector< FontMetaChar >::iterator end, float size, float width)
Justifies a line of text (multi-format)
Definition: text.cpp:393
const float FONT_SIZE_SMALL
Standard small font size.
Definition: text.h:43
RGBA color.
Definition: color.h:38
void SetTabSize(int tabSize)
Tab size management.
Definition: text.cpp:166
Mask for image bit (TODO: not used?)
Definition: text.h:140
std::string GetError()
Returns the last encountered error.
Definition: text.cpp:133
Mask for FontTitle.
Definition: text.h:136
FontTitle
Size of font title.
Definition: text.h:102
Alias for italic colobot font.
Definition: text.h:81
FontType
Type of font.
Definition: text.h:69
void SizeText(const std::string &text, std::vector< FontMetaChar >::iterator format, std::vector< FontMetaChar >::iterator endFormat, float size, Math::Point pos, TextAlign align, Math::Point &start, Math::Point &end)
Calculates dimensions for text (multi-format)
Definition: text.cpp:216
Default colobot font used for interface.
Definition: text.h:77
Abstract interface of graphics device.
Definition: device.h:251
void FlushCache()
Flushes cached textures.
Definition: text.cpp:138