QuantEcon / QuantEcon/lecture-python-programming.fa

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

Aperta
#143 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
1
Fork
1
Merge medio
10h 5m
PR unite (30g)
5

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dalle righe 820-822 di numba.md e environment.yml, poi esamina come le altre edizioni tradotte gestiscono le etichette delle figure non latine. Confronta le dipendenze di shaping proposte con le opzioni per etichetta, tramite helper e di evitamento del testo; il lavoro è completato quando il progetto dispone di una decisione testata e documentata e le etichette in persiano vengono visualizzate correttamente se si adotta lo shaping.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
data-visualization, internationalization
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.