mirror of
https://github.com/2234839/web-font.git
synced 2026-09-04 23:02:27 +08:00
Font.create 内 readWindowsAllCodes 在 subset 模式下对每个 subset 字符做 lookupFormat4/lookupFormat12 二分查找产出 codepoint→gid,这与之前 probeGsubAndCmap 的 probe.lookup(算法一致)完全重复。subset 模式下 format0/format14 不解析 (glyphIdArray/groups 为空),codes 仅来自 format4/12,故 probe.lookup 与 readWindowsAllCodes 产出严格等价。 fontSubset 在 probe.ok 时将 probe.lookup(Map)转为普通对象经 readOptions.presetCmap 注入,readWindowsAllCodes 检测到 presetCmap 直接返回,跳过 N 次(subset 长度)二分查找。 收益(best-of Font.create):千字文 -10.2%、初夏纯标点 -5.5%、FiraCode -3.7% (与 subset 长度成正比,每 codepoint 省一次二分)。5 字体 woff2 sha 逐字节一致, SSIM 全部不变。probe 不 ok(otf 或无 format4/12)时不注入,走原逻辑。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>