[Image-SIG] ImageFont.load_path() searching patch
Richard Jones
richard.jones@fulcrum.com.au
Wed, 17 Mar 1999 11:35:53 +1100
Hi all,
Here's a simple patch to ImageFont.load_path() that makes it search the
directories specified by the ".pth" files in the Python search path. I'm not
sure if I implemented the searching exactly as the interpreter does it - but it
works for me. YMMV.
Richard
*** ImageFont.py.old Wed Mar 17 11:21:23 1999
--- ImageFont.py Wed Mar 17 11:33:29 1999
***************
*** 20,26 ****
#
import Image
! import math, os, string, sys
# --------------------------------------------------------------------
# Font metrics format:
--- 20,26 ----
#
import Image
! import math, os, string, sys, glob
# --------------------------------------------------------------------
# Font metrics format:
***************
*** 113,117 ****
--- 113,124 ----
return load(os.path.join(dir, filename))
except:
pass
+ for extra in glob.glob(os.path.join(dir, "*.pth")):
+ try:
+ dir = os.path.join(dir, string.strip(open(extra).read()))
+ return load(os.path.join(dir, filename))
+ except:
+ pass
+
raise IOError, "cannot find font file"