|
GREM 3.12.0
Game/Rendering Engine Modules for C++
|
Facility for shaping text, according to a Font2D, into renderable glyphs. More...
#include <GREM/graphics_2d/Text2D.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 text shaping functions. More... | |
Public Member Functions | |
| Text2D () noexcept=default | |
| Construct an empty text. | |
| Text2D (Font2D &font, uint32_t characterSize, UTF8StringView string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) | |
| Construct a shaped text from a UTF-8 string. | |
| Text2D (Font2D &font, uint32_t characterSize, StringView string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) | |
| Helper overload of Text2D() that takes an arbitrary byte string and interprets it as UTF-8. | |
| void | clear () noexcept |
| Erase all shaped glyphs and reset the text to an empty state. | |
| ShapeResult | assign (Font2D &font, uint32_t characterSize, StringView string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) |
| Helper function that is equivalent to clear() followed by append(). | |
| ShapeResult | assign (Font2D &font, uint32_t characterSize, UTF8StringView string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) |
| Helper function that is equivalent to clear() followed by append(). | |
| ShapeResult | append (Font2D &font, uint32_t characterSize, UTF8StringView 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. | |
| ShapeResult | append (Font2D &font, uint32_t characterSize, StringView string, vec2 offset={0.0f, 0.0f}, vec2 scale={1.0f, 1.0f}) |
| Helper overload of append() that takes an arbitrary byte string and interprets it as UTF-8. | |
| Span< const ShapedGlyph > | getShapedGlyphs () const noexcept |
| Get the list of ShapedGlyph data for all shaped glyphs. | |
| Span< const ShapedGlyphInfo > | getShapedGlyphsInfo () const noexcept |
| Get the list of ShapedGlyphInfo data for all shaped glyphs. | |
| Span< const ShapedLineInfo > | getShapedLinesInfo () const noexcept |
| Get the list of ShapedLineInfo data for all shaped lines. | |
| Box< 2, float > | getBoundingBox () const noexcept |
| Get the scaled bounding box of the shaped text. | |
| vec2 | getNextLineOffset () const noexcept |
| Get the scaled offset where the next line would have ended up if another line had followed the last shaped line of text. | |
| float | getHorizontalAlignmentOffset (TextAlignHorizontal horizontalAlignment) const |
| Get the scaled horizontal offset to apply when rendering the text with a specific horizontal alignment. | |
| float | getVerticalAlignmentOffset (TextAlignVertical verticalAlignment) const |
| Get the scaled vertical offset to apply when rendering the text with a specific vertical alignment. | |
| vec2 | getAlignmentOffset (TextAlign alignment) const noexcept |
| Get the scaled offset to apply when rendering the text with a specific alignment. | |
Facility for shaping text, according to a Font2D, 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 Font2DOptions::useLinearFiltering. |
| graphics::Error | on failure to shape a glyph. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Helper overload of Text2D() 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.
|
inline |
|
inline |
| ShapeResult grem::graphics::Text2D::append | ( | Font2D & | font, |
| uint32_t | characterSize, | ||
| UTF8StringView | 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 Font2DOptions::useLinearFiltering. |
| graphics::Error | on failure to shape a glyph. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Helper overload of append() that takes an arbitrary byte string and interprets it as UTF-8.
|
inlinenodiscardnoexcept |
Get the list of ShapedGlyph data for all shaped glyphs.
|
inlinenodiscardnoexcept |
Get the list of ShapedGlyphInfo data for all shaped glyphs.
|
inlinenodiscardnoexcept |
Get the list of ShapedLineInfo data for all shaped lines.
|
inlinenodiscardnoexcept |
Get the scaled bounding box of the shaped text.
|
inlinenodiscardnoexcept |
Get the scaled offset where the next line would have ended up if another line had followed the last shaped line of text.
|
inlinenodiscard |
Get the scaled horizontal offset to apply when rendering the text with a specific horizontal alignment.
| horizontalAlignment | horizontal alignment mode. |
|
inlinenodiscard |
Get the scaled vertical offset to apply when rendering the text with a specific vertical alignment.
| verticalAlignment | vertical alignment mode. |
|
inlinenodiscardnoexcept |
Get the scaled offset to apply when rendering the text with a specific alignment.
| alignment | alignment mode. |