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. --- symbols/symbols-tool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'symbols') diff --git a/symbols/symbols-tool.c b/symbols/symbols-tool.c index 0682c1c..5b8595f 100644 --- a/symbols/symbols-tool.c +++ b/symbols/symbols-tool.c @@ -1178,11 +1178,12 @@ static int paragraph(int argc, char **argv) { VegaShaper *shaper = vega_shaper_new(); VegaGlyphs *glyphs = vega_glyphs_open(&s, (float)(pixels / s.units)); VegaLayout layouts[16] = {0}; + VegaFonts fonts = {{&shaping}, 1, NULL, NULL}; int paragraphs = argc - 6 < 16 ? argc - 6 : 16, height = 2 * margin; for (int k = 0; k < paragraphs; ++k) { uint32_t codes[4096]; size_t count = decode_utf8(argv[6 + k], codes, 4096); - if (!vega_layout(&layouts[k], shaper, &shaping, codes, count, VEGA_BIDI_AUTO, (int32_t)(width / per_unit))) + if (!vega_layout(&layouts[k], shaper, &fonts, codes, count, VEGA_BIDI_AUTO, (int32_t)(width / per_unit))) fail("cannot lay out"); height += (int)layouts[k].line_count * line_height + line_height / 2; } -- cgit v1.2.3