From 9db96b83e8827db9c01723dc85262796123bf3b6 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Fri, 24 Jul 2026 12:05:16 +1000 Subject: [PATCH 1/2] Restore CJK font configuration in jax_intro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 QuantEcon/lecture-python-programming.zh-cn#77 Co-Authored-By: Claude Opus 4.8 (1M context) --- lectures/jax_intro.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lectures/jax_intro.md b/lectures/jax_intro.md index a2af66b..28baf48 100644 --- a/lectures/jax_intro.md +++ b/lectures/jax_intro.md @@ -71,6 +71,11 @@ JAX 也在日益维护和提供 [更多专业化的科学计算例程](https://d import jax import jax.numpy as jnp import matplotlib.pyplot as plt +import matplotlib as mpl # i18n +import matplotlib.font_manager # i18n +FONTPATH = "_fonts/SourceHanSerifSC-SemiBold.otf" # i18n +mpl.font_manager.fontManager.addfont(FONTPATH) # i18n +mpl.rcParams['font.family'] = ['Source Han Serif SC'] # i18n import numpy as np import quantecon as qe ``` From 192cfa6d1a8f6a3a2b7d18b7ce7791268fe5e86e Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Fri, 24 Jul 2026 12:19:05 +1000 Subject: [PATCH 2/2] Add a DejaVu fallback so the font block does not trade one tofu for another MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lectures/jax_intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/jax_intro.md b/lectures/jax_intro.md index 28baf48..c035263 100644 --- a/lectures/jax_intro.md +++ b/lectures/jax_intro.md @@ -75,7 +75,7 @@ import matplotlib as mpl # i18n import matplotlib.font_manager # i18n FONTPATH = "_fonts/SourceHanSerifSC-SemiBold.otf" # i18n mpl.font_manager.fontManager.addfont(FONTPATH) # i18n -mpl.rcParams['font.family'] = ['Source Han Serif SC'] # i18n +mpl.rcParams['font.family'] = ['Source Han Serif SC', 'DejaVu Sans'] # i18n import numpy as np import quantecon as qe ```