Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,9 +65,9 @@ from google.cloud import storage, exceptions # Import exceptions for error hand
|
|
| 65 |
from google.cloud.exceptions import NotFound
|
| 66 |
from google.oauth2 import service_account
|
| 67 |
|
| 68 |
-
from reportlab.lib.pagesizes import letter
|
| 69 |
from reportlab.pdfgen import canvas
|
| 70 |
-
from reportlab.
|
|
|
|
| 71 |
from reportlab.lib import colors
|
| 72 |
|
| 73 |
import logging
|
|
@@ -405,11 +405,11 @@ def generate_document(task_description, md_content, user_name='jayw', bucket_nam
|
|
| 405 |
try:
|
| 406 |
# Register the Simplified Chinese font
|
| 407 |
sc_font = TTFont('NotoSansSC', sc_font_path)
|
| 408 |
-
|
| 409 |
|
| 410 |
# Register the Traditional Chinese font
|
| 411 |
tc_font = TTFont('NotoSansTC', tc_font_path)
|
| 412 |
-
|
| 413 |
|
| 414 |
# Set default font (Simplified Chinese or Traditional Chinese depending on content)
|
| 415 |
c.setFont('NotoSansSC', 12)
|
|
@@ -455,8 +455,7 @@ def generate_document(task_description, md_content, user_name='jayw', bucket_nam
|
|
| 455 |
public_url = save_to_google_storage(bucket_name, local_filename, destination_blob_name)
|
| 456 |
logger.debug("Finished generating document")
|
| 457 |
return public_url
|
| 458 |
-
|
| 459 |
-
|
| 460 |
# In[10]:
|
| 461 |
|
| 462 |
|
|
|
|
| 65 |
from google.cloud.exceptions import NotFound
|
| 66 |
from google.oauth2 import service_account
|
| 67 |
|
|
|
|
| 68 |
from reportlab.pdfgen import canvas
|
| 69 |
+
from reportlab.lib.pagesizes import letter
|
| 70 |
+
from reportlab import pdfmetrics
|
| 71 |
from reportlab.lib import colors
|
| 72 |
|
| 73 |
import logging
|
|
|
|
| 405 |
try:
|
| 406 |
# Register the Simplified Chinese font
|
| 407 |
sc_font = TTFont('NotoSansSC', sc_font_path)
|
| 408 |
+
pdfmetrics.registerFont(sc_font)
|
| 409 |
|
| 410 |
# Register the Traditional Chinese font
|
| 411 |
tc_font = TTFont('NotoSansTC', tc_font_path)
|
| 412 |
+
pdfmetrics.registerFont(tc_font)
|
| 413 |
|
| 414 |
# Set default font (Simplified Chinese or Traditional Chinese depending on content)
|
| 415 |
c.setFont('NotoSansSC', 12)
|
|
|
|
| 455 |
public_url = save_to_google_storage(bucket_name, local_filename, destination_blob_name)
|
| 456 |
logger.debug("Finished generating document")
|
| 457 |
return public_url
|
| 458 |
+
|
|
|
|
| 459 |
# In[10]:
|
| 460 |
|
| 461 |
|