1#ifndef DONUT_GRAPHICS_TEXT_HPP 
    2#define DONUT_GRAPHICS_TEXT_HPP 
  120    Text(
Font& font, u32 characterSize, std::u8string_view 
string, vec2 offset = {0.0f, 0.0f}, vec2 scale = {1.0f, 1.0f}) {
 
  121        shape(font, characterSize, 
string, offset, scale);
 
 
  130    Text(
Font& font, u32 characterSize, std::string_view 
string, vec2 offset = {0.0f, 0.0f}, vec2 scale = {1.0f, 1.0f}) {
 
  131        shape(font, characterSize, 
string, offset, scale);
 
 
  138        shapedGlyphs.clear();
 
  139        shapedGlyphsInfo.clear();
 
  140        shapedLinesInfo.clear();
 
  141        minExtent = {std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity()};
 
  142        maxExtent = {-std::numeric_limits<float>::infinity(), -std::numeric_limits<float>::infinity()};
 
 
  183    ShapeResult shape(
Font& font, u32 characterSize, std::u8string_view 
string, vec2 offset = {0.0f, 0.0f}, vec2 scale = {1.0f, 1.0f});
 
  191    ShapeResult shape(
Font& font, u32 characterSize, std::string_view 
string, vec2 offset = {0.0f, 0.0f}, vec2 scale = {1.0f, 1.0f}) {
 
  192        static_assert(
sizeof(char) == 
sizeof(
char8_t));
 
  193        static_assert(
alignof(char) == 
alignof(
char8_t));
 
  194        return shape(font, characterSize, std::u8string_view{
reinterpret_cast<const char8_t*
>(
string.data()), 
string.size()}, offset, scale);
 
 
  203    ShapeResult reshape(
Font& font, u32 characterSize, std::string_view 
string, vec2 offset = {0.0f, 0.0f}, vec2 scale = {1.0f, 1.0f}) {
 
  205        return shape(font, characterSize, 
string, offset, scale);
 
 
  214    ShapeResult reshape(
Font& font, u32 characterSize, std::u8string_view 
string, vec2 offset = {0.0f, 0.0f}, vec2 scale = {1.0f, 1.0f}) {
 
  216        return shape(font, characterSize, 
string, offset, scale);
 
 
  244        return shapedGlyphsInfo;
 
 
  258        return shapedLinesInfo;
 
 
  282    std::vector<ShapedGlyph> shapedGlyphs{};
 
  283    std::vector<ShapedGlyphInfo> shapedGlyphsInfo{};
 
  284    std::vector<ShapedLineInfo> shapedLinesInfo{};
 
  285    vec2 minExtent{std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity()};
 
  286    vec2 maxExtent{-std::numeric_limits<float>::infinity(), -std::numeric_limits<float>::infinity()};
 
 
Typeface describing an assortment of character glyphs that may be rendered on-demand into an expandin...
Definition Font.hpp:42
 
Facility for shaping text, according to a Font, into renderable glyphs.
Definition Text.hpp:19
 
void clear() noexcept
Erase all shaped glyphs and reset the text to an empty state.
Definition Text.hpp:137
 
Text() noexcept=default
Construct an empty text.
 
std::span< const ShapedLineInfo > getShapedLinesInfo() const noexcept
Get the list of ShapedLineInfo data for all shaped lines.
Definition Text.hpp:257
 
std::span< const ShapedGlyph > getShapedGlyphs() const noexcept
Get the list of ShapedGlyph data for all shaped glyphs.
Definition Text.hpp:229
 
std::span< const ShapedGlyphInfo > getShapedGlyphsInfo() const noexcept
Get the list of ShapedGlyphInfo data for all shaped glyphs.
Definition Text.hpp:243
 
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.
Definition Text.hpp:191
 
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().
Definition Text.hpp:214
 
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().
Definition Text.hpp:203
 
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 dra...
 
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.
Definition Text.hpp:130
 
vec2 getMinExtent() const noexcept
Get the minimum extent of the shaped text.
Definition Text.hpp:267
 
vec2 getMaxExtent() const noexcept
Get the maximum extent of the shaped text.
Definition Text.hpp:277
 
Result of the shape() function.
Definition Text.hpp:67
 
std::size_t shapedLineOffset
Index, into the list returned by getShapedLinesInfo(), of the ShapedLineInfo corresponding to the fir...
Definition Text.hpp:82
 
std::size_t shapedGlyphOffset
Index, into the lists returned by getShapedGlyphs() and getShapedGlyphsInfo(), of the ShapedGlyph and...
Definition Text.hpp:76
 
Additional information about a single shaped glyph, including some data that is not strictly required...
Definition Text.hpp:43
 
vec2 shapedAdvance
Scaled offset to apply in order to advance to the next glyph position, including kerning.
Definition Text.hpp:45
 
std::size_t stringOffset
Byte offset in the input string of the first code unit that this glyph originated from.
Definition Text.hpp:47
 
vec2 shapedOffset
Scaled offset from the starting position to draw this glyph at, in pixels.
Definition Text.hpp:44
 
std::size_t shapedLineIndex
Index of the ShapedLineInfo corresponding to the line that this glyph is part of.
Definition Text.hpp:46
 
Data required to render a single shaped glyph relative to at any given starting position.
Definition Text.hpp:28
 
u32 characterSize
Character size that this glyph was shaped at.
Definition Text.hpp:32
 
Font * font
Non-owning read-only non-null pointer to the font used to shape this glyph.
Definition Text.hpp:29
 
vec2 shapedOffset
Scaled offset from the starting position to draw this glyph at, in pixels.
Definition Text.hpp:30
 
char32_t codePoint
Unicode code point of this glyph.
Definition Text.hpp:33
 
vec2 shapedSize
Scaled size of this glyph's rectangle, in pixels.
Definition Text.hpp:31
 
Information about a line of shaped glyphs, including some data that is not strictly required for simp...
Definition Text.hpp:57
 
std::size_t stringOffset
Byte offset in the input string of the first code unit that the first glyph that is part of this line...
Definition Text.hpp:61
 
vec2 shapedOffset
Scaled offset of the baseline at the start of this line of text.
Definition Text.hpp:58
 
vec2 shapedSize
Scaled total size of this line.
Definition Text.hpp:59
 
std::size_t shapedGlyphOffset
Index of the ShapedGlyph and ShapedGlyphInfo corresponding to the first glyph that is part of this li...
Definition Text.hpp:60