Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Three lectures render Chinese plot labels as tofu — no matplotlib font configuration

Đang mở
#205 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của QuantEcon/lecture-python.zh-cn

Tất cả issue của QuantEcon/lecture-python.zh-cn

Issue tương tự

Thêm issue về Data Visualization

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.