10 std::string_view text,
17 return { .
quads = {}, .final_pen_x = pen_x, .final_pen_y = pen_y };
21 out.
quads.reserve(text.size());
23 const float origin_x = 0.F;
25 const auto* bytes =
reinterpret_cast<const utf8proc_uint8_t*
>(text.data());
26 auto remaining =
static_cast<utf8proc_ssize_t
>(text.size());
27 utf8proc_ssize_t offset = 0;
29 while (offset < remaining) {
30 utf8proc_int32_t codepoint = 0;
31 const utf8proc_ssize_t n = utf8proc_iterate(bytes + offset, remaining - offset, &codepoint);
35 "TypeSetter: invalid UTF-8 sequence at byte offset {}, skipping byte",
36 static_cast<size_t>(offset));
47 if (codepoint ==
'\n') {
53 if (codepoint ==
'\r') {
65 q.y0 = pen_y -
static_cast<float>(m->
bearing_y);
66 q.x1 =
q.x0 +
static_cast<float>(m->
width);
67 q.y1 =
q.y0 +
static_cast<float>(m->
height);
71 q.codepoint =
static_cast<uint32_t
>(codepoint);
76 pen_x +=
static_cast<float>(m->
advance_x);
78 if (wrap_w > 0 &&
static_cast<uint32_t
>(std::ceil(pen_x)) > wrap_w) {
uint32_t line_height() const
Line advance in pixels for this atlas's pixel_size.
const GlyphMetrics * get_or_rasterize(FT_UInt glyph_index)
Return metrics for a glyph, rasterizing it into the atlas if needed.
Rasterizes and packs glyphs from a FontFace into a TextureContainer.
LayoutResult lay_out(std::string_view text, GlyphAtlas &atlas, float pen_x, float pen_y, uint32_t wrap_w)
Lay out a UTF-8 string into a sequence of screen-space quads.
int32_t bearing_x
Horizontal bearing in pixels (from FT_GlyphSlot).
float uv_x0
Left UV edge in atlas texture.
float uv_x1
Right UV edge in atlas texture.
uint32_t height
Glyph bitmap height in pixels.
int32_t advance_x
Horizontal advance in pixels (26.6 fixed-point >> 6).
uint32_t width
Glyph bitmap width in pixels.
float uv_y0
Top UV edge in atlas texture.
int32_t bearing_y
Vertical bearing in pixels (from FT_GlyphSlot).
float uv_y1
Bottom UV edge in atlas texture.
Per-glyph layout and UV data produced by GlyphAtlas.
Screen-space quad for one rasterized glyph.
std::vector< GlyphQuad > quads
Result of lay_out(), carrying the quads and the final pen position.