Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Gfx::CText Class Reference

Text rendering engine. More...

#include <text.h>

Public Member Functions

 CText (CEngine *engine)
 
void SetDevice (CDevice *device)
 Sets the device to be used.
 
std::string GetError ()
 Returns the last encountered error.
 
bool Create ()
 Initializes the font engine; must be called after SetDevice()
 
void Destroy ()
 Frees resources before exit.
 
void FlushCache ()
 Flushes cached textures.
 
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)
 
void DrawText (const std::string &text, FontType font, float size, Math::Point pos, float width, TextAlign align, int eol, Color color=Color(0.0f, 0.0f, 0.0f, 1.0f))
 Draws text (one font)
 
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)
 
void SizeText (const std::string &text, FontType font, float size, Math::Point pos, TextAlign align, Math::Point &start, Math::Point &end)
 Calculates dimensions for text (one font)
 
float GetAscent (FontType font, float size)
 Returns the ascent font metric.
 
float GetDescent (FontType font, float size)
 Returns the descent font metric.
 
float GetHeight (FontType font, float size)
 Returns the height font metric.
 
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)
 
TEST_VIRTUAL float GetStringWidth (std::string text, FontType font, float size)
 Returns width of string (single font)
 
TEST_VIRTUAL float GetCharWidth (UTF8Char ch, FontType font, float size, float offset)
 Returns width of single character.
 
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)
 
int Justify (const std::string &text, FontType font, float size, float width)
 Justifies a line of text (one font)
 
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)
 
int Detect (const std::string &text, FontType font, float size, float offset)
 Returns the most suitable position to a given offset (one font)
 
UTF8Char TranslateSpecialChar (int specialChar)
 
void SetTabSize (int tabSize)
 Tab size management.
 
int GetTabSize ()
 

Protected Member Functions

CachedFontGetOrOpenFont (FontType type, float size)
 
CharTexture CreateCharTexture (UTF8Char ch, CachedFont *font)
 
void DrawString (const std::string &text, std::vector< FontMetaChar >::iterator format, std::vector< FontMetaChar >::iterator end, float size, Math::Point pos, float width, int eol, Color color)
 
void DrawString (const std::string &text, FontType font, float size, Math::Point pos, float width, int eol, Color color)
 
void DrawHighlight (FontHighlight hl, Math::Point pos, Math::Point size)
 
void DrawCharAndAdjustPos (UTF8Char ch, FontType font, float size, Math::Point &pos, Color color)
 
void StringToUTFCharList (const std::string &text, std::vector< UTF8Char > &chars)
 

Protected Attributes

CEnginem_engine
 
CDevicem_device
 
std::string m_error
 
float m_defaultSize
 
int m_tabSize
 
std::map< FontType,
MultisizeFont * > 
m_fonts
 
FontType m_lastFontType
 
int m_lastFontSize
 
CachedFontm_lastCachedFont
 

Detailed Description

Text rendering engine.

CText is responsible for drawing text in 2D interface. Font rendering is done using textures generated by SDL_ttf from TTF font files.

All functions rendering text are divided into two types:

All font rendering is done in UTF-8.


The documentation for this class was generated from the following files: