QuantEcon / QuantEcon/lecture-python-programming.fa
Persian figure labels in numba.md are unshaped and reversed — matplotlib does no Arabic shaping or bidi
还没有人认领这个 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-reshaperto apply contextual formspython-bidito 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.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先从 numba.md 第 820-822 行和 environment.yml 开始,然后检查其他翻译版本如何处理非拉丁文字的图表标签。将提议的 shaping 依赖项与按标签处理、使用 helper 以及避免文本这几种方案进行比较;完成的标准是项目有一个经过测试并记录在案的决定,并且如果采用 shaping,波斯语标签能够正确渲染。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization, internationalization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100