docs(architecture): 完成技术验证 S1–S4,确定 FR-M2-05/06 目标值
- spikes/:Word 转 PDF(Gotenberg)、格式识别、原句坐标、DeepSeek 抽取四项验证代码与两版提示词;样本派生产物和 .env 不进 git - tech-validation.md:完整结论。四项都可行:WPS 字体字符集要修正并改用行高调整过的字体;格式识别不需要 Docling;表格内切句待改进;抽取需第三道依据校验与规则兜底 - architecture.md:§3.5 加预处理与字体包,§3.6 证据校验改为三道,§10 回填结论 - 03 功能需求与 decisions.md(TV1):召回 ≥ 99%、采纳准确率 ≥ 95%、页码 100%、高亮正文 ≥ 98% / 表格 ≥ 95% Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
30
spikes/s1-convert/make_fonts.py
Normal file
30
spikes/s1-convert/make_fonts.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""从 Noto CJK SC 克隆出行高接近宋体 / 黑体的字体(OFL 允许修改,改名后仍按 OFL 分发)。
|
||||
字形不变,只改垂直度量:ascent + descent = EM 倍数(参数 total),lineGap = 0。
|
||||
用法:python -I make_fonts.py <源目录> <输出目录> <total,如 1.0>"""
|
||||
import sys, pathlib
|
||||
from fontTools.ttLib import TTCollection
|
||||
|
||||
src, dst, total = pathlib.Path(sys.argv[1]), pathlib.Path(sys.argv[2]), float(sys.argv[3])
|
||||
dst.mkdir(parents=True, exist_ok=True)
|
||||
plan = [("NotoSerifCJK-Regular.ttc", "BD Song", "Regular"), ("NotoSerifCJK-Bold.ttc", "BD Song", "Bold"),
|
||||
("NotoSansCJK-Regular.ttc", "BD Hei", "Regular"), ("NotoSansCJK-Bold.ttc", "BD Hei", "Bold")]
|
||||
for fname, family, style in plan:
|
||||
coll = TTCollection(str(src / fname))
|
||||
font = next(f for f in coll.fonts if "SC" in f["name"].getDebugName(1))
|
||||
upm = font["head"].unitsPerEm
|
||||
asc = round(upm * total * 0.86); desc = round(upm * total) - asc # 与宋体相同的 0.86 / 0.14 比例
|
||||
font["hhea"].ascent, font["hhea"].descent, font["hhea"].lineGap = asc, -desc, 0
|
||||
os2 = font["OS/2"]
|
||||
os2.sTypoAscender, os2.sTypoDescender, os2.sTypoLineGap = asc, -desc, 0
|
||||
os2.usWinAscent, os2.usWinDescent = asc, desc
|
||||
name = font["name"]
|
||||
full = f"{family} {style}" if style != "Regular" else family
|
||||
for rec in list(name.names):
|
||||
if rec.nameID in (1, 3, 4, 6, 16, 17, 21, 22):
|
||||
name.removeNames(nameID=rec.nameID)
|
||||
for nid, val in ((1, family), (2, style), (3, f"{family.replace(' ', '')}-{style};{total}"),
|
||||
(4, full), (6, f"{family.replace(' ', '')}-{style}")):
|
||||
name.setName(val, nid, 3, 1, 0x409); name.setName(val, nid, 1, 0, 0)
|
||||
out = dst / f"{family.replace(' ', '')}-{style}.otf"
|
||||
font.save(str(out))
|
||||
print(out.name, upm, asc, desc)
|
||||
Reference in New Issue
Block a user