我试图将dejavucondensed.ttf复制到pyfpdf / font / 但是当我尝试时没有运气
>>> from pyfpdf import *
>>> p = FPDF()
>>> p.add_font('dejavucondensed')
SyntaxError: Non-ASCII character '\xfd' in file pyfpdf/font/dejavucondensed.font
on line 2,
but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
答案 0 :(得分:0)
这可能是Unicode /编码问题(请参阅PEP linked in the message)。我这里没有安装pypdf,但根据reference documentation for add_font,您需要使用uni
参数:
pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)