QuantEcon / QuantEcon/lecture-python-programming.fa

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

未關閉
#143 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
1
分支
1
平均合併
10 小時 5 分鐘
30 天內合併 PR
5

描述

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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先從 numba.md 第 820-822 行和 environment.yml 開始,接著檢查其他翻譯版本如何處理非拉丁文字的圖表標籤。將提議的 shaping 相依項目與按標籤處理、使用 helper 以及避免文字這幾種方案進行比較;完成的標準是專案有一個經過測試並記錄在案的決定,並且如果採用 shaping,波斯語標籤能夠正確呈現。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
data-visualization, internationalization
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。