QuantEcon / QuantEcon/lecture-python-programming.fa

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

Open
#143 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1
Forks
1
Avg merge
10h 5m
Merged PRs (30d)
5

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with numba.md lines 820-822 and environment.yml, then inspect how other translated editions handle non-Latin figure labels. Compare the proposed shaping dependencies with the per-label, helper, and text-avoidance options; done means the project has a tested, documented decision and Persian labels render correctly if shaping is adopted.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization, internationalization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.