mirror of
https://github.com/YuleBest/FontMM.git
synced 2026-12-04 03:11:48 +08:00
refactor(metrics): 度量载体改为内置 Roboto Flex, 去掉设备端生成 (issue #17)
原方案在设备上按候选列表挖空系统字体, 依赖设备端字体文件名与是否存在, 既复杂又脆。 改为从 Google Fonts 取 Roboto Flex 裁出只有度量的载体 (1.79MB -> 16KB) 直接入库: - src/system/fonts/FontMM-Metrics.ttf: 度量 1900/-500 (upem 2048) = 1.171 em, 即 AOSP Roboto 拉丁基线; 字符集只剩 U+0020/U+00A0; OFL-1.1 且无保留字体名, 许可文本随包附上 (LICENSE-OFL-RobotoFlex) - apply.sh 只引用该文件并按开关调 fontmm-wght 插/移条目, 设备端不再生成字体: 删掉候选字体列表、挖空步骤与相应失败分支; 关闭开关也不再删载体 (它是模块自带文件) - fontmm-subset -metrics 保留为维护端工具, 重新生成命令写进 DEVELOPMENT.md - dev/ci.mjs 增加「载体文件必须存在」与「不得被占位脚本清空」两项检查 - README / DEVELOPMENT 措辞同步
This commit is contained in:
1 parent
176263e400
commit
05ddf554c2
8 files changed
+141
-59
No files matched your search
+15
@@ -210,6 +210,21 @@ await check('度量载体与开关文件名一致 (apply.sh / Go / WebUI)', asyn
|
||||
throw new Error(`载体文件名不一致: apply.sh=${carrier[1]}, Go=${goCarrier[1]}`);
|
||||
}
|
||||
|
||||
// 载体随模块打包, 缺失时开关会静默失效
|
||||
const carrierFile = path.join(SRC_DIR, 'system', 'fonts', carrier[1]);
|
||||
try {
|
||||
const { size } = await fsp.stat(carrierFile);
|
||||
if (size === 0) throw new Error('文件为空');
|
||||
} catch (e) {
|
||||
throw new Error(`缺少度量载体 ${path.relative(ROOT, carrierFile)} (${e.message})`);
|
||||
}
|
||||
|
||||
// 占位字体脚本会把列表内的文件清空, 载体不能被卷进去
|
||||
const emptyFont = await fsp.readFile(path.join(ROOT, 'dev', 'empty-font.mjs'), 'utf8');
|
||||
if (emptyFont.includes(carrier[1])) {
|
||||
throw new Error(`dev/empty-font.mjs 的占位列表包含度量载体 ${carrier[1]}, 会被清空`);
|
||||
}
|
||||
|
||||
// 开关文件名: apply.sh 与 Go 读、WebUI 写, 三处必须同名
|
||||
const sh = /\$\{?FONTS_DIR\}?\/metrics\.txt/.test(applySh);
|
||||
const golang = /"FONTS", "metrics\.txt"/.test(go);
|
||||
|
||||
Reference in new issue
Block a user