gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 06:28:29 24 4
gpt4 key购买 nike

全部!我正在编写一个可以在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com