md2pdf 中文字体修复:install.sh 只认 TrueType(glyf) 轮廓,Noto(CFF) 移出候选并魔数校验自愈重建 fonts/cjk.ttf;img-utils 水印字型优先文泉驿(Noto ttc 默认字型是 JP),仅作兜底
This commit is contained in:
@@ -36,8 +36,10 @@ NAMED_COLORS = {
|
||||
CJK_FONT_CANDIDATES = [
|
||||
'/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc',
|
||||
'/usr/share/fonts/truetype/wqy/wqy-microhei.ttc',
|
||||
'/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc',
|
||||
]
|
||||
# Noto 只作最后兜底:Pillow(FreeType) 能读它的 CFF 轮廓,但 ttc 默认字型(索引 0)是 JP 字形,
|
||||
# 中文水印会出日式写法;同仓 md2pdf 的 cjk.ttf(文泉驿)排在它前面。
|
||||
NOTO_CJK_FALLBACK = '/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc'
|
||||
|
||||
|
||||
def to_int(v, default=0):
|
||||
@@ -221,7 +223,7 @@ def action_compress(img, fmt, args):
|
||||
|
||||
|
||||
def find_font(explicit):
|
||||
"""字体查找:显式 font > 系统 CJK 候选 > 同仓 md2pdf 技能准备的字体。"""
|
||||
"""字体查找:显式 font > 系统 wqy > 同仓 md2pdf 准备的字体 > Noto 兜底。"""
|
||||
if explicit:
|
||||
p = Path(explicit)
|
||||
if not p.exists():
|
||||
@@ -230,6 +232,7 @@ def find_font(explicit):
|
||||
skill_root = Path(__file__).resolve().parent.parent
|
||||
candidates = list(CJK_FONT_CANDIDATES)
|
||||
candidates.append(str(skill_root / 'md2pdf' / 'fonts' / 'cjk.ttf'))
|
||||
candidates.append(NOTO_CJK_FALLBACK)
|
||||
for c in candidates:
|
||||
if Path(c).exists():
|
||||
return c
|
||||
|
||||
Reference in New Issue
Block a user