Three lectures render Chinese plot labels as tofu — no matplotlib font configuration
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- markdown, matplotlib, python
- Lĩnh vực
- data-visualization, documentation
Hướng nghiên cứu
Kiểm tra divergence_measures.md, kesten_processes.md và jv.md, so sánh các phần plotting của chúng với 103 bài giảng đã sử dụng khối font tiêu chuẩn của edition. Kiểm tra asset tại lectures/fonts/SourceHanSerifSC-SemiBold.otf và render các hình bị ảnh hưởng. Được xem là hoàn tất khi cả ba bài giảng đều cấu hình font đó trước khi plotting và các nhãn tiếng Trung của chúng được render mà không có tofu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Three lectures set Chinese text on matplotlib figures but carry no font configuration, so matplotlib falls back to DejaVu Sans, which has no CJK coverage. The labels render as tofu — blank rectangles — in a valid PNG, and nothing fails.
| Lecture | Chinese plot text | How it broke |
|---|---|---|
divergence_measures.md |
7 sites, e.g. plt.ylabel('密度'), axes[0].set_xlabel('KL散度 KL(f, g)') |
never had a block; labels hand-added 2025-09-12, after the blanket font pass |
kesten_processes.md |
4 sites, e.g. ax.set_ylabel("收益率"), ax.set_xlabel("日期") |
regression — block deleted by resync da7b176 (#190), labels kept |
jv.md |
via titles = [r"$s$策略", r"$\phi$策略", "价值函数"] |
block stripped by resync |
Fix
Add the edition's standard block to each, above first plotting use:
FONTPATH = "fonts/SourceHanSerifSC-SemiBold.otf"
mpl.font_manager.fontManager.addfont(FONTPATH)
plt.rcParams['font.family'] = ['Source Han Serif SC']
Note fonts/, not _fonts/ — this edition keeps the asset at lectures/fonts/SourceHanSerifSC-SemiBold.otf and the other 103 configured lectures all use that path.
Context
Not yet visible to readers: this edition last published 2025-11-06 and the breakage is post-dated, so the live site still serves pre-resync content. That is timing, not safety — it ships on the next publish.
Root cause and the recommendation against reverting to usetex are in the program review: project-translation reports/2026-07-24-cjk-font-rendering-review.md. Engine side is action-translation#107 — the resync drops i18n adaptations. A further ~12 lectures here use matplotlib with English labels and no config, which becomes tofu the moment anyone localises a label.
CI cannot currently catch any of this: the missing-glyph warning is raised in the kernel subprocess, so -W never sees it.
- Ngôn ngữ chính
- TeX
- Star
- 5
- Fork
- 4
- Merge trung bình
- 18 giờ 24 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của QuantEcon/lecture-python.zh-cn
-
Phase 2 tidy-up: revert intersphinx-qualified references once their target lectures are translatedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
QuantEcon/lecture-python.zh-cn#173 · 2 bình luận ·
-
The -W gate is blind in ci.yml, and a warning-only cache failure discards a completed executionĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
QuantEcon/lecture-python.zh-cn#271 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
QuantEcon/lecture-python.zh-cn#266 · 4 bình luận ·
Tất cả issue của QuantEcon/lecture-python.zh-cn
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
datacarpentry/semester-biology#1265 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Pivot table reports/exports pick an arbitrary metric for a mixed-metric total instead of blanking itĐang mởpreset-io
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
E3SM-Project/e3sm_diags#1093 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày