MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Portal::Text::TextRun Class Reference

One string laid out as glyph quads, ready to draw as vertices. More...

#include <TextRun.hpp>

+ Collaboration diagram for MayaFlux::Portal::Text::TextRun:

Public Member Functions

void assign (std::string_view text, PressParams params)
 Replace text and parameters together, laying out once.
 
GlyphAtlas * atlas () const
 The atlas the run draws from: params().atlas, else the default.
 
Kinesis::AABB2D caret (size_t byte_offset, float width_px)
 Pixel rectangle of a caret at a byte offset of the text.
 
float content_height () const
 Height in pixels the text occupies, from the top of the first line to the bottom of the last.
 
glm::vec2 extent () const
 Size in pixels the run is drawn at.
 
size_t index_at (glm::vec2 px)
 Byte offset of the codepoint boundary nearest a layout pixel.
 
const LayoutResult & layout () const noexcept
 The layout of the current text, in pixels with y down.
 
const PressParams & params () const noexcept
 
void set (std::string_view text)
 Replace the text and lay it out.
 
void set_params (PressParams params)
 Replace the parameters and lay the current text out again.
 
bool stale () const
 True when the atlas the layout was built against has since been replaced or has grown, so its UVs no longer match.
 
const std::string & text () const noexcept
 
 TextRun (PressParams params={})
 
std::vector< Kakshya::MeshVertex > vertices (const GlyphMap &map, uint32_t slot)
 Vertices for the background, if any, then every glyph.
 

Private Member Functions

void lay_out_text ()
 

Private Attributes

const GlyphAtlas * m_atlas { nullptr }
 
uint32_t m_atlas_size { 0 }
 
LayoutResult m_layout
 
PressParams m_params
 
std::string m_text
 

Detailed Description

One string laid out as glyph quads, ready to draw as vertices.

Owns the text, its PressParams and the layout, and turns them into triangle list vertices through a GlyphMap, so the same run can draw in NDC, a world plane or any other space. It is the vertex counterpart of press(): no pixels are rasterized, the glyphs are drawn from the atlas image (see AtlasImage) as coverage.

Layout runs from the pen origin press() uses for a VKImage: x at zero, baseline at the atlas ascender, wrapping at render_bounds.x. Of PressParams it reads atlas, color, spans, background and render_bounds; budget_h has no meaning here. A background with alpha above zero is drawn as one opaque flat quad over render_bounds beneath the glyphs.

The layout bakes in atlas UVs. When the atlas is replaced or grows, the run is stale; vertices() lays out again first, so its output is always current. The caller binds the atlas image at the slot it passes.

Definition at line 27 of file TextRun.hpp.


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