QuantEcon / QuantEcon/lecture-python-programming.fa

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

Abierto
#143 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
1
Forks
1
Merge medio
10 h 5 min
PR fusionados (30 d)
5

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con las líneas 820-822 de numba.md y environment.yml y, después, inspecciona cómo otras ediciones traducidas gestionan las etiquetas de figuras no latinas. Compara las dependencias de shaping propuestas con las opciones por etiqueta, mediante un helper y de evitación de texto; se considera terminado cuando el proyecto tiene una decisión probada y documentada, y las etiquetas en persa se renderizan correctamente si se adopta el shaping.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
data-visualization, internationalization
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.