From a4ca275ad1b5edc15474407e2852f8fe9abaac4e Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 28 Sep 2026 15:52:13 +0100 Subject: Set text in a stack of fonts: each grapheme cluster in the first that has it vega_layout takes fonts in order of preference (VegaFonts). A grapheme cluster goes to the first font that has all its characters (default ignorables aside: shaping hides them); a cluster of Common and Inherited characters stays in the font before it when that one has it, so the spaces between Arabic words stay in the Arabic font; failing that, the first font with its first character, else the first font. Runs split where the font changes too. Positions are in the first font's units, a run's pen scaled as a whole so rounding does not add up. Callers can narrow what a font has (a symbol file holds only the glyphs its codes reach). vega_default_ignorable is shape.c's HarfBuzz 10.2 set, now public. --- text/test-layout.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'text/test-layout.c') diff --git a/text/test-layout.c b/text/test-layout.c index 5282572..420733a 100644 --- a/text/test-layout.c +++ b/text/test-layout.c @@ -88,6 +88,7 @@ int main(int argc, char **argv) { '1', '2', '3', 0x0661, 0x0662, 0x200E, 0x200F, 0x2028, 0x2014, 0x00A0}; VegaShaper *shaper = vega_shaper_new(); VegaLayout layout = {0}; + VegaFonts fonts = {{&shaping}, 1, NULL, NULL}; size_t lines = 0, glyphs = 0, characters = 0; double seconds = 0; static uint32_t codes[2048]; @@ -115,7 +116,7 @@ int main(int argc, char **argv) { int32_t width = below(5) == 0 ? 0 : (int32_t)(shaping.upem * (1 + below(30))); struct timespec a, b; clock_gettime(CLOCK_MONOTONIC, &a); - if (!vega_layout(&layout, shaper, &shaping, codes, n, direction, width)) { + if (!vega_layout(&layout, shaper, &fonts, codes, n, direction, width)) { fail(k, "no layout"); continue; } -- cgit v1.2.3