7 const glm::vec2 source = glm::max(source_px, glm::vec2(1.F));
9 .origin = { region.min.x, region.max.y },
10 .scale = { region.width() / source.x, -region.height() / source.y },
15 std::span<const GlyphQuad> quads,
17 std::span<const StyleSpan> spans,
24 out.reserve(quads.size() * 6);
28 for (
const auto&
q : quads) {
29 glm::vec3 rgb {
color };
30 for (
auto it = spans.rbegin(); it != spans.rend(); ++it) {
31 const size_t lo = std::min(it->start, it->end);
32 const size_t hi = std::max(it->start, it->end);
33 if (
q.byte_offset >= lo &&
q.byte_offset < hi) {
34 rgb = glm::vec3(it->color);
39 const glm::vec2 top_left = map({
q.x0,
q.y0 });
40 const glm::vec2 bottom_right = map({
q.x1,
q.y1 });
42 const V bl { .position = { top_left.x, bottom_right.y, 0.F }, .color = rgb, .weight =
weight, .uv = {
q.uv_x0,
q.uv_y1 } };
43 const V br { .position = { bottom_right.x, bottom_right.y, 0.F }, .color = rgb, .weight =
weight, .uv = {
q.uv_x1,
q.uv_y1 } };
44 const V tl { .position = { top_left.x, top_left.y, 0.F }, .color = rgb, .weight =
weight, .uv = {
q.uv_x0,
q.uv_y0 } };
45 const V tr { .position = { bottom_right.x, top_left.y, 0.F }, .color = rgb, .weight =
weight, .uv = {
q.uv_x1,
q.uv_y0 } };
47 out.insert(
out.end(), { bl, br, tl, br, tr, tl });
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.
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 ...
static GlyphMap fit(Kinesis::AABB2D region, glm::vec2 source_px) noexcept
Map layout pixels [0, source_px] onto region, y flipped.
Linear map from layout pixels to whatever space the vertices are drawn in.