fix(pdf): le texte persan s'affichait en points d'interrogation
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m51s

Cause racine (reproduite et verrouillee par test) : l'insertion PDF
demandait la police integree Helvetica tout en fournissant un fichier
de police — PyMuPDF ignore alors le fichier, et Helvetica n'a aucun
glyphe arabe : chaque lettre persane devenait un '?', et ces '?'
debordaient les boites d'origine (les nombreux « [translation
overflow] »). Defaut present dans toutes les versions deployees.

- le nom de police est desormais Personnalise quand un fichier de
  police est fourni : le fichier est reellement integre
- reproduction complete avant/apres : 0 '?', 0 debordement, persan
  rendu avec la police resolue
- test de non-regression : la page traduite ne contient PAS Helvetica
  et le texte extrait n'a aucun '?'
- bouton « Reconstruire » de la relecture : une infobulle explique
  desormais pourquoi il est grise (aucun segment approuve ni modifie),
  dans les 13 langues
This commit is contained in:
2026-09-01 21:32:40 +02:00
parent 5f3d57b4f7
commit f93b13b53f
16 changed files with 76 additions and 22 deletions

View File

@@ -1065,15 +1065,15 @@ class PDFTranslator:
color = self._int_to_rgb(block["color"])
align = fitz.TEXT_ALIGN_RIGHT if rtl_target else fitz.TEXT_ALIGN_LEFT
# PyMuPDF bug: fontname=None raises AttributeError. Default to 'helv'.
# If a custom font file is available, use it via fontfile (fontname ignored).
# Base-14 font variant honouring the block's bold/italic flags —
# previously every block (headings included) rendered in regular.
# When a custom Unicode fontfile is used we keep it: we have no
# bold/italic variant of that file, and glyph coverage matters more
# than weight.
# PyMuPDF: fontname must be a CUSTOM name when a fontfile is given —
# a base-14 name ("helv"…) makes the fontfile SILENTLY IGNORED and
# every non-Latin glyph renders as "?". This is exactly how Persian
# PDFs used to come out full of question marks.
# Without a font file, pick the base-14 variant honouring the
# block's bold/italic flags. When a custom Unicode fontfile is used
# we keep one regular face: glyph coverage matters more than weight.
if font_path:
fontname = "helv"
fontname = "wordly-unicode"
fontfile = font_path
else:
fontname = (