【发布时间】:2013-12-10 23:53:48
【问题描述】:
我使用的是Canopy内部的matplotlib库,具体函数是xkcd()。此函数使用特定字体来绘制图表。字体是 Comic Sans MS,如果不存在,应该下载。
/home/luis/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['Humor Sans', 'Comic Sans MS'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext]))
我使用下面的小脚本来检查字体的存在/不存在。如果不存在,它会下载它。
import os
import urllib2
if not os.path.exists('Humor-Sans.ttf'):
fhandle = urllib2.urlopen('http://antiyawn.com/uploads/Humor-Sans-1.0.ttf')
open('Humor-Sans.ttf', 'wb').write(fhandle.read())
问题是我仍然没有得到正确的字体来显示。如果字体缓存出现问题,我会执行以下操作:
luis@luis-VirtualBox:~$ rm /home/luis/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/fontList.cache
获得以下内容:
rm: cannot remove ‘/home/luis/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/fontList.cache’: No such file or directory
我错过了什么?
【问题讨论】:
-
全世界都在告诉你不要使用comic sans ;) 你的字体缓存应该在像
./.cache/matplotlib/fontList.cache这样不在安装路径中的地方。您可能正在删除永远不会重新生成的系统安装级别fontList.cache。 -
tcaswell,非常感谢您的反馈。我尝试从您指定的位置删除 fontList.cache,但我仍然没有让 matplotlib 显示正确的字体
标签: matplotlib ipython canopy