Spaces:
Sleeping
Sleeping
Update main.py
Browse files
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
|
| 660 |
-
# Assuming you have
|
|
|
|
| 661 |
try:
|
| 662 |
pdf.add_font('DejaVu', '', 'DejaVuSans.ttf', uni=True)
|
| 663 |
-
pdf.
|
|
|
|
| 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',
|
| 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 |
|