Я протестировал рабочий процесс с помощью моя локальная установка fpdf2, и все работало нормально, но, похоже, оно не работает, когда я запускаю его на консоли GC.
Шрифты хранятся в репозитории GitHub.
Код ниже –
Код: Выделить всё
class PDF(FPDF):
import logging
....
def header(self):
..........
self.add_font('Spectral', '', fname = repo.get_contents("Style/Spectral/spectrallight.php").decoded_content)
self.add_font('Spectral', 'B', fname = repo.get_contents("Style/Spectral/spectralb.php").decoded_content)
self.add_font('SpectralB', 'B', fname = repo.get_contents("Style/Spectral/spectralb.php").decoded_content)
self.add_font('Spectral', 'BI', fname = repo.get_contents("Style/Spectral/spectralbi.php").decoded_content)
self.add_font('Spectral', 'I', fname = repo.get_contents("Style/Spectral/spectrali.php").decoded_content)
.....
Код: Выделить всё
.......File "/workspace/main.py", line 378, in generation
pdf.add_page()
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/fpdf/fpdf.py", line 904, in add_page
self.header()
File "/workspace/main.py", line 217, in header
self.add_font('Spectral', '', fname = repo.get_contents("Style/Spectral/spectrallight.php").decoded_content, uni = False)
File "/layers/google.python.pip/pip/lib/python3.11/site-packages/fpdf/fpdf.py", line 1810, in add_font
raise ValueError(
ValueError: Unsupported font file extension: . add_font() used to accept .pkl file as input, but for security reasons this feature is deprecated since v2.5.1 and has been removed in v2.5.3
Я также пробовал анализировать шрифты с помощью BytesIO, пытался изменить свой fpfd2 на 2.5.1 (функция не развертывалась"... и еще целый ряд других исправлений...
Подробнее здесь: https://stackoverflow.com/questions/787 ... -functions