On Sat, Mar 20, 2010 at 9:10 PM, clive sinclair
<cl...@evclose.freeserve.co.uk> wrote:
> I am running Python 2.6 and have just installed PIL 1.1.7 running on Win
> 2000.
>
> When I try to get a font object eg by
> font = ImageFont.truetype("C:\WINNT\Fonts\arial.ttf", 15)
> I get an exception
>  File "C:\Python26\lib\site-packages\PIL\ImageFont.py", line 134, in
> __init__
>    self.font = core.getfont(file, size, index, encoding)
> IOError: cannot open resource.
>
> Looking into Class FreeTypeFont I see that _imagingft service is required.
> This file is present in C:\Python26\Lib\site-packages\PIL.
> Should this file be installed during the Python2.6 setup? What should I do
> to fix this problem? I had basically the same problem with PIL 1.1.6.

Python interprets the "\a" in your string as a control character:

>>> "C:\WINNT\Fonts\arial.ttf"
'C:\\WINNT\\Fonts\x07rial.ttf'

See

    http://docs.python.org/reference/lexical_analysis.html#string-literals

for a list of such escape codes.

To fix this, use forward slashes (they work on both Unix and Windows),
double the backslashes, or use "raw" strings.  Your favourite Python
tutorial should have more information on how to work with file names.

</F>
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to