全部! 我正在编写一个可以在 Google App Engine 上运行的应用程序。我正在使用 ReportLab 生成 PDF 文件。但是,应用程序需要能够生成带有西里尔文本的 PDF。所以我需要加载一些 True Type 字体。我应该写这样的东西
pdfmetrics.registerFont(TTFont('Verdana', 'verdana.ttf'))
我试图将“verdana.ttf”文件复制到 /reportlab/fonts
但 registerFont
再次失败。但是在桌面环境中它工作正常。
如何从在 GAE 上运行的应用程序加载 True Type 字体?
提前致谢
最佳答案
如果你使用 docker 容器来完成这项工作,或者任何 linux 环境只需使用
pdfmetrics.registerFont(TTFont('Verdana', 'Vera.ttf'))
或
pdfmetrics.registerFont(TTFont('Verdana-Bold', 'VeraBd.ttf'))
代替
pdfmetrics.registerFont(TTFont('Verdana', 'verdana.ttf'))
它对我有用。
关于python - Google App Engine、ReportLab 和 True Type 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5608290/