Skip to content

Commit 34be2ea

Browse files
mmckyclaude
andauthored
Fix the live tofu in jax_intro, without trading it for subscript tofu (#78)
* Restore CJK font configuration in jax_intro The PRNG key-splitting figure sets a Chinese axis title ("PRNG 密钥拆分树"), but this lecture never registers a CJK font. matplotlib therefore falls back to DejaVu Sans, which has no CJK coverage, and the title renders as blank boxes ("tofu"). Nothing errors and a valid PNG is written, so the defect is silent -- it only shows up in the published output. Adds this edition's standard font block to the existing import cell, immediately after the matplotlib import, so it runs before any figure is drawn. The block is byte-for-byte identical to the one already carried by debugging.md, numba.md and the other 15 lectures in this repo, and the font path resolves to the tracked asset lectures/_fonts/SourceHanSerifSC-SemiBold.otf. See #77 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Add a DejaVu fallback so the font block does not trade one tofu for another jax_intro's figure labels the split tree with key₀, key₁, subkey₁ ... and a vertical ellipsis. Source Han Serif SC follows Adobe-GB1 and contains none of U+2080-2083 or U+22EE, so registering it as the sole font.family entry would have fixed the title (5 CJK characters) while breaking 8 label glyphs that render correctly today — a wash at best, and silent either way. Measured on matplotlib 3.11.1 against this repo's own font: font.family = ['Source Han Serif SC'] -> 4 missing-glyph warnings font.family = ['Source Han Serif SC', 'DejaVu Sans'] -> 0 Deliberately deviates from the single-entry dialect used elsewhere here. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d13992d commit 34be2ea

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lectures/jax_intro.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ JAX 也在日益维护和提供 [更多专业化的科学计算例程](https://d
7171
import jax
7272
import jax.numpy as jnp
7373
import matplotlib.pyplot as plt
74+
import matplotlib as mpl # i18n
75+
import matplotlib.font_manager # i18n
76+
FONTPATH = "_fonts/SourceHanSerifSC-SemiBold.otf" # i18n
77+
mpl.font_manager.fontManager.addfont(FONTPATH) # i18n
78+
mpl.rcParams['font.family'] = ['Source Han Serif SC', 'DejaVu Sans'] # i18n
7479
import numpy as np
7580
import quantecon as qe
7681
```

0 commit comments

Comments
 (0)