FreeType2-based glyph shaping/caching. More...
#include <GuiTextRenderer.h>
Public Member Functions | |
| GuiTextRenderer (const uint8_t *fontBuffer, FT_Long bufferSize, GlyphRenderer *glyphRenderer, float uiScale=1.0f) | |
| void | setPixelSize (int16_t pixelSize) |
| Selects the pixel size subsequent drawText()/getWidth()/getHeight() calls use. | |
| uint16_t | drawText (int16_t x, int16_t y, const wchar_t *text, PixelColor color=black, uint32_t renderFlags=0) |
| Draws text at (x, y) using the current pixel size. | |
| uint16_t | drawText (int16_t x, int16_t y, const char *text, PixelColor color=black, uint32_t renderFlags=0) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| uint16_t | getWidth (const wchar_t *text) |
| uint16_t | getWidth (const char *text) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| uint16_t | getHeight (const wchar_t *text) |
| uint16_t | getHeight (const char *text) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | getOffset (const wchar_t *text, FontOffset *offset) |
Static Public Member Functions | |
| static wchar_t * | charToWideChar (const char *p) |
FreeType2-based glyph shaping/caching.
Shapes and caches glyphs per pixel size, then delegates only the final rasterized-quad draw to a GlyphRenderer - GuiText calls through this rather than touching FreeType or a platform texture directly.
Definition at line 77 of file GuiTextRenderer.h.
| GuiTextRenderer::GuiTextRenderer | ( | const uint8_t * | fontBuffer, |
| FT_Long | bufferSize, | ||
| GlyphRenderer * | glyphRenderer, | ||
| float | uiScale = 1.0f ) |
| fontBuffer | TTF/OTF font data - must remain valid for the lifetime of this GuiTextRenderer, FreeType keeps a pointer into it |
| bufferSize | Length of fontBuffer in bytes |
| glyphRenderer | Platform renderer rasterized glyph quads are drawn through |
| uiScale | Physical-pixels-per-design-pixel to rasterize glyphs at (pass VideoDriver::getUIScale()). Sizes, metrics and layout stay in design pixels; only the glyph textures get sharper. 1.0 rasterizes at the design size. |
Definition at line 68 of file GuiTextRenderer.cpp.
| GuiTextRenderer::~GuiTextRenderer | ( | ) |
Definition at line 76 of file GuiTextRenderer.cpp.
|
static |
Definition at line 292 of file GuiTextRenderer.cpp.
| uint16_t GuiTextRenderer::drawText | ( | int16_t | x, |
| int16_t | y, | ||
| const char * | text, | ||
| PixelColor | color = black, | ||
| uint32_t | renderFlags = 0 ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 338 of file GuiTextRenderer.cpp.
| uint16_t GuiTextRenderer::drawText | ( | int16_t | x, |
| int16_t | y, | ||
| const wchar_t * | text, | ||
| PixelColor | color = black, | ||
| uint32_t | renderFlags = 0 ) |
Draws text at (x, y) using the current pixel size.
| x | Left edge, in pixels |
| y | Top edge, in pixels |
| text | Text to draw |
| color | Text color |
| renderFlags | Bitmask of GUI_TEXT_JUSTIFY_*/GUI_TEXT_ALIGN_*/GUI_TEXT_STYLE_* flags |
Definition at line 231 of file GuiTextRenderer.cpp.
| uint16_t GuiTextRenderer::getHeight | ( | const char * | text | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 352 of file GuiTextRenderer.cpp.
| uint16_t GuiTextRenderer::getHeight | ( | const wchar_t * | text | ) |
Definition at line 223 of file GuiTextRenderer.cpp.
| void GuiTextRenderer::getOffset | ( | const wchar_t * | text, |
| FontOffset * | offset ) |
| text | Text to measure |
| offset | Filled with the ascender/descender/max/min metrics for text at the current pixel size |
Definition at line 183 of file GuiTextRenderer.cpp.
| uint16_t GuiTextRenderer::getWidth | ( | const char * | text | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 345 of file GuiTextRenderer.cpp.
| uint16_t GuiTextRenderer::getWidth | ( | const wchar_t * | text | ) |
Definition at line 204 of file GuiTextRenderer.cpp.
| void GuiTextRenderer::setPixelSize | ( | int16_t | pixelSize | ) |
Selects the pixel size subsequent drawText()/getWidth()/getHeight() calls use.
Shaped glyphs are cached per size, so switching sizes repeatedly doesn't re-shape glyphs already seen at that size.
Definition at line 94 of file GuiTextRenderer.cpp.