From be1129475e4739293387df8a6d1e2066c48ee16a Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 4 Jan 2026 20:47:57 +0100 Subject: [PATCH] =?UTF-8?q?ajout=20des=20caract=C3=A8res=20cyrilics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 4248307..d9831c2 100644 --- a/main.py +++ b/main.py @@ -70,6 +70,9 @@ def create_pdf_from_results(results, output_path): doc = SimpleDocTemplate(output_path, pagesize=letter, topMargin=inch, bottomMargin=inch) story = [] + # Enregistre une police qui supporte le cyrilique + font_name = register_unicode_font() + # Style personnalisé styles = getSampleStyleSheet() title_style = ParagraphStyle( @@ -78,7 +81,8 @@ def create_pdf_from_results(results, output_path): fontSize=16, textColor='#1f4788', spaceAfter=0.3*inch, - alignment=TA_JUSTIFY + alignment=TA_JUSTIFY, + fontName=font_name ) page_style = ParagraphStyle( @@ -87,7 +91,8 @@ def create_pdf_from_results(results, output_path): fontSize=12, textColor='#1f4788', spaceAfter=0.2*inch, - spaceBefore=0.2*inch + spaceBefore=0.2*inch, + fontName=font_name ) body_style = ParagraphStyle( @@ -95,7 +100,8 @@ def create_pdf_from_results(results, output_path): parent=styles['BodyText'], fontSize=11, alignment=TA_JUSTIFY, - spaceAfter=0.2*inch + spaceAfter=0.2*inch, + fontName=font_name ) # Titre @@ -123,7 +129,7 @@ def main(): # Traitement page par page for i, page_text in enumerate(pages, start=1): - if( i > 3) : # Limite le nombre de pages pour les tests + if( i > 2) : # Limite le nombre de pages pour les tests break print(f"{15 * '-'} Traduction de la page {i}/{len(pages)}...") prompt = f"Traduis le texte suivant de l'ukrainien vers le français : {page_text}"