rairo commited on
Commit
8f6ba4a
·
verified ·
1 Parent(s): cb49a43

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -5
main.py CHANGED
@@ -656,11 +656,13 @@ def download_story_archive(story_id):
656
  pdf.set_auto_page_break(auto=True, margin=15)
657
  pdf.add_page()
658
 
659
- # --- Register and set Unicode font ---
660
- # Assuming you have a TTF file named 'DejaVuSans.ttf' in the same directory
 
661
  try:
662
  pdf.add_font('DejaVu', '', 'DejaVuSans.ttf', uni=True)
663
- pdf.set_font('DejaVu', '', 12)
 
664
  except Exception as e:
665
  print(f"Error loading Unicode font: {e}")
666
  pdf.set_font("Arial", size=12) # Fallback to Arial if DejaVu fails
@@ -684,10 +686,10 @@ def download_story_archive(story_id):
684
  image_url = section_obj.get("image_url", "")
685
 
686
  pdf.add_page()
687
- pdf.set_font('DejaVu', style='B', size=14)
688
  pdf.cell(0, 10, f"Section {idx + 1}")
689
  pdf.ln(15)
690
- pdf.set_font('DejaVu', '', 12)
691
  pdf.multi_cell(0, 10, section_text)
692
  pdf.ln(10)
693
 
 
656
  pdf.set_auto_page_break(auto=True, margin=15)
657
  pdf.add_page()
658
 
659
+ # --- Register and set Unicode fonts ---
660
+ # Assuming you have TTF files named 'DejaVuSans.ttf' (regular) and 'DejaVuSans-Bold.ttf' (bold)
661
+ # in the same directory
662
  try:
663
  pdf.add_font('DejaVu', '', 'DejaVuSans.ttf', uni=True)
664
+ pdf.add_font('DejaVu', 'B', 'dejaVu-sans-bold.ttf', uni=True)
665
+ pdf.set_font('DejaVu', '', 12) # Set default font to regular
666
  except Exception as e:
667
  print(f"Error loading Unicode font: {e}")
668
  pdf.set_font("Arial", size=12) # Fallback to Arial if DejaVu fails
 
686
  image_url = section_obj.get("image_url", "")
687
 
688
  pdf.add_page()
689
+ pdf.set_font('DejaVu', 'B', 14) # Set font to bold for section title
690
  pdf.cell(0, 10, f"Section {idx + 1}")
691
  pdf.ln(15)
692
+ pdf.set_font('DejaVu', '', 12) # Set font back to regular for section text
693
  pdf.multi_cell(0, 10, section_text)
694
  pdf.ln(10)
695