[Pythonmac-SIG] py2app and PIL question

Bob Ippolito bob at redivi.com
Wed Nov 16 22:38:29 CET 2005


On Nov 16, 2005, at 1:24 PM, Chris Jerdonek wrote:

> On Nov 16, 2005, at 12:18 PM, Bob Ippolito wrote:
>
>> Code helps...
>
> Not sure which code is most important.  I'll go through the Traceback
> and intersperse the code.  I also inserted line numbers in  
> parentheses:
>
> def truetype(filename, size, index=0, encoding=""):
>      "Load a truetype font file."
>      try:
> (202)   return FreeTypeFont(filename, size, index, encoding)
>      except IOError:
>          if sys.platform == "win32":
>              # check the windows font repository
>              # NOTE: must use uppercase WINDIR, to work around bugs in
>              # 1.5.2's os.environ.get()
>              windir = os.environ.get("WINDIR")
>              if windir:
>                  filename = os.path.join(windir, "fonts", filename)
>                  return FreeTypeFont(filename, size, index, encoding)
>          raise
>
>    File "PIL/ImageFont.pyc", line 121, in __init__
> IOError: cannot open resource
>
> # Wrapper for FreeType fonts.  Application code should use the
> # <b>truetype</b> factory function to create font objects.
>
> class FreeTypeFont:
>      "FreeType font wrapper (requires _imagingft service)"
>
>      def __init__(self, file, size, index=0, encoding=""):
>          # FIXME: use service provider instead
>          import _imagingft
> (121)   self.font = _imagingft.getfont(file, size, index, encoding)

Looks like it's trying to find a font or something that isn't where  
PIL expects it to be... you sure you added all the data files that  
you're using?

-bob



More information about the Pythonmac-SIG mailing list