17 , m_text(
std::move(text))
36 , m_pixel_size(pixel_size)
37 , m_text(
std::move(text))
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;
97 while (offset < remaining) {
98 utf8proc_int32_t cp = 0;
99 const utf8proc_ssize_t n = utf8proc_iterate(bytes + offset, remaining - offset, &cp);
111 const uint32_t px =
m_face
147 size_t total_pairs = 0;
150 uint32_t prev_end = 0;
151 for (uint32_t end : ol.contour_ends) {
152 const uint32_t
count = end - prev_end;
154 total_pairs +=
count - 1;
159 std::vector<Kakshya::LineVertex> verts;
160 verts.reserve(total_pairs * 2);
162 for (
size_t gi = 0; gi <
m_outlines.size(); ++gi) {
166 uint32_t prev_end = 0;
167 for (uint32_t end : ol.contour_ends) {
168 const uint32_t
count = end - prev_end;
174 for (uint32_t pi = prev_end; pi < end - 1; ++pi) {
175 const glm::vec2
a = ol.points[pi] + off;
176 const glm::vec2
b = ol.points[pi + 1] + off;
185 set_vertices<Kakshya::LineVertex>(std::span { verts.data(), verts.size() });
188 layout->vertex_count =
static_cast<uint32_t
>(verts.size());
bool m_vertex_data_dirty
Flag: vertex data or layout changed since last GPU upload.
std::optional< Kakshya::VertexLayout > get_vertex_layout() const
Get cached vertex layout.
void set_vertex_layout(const Kakshya::VertexLayout &layout)
Set cached vertex layout.
void resize_vertex_buffer(uint32_t vertex_count, bool preserve_data=false)
Resize vertex buffer to hold specified number of vertices.
void set_vertex_stride(size_t stride)
Set vertex stride (bytes per vertex)
Base class for nodes that generate 3D geometry data.
void compute_frame() override
Upload cached vertex data if dirty.
std::vector< glm::vec2 > m_pen_offsets
void set_pen(float pen_x, float pen_y)
Set pen origin for layout.
std::vector< Portal::Text::GlyphOutline > m_outlines
void set_pen_offsets(std::vector< glm::vec2 > offsets)
Override pen offsets for all glyphs.
void rebuild_outlines()
Rebuild outline geometry from the current text and pen settings.
Portal::Text::FontFace * m_face
void set_center(std::optional< glm::vec2 > center)
Place the text block so its bounding box center falls on center.
std::optional< glm::vec2 > m_center
void set_thickness(float thickness)
Set uniform line thickness for all glyph contours.
void set_color(glm::vec3 color)
Set uniform color for all glyph contours.
void set_text(std::string text)
Replace the text string and rebuild outlines.
GlyphGeometryNode(std::string text, float pen_x=0.F, float pen_y=0.F, float tolerance=0.5F)
Construct from a UTF-8 string using the default font.
Owns a single FT_Face loaded from a file path.
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.
static TypeFaceFoundry & instance()
GlyphOutline decompose_glyph(FontFace &face, uint32_t codepoint, uint32_t pixel_size, float tolerance)
Decompose a Unicode codepoint into a tessellated polyline outline.
Vertex type for line primitives (LINE_LIST / LINE_STRIP topology)
static VertexLayout for_lines(uint32_t stride=60)
Factory: layout for LineVertex (position, color, thickness, uv, normal, tangent)
Vector outline for a single glyph as a flat polyline sequence.