[triangle-zpug] can't find font problem

Joseph Mack NA3T jmack at wm7d.net
Sun Mar 30 15:21:35 CEST 2008


On Sat, 29 Mar 2008, David Handy wrote:

> The Python path is only used for finding Python modules and packages, and
> then only by the "import" statement. For opening regular files, you have to
> specify a full pathname or a path relative to the current directory.

OK. Thanks

> In this case, it looks you are trying to load the font file out of the PIL
> package directory. You can find the directory of a Python package like this:
>
>>>> import PIL
>>>> PIL.__file__
> '/usr/lib/python2.4/site-packages/PIL/__init__.pyc'
>>>> import os
>>>> os.path.dirname(PIL.__file__)
> '/usr/lib/python2.4/site-packages/PIL'
>
> So I suppose you could do something like this in your code:
>
> label_font=ImageFont.load(os.path.dirname(PIL.__file__) + "/courR18.pil")

thanks.

There's demo code out there eg

http://www.pythonware.com/library/pil/handbook/imagefont.htm

http://www.livibetter.com/blog/2006/11/24/making-pil-font-for-python-image-library/

(look for "arial.pil")

that finds the font without doing anything special. I 
thought that maybe there was some font path or python path 
that allowed python to find the file without me having to do 
anything.

> By the way, I just now looked in the PIL directory on my 
> computer and didn't see any .pil files there; I assume you 
> put courR18.pil in that directory yourself?

I moved the files from directory to directory, hoping they'd 
be picked up by the load command. Their current location is 
just where they are now. If there's a canonical location, 
I'd be happy to move them there.

Joe

-- 
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!




More information about the TriZPUG mailing list