gdk-graphics 0a0aef92e917cfbac53dffbc32c295e4de914093
Loading...
Searching...
No Matches
gdk::graphics::ext::text_modeler Class Referencefinal

lays a string out into a single model, using a font's glyphs. More...

#include <text_modeler.h>

Public Member Functions

const_model_ptr_type model () const
 get the model, contains the uploaded geometry for the text
const_material_ptr_type material () const
 get the material, used to render the model
void set_text (std::string_view aUTF8)
 lay out new text, replacing whatever was there.
void upload ()
 brings the model and the atlas texture up to date.
std::size_t uploaded_atlas_generation () const
 the font atlas generation of the texture this modeler draws from
std::size_t fallback_glyph_count () const
 how many glyphs in the last layout could not be rasterised, and were drawn as the font's fallback instead.
vector2_type size () const
 the size of the text laid out by the last set_text, in model units
 text_modeler (context_ptr_type aContext, std::shared_ptr< font > aFont, material_ptr_type aMaterial={}, float aScale=0.f)
 builds a modeler
 text_modeler (context_ptr_type aContext, std::shared_ptr< font_texture > aFontTexture, material_ptr_type aMaterial={}, float aScale=0.f)
 builds a modeler that draws from a texture of the font's atlas it shares with others

Detailed Description

lays a string out into a single model, using a font's glyphs.

Constructor & Destructor Documentation

◆ text_modeler() [1/2]

gdk::graphics::ext::text_modeler::text_modeler ( context_ptr_type aContext,
std::shared_ptr< font > aFont,
material_ptr_type aMaterial = {},
float aScale = 0.f )

builds a modeler

Parameters
aScalemodel units per pixel. The default makes one line of text one unit tall, so a string's size does not depend on the pixel height the font was rasterised at.

◆ text_modeler() [2/2]

gdk::graphics::ext::text_modeler::text_modeler ( context_ptr_type aContext,
std::shared_ptr< font_texture > aFontTexture,
material_ptr_type aMaterial = {},
float aScale = 0.f )

builds a modeler that draws from a texture of the font's atlas it shares with others

Parameters
aFontTexturethe font, as its atlas's texture

Member Function Documentation

◆ set_text()

void gdk::graphics::ext::text_modeler::set_text ( std::string_view aUTF8)

lay out new text, replacing whatever was there.

Parameters
aUTF8the text. Invalid UTF-8 is rendered as the replacement character rather than throwing, since text often arrives from outside the program.
See also
decode_utf8

Newline returns the pen to the left and moves it down one line. Tab advances four spaces. Glyphs not yet in the font's atlas are rasterised as they are met.

◆ upload()

void gdk::graphics::ext::text_modeler::upload ( )

brings the model and the atlas texture up to date.

Sends the layout if it has changed since the last upload, and the atlas texture if the atlas has. When the atlas has grown or been cleared since the text was laid out, by this modeler or another sharing the font, the text is laid out again first, so its glyphs are found where they now are. Nothing is sent when nothing has changed.


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