Textogl
1.1.2
OpenGL Text renderer
|
Container for font and text rendering. More...
#include <font.hpp>
Public Member Functions | |
Font_sys (const std::string &font_path, const unsigned int font_size) | |
Load a font file at a specified size. More... | |
Font_sys (const unsigned char *font_data, const std::size_t font_data_size, const unsigned int font_size) | |
Load a font at a specified size from memory. More... | |
void | resize (const unsigned int font_size) |
Resize font. More... | |
void | render_text (const std::string &utf8_input, const Color &color, const Vec2< float > &win_size, const Vec2< float > &pos, const int align_flags=0) |
Render given text. More... | |
void | render_text_rotate (const std::string &utf8_input, const Color &color, const Vec2< float > &win_size, const Vec2< float > &pos, const float rotation, const int align_flags=0) |
Render given text, with rotatation. More... | |
void | render_text_mat (const std::string &utf8_input, const Color &color, const Mat4< float > &model_view_projection) |
Render given text, using a model view projection matrix. More... | |
Container for font and text rendering.
Contains everything needed for rendering from the specified font at the specified size. Unicode is supported for all glyphs provided by the specified font.
Rendering data is created by unicode code page (block of 256 code-points), as it is used. Only those pages that are used are built. The 1st page (Basic Latin and Latin-1 Supplement) is always created.
textogl::Font_sys::Font_sys | ( | const std::string & | font_path, |
const unsigned int | font_size | ||
) |
Load a font file at a specified size.
font_path | Path to font file to use |
font_size | Font size (in pixels) |
textogl::Font_sys::Font_sys | ( | const unsigned char * | font_data, |
const std::size_t | font_data_size, | ||
const unsigned int | font_size | ||
) |
Load a font at a specified size from memory.
data is not copied, so the client is responsible for maintaining the data for the lifetime of this object
font_data | Font file data (in memory) |
font_data_size | Font file data's size in memory |
font_size | Font size (in pixels) |
void textogl::Font_sys::render_text | ( | const std::string & | utf8_input, |
const Color & | color, | ||
const Vec2< float > & | win_size, | ||
const Vec2< float > & | pos, | ||
const int | align_flags = 0 |
||
) |
Render given text.
Renders the text supplied in utf8_input parameter
utf8_input | Text to render, in UTF-8 encoding. For best performance, normalize the string before rendering |
color | Text Color |
win_size | Window dimensions. A Vec2 with X = width and Y = height |
pos | Render position, in screen pixels |
align_flags | Text Alignment. Should be Text_origin flags bitwise-OR'd together |
void textogl::Font_sys::render_text_mat | ( | const std::string & | utf8_input, |
const Color & | color, | ||
const Mat4< float > & | model_view_projection | ||
) |
Render given text, using a model view projection matrix.
Renders the text supplied in utf8_input parameter, using a model view projection matrix
utf8_input | Text to render, in UTF-8 encoding. For best performance, normalize the string before rendering |
color | Text Color |
model_view_projection | Model view projection matrix. The text will be rendered as quads, one for each glyph, with vertex coordinates centered on the baselines and sized in pixels. This matrix will be used to transform that geometry |
void textogl::Font_sys::render_text_rotate | ( | const std::string & | utf8_input, |
const Color & | color, | ||
const Vec2< float > & | win_size, | ||
const Vec2< float > & | pos, | ||
const float | rotation, | ||
const int | align_flags = 0 |
||
) |
Render given text, with rotatation.
Renders the text supplied in utf8_input parameter
utf8_input | Text to render, in UTF-8 encoding. For best performance, normalize the string before rendering |
color | Text Color |
win_size | Window dimensions. A Vec2 with X = width and Y = height |
pos | Render position, in screen pixels |
rotation | Clockwise text rotation (in radians) around origin as defined in align_flags. 0 is vertical |
align_flags | Text Alignment. Should be Text_origin flags bitwise-OR'd together |
void textogl::Font_sys::resize | ( | const unsigned int | font_size | ) |
Resize font.
Resizes the font without destroying it
font_size | Font size (in pixels) |