Skip to content

fix(docker): add Type1 fonts for common LaTeX documents to the engine image - #67

Merged
nishide-dev merged 4 commits into
mainfrom
fix/engine-fonts
Oct 6, 2026
Merged

nishide-dev merged 4 commits into
mainfrom
fix/engine-fonts

Conversation

@nishide-dev

@nishide-dev nishide-dev commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

概要

公開済みの engine image 0.1.0 と dev image では、普通の itemize を含む文書が !pdfTeX error: pdflatex (file tcrm1000): Font tcrm1000 at 600 not found で失敗していた。両 image に Type1 font(cm-super・lmodern・texlive-fonts-recommended)を追加して直す。MKTEXPK=0(docs/security.md §3.4)の方針は変えていない。

原因

  • LaTeX 2024-11-01(trixie の TeX Live 2024)では、OT1 文書の \textbullet が \UseTextSymbol{TS1} になっている(\?\textbullet の定義で確認)。そのため \labelitemi を使う itemize は TS1 の tcrm1000 を必要とする。\usepackage[T1]{fontenc} の文書も EC の ecrm1000 を必要とする

  • image には texlive-latex-base の TFM(fonts/tfm/jknappen/ec/tcrm1000.tfm)だけが入っていて、Type1(.pfb と map)は入っていなかった

  • texrun は MKTEXPK=0 で bitmap(PK)を生成させないので、pdfTeX は font を埋め込めずに失敗する。PK を生成させずに Type1 を入れるのが正しい対処

  • 再現の結果(修正前)

    文書 engine 0.1.0 dev image(host backend 相当)
    itemize だけ tcrm1000 not found 同じ
    textcomp 記号 + amsmath/amssymb/graphicx/booktabs/geometry/microtype/hyperref tcrm1000 not found 同じ
    \usepackage[T1]{fontenc} + microtype ecrm1000 not found 同じ
    T1 + lmodern + 上記 lmodern.sty not found 同じ
    mathptmx / helvet / mathpazo ptmr8t / pplr7t の TFM が無い 同じ
  • 既存の fixture が通っていた理由: どれも OT1 の本文だけで、itemize・textcomp 記号・T1 を使っていなかった。OT1 の Computer Modern の Type1 は texlive-base(amsfonts)に入っている

変更内容

  • docker/engine/Dockerfile と docker/dev/Dockerfile: texlive-fonts-recommended・cm-super・lmodern を追加した(--no-install-recommends のまま)。理由はコメントに書いた
  • crates/texrun-texlive/tests/fixtures/common-packages/: 4 つの文書を追加した
    • main.tex: 11pt、OT1。入れ子の itemize、enumerate、textcomp 記号(脚注や \small / \Huge の中でも使う)、amsmath/amssymb、graphicx(PNG)、booktabs、geometry、microtype、hyperref
    • t1.tex: 12pt、T1。lmodern なしで cm-super をいろいろなサイズで使う
    • lmodern.tex: T1 + lmodern + 上記のパッケージ
    • psnfss.tex: mathptmx / helvet / courier
    • palatino.tex: mathpazo(sc,osf)
    • main.tex には description(中に itemize)も入れている
  • scenarios.rs に common_packages を追加した。5 文書が成功し、error と未解決の参照が無く、1 ページの PDF ができることを確認する。scenarios.rs は CI の integration job(dev image で latexmk を host backend として実行)と sandbox job(TEXRUN_TEST_BACKEND=container)の両方で走るので、両 backend を検証できる。engine-image workflow の verify でも走る
  • fix(diagnostics): report pdfTeX and fatal engine errors #68(!pdfTeX error: の parser 対応)との整合
    • fix(diagnostics): report pdfTeX and fatal engine errors #68 の log fixture pdftex-missing-font は、cm-super が無いことを前提にした ecrm1000 で失敗させていた。この PR で dev image に cm-super が入るので、Type1 の無い cmntt10(cmextra)を使う文書に変えた。log を再生成し、real_logs.rs の期待値と regenerate.sh のコメントを更新した。ほかの log は timestamp しか変わらないので戻している
    • skills/texrun/reference/errors.md と docs/cli.md の font 不足の例を cmntt10 に変えた。errors.md は、Type1 のある font(既定の CM、T1、lmodern、mathptmx / helvet / mathpazo)に切り替えるよう案内する。itemize や T1 でも失敗するなら engine image 0.1.0 なので、新しい image を使うよう書いた
  • docs: engine-image.md のライセンス表に font と依存パッケージを追加し(cm-super / cm-super-minimal、URW の Type1 は GPL + font exception)、PDF への font 埋め込みについて追記した。development.md(dev image の内容と version)と security.md(§3.4・§4 の image 構成)も更新した

パッケージの選定

候補 image layer sources tar への追加 結果
cm-super-minimal +6.8 MB cm-super source(約 65 MiB) 10pt の font しか入っていない。itemize の 10pt 文書は通るが、11pt 文書・見出し(sfbx1440)・脚注(tcrm0800)で失敗するので不採用
cm-super +63 MB cm-super source(約 65 MiB)+ pfb2t1c2pfb T1 / TS1 の全サイズ。LaTeX の既定の font で必要になるので採用
lmodern +39 MB ほぼ 0(source package lmodern は既存の fonts-lmodern と同じ。xfonts-utils などが約 2 MiB) \usepackage{lmodern} は T1 文書の定番なので採用。font 本体の fonts-lmodern はもともと texlive-latex-base の依存で入っていて、LaTeX 用のファイル(sty/fd/tfm)だけが無かった
texlive-fonts-recommended +19 MB 0(source package texlive-base は既存) PSNFSS(Times・Helvetica・Courier・Palatino など)。論文でよく使われ、source は増えないので採用
tex-gyre など — — 追加しない(必要になったら別 Issue で)
  • ライセンス: cm-super は GPL-2.0-or-later(font exception 付き)、Latin Modern は GUST Font License(LPPL の変種)。依存の pfb2t1c2pfb は GPL、xfonts-utils / xfonts-encodings / libfontenc は MIT / X11。いずれも PDF への font 埋め込みは許されている
  • 新しく入る source package は cm-super、pfb2t1c2pfb、xfonts-utils、xfonts-encodings、libfontenc の 5 つ(dpkg-query の差分で確認)

サイズ

修正前(main) 修正後
engine image(ローカル build、arm64、圧縮 / 展開後) 171.4 MB / 657 MB 250.9 MB / 856 MB
dev image(圧縮 / 展開後) 431.3 MB / 1.67 GB 510.8 MB / 1.87 GB
sources tar 1,230,028,800 B(v0.1.0 の asset) 1,299,312,640 B(この PR の engine-image workflow の sources job、148 source packages)。+69.3 MB(+66 MiB)で、上限 2 GiB に対する余裕は 848,170,368 B(約 809 MiB)

確認方法

  • cargo check --workspace --all-targets --all-features --locked
  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo test --workspace --all-features --locked(host)
  • dev image(この PR の Dockerfile で build)で TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --locked: 全部成功
  • ローカル build の engine image で、CI の sandbox job と同じ container テスト一式(TEXRUN_TEST_BACKEND=container TEXRUN_REQUIRE_SANDBOX=1 TEXRUN_REQUIRE_TEXLIVE=1): 全部成功、ignored 0
  • 修正前の image(main の engine image、既存の dev image)では common_packages が Font tcrm0900 at 600 not found で失敗することを確認した
  • 生成された PDF の font は、pdffonts で見るとすべて Type 1 だった(bitmap は無い)
  • workflow は変えていないので actionlint は対象外。engine-image workflow の dry run(verify / build / sources)はこの PR で走る

関連 Issue

Closes #65

修正版 image の公開(v0.1.1 の tag push と release)は、merge 後に owner の判断で行う。この PR では公開しない。

補足

  • 修正前は、この font error が diagnostics に error として出ていなかった(!pdfTeX error: の行が parser で拾われない)。parser 側は Report pdfTeX errors that the log parser misses #66 で扱っているので、この PR では触っていない
  • image は約 +80 MB(圧縮)大きくなる。cm-super が大部分を占めるが、LaTeX の既定の font(T1 / TS1)なので削れない

🤖 Generated with Claude Code

@nishide-dev nishide-dev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Verdict: APPROVE

must-fix と should-fix はありません。nit がいくつかと、merge 後(v0.1.1 の公開)のための注意を書いておきます。

確認したこと

  • PR の head を clone し、engine image を別の tag(texrun-engine:review-67)で build した(arm64、OrbStack)。サイズは展開後 856 MB、圧縮 251 MB で、PR 本文の数字と一致した
  • CI の sandbox job と同じ container テスト一式(TEXRUN_TEST_BACKEND=container TEXRUN_REQUIRE_SANDBOX=1 TEXRUN_REQUIRE_TEXLIVE=1、texrun-sandbox / texrun-texlive の container・scenarios・security / texrun-preview の container・real_tools / texrun の container): すべて成功、ignored 0。common_packages も成功
  • sources job のログ: texrun-engine-0.1.0-sources.tar は 1,299,312,640 B で、PR 本文と一致する。2 GiB 上限まで約 809 MiB の余裕がある
  • cm-super-minimal の中身: .pfb は 41 個で、すべて 10pt(sfrm1000 など)。cm-super は 369 個。不採用にした理由(11pt の文書、見出しの sfbx1440、脚注の tcrm0800)は正しい。cm-super は cm-super-minimal に依存しているので、両方が入る
  • より小さい代替があるか: 既定の OT1 / T1 文書が使うのは EC / TC(ecrm / tcrm → sf*)なので、Latin Modern だけでは代わりにならない。cm-super は外せないと判断した。cm-super.t1c は 0 B(postinst が展開済み)なので、Type1 が二重に入ってはいない
  • ライセンス: image 内の copyright を見た。cm-super は GPL-2+ or GPL_Font_exception、Latin Modern は GUST Font License、pfb2t1c2pfb は GPL、xfonts-utils などは X11 系。表の内容は正しい。PSNFSS の Times などとして実際に埋め込まれるのは、texlive-fonts-recommended の fonts/type1/urw/(NimbusRomNo9L など)だった
  • MKTEXPK=0 の方針と矛盾しない。下のとおり、生成された PDF の font はすべて埋め込みの Type 1 で、bitmap(Type 3)は 1 つも無い
  • dev image と engine image は、追加したパッケージが同じ。docs(development.md、security.md §3.4・§4、engine-image.md)の記述もそれと合っている

自分で compile した文書

engine image で、texrun と同じ環境変数を渡して(--network none --read-only、MKTEX*=0、openin_any=p など)latexmk を実行した。一部は texrun compile --backend container --container-image texrun-engine:review-67 でも実行した。

共通の本文: babel english、amsmath / amssymb / amsthm(theorem と proof)、textcomp の記号約 30 種(\textbullet \textdegree \texteuro \textcelsius \textohm \textperthousand \textonehalf ほか)、itemize / enumerate を 4 段まで入れ子にしたもの、description に itemize を入れたもの、\tiny から \Huge までの全サイズ、bf / it / sl / sf / tt / sc、アクセント付き文字、脚注、graphicx(PNG)、booktabs、geometry、microtype、hyperref(\url / \href / 参照)、\tableofcontents。

文書 結果
article / report / book × 10 / 11 / 12pt × OT1 / T1(18 文書) すべて成功。PDF の font はすべて埋め込みの Type 1
T1 + lmodern、OT1 + lmodern 成功、すべて Type 1
T1 + times、OT1 / T1 + mathptmx + helvet + courier、T1 + mathpazo(sc,osf)、OT1 + palatino、T1 + helvet(sans を既定にする) 成功、すべて Type 1
microtype どの文書でも Character protrusion enabled と Automatic font expansion enabled (level 2) が出た(OT1 と T1 の両方)。expansion に関する error や warning は無い
beamer(OT1 / T1) 失敗。pgfmath.sty が無い(beamer.cls はあるが、pgf が無い。font とは関係ない)
siunitx 失敗。siunitx.sty が無い(texlive-science)

font の warning は、OT1/cmr/bx/sc・T1/lmr/bx/sc・T1/pplj/b/sc の Font shape undefined(太字の small caps)だけだった。これは CM / LM / Palatino にもともと無い shape なので、image の問題ではない。

beamer と siunitx は font の問題ではなく、この PR(#65)の範囲外。参考までにサイズを書いておく(trixie arm64 の Installed-Size)。texlive-pictures(pgf / TikZ、beamer に必要)は 82 MB で、依存で python3.13 が入るので sources tar も増える。texlive-science(siunitx)は 21 MB、texlive-latex-extra は 97 MB。入れるかどうかは別の Issue で決めればよいと思う。ただ、beamer.cls はあるのに使えない状態なので、少なくとも docs に「beamer / TikZ は未対応」と書いておくと親切。

nit

  1. fixture に mathpazo / palatino が無い: PR 本文と Dockerfile のコメントでは、mathpazo(pplr7t)が修正前に失敗していたこと、Palatino を入れたことを書いている。しかし psnfss.tex は mathptmx / helvet / courier だけを試している。psnfss.tex に \usepackage[sc]{mathpazo} を足すか、palatino.tex を追加すると、書いていることと検証していることが一致する(Palatino の Type1 は urw/palatino で、Times とは別のファイル)
  2. fixture に description が無い: Issue の観点(itemize / enumerate / description の入れ子)から見ると、main.tex に description を 1 つ入れておくとよい。font の観点では、description の見出しは bf なので、main.tex の他の部分ですでに試せている。重要度は低い
  3. ライセンス表で cm-super-minimal が抜けている: cm-super は cm-super-minimal に依存していて、image にも入っている。表の行を `cm-super` / `cm-super-minimal` にすると、dpkg -l と照らし合わせやすい。ライセンスは同じ
  4. texlive-fonts-recommended の行: 「the TeX Live fonts' own」だけだと、何のライセンスか分からない。PSNFSS で実際に埋め込まれるのは URW の Type1(fonts/type1/urw/、NimbusRomNo9L など)で、これは GPL(font exception 付き)。たとえば「mostly GPL with a font exception (the URW fonts)」のように書くと、下の「pdfTeX embeds subsets ...」の段落とつながる。そのうえで、段落の「The font exception of cm-super and the GUST Font License」に URW も含める
  5. (任意)test の失敗メッセージ: common_packages は 4 文書をループで compile しているので、失敗したときにどの文書か分かるように、assert のメッセージの先頭に main を入れるとよい(例: "{main}: {}")。今の describe の出力にも latexmk の stdout が含まれるので、そこから分かりはする
  6. (任意)lmodern の AFM: lmodern は /usr/share/texmf/fonts/afm/public/lm を 19 MB 持ってくるが、pdfTeX は AFM を使わない。path-exclude=/usr/share/texmf/fonts/afm/* を足すと展開後のサイズが約 19 MB 減る。ただし圧縮後は約 2.5 MB しか減らないので、やらなくてもよい

merge 後(v0.1.1)の注意(この PR の指摘ではない)

  • engine-image workflow は、tag と Cargo.toml の workspace.package.version が一致しないと publish しない。v0.1.1 の tag を push する前に、version を 0.1.1 にする commit が必要になる
  • texrun_sandbox::DEFAULT_IMAGE は texrun の version に紐づいていて、公開した tag は上書きしない方針になっている。そのため texrun 0.1.0 の利用者は、0.1.1 に上げるか --container-image ghcr.io/nishide-dev/texrun-engine:0.1.1 を指定しないと直らない。release notes にそう書いておくとよい

nishide-dev and others added 4 commits October 7, 2026 07:51
…kages fixture

Also name the cm-super-minimal and URW font licenses in docs/engine-image.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The dev image now has the EC / TC fonts as Type1 (cm-super), so the
fixture uses cmntt10, and the skill and docs/cli.md say which fonts work.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nishide-dev
nishide-dev merged commit de960e7 into main Oct 6, 2026
19 checks passed
@nishide-dev
nishide-dev deleted the fix/engine-fonts branch October 6, 2026 23:06
@nishide-dev nishide-dev mentioned this pull request Oct 6, 2026
2 tasks done
nishide-dev added a commit that referenced this pull request Oct 6, 2026
## 概要

v0.1.1 を公開するため、版を 0.1.1 に上げます。

## 変更内容

- `Cargo.toml` の workspace と内部 crate の版を 0.1.1 に(`Cargo.lock` も更新)
- README、docs/engine-image.md、skills/texrun/reference/setup.md の版表記を
0.1.1 に(docs/development.md のリリース手順の版表記も)

v0.1.1 に含まれる主な変更:
- engine image / dev image に Type1
font(cm-super、lmodern、texlive-fonts-recommended)を追加し、itemize や T1
を使う一般的な文書が compile できるように(#65、PR #67)
- `!pdfTeX error:` を error diagnostic として報告し、失敗した compile には必ず error
を返す(#66、PR #68)
- Agent Skill と Claude Code の plugin marketplace(#63、PR #64)

## 確認方法

- [x] `cargo test --workspace --all-features --locked`
- [x] `git grep -n '0\.1\.0' -- README.md docs/ skills/`
で残りは履歴・説明上の記述のみ(release notes の初版の例、engine image 0.1.0 の不具合の説明)

## 補足

merge 後に main へ `v0.1.1` の tag を push し、engine image と release(notes
付き)を自動公開します。texrun 0.1.0 は既定で engine image 0.1.0 を使うため、font の修正を得るには
texrun を 0.1.1 に上げる必要があります(release notes に追記予定)。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Engine image cannot compile documents that need TS1 fonts (e.g. itemize)

1 participant