python - Google App Engine、ReportLab 和 True Type 字体

标签 python google-app-engine truetype reportlab

全部! 我正在编写一个可以在 Google App Engine 上运行的应用程序。我正在使用 ReportLab 生成 PDF 文件。但是,应用程序需要能够生成带有西里尔文本的 PDF。所以我需要加载一些 True Type 字体。我应该写这样的东西

pdfmetrics.registerFont(TTFont('Verdana', 'verdana.ttf'))

我试图将“verdana.ttf”文件复制到 /reportlab/fontsregisterFont 再次失败。但是在桌面环境中它工作正常。

如何从在 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/

相关文章:

javascript - Pico 找不到 python 模块

python - 如何快速检查 PySpark Dataframe 中是否存在行?

python - if语句中 "in"的用法和含义?

java - 将图像作为 Base64 字符串从 cms 发送到 Google Cloud 端点

iphone - 带有 ttf 字体的 UIButton

python - Django运行时警告: DateTimeField received a naive datetime

python - 使用 App Engine 正确解析来自 FTP 服务器的 CSV 文件

java - 在 Datastore Google App 引擎的 endpint 类中使用正则表达式或模式匹配

html - 添加自定义字体 ttf 不起作用

pdf - 如何从 PDF 中提取嵌入字体作为有效字体文件?