gpt4 book ai didi

python - ImageFont 检测丢失的字形(Python Pillow)

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

<分区>

这是一个简短的example .

from PIL import ImageFont, ImageDraw

draw = ImageDraw.Draw(image)

# use a bitmap font
font = ImageFont.load("arial.pil")

draw.text((10, 10), "hello", font=font)

# use a truetype font
font = ImageFont.truetype("arial.ttf", 15)

draw.text((10, 25), "world", font=font)

I want to know if the font is missing any glyphs from the rendered text.

当我尝试渲染一个缺失的字形时,我得到一个空方 block 。

draw.text((10, 10), chr(1234), font=font)
  • 如何以编程方式确定缺失的字形?
  • 如何在 ttf 文件中列出可用的字形?

两个问题几乎一样。

I would prefer using Pillow to determine what I want. Other modules from PyPI are welcome as well.

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