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

Classes

class  AtlasImage
 The GPU image of a GlyphAtlas, for anything that samples glyph coverage. More...
 
struct  CopiedText
 Result of copy(): a byte range's text plus the quads that render it. More...
 
struct  EditableText
 Mutable UTF-8 text plus a byte-offset cursor. More...
 
class  FontFace
 Owns a single FT_Face loaded from a file path. More...
 
class  GlyphAtlas
 Rasterizes and packs glyphs from a FontFace into a TextureContainer. More...
 
struct  GlyphMap
 Linear map from layout pixels to whatever space the vertices are drawn in. More...
 
struct  GlyphMetrics
 Per-glyph layout and UV data produced by GlyphAtlas. More...
 
struct  GlyphOutline
 Vector outline for a single glyph as a flat polyline sequence. More...
 
struct  GlyphQuad
 Screen-space quad for one rasterized glyph. More...
 
struct  LayoutResult
 Result of lay_out(), carrying the quads and the final pen position. More...
 
struct  PenPosition
 Pen coordinates returned by x_at(), in the same space as GlyphQuad. More...
 
struct  PressParams
 Construction parameters for press(). More...
 
struct  StyleSpan
 A colored byte range within the text passed to a composite call. More...
 
class  TextRun
 One string laid out as glyph quads, ready to draw as vertices. More...
 
class  TypeFaceFoundry
 Singleton owner of the FT_Library handle. More...
 

Enumerations

enum class  ImpressResult : uint8_t { Ok , Overflow }
 Result of an impress() call. More...
 
enum class  RedrawPolicy : uint8_t { Clip , Fit }
 Policy controlling TextBuffer reuse behaviour in repress(). More...
 

Functions

bool add_fallback_font (const std::string &font_path)
 Load a font file and register it as a fallback on the default atlas.
 
bool add_fallback_font (std::string_view family, std::string_view style)
 Locate a system font by family and style, then register it as a fallback.
 
CopiedText copy (std::string_view text, const LayoutResult &layout, size_t a, size_t b)
 Copy a byte range: the text it spans, and the quads that render it.
 
constexpr float coverage_weight (uint32_t slot) noexcept
 MeshVertex::weight that makes a fragment shader read a texture slot as glyph coverage rather than as an image.
 
std::shared_ptr< LayoutResult > create_layout (std::string_view text, float pen_x=0.F, float pen_y=0.F, uint32_t wrap_w=0)
 Lay out a UTF-8 string into screen-space glyph quads using the default atlas.
 
GlyphOutline decompose_glyph (FontFace &face, uint32_t codepoint, uint32_t pixel_size, float tolerance=0.5F)
 Decompose a Unicode codepoint into a tessellated polyline outline.
 
GlyphOutline decompose_glyph (uint32_t codepoint, float tolerance=0.5F)
 Decompose a Unicode codepoint using the default atlas pixel size.
 
std::string encode_utf8 (uint32_t codepoint)
 Encode a Unicode codepoint as a UTF-8 byte sequence.
 
void erase (EditableText &s, int n)
 Erase n codepoints from the cursor.
 
MAYAFLUX_API std::optional< std::string > find_font (std::string_view family, std::string_view style={})
 Locate a system font file by family name and optional style.
 
GlyphAtlas & get_default_atlas ()
 Return the default GlyphAtlas, or nullptr if set_default_font() has not been called successfully.
 
std::vector< Kakshya::MeshVertex > glyph_vertices (std::span< const GlyphQuad > quads, glm::vec4 color, std::span< const StyleSpan > spans, const GlyphMap &map, uint32_t slot)
 Triangle list vertices for glyph quads, six per quad.
 
ImpressResult impress (const std::shared_ptr< Buffers::TextBuffer > &target, std::string_view text, glm::vec4 color={ 1.F, 1.F, 1.F, 1.F }, std::span< const StyleSpan > spans={})
 Append a UTF-8 string into an existing TextBuffer at the current cursor.
 
size_t index_at (std::string_view text, const LayoutResult &layout, GlyphAtlas &atlas, float x, float y, float pen_x=0.F, float pen_y=0.F, uint32_t wrap_w=0, uint32_t tab_width=4)
 Byte offset of the codepoint boundary nearest a screen-space point.
 
bool initialize (std::optional< Core::TextConfig > config)
 Initialize Portal::Text.
 
void ink_quads (const std::shared_ptr< Buffers::TextBuffer > &target, std::span< const GlyphQuad > quads, glm::vec4 color, GlyphAtlas *atlas=nullptr)
 Rasterize a mutated quad span into an existing TextBuffer.
 
void insert_codepoint (EditableText &s, uint32_t codepoint)
 Insert one codepoint at the cursor, advancing it past the insert.
 
void insert_literal (EditableText &s, char c)
 Insert one raw ASCII byte at the cursor, advancing it past the insert.
 
bool is_control (uint32_t codepoint) noexcept
 True if a codepoint must never be rasterized or treated as printable content.
 
bool is_initialized ()
 Returns true after a successful initialize() call.
 
LayoutResult lay_out (std::string_view text, GlyphAtlas &atlas, float pen_x=0.F, float pen_y=0.F, uint32_t wrap_w=0, uint32_t tab_width=4)
 Lay out a UTF-8 string into a sequence of screen-space quads.
 
void move (EditableText &s, int n)
 Move the cursor by n codepoints.
 
size_t next_codepoint_offset (std::string_view text, size_t byte_offset)
 Byte offset of the codepoint boundary after byte_offset.
 
std::shared_ptr< Buffers::TextBuffer > press (std::string_view text, const PressParams &params={})
 Composite a UTF-8 string into a new TextBuffer.
 
std::shared_ptr< Core::VKImage > press (std::string_view text, glm::uvec2 render_bounds, const PressParams &params={}, const std::shared_ptr< Buffers::VKBuffer > &staging=nullptr)
 Composite a UTF-8 string directly into a new GPU texture.
 
size_t previous_codepoint_offset (std::string_view text, size_t byte_offset)
 Byte offset of the codepoint boundary before byte_offset.
 
void rasterize_quads (std::span< const GlyphQuad > quads, GlyphAtlas &atlas, glm::vec4 color, uint8_t *dst, uint32_t buf_w, uint32_t buf_h)
 Write glyph quads into a caller-provided RGBA8 pixel buffer.
 
bool repress (const std::shared_ptr< Buffers::TextBuffer > &target, std::string_view text, glm::vec4 color={ 1.F, 1.F, 1.F, 1.F }, RedrawPolicy policy=RedrawPolicy::Clip, std::span< const StyleSpan > spans={})
 Re-composite a UTF-8 string into an existing TextBuffer.
 
bool repress (std::shared_ptr< Core::VKImage > &target, std::string_view text, const PressParams &params={}, const std::shared_ptr< Buffers::VKBuffer > &staging=nullptr)
 Re-composite a UTF-8 string into an existing GPU texture.
 
bool set_default_font (const std::string &font_path, uint32_t pixel_size=24, uint32_t atlas_size=512)
 Load a font file and create the default GlyphAtlas at a given size.
 
bool set_default_font (std::string_view family, std::string_view style, uint32_t pixel_size, uint32_t atlas_size=512)
 Locate a system font by family and style, then load it as the default.
 
void shutdown ()
 Shutdown Portal::Text.
 
PenPosition x_at (std::string_view text, GlyphAtlas &atlas, size_t byte_offset, float pen_x=0.F, float pen_y=0.F, uint32_t wrap_w=0, uint32_t tab_width=4)
 Pen position immediately before byte_offset, in lay_out()'s space.