107 FONT_TITLE_BIG = 0x01 << 4,
108 FONT_TITLE_NORM = 0x02 << 4,
109 FONT_TITLE_LITTLE = 0x03 << 4,
120 FONT_HIGHLIGHT_NONE = 0x00 << 6,
164 explicit UTF8Char(
char ch1 =
'\0',
char ch2 =
'\0',
char ch3 =
'\0')
165 : c1(ch1), c2(ch2), c3(ch3), pad(
'\0') {}
167 inline bool operator<(
const UTF8Char &other)
const
171 else if (c1 > other.c1)
176 else if (c2 > other.c2)
179 return c3 < other.c3;
182 inline bool operator==(
const UTF8Char &other)
const
184 return c1 == other.c1 && c2 == other.c2 && c3 == other.c3;
260 void DrawText(
const std::string &text, std::vector<FontMetaChar>::iterator format,
261 std::vector<FontMetaChar>::iterator end,
263 int eol,
Color color =
Color(0.0f, 0.0f, 0.0f, 1.0f));
267 int eol,
Color color =
Color(0.0f, 0.0f, 0.0f, 1.0f));
270 void SizeText(
const std::string &text, std::vector<FontMetaChar>::iterator format,
271 std::vector<FontMetaChar>::iterator endFormat,
285 int GetHeightInt(
FontType font,
float size);
289 std::vector<FontMetaChar>::iterator format,
290 std::vector<FontMetaChar>::iterator end,
float size);
298 int Justify(
const std::string &text, std::vector<FontMetaChar>::iterator format,
299 std::vector<FontMetaChar>::iterator end,
300 float size,
float width);
302 int Justify(
const std::string &text,
FontType font,
float size,
float width);
305 int Detect(
const std::string &text, std::vector<FontMetaChar>::iterator format,
306 std::vector<FontMetaChar>::iterator end,
307 float size,
float offset);
309 int Detect(
const std::string &text,
FontType font,
float size,
float offset);
311 UTF8Char TranslateSpecialChar(
int specialChar);
323 void DrawString(
const std::string &text, std::vector<FontMetaChar>::iterator format,
324 std::vector<FontMetaChar>::iterator end,
326 void DrawString(
const std::string &text,
FontType font,
330 void StringToUTFCharList(
const std::string &text, std::vector<UTF8Char> &chars);
331 void StringToUTFCharList(
const std::string &text, std::vector<UTF8Char> &chars, std::vector<FontMetaChar>::iterator format, std::vector<FontMetaChar>::iterator end);
341 std::map<FontType, std::unique_ptr<MultisizeFont>> m_fonts;
342 std::vector<FontTexture> m_fontTextures;
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:338
Font with multiple possible sizes.
Definition: text.cpp:47
void SetDevice(CDevice *device)
Sets the device to be used.
Definition: text.cpp:154
Base TTF font with UTF-8 char cache.
Definition: text.cpp:71
Flag for bold font subtype.
Definition: text.h:75
Mask for FontType.
Definition: text.h:139
FontMask
Masks in FontMetaChar for different attributes.
Definition: text.h:136
TEST_VIRTUAL float GetCharWidth(UTF8Char ch, FontType font, float size, float offset)
Returns width of single character.
Definition: text.cpp:389
Texture of font character.
Definition: text.h:192
types in CBot scripts
Definition: text.h:124
Point struct and related functions.
SpecialChar
Special codes for certain characters.
Definition: text.h:208
string literals in CBot scripts
Definition: text.h:129
void Destroy()
Frees resources before exit.
Definition: text.cpp:143
code background in SatCom
Definition: text.h:121
Newline character - arrow pointing down and left.
Definition: text.h:212
FontHighlight
Type of color highlight for text.
Definition: text.h:118
Alias for bold courier font.
Definition: text.h:89
Tab character - :
Definition: text.h:211
Mask for links.
Definition: text.h:145
builtin keywords in CBot scripts
Definition: text.h:128
short FontMetaChar
Type used for font character metainfo.
Definition: text.h:64
float GetDescent(FontType font, float size)
Returns the descent font metric.
Definition: text.cpp:305
Courier (monospace) font used mainly in code editor (only regular & bold)
Definition: text.h:87
Flag for italic font subtype.
Definition: text.h:77
keywords in CBot scripts
Definition: text.h:123
const float FONT_SIZE_BIG
Standard big font size.
Definition: text.h:48
Square.
Definition: text.h:214
float GetAscent(FontType font, float size)
Returns the ascent font metric.
Definition: text.cpp:293
bool Create()
Initializes the font engine; must be called after SetDevice()
Definition: text.cpp:117
Alias for bold colobot font.
Definition: text.h:82
Color structs and related functions.
Mask for FontHighlight.
Definition: text.h:143
UTF-8 character in font cache.
Definition: text.h:157
"this" keyword in CBot scripts
Definition: text.h:126
Pseudo-font loaded from textures for buttons, icons, etc.
Definition: text.h:94
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:557
2D point
Definition: point.h:50
Single texture filled with character textures.
Definition: text.cpp:60
comments in CBot scripts
Definition: text.h:127
constants in CBot scripts
Definition: text.h:125
Namespace for (new) graphics code.
Definition: app.h:49
Filled triangle pointing right.
Definition: text.h:215
The graphics engine.
Definition: engine.h:585
background for keys in documentation in SatCom
Definition: text.h:122
Single dot in the middle.
Definition: text.h:213
float GetHeight(FontType font, float size)
Returns the height font metric.
Definition: text.cpp:317
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:197
TextAlign
Type of text alignment.
Definition: text.h:54
Text rendering engine.
Definition: text.h:233
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:472
const float FONT_SIZE_SMALL
Standard small font size.
Definition: text.h:46
2D Point with integer coords
Definition: intpoint.h:41
RGBA color.
Definition: color.h:39
void SetTabSize(int tabSize)
Tab size management.
Definition: text.cpp:192
Mask for image bit (TODO: not used?)
Definition: text.h:147
std::string GetError()
Returns the last encountered error.
Definition: text.cpp:159
Mask for FontTitle.
Definition: text.h:141
FontTitle
Size of font title.
Definition: text.h:105
Alias for italic colobot font.
Definition: text.h:84
FontType
Type of font.
Definition: text.h:72
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:246
Default colobot font used for interface.
Definition: text.h:80
Abstract interface of graphics device.
Definition: device.h:323
void FlushCache()
Flushes cached textures.
Definition: text.cpp:164