aggdraw cannot load font (no text renderer)

筅森魡賤 提交于 2020-01-05 05:52:34

问题


I've installed aggdraw on OS X 10.8 using Apple's stock Python (2.7.2) using these instructions. Before doing so, I used homebrew to install freetype, and I modified aggdraw's setup.py to point to my freetype installation (FREETYPE_ROOT = "/usr/local/Cellar/freetype/2.4.10/" on line 32).

Despite all of this, when I try to load a font, I get:

$ python test.py 
Traceback (most recent call last):
  File "test.py", line 9, in <module>
      font = Font('black', '/Library/Fonts/Georgia.ttf')
IOError: cannot load font (no text renderer)

test.py looks like this:

from PIL import Image
from aggdraw import Draw, Brush, Pen, Font

size = 500, 500
img = Image.new("RGBA", size)
draw = Draw(img)
draw.rectangle((0, 0) + size, Brush((255, 255, 255), opacity=255))
draw.setantialias(True)
font = Font('black', '/Library/Fonts/Georgia.ttf')
draw.text((100, 100), "hello, world", font)
draw.flush()
img.save("test.png")

What do I need to do in order to load and use fonts in aggdraw?


回答1:


The problem was with my FREETYPE_ROOT. Line 32 of aggdraw's setup.py should be as follows: FREETYPE_ROOT = "/usr/local"

After changing that line, rebuilding and reinstalling, the test.py script above works fine.

I've updated my install script to apply that patch.



来源:https://stackoverflow.com/questions/17770413/aggdraw-cannot-load-font-no-text-renderer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!