Skip to content

jax_intro renders its Chinese figure title as tofu — live to readers for three months #77

Description

@mmcky

jax_intro.md:544 sets a Chinese figure title — ax.set_title("PRNG 密钥拆分树", fontsize=13, pad=10) — and the lecture carries no matplotlib font configuration. matplotlib falls back to DejaVu Sans, which has no CJK coverage, so the title renders as tofu: blank rectangles in an otherwise valid PNG.

This one is live. The font block was stripped in 4120371 (2026-04-12), the title was re-translated to Chinese two days later, and the block was never restored. This edition has published three times since, so readers have been seeing a boxed-out figure title for roughly three months. It is the only instance in the estate that has actually reached readers — the intermediate and intro editions have the same defect but have not published since it appeared.

Fix

Restore the block above first plotting use:

FONTPATH = "_fonts/SourceHanSerifSC-SemiBold.otf"
mpl.font_manager.fontManager.addfont(FONTPATH)
plt.rcParams['font.family'] = ['Source Han Serif SC']

Check the path against this repo before committing — the estate currently has two conventions for a byte-identical asset (lectures/fonts/ in 136 lectures across the other editions, lectures/_fonts/ in 17 here and in the engine's output), and standardising on one is a separate item in the program review.

Why CI did not catch it

The missing-glyph warning is a UserWarning raised inside the Jupyter kernel subprocess. Sphinx's -W only escalates Sphinx-logger warnings, so it never sees it; myst-nb renders it into the published page as stderr output instead. No CI log in the estate has ever contained findfont or Glyph … missing.

Separately and more seriously for this repo: the -n -W --keep-going on the sphinx-tojupyter step is inertsphinx_tojupyter/builders/jupyter.py:297 calls exit(self.execution_status_code), initialised to 0 and never set, so that step swallows all execution errors. That also bounds what #76 achieves.

Context

Root cause, the recommendation against reverting to usetex, and a proposed CI tofu detector: project-translation reports/2026-07-24-cjk-font-rendering-review.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions