aafigure fails to run examples : missing font files cause breakage
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
aafigure |
Fix Released
|
Medium
|
Oliver Joos |
Bug Description
I have reproduced this error w/ both the installed debian package, and syncing via bzr and installing from source. Apparently, this is a known issue, mentioned in the code for aafigure/pil.py. The problem is that aafigure is not using a very sound method of finding font files. By default, pil.py is configured to look for Courier_New.ttf. However, on my ubuntu jaunty install, I do not have that font. So, PIL throws when it is asked to load a non-existent font. I hacked a font into aafigure/pil.py in order to verify that referencing an extant font file solves this problem, and it does.
INSTALL METHODS:
-------
1. download and install this deb: https:/
2. bzr branch https:/
REPRO:
----------
1. ~/sandbox/
2. Error getting font, or somesuch:
>>> File "/usr/lib/
>>> self.font = _imagingft.
>>> IOError: cannot open resource
STACKTRACE:
------------------
Traceback (most recent call last):
File "/usr/local/
aafigure.
File "/usr/local/
(visitor, output) = render(input, output, options_dict)
File "/usr/local/
visitor = process(input, visitor_class, options)
File "/usr/local/
visitor.
File "/usr/local/
self.
File "/usr/local/
getattr(self, visitor_
File "/usr/local/
88, in visit_group
self.
File "/usr/local/
getattr(self, visitor_
File "/usr/local/
font=
File "/usr/lib/
return FreeTypeFont(
File "/usr/lib/
self.font = _imagingft.
IOError: cannot open resource
HACK:
#/usr/local/
20 class PILOutputVisitor:
21 """Render a list of shapes as bitmap.
22 """
23
HOST DETAILS:
24 def __init__(self, options):
25 self.options = options
26 self.scale = options['scale']*8
27 self.debug = options['debug']
28 self.line_width = options[
29 self.foreground = options[
30 self.background = options[
31 self.fillcolor = options['fill']
32 # if front is given explicit, use it instead of textual/
33 if 'font' in options:
34 self.font = options['font']
35 else:
36 # XXX find a good way to locate font files... as the following does not
37 # work on all platforms
38 if options[
39 self.font = 'Arial.ttf'
40 else:
41 #self.font = 'Courier_New.ttf' # original code, broken, as I don't have this font
42 #self.font = 'ae_AlMohanad.ttf' # referencing extant font by name, also broken
43 self.font = '/usr/share/
SIMILAR BUGS:
* http://
* http://
Related branches
- zsquareplusc: Disapprove
-
Diff: 96 lines (+31/-11)2 files modifiedaafigure/pil.py (+29/-6)
aafigure/svg.py (+2/-5)
Changed in aafigure: | |
importance: | Undecided → Medium |
status: | New → Confirmed |
Changed in aafigure: | |
assignee: | nobody → Oliver Joos (oliver-joos) |
Changed in aafigure: | |
status: | Confirmed → Fix Committed |
milestone: | none → 0.5 |
Changed in aafigure: | |
status: | Fix Committed → Fix Released |
I think this is a known PIL issue. As a workarround you can use the new -O command line option to pass a custom font to the PIL backend.
This should work for you:
aafigure fill.txt -o test.png -O font=/usr/ share/fonts/ truetype/ ttf-arabeyes/ ae_AlMohanad. ttf