libdonut  2.3.2
Application framework for cross-platform game development in C++20
Public Attributes | List of all members
donut::graphics::TextUTF8StringInstance Struct Reference

Configuration of a 2D instance of a UTF-8 string of text with a Font, for drawing as part of a RenderPass. More...

#include <donut/graphics/RenderPass.hpp>

Public Attributes

Shader2Dshader = Shader2D::ALPHA
 Non-owning pointer to the shader to use when rendering the glyphs of this text. More...
 
Fontfont
 Non-owning pointer to the font from which to shape the text. More...
 
u32 characterSize
 Character size to shape the glyphs at. More...
 
vec2 position {0.0f, 0.0f}
 Starting position, in world coordinates, to render the text at. More...
 
vec2 scale {1.0f, 1.0f}
 Scaling to apply to the size of the shaped glyphs. More...
 
vec2 origin {0.0f, 0.0f}
 Offset, in normalized coordinates, specifying the origin relative to the baseline of the first line of text. More...
 
Color color = Color::WHITE
 Base text color. More...
 
std::u8string_view string
 UTF8-encoded string to shape the text from. More...
 

Detailed Description

Configuration of a 2D instance of a UTF-8 string of text with a Font, for drawing as part of a RenderPass.

Required fields:

Note
Consecutive text instances with the same shader and font will be batched and rendered together.
See also
TextInstance
TextStringInstance

Member Data Documentation

◆ shader

Shader2D* donut::graphics::TextUTF8StringInstance::shader = Shader2D::ALPHA

Non-owning pointer to the shader to use when rendering the glyphs of this text.

Warning
The pointed-to shader must remain valid for the duration of its use in the RenderPass, and must not be nullptr.

◆ font

Font* donut::graphics::TextUTF8StringInstance::font

Non-owning pointer to the font from which to shape the text.

Warning
The pointed-to font must remain valid for the duration of its use in the RenderPass, and must not be nullptr.

◆ characterSize

u32 donut::graphics::TextUTF8StringInstance::characterSize

Character size to shape the glyphs at.

◆ position

vec2 donut::graphics::TextUTF8StringInstance::position {0.0f, 0.0f}

Starting position, in world coordinates, to render the text at.

This will be the first position on the baseline of the first line of text.

◆ scale

vec2 donut::graphics::TextUTF8StringInstance::scale {1.0f, 1.0f}

Scaling to apply to the size of the shaped glyphs.

The result is affected by FontOptions::useLinearFiltering.

Remarks
The best visual results are usually achieved when the text is shaped at an appropriate character size to begin with, rather than relying on this scale parameter. As such, the scale should generally be kept at (1, 1) unless many different character sizes are used with this font and there is a strict requirement on the maximum size of the texture atlas.

◆ origin

vec2 donut::graphics::TextUTF8StringInstance::origin {0.0f, 0.0f}

Offset, in normalized coordinates, specifying the origin relative to the baseline of the first line of text.

For example, a value of (0.5, 0.5) would represent the middle of the first line of text.

Remarks
A value of (0.5, 0.0) can be used to center text on the X axis.

◆ color

Color donut::graphics::TextUTF8StringInstance::color = Color::WHITE

Base text color.

◆ string

std::u8string_view donut::graphics::TextUTF8StringInstance::string

UTF8-encoded string to shape the text from.

Note
Right-to-left text shaping is currently not supported.
Grapheme clusters are currently not supported, and may be rendered incorrectly. Only one Unicode code point is rendered at a time.
Warning
If the string contains invalid UTF-8, the invalid code points will generate unspecified glyphs that may have any appearance.

The documentation for this struct was generated from the following file: