MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ rebuild_outlines()

void MayaFlux::Nodes::GpuSync::GlyphGeometryNode::rebuild_outlines ( )

Rebuild outline geometry from the current text and pen settings.

Called automatically by set_text(). Call directly after mutating pen, color, or thickness without changing text.

Definition at line 79 of file GlyphGeometryNode.cpp.

80{
81 m_outlines.clear();
82 m_pen_offsets.clear();
83
84 if (m_text.empty()) {
85 resize_vertex_buffer(0, false);
87 return;
88 }
89
90 float cursor_x = m_pen_x;
91 float cursor_y = m_pen_y;
92
93 const auto* bytes = reinterpret_cast<const utf8proc_uint8_t*>(m_text.data());
94 auto remaining = static_cast<utf8proc_ssize_t>(m_text.size());
95 utf8proc_ssize_t offset = 0;
96
97 while (offset < remaining) {
98 utf8proc_int32_t cp = 0;
99 const utf8proc_ssize_t n = utf8proc_iterate(bytes + offset, remaining - offset, &cp);
100
101 if (n <= 0) {
102 offset += 1;
103 continue;
104 }
105 offset += n;
106
107 if (cp < 0)
108 continue;
109
110 if (cp == '\n') {
111 const uint32_t px = m_face
115 : 0);
117 cursor_y += static_cast<float>(px);
118 continue;
119 }
120
121 if (cp == '\r')
122 continue;
123
124 Portal::Text::GlyphOutline outline = m_face
125 ? Portal::Text::decompose_glyph(*m_face, static_cast<uint32_t>(cp), m_pixel_size, m_tolerance)
126 : Portal::Text::decompose_glyph(static_cast<uint32_t>(cp), m_tolerance);
127
128 m_pen_offsets.emplace_back(cursor_x, cursor_y);
129 m_outlines.push_back(std::move(outline));
130
131 cursor_x += static_cast<float>(m_outlines.back().advance_x);
132 }
133
135}
uint32_t cursor_y
Definition InkPress.cpp:30
uint32_t cursor_x
Definition InkPress.cpp:29
bool m_vertex_data_dirty
Flag: vertex data or layout changed since last GPU upload.
void resize_vertex_buffer(uint32_t vertex_count, bool preserve_data=false)
Resize vertex buffer to hold specified number of vertices.
std::vector< Portal::Text::GlyphOutline > m_outlines
uint32_t pixel_size() const
Pixel size passed at construction.
GlyphAtlas * get_default_glyph_atlas() const
Return the default GlyphAtlas, or nullptr if set_default_font() has not been called successfully.
@ Portal
High-level user-facing API layer.
GlyphOutline decompose_glyph(FontFace &face, uint32_t codepoint, uint32_t pixel_size, float tolerance)
Decompose a Unicode codepoint into a tessellated polyline outline.

References cursor_x, cursor_y, MayaFlux::Portal::Text::decompose_glyph(), MayaFlux::Portal::Text::TypeFaceFoundry::get_default_glyph_atlas(), MayaFlux::Portal::Text::TypeFaceFoundry::instance(), m_face, m_outlines, m_pen_offsets, m_pen_x, m_pen_y, m_pixel_size, m_text, m_tolerance, MayaFlux::Nodes::GpuSync::GeometryWriterNode::m_vertex_data_dirty, MayaFlux::Portal::Text::GlyphAtlas::pixel_size(), MayaFlux::Nodes::GpuSync::GeometryWriterNode::resize_vertex_buffer(), and write_vertices().

Referenced by GlyphGeometryNode(), GlyphGeometryNode(), and set_text().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: