feat: 建立可复现字体包构建链

This commit is contained in:
SkyJourney
2026-07-31 21:52:36 +08:00
parent 9f96d51922
commit ae9fde3ac6
14 changed files with 1225 additions and 5 deletions
+47
View File
@@ -0,0 +1,47 @@
# 可选字体包构建
本目录只保存字体包配方、许可证和来源说明,不保存字体二进制。主程序、
Desktop 安装包和 Docker 主镜像不会因为这些配方增加字体体积。
## 源目录
发布人员需要在 Git 忽略的本地目录中准备配方声明的冻结资源。默认目录为:
```text
.local/font-pack-sources/mdtp-serif-sc/1.0.0/
├── MdTPSerifSC-Regular.ttf
├── MdTPSerifSC-Regular.woff2
├── MdTPSerifSC-Bold.ttf
└── MdTPSerifSC-Bold.woff2
```
构建器不会联网下载、转换或自动替换字体。每个输入文件都必须与配方声明的
字节数和 SHA-256 完全一致;TTF 还必须是无需运行时规范化的原生静态
TrueType,并具有可安装或可编辑的文档嵌入权限。
## 构建与验证
```powershell
npm run build:font-pack
npm run verify:font-pack
```
也可以显式指定源目录:
```powershell
npm run build:font-pack -- --source-root D:/font-pack-sources/mdtp-serif-sc/1.0.0
```
默认运行时字体包根目录为 `output/font-packs/root`,构建报告写入
`output/font-packs/build-report.json`,两者均被 Git 忽略。输出布局为:
```text
root/<pack-id>/<semver>/font-pack.json
```
同一 ID 和版本的内容完全相同时,重复构建保持幂等;只要任一文件发生
变化,构建器就会拒绝覆盖。发行内容变化必须提升字体包 SemVer。
当前 `mdtp-serif-sc@1.0.0` 只替换 `FandolSong`
`Mdpdf Fandol Song` 的 400/700 字重,不匹配 `SimSun` 等通用别名,避免
错误替换仿宋、黑体、楷体或普通外部主题字体。
@@ -0,0 +1,94 @@
Copyright 2012 Google Inc. All Rights Reserved.
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to
provide a free and open framework in which fonts may be shared and
improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software
components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created using
the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,19 @@
# MdTP Serif SC 字体来源说明
本字体包的 Regular 400 与 Bold 700 字形面派生自 Noto Serif SC 可变字体。
- 上游项目:Noto CJK
- 上游仓库:<https://github.com/notofonts/noto-cjk>
- Google Fonts 源提交:`985fa52c81c1d6692ccdd82bc3656e8fb932fd89`
- 上游源文件:`google-fonts/NotoSerifSC[wght].ttf`
- 上游源 SHA-256`050080d9255a86808f2945bffac582b31ef32bc36411ce29563b4961670c66f9`
- 许可证:SIL Open Font License 1.1
发行字形面使用 fontTools 4.60.1 从 `wght` 轴固定生成,并将主字体家族改名
`MdTP Serif SC`、PostScript 前缀改名为 `MdTPSerifSC`。改名用于明确
标识派生版本,并避免派生字体占用上游字体名称。字形轮廓与字符覆盖未做
删减;`OS/2.fsType` 为 0,允许安装和文档嵌入。
字体包构建器不从网络下载字体,也不在主程序安装包中包含这些二进制。
发布人员必须将配方声明的四个冻结资源放入受信任源目录;构建器会同时
校验文件大小、SHA-256、格式、字体内部家族、字重与嵌入权限。
@@ -0,0 +1,57 @@
{
"recipeVersion": 1,
"manifestVersion": 1,
"id": "mdtp-serif-sc",
"version": "1.0.0",
"name": "MdTP 中文宋体兼容包",
"description": "为政企公文主题提供经过 Word/WPS 验证的原生静态中文宋体 Regular 与 Bold 字形面。",
"internalFamily": "MdTP Serif SC",
"license": "OFL-1.1",
"licenseSource": "OFL-NotoSerifSC.txt",
"licensePath": "OFL-NotoSerifSC.txt",
"licenseBytes": 4350,
"licenseSha256": "5e0da210fb04058a8c0087985d2d456b931c2579811a49655721d3cf0c36b6d6",
"noticeSource": "SOURCE.md",
"noticePath": "SOURCE.md",
"compatibility": {
"minimumAppVersion": "0.6.0"
},
"faces": [
{
"id": "serif-regular",
"targets": ["FandolSong", "Mdpdf Fandol Song"],
"weight": 400,
"style": "normal",
"web": {
"source": "MdTPSerifSC-Regular.woff2",
"path": "fonts/MdTPSerifSC-Regular.woff2",
"bytes": 5732996,
"sha256": "b1887c69d28ffba5a9f5eb5f8240c12264ea4b8e807f27ef45e308fb53b8e3ac"
},
"docx": {
"source": "MdTPSerifSC-Regular.ttf",
"path": "fonts/MdTPSerifSC-Regular.ttf",
"bytes": 14854872,
"sha256": "3bc4775662cfdb8bcbd59ddfc529852b7f72ca4906f339950ee9d7a44b844942"
}
},
{
"id": "serif-bold",
"targets": ["FandolSong", "Mdpdf Fandol Song"],
"weight": 700,
"style": "normal",
"web": {
"source": "MdTPSerifSC-Bold.woff2",
"path": "fonts/MdTPSerifSC-Bold.woff2",
"bytes": 5925732,
"sha256": "cce565f7504b22c9c08bbcb342f178ab2f730a202a76913afe77a5bd49125961"
},
"docx": {
"source": "MdTPSerifSC-Bold.ttf",
"path": "fonts/MdTPSerifSC-Bold.ttf",
"bytes": 14853848,
"sha256": "f0bcd279ae061180e12ea0b7f2715de75bede67411373816495b35ade989b154"
}
}
]
}