From 960fa21762484d3014a6778a7673f15acf2d34bb Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 28 Sep 2026 16:04:05 +0100 Subject: Map characters as HarfBuzz maps them, not as it lists them The shaping section's character map came from hb_face_collect_unicodes. HarfBuzz's own suite showed where that list and its mapping part: it cuts a format 13 map short (AdobeBlank2's whole Unicode to one glyph), and a symbol map (3,0) it searches through the private use area, Latin and, in an old Arabic font, Arabic too. Now every code point is asked with hb_font_get_nominal_glyph (about 30 ms a font) and the map carried as groups: codes going to consecutive glyphs, or all to one (12 bytes each, so a format 13 map stays small). HarfBuzz's suite: 5011 of 5199 cases the same (1355 before). The installed fonts (213) and the Noto ones (21) still shape as HarfBuzz does on random runs. --- text/shape.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'text/shape.h') diff --git a/text/shape.h b/text/shape.h index cafa9b4..3fe3ff8 100644 --- a/text/shape.h +++ b/text/shape.h @@ -21,7 +21,11 @@ * * The section, little-endian: * "VSHP", u32 size, u16 upem, u16 glyph_count, - * u32 cmap_count, u32 cmap_offset (u32 code, u32 glyph; by code), + * u32 cmap_groups, u32 cmap_offset (u32 first, u32 last code, u32 + * glyph: first's, the next codes' + * following it, or with the top bit + * set, the glyph of them all; by + * code, apart), * u32 advances_offset (glyph_count u16), * u32 offset, u32 size of GDEF, of GSUB and of GPOS (0 0 when absent), * u32 plan_count, u32 plans_offset (VEGA_PLAN_BYTES each), @@ -109,7 +113,7 @@ typedef struct { const unsigned char *bytes; size_t size; uint16_t upem, glyph_count; - uint32_t cmap_count, plan_count; + uint32_t cmap_groups, plan_count; const unsigned char *cmap, *advances, *plans, *steps, *extents; VegaTable gdef, gsub, gpos, kern; VegaTable fallback; /* Arabic fallback shaping's lookups, a GSUB table */ -- cgit v1.2.3