【问题标题】:unable to read woff file with PIL in Python无法在 Python 中使用 PIL 读取 woff 文件
【发布时间】:2020-07-11 16:00:04
【问题描述】:

我试图执行ImageFont.truetype

您可以下载woff文件here

from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype('89874f10.woff', 40)

但是,我收到以下错误。

Traceback (most recent call last):
  File "<pyshell#64>", line 1, in <module>
    font = ImageFont.truetype('89874f10.woff', 10)
  File "C:\Program Files\Python38\lib\site-packages\PIL\ImageFont.py", line 642, in truetype
    return freetype(font)
  File "C:\Program Files\Python38\lib\site-packages\PIL\ImageFont.py", line 639, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "C:\Program Files\Python38\lib\site-packages\PIL\ImageFont.py", line 187, in __init__
    self.font = core.getfont(
OSError: invalid argument

错误的原因是什么?

如何解决问题?

非常感谢。

【问题讨论】:

    标签: python python-imaging-library truetype woff


    【解决方案1】:

    我认为您要么需要安装 freetype 库来处理该问题,要么使用诸如 this 之类的转换器将字体转换为传统的 Truetype。

    【讨论】:

    • 这个运气好吗?
    猜你喜欢
    • 2011-04-05
    • 2016-02-10
    • 1970-01-01
    • 2019-06-15
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多