md2pdf重构为x2pdf:渲染层reportlab→WeasyPrint(md/txt/html)+LibreOffice(docx/xlsx/pptx/odt*),md/txt套默认黑白CSS并页码、html不套仅显式page生效,page/css参数化版式(默认CSS<page<css文件),依赖自带声明(requirements锁weasyprint==65.1/markdown==3.6——62.x对pydyf≥0.11无上界致transform崩,63+已适配;install.sh自检pango/cairo与CJK字体),删md2pdf整目录与cjk.ttf提取逻辑,img-utils改认系统wqy,README范例改指img-utils/x2pdf,system-prompt加PDF一律走x2pdf,技能清单段落格式改为名字:描述(listSkills已排序不动)
This commit is contained in:
@@ -106,5 +106,5 @@ output_schema:
|
||||
- 本技能**只做确定性图像处理**(转换/缩放/裁剪/压缩/水印/拼图),不含 AI 生成、抠图、换脸、扩图、修复等生成式/语义编辑能力。
|
||||
- 若用户的需求属于"文生图 / AI 修图"等生成式范畴,不要用本技能硬凑,应说明能力边界并推荐第三方工具(豆包、即梦、可灵、Photoshop 等)。
|
||||
- 任何操作都不会覆盖输入原图;输出目录不存在时自动创建。
|
||||
- 中文水印需要字体:优先用 `font` 参数指定;否则依赖系统字体(install.sh 会自动装文泉驿)或同仓 md2pdf 技能准备过的字体。
|
||||
- 中文水印需要字体:优先用 `font` 参数指定;否则依赖系统字体(镜像预装文泉驿,install.sh 会兑底安装)。
|
||||
- 输入依赖预装的 Pillow,无需额外 Python 依赖;系统级字体依赖见 install.sh。
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# 确保存在可用的中文字体(watermark 中文水印需要),Pillow 读字体无 reportlab 的 CFF 限制,
|
||||
# 确保存在可用的中文字体(watermark 中文水印需要):Pillow 能读 wqy/Noto 任意字体,
|
||||
# 但 NotoSansCJK ttc 的默认字型(索引 0)是 JP,中文水印会出日式字形,
|
||||
# 因此就绪判定只认文泉驿(系统 wqy 或同仓 md2pdf 提取的 fonts/cjk.ttf),Noto 仅作兜底。
|
||||
# 因此就绪判定优先文泉驿(镜像已预装,缺失时 apt 兑底),Noto 仅作告警兑底。
|
||||
# 命中即幂等退出;依赖缓存由 Skill Manager 依据本脚本内容哈希管理。
|
||||
|
||||
SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
MD2PDF_FONT="$SKILL_DIR/../md2pdf/fonts/cjk.ttf"
|
||||
|
||||
has_wqy() {
|
||||
for f in /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc \
|
||||
/usr/share/fonts/truetype/wqy/wqy-microhei.ttc; do
|
||||
@@ -22,11 +19,6 @@ if has_wqy; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -s "$MD2PDF_FONT" ]; then
|
||||
echo "使用同仓 md2pdf 准备的中文字体:$MD2PDF_FONT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
echo "未找到中文字体,安装 fonts-wqy-zenhei..."
|
||||
# best-effort:apt 失败不直接报错,交给下面的就绪判定兜底
|
||||
@@ -34,7 +26,7 @@ if [ "$(id -u)" -eq 0 ]; then
|
||||
apt-get install -y -qq fonts-wqy-zenhei || true
|
||||
fi
|
||||
|
||||
if has_wqy || [ -s "$MD2PDF_FONT" ]; then
|
||||
if has_wqy; then
|
||||
echo "中文字体就绪"
|
||||
elif [ -f /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc ]; then
|
||||
# Noto 兜底:中文能显示,只是默认字型偏日式;不算失败
|
||||
|
||||
@@ -37,8 +37,8 @@ CJK_FONT_CANDIDATES = [
|
||||
'/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc',
|
||||
'/usr/share/fonts/truetype/wqy/wqy-microhei.ttc',
|
||||
]
|
||||
# Noto 只作最后兜底:Pillow(FreeType) 能读它的 CFF 轮廓,但 ttc 默认字型(索引 0)是 JP 字形,
|
||||
# 中文水印会出日式写法;同仓 md2pdf 的 cjk.ttf(文泉驿)排在它前面。
|
||||
# Noto 只作最后兑底:Pillow(FreeType) 能读它的 CFF 轮廓,但 ttc 默认字型(索引 0)是 JP 字形,
|
||||
# 中文水印会出日式写法;因此系统文泉驿(CJK_FONT_CANDIDATES)排在它前面。
|
||||
NOTO_CJK_FALLBACK = '/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc'
|
||||
|
||||
|
||||
@@ -223,15 +223,13 @@ def action_compress(img, fmt, args):
|
||||
|
||||
|
||||
def find_font(explicit):
|
||||
"""字体查找:显式 font > 系统 wqy > 同仓 md2pdf 准备的字体 > Noto 兜底。"""
|
||||
"""字体查找:显式 font > 系统 wqy > Noto 兑底。"""
|
||||
if explicit:
|
||||
p = Path(explicit)
|
||||
if not p.exists():
|
||||
raise ValueError('指定的字体不存在:%s' % explicit)
|
||||
return str(p)
|
||||
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():
|
||||
|
||||
Reference in New Issue
Block a user