嗯,这是我的第一个评论。我们走了。
我会尝试澄清这个程序。起初我做的是使用" name"像这样的字体
font = ImageFont.truetype("C:\Windows\Fonts\\Arial Negrita.ttf",25)
但只有这样的错误:
Traceback (most recent call last):
File "C:/Users/555STi/PycharmProjects/PIL/img.py", line 8, in
font = ImageFont.truetype("C:\Windows\Fonts\Arial negrita.ttf",25)
File "C:\Python27\lib\site-packages\PIL\ImageFont.py", line 262, in truetype
return FreeTypeFont(font, size, index, encoding)
File "C:\Python27\lib\site-packages\PIL\ImageFont.py", line 142, in __init__
self.font = core.getfont(font, size, index, encoding)
IOError: cannot open resource
然后我记得有时字体有其他的名字"或"文件名",所以,我做的是去字体文件夹,然后打开Arial字体,显示所有样式,如negrita(粗体),cursiva(斜体)等。
右键点击" negrita"风格,选择"属性"然后就是真正的名字"字体。
就我而言,名字是" ariblk"
然后,最后,只使用了这样的名字。
font = ImageFont.truetype("C:\Windows\Fonts\\ariblk.ttf",25)
我知道这篇文章很老,但今天帮助我找到解决方案。所以我希望能帮助任何人。
=)