gpt4 book ai didi

python - PyFPDF 在 Google App Engine 中添加 Unicode 字体

转载 作者:太空宇宙 更新时间:2023-11-03 15:48:37 25 4
gpt4 key购买 nike

如何使用 PyFPDF 在我的 GAE 应用程序中添加 unicode 字体?

我已经完成了以下教程: https://pyfpdf.readthedocs.io/en/latest/Unicode/index.html#metric-files

FPDF will try to automatically generate metrics (i.e. character widths) about TTF font files to speed up their processing.

Such metrics are stored using the Python Pickle format (.pkl extension), by default in the font directory (ensure read and write permission!). Additional information about the caching mechanism is defined in the add_font reference.

这里的问题是 PyFPDF 会在文件夹中创建指标文件 (.pkl),它需要写权限,GAE 不允许写文件,我应该怎么做?

谢谢!

乔尔

最佳答案

add_font()函数使用 FPDF_CACHE_MODE 常量,它看起来像是指定是否写入 .pkl 文件的常量。该常量可能具有三个值(0、1 或 2)。如果设置为 1,则它不会写入 .pkl 文件。此常量在 fpdf.py 中定义库的文件。因此,您需要在部署之前修改此文件并将常量设置为 1。

关于python - PyFPDF 在 Google App Engine 中添加 Unicode 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48251494/

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