Skip to content

[0612] TikZ 插件移除 Ghostscript 依赖,改用 pdflatex + MuPDF#3434

Merged
JackYansongLi merged 9 commits into
mainfrom
jl/tikz2
May 20, 2026
Merged

[0612] TikZ 插件移除 Ghostscript 依赖,改用 pdflatex + MuPDF#3434
JackYansongLi merged 9 commits into
mainfrom
jl/tikz2

Conversation

@JackYansongLi

@JackYansongLi JackYansongLi commented May 20, 2026

Copy link
Copy Markdown
Contributor

TikZ 插件移除 Ghostscript 依赖,改用 pdflatex 直接生成 PDF:

  • 将图片生成流程从 latex -> dvips -> gs -> png 简化为 pdflatex -> pdf
  • 利用 Mogan 内置的 MuPDF 直接渲染 PDF 图片,不要求用户安装 Ghostscript
  • 移除 run-dvipsrun-gspng-sizeeps-bbox-empty? 等不再需要的工作函数
  • 添加 image-valid? 检测生成的 PDF 文件有效性
  • 更新 init-tikz.scm 移除 (binary gs) 依赖,仅依赖 goldfishpdflatex
  • binary/tikz.scm 中补充 find-binary-pdflatex 查找逻辑
  • 更新单元测试覆盖新的文件有效性检测
  • 修复file_flush 对 PDF 缺少原生尺寸回退,导致默认插入大小异常(0.618par),改为按 144 DPI 转换 pt 到像素,与旧 gs -r144 行为保持一致

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

JackYansongLi and others added 5 commits May 20, 2026 18:51
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 将图片生成流程从 latex -> dvips -> gs -> png 简化为 pdflatex -> pdf
- 利用 Mogan 内置 MuPDF 直接渲染 PDF,不要求用户安装 Ghostscript
- 添加 pdf-page-empty? 解析 pdflatex 日志检测空图形,保留提示文本
- 更新 init-tikz.scm 和 binary/tikz.scm 引入 pdflatex 支持
- 更新单元测试覆盖新的 image-valid? 和 pdf-page-empty?

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
file_flush 对 PDF 缺少原生尺寸回退,导致 width=0px&height=0px 时
image_flush 默认使用 0.618par,图片被拉伸到页面宽度的 61.8%。

修复:为 PDF 补充 image_size 检测,并将 pt 按 144 DPI 转换为像素
(px = pt * 144 / 72 = pt * 2),与旧 Ghostscript -r144 参数保持一致。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (dvips-binary-candidates)
(define (pdflatex-binary-candidates)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个应该是 pdflatex.scm

@da-liii da-liii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

JackYansongLi and others added 2 commits May 20, 2026 21:04
- 新增 pdf-page-size 函数,从 pdflatex log 中解析 papersize=
- 当用户未指定宽高时,eval-and-print 自动将 pt 换算为 px(144 DPI)
- 移除对 src/Data/Convert/Generic/input.cpp 的修改需求
- 更新 pdf-page-empty? 复用 pdf-page-size
- 更新单元测试覆盖 pdf-page-size 和 pdf-page-empty?

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@JackYansongLi JackYansongLi merged commit b015465 into main May 20, 2026
@JackYansongLi JackYansongLi deleted the jl/tikz2 branch May 20, 2026 13:09
@JackYansongLi JackYansongLi restored the jl/tikz2 branch May 20, 2026 13:11
@JackYansongLi JackYansongLi deleted the jl/tikz2 branch May 29, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants