[Image-SIG] Question about PIL fonts

Aaron Optimizer Digulla digulla at hepe.com
Thu Oct 16 16:20:22 EDT 2003


On Thu, Oct 16, 2003 at 01:16:35PM -0400, Frank Sogandares wrote:

> Our sysadmins are installing PIL on the corporate LAN, which supports both linux and solaris. 
> 
> I also have some PIL fonts that I'd like them to install. I ask because I'd prefer not to have to hardcode a fontpath in my code. I'd like to be able to get the fonts when I import PIL (without specifying any font paths)
> 
> 1] Is there a recommended location for the fonts so that I can just import pil?

Not that I know of.

> 2] If not, am I stuck hardcoding a fontpath into my code?

No, I'd suggest that you use os.getenv("PIL_FONTS") in your code,
then every user can just set the env variable PIL_FONTS and put
the fonts where they want them.

Even more comfortable:

    def findFont (name):
	for path in os.getenv("PIL_FONTS").split(":"):
	    file = os.path.join (path, name)
	    if os.path.exists (file):
		return file
	
	throw "Font %s not found. Please set PIL_FONTS!" % name

I guess the python library needs a path-searching module :-)

-- 
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits." 
http://www.philmann-dark.de/



More information about the Image-SIG mailing list