From 67439be486121317d66226d091eade83accdeae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=AE=E7=94=9F=EF=BC=88=E5=AD=90=E8=99=9A=EF=BC=89?= <2234839456@qq.com> Date: Fri, 24 Jul 2026 23:00:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(cff-subset):=20replaceDictOffsets=20?= =?UTF-8?q?=E8=A1=A5=E5=85=A8=20op30(BCD)=20=E8=B7=B3=E8=BF=87=E5=88=86?= =?UTF-8?q?=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CFF DICT 的 op30 是 BCD 实数,每字节两 nibble 遇 0xf 结束。replaceDictOffsets 原仅处理 28/29/247-254 整数编码,漏 op30,遇到 BCD 字节会逐字节误扫。当前思源 Top DICT 的 CIDFontVersion(BCD 2.004) 后紧跟非替换目标 operator 且 BCD 字节均 >21,operator 边界 未被破坏故输出恰好正确,但若 BCD 内出现 <=21 字节会致 operator 错乱——潜在 bug。 补 op30 分支完整跳过 nibbles 至 0xf。基准测试全用例 SSIM 无变化(思源 otf 0.9530、白狐 1.0)。 Co-Authored-By: Claude Opus 4.8 (1M context) --- backend/font_util/cff-subset.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/font_util/cff-subset.ts b/backend/font_util/cff-subset.ts index 8e318c0..5f2e204 100644 --- a/backend/font_util/cff-subset.ts +++ b/backend/font_util/cff-subset.ts @@ -723,6 +723,13 @@ function replaceDictOffsets(dictBytes: Uint8Array, replacements: Map> 4) === 0xf || (byte & 0xf) === 0xf) break; + } } else if (b0 >= 247 && b0 <= 254) { p += 1; }