libdonut
2.3.2
Application framework for cross-platform game development in C++20
|
Facility for shaping text, according to a Font, into renderable glyphs. More...
#include <donut/graphics/Text.hpp>
Classes | |
struct | ShapedGlyph |
Data required to render a single shaped glyph relative to at any given starting position. More... | |
struct | ShapedGlyphInfo |
Additional information about a single shaped glyph, including some data that is not strictly required for simple rendering. More... | |
struct | ShapedLineInfo |
Information about a line of shaped glyphs, including some data that is not strictly required for simple rendering. More... | |
struct | ShapeResult |
Result of the shape() function. More... | |
Public Member Functions | |
Text () noexcept=default | |
Construct an empty text. More... | |
Text (Font &font, u32 characterSize, std::u8string_view string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) | |
Construct a shaped text from a UTF-8 string. More... | |
Text (Font &font, u32 characterSize, std::string_view string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) | |
Helper overload of Text() that takes an arbitrary byte string and interprets it as UTF-8. More... | |
void | clear () noexcept |
Erase all shaped glyphs and reset the text to an empty state. More... | |
ShapeResult | shape (Font &font, u32 characterSize, std::u8string_view string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) |
Use a font to shape a string of UTF-8 encoded text into a sequence of glyphs that are ready to be drawn at a given offset, relative to any starting position. More... | |
ShapeResult | shape (Font &font, u32 characterSize, std::string_view string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) |
Helper overload of shape() that takes an arbitrary byte string and interprets it as UTF-8. More... | |
ShapeResult | reshape (Font &font, u32 characterSize, std::string_view string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) |
Helper function that is equivalent to clear() followed by shape(). More... | |
ShapeResult | reshape (Font &font, u32 characterSize, std::u8string_view string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) |
Helper function that is equivalent to clear() followed by shape(). More... | |
std::span< const ShapedGlyph > | getShapedGlyphs () const noexcept |
Get the list of ShapedGlyph data for all shaped glyphs. More... | |
std::span< const ShapedGlyphInfo > | getShapedGlyphsInfo () const noexcept |
Get the list of ShapedGlyphInfo data for all shaped glyphs. More... | |
std::span< const ShapedLineInfo > | getShapedLinesInfo () const noexcept |
Get the list of ShapedLineInfo data for all shaped lines. More... | |
vec2 | getMinExtent () const noexcept |
Get the minimum extent of the shaped text. More... | |
vec2 | getMaxExtent () const noexcept |
Get the maximum extent of the shaped text. More... | |
Facility for shaping text, according to a Font, into renderable glyphs.
|
defaultnoexcept |
Construct an empty text.
|
inline |
Construct a shaped text from a UTF-8 string.
font | font to shape the glyphs with. |
characterSize | character size to shape the glyphs at. |
string | UTF-8 encoded text string to shape. |
offset | relative offset from the starting position to begin shaping at. |
scale | scaling to apply to the size of the shaped glyphs. The result is affected by FontOptions::useLinearFiltering. |
graphics::Error | on failure to shape a glyph. |
std::bad_alloc | on allocation failure. |
|
inline |
Helper overload of Text() that takes an arbitrary byte string and interprets it as UTF-8.
|
inlinenoexcept |
Erase all shaped glyphs and reset the text to an empty state.
ShapeResult donut::graphics::Text::shape | ( | Font & | font, |
u32 | characterSize, | ||
std::u8string_view | string, | ||
vec2 | offset = {0.0f, 0.0f} , |
||
vec2 | scale = {1.0f, 1.0f} |
||
) |
Use a font to shape a string of UTF-8 encoded text into a sequence of glyphs that are ready to be drawn at a given offset, relative to any starting position.
font | font to shape the glyphs with. |
characterSize | character size to shape the glyphs at. |
string | UTF-8 encoded text string to shape. |
offset | relative offset from the starting position to begin shaping at. |
scale | scaling to apply to the size of the shaped glyphs. The result is affected by FontOptions::useLinearFiltering. |
graphics::Error | on failure to shape a glyph. |
std::bad_alloc | on allocation failure. |
|
inline |
Helper overload of shape() that takes an arbitrary byte string and interprets it as UTF-8.
|
inline |
|
inline |
|
inlinenoexcept |
Get the list of ShapedGlyph data for all shaped glyphs.
|
inlinenoexcept |
Get the list of ShapedGlyphInfo data for all shaped glyphs.
|
inlinenoexcept |
Get the list of ShapedLineInfo data for all shaped lines.
|
inlinenoexcept |
Get the minimum extent of the shaped text.
|
inlinenoexcept |
Get the maximum extent of the shaped text.