aggdraw无法加载字体(无文本渲染器) [英] aggdraw cannot load font (no text renderer)

查看:110
本文介绍了aggdraw无法加载字体(无文本渲染器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用苹果公司的Python(2.7.x操作系统)在OS X 10.8上安装了 aggdraw 。 2)使用这些说明。在这样做之前,我使用自制软件安装了freetype,并修改了aggdraw的setup.py以指向我的freetype安装( FREETYPE_ROOT = /usr/local/Cellar/freetype/2.4.10/\"在第32行)。

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看起来像这样:

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")

我需要做什么加载并使用aggdraw中的字体?

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

推荐答案

问题出在我的 FREETYPE_ROOT 。 aggdraw的setup.py的第32行应如下所示: FREETYPE_ROOT = / usr / local

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

该行,重建并重新安装,上面的test.py脚本可以正常工作。

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

我已经更新了安装脚本以应用该补丁。

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

这篇关于aggdraw无法加载字体(无文本渲染器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆