QuantEcon / QuantEcon/lecture-python-programming.fa

Persian figure labels in numba.md are unshaped and reversed — matplotlib does no Arabic shaping or bidi

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

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
1
Fork
1
Merge trung bình
10 giờ 5 phút
Pull request đã merge (30 ngày)
5

Mô tả

numba.md sets Persian text on matplotlib figures — ax.set_xlabel('تعداد نمونه‌ها') at line 820 and ax.set_ylabel(r'تخمین $\pi$') at 822, introduced by sync commit 7cd985b — and this repo carries no matplotlib font configuration and no font assets at all.

This is not the same problem as the Chinese editions, and it must not get the same fix. The glyphs do render: DejaVu Sans, matplotlib's default, covers all 29 codepoints involved. What fails is shaping. matplotlib performs no Arabic contextual shaping and no bidirectional reordering, so the label comes out as isolated letterforms in left-to-right order — legible as individual characters, wrong as Persian text. Swapping in a Persian font would not help, because the defect is in the text-layout stage rather than in glyph coverage.

Fix

The conventional approach is to reshape and reorder the string before it reaches matplotlib:

  • arabic-reshaper to apply contextual forms
  • python-bidi to apply the Unicode bidirectional algorithm

Both would need adding to environment.yml. Worth deciding whether to apply this per-label, via a small helper, or to avoid Persian in figure text altogether for now — the third option is legitimate and is what the rest of this edition currently does by default.

How it was found

A survey of CJK font handling across the translation program (project-translation reports/2026-07-24-cjk-font-rendering-review.md) checked the non-Latin editions for the same class of defect. This is the only instance in .fa; the .fr edition needs nothing, since DejaVu covers Latin with accents and French needs no shaping.

Filed for a decision rather than as an urgent break — one lecture, and the text is present rather than absent.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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.

Hướng nghiên cứu

Bắt đầu với các dòng 820-822 trong numba.md và environment.yml, sau đó kiểm tra cách các phiên bản dịch khác xử lý nhãn hình không dùng ký tự Latin. So sánh các dependency shaping được đề xuất với các tùy chọn theo từng nhãn, dùng helper và tránh văn bản; được xem là hoàn tất khi dự án có một quyết định đã được kiểm thử và ghi lại, đồng thời các nhãn tiếng Ba Tư được render chính xác nếu áp dụng shaping.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
data-visualization, internationalization
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

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.