Could not fire up pylab in Japanese Win XP


This problem seems to caused by (unhandled) ft2font.pyd crash for some
kind of third-party TTF fonts.

In, createFontDict:

  font = ft2font.FT2Font(str(fpath)) # <---- HERE
except RuntimeError:
  verbose.report_error("Could not open font file %s"%fpath)

For any 'clean' Japanese WinXP box having only MS-bundled TTFfonts,
matplotlib 0.72.1 runs fine, but with some third-party fonts
are problematic even though they seem to have no problem with other
Windows applications. In my case, two Japanese fonts were wrong.
(I don't think this is Japanese-font specific problem, because I have
many Japanese fonts in my C:/WINDOWS/Fonts directory.)

I'm now looking into ft2pyd sources to find exact cause, but it will
take a while (I'm not expert in font handling). Instead, you may
find fonts causing problem with following script:


import os
from matplotlib import rcParams
from matplotlib.ft2font import FT2Font
from matplotlib.font_manager import findSystemFonts

paths = [rcParams['datapath']]
if os.environ.has_key('TTFPATH'):
    ttfpath = os.environ['TTFPATH']
    if ttfpath.find(';') >= 0: #win32 style

ttffiles = findSystemFonts(paths) + findSystemFonts()

for fpath in ttffiles:
    print "probing %s" %(str(fpath))
    font = FT2Font(str(fpath))
print "all fine.'
This program will crash at the problematic font. Remove it from font
directory and run again untill it says all fine.
After removing all problematic fonts, Your matplotlib will work.


2005-03-17 01:31, Natsu wrote:

After resolving the issue, I could fire up pylab on
Japanese Win 2K. However, on my Win XP Japanese PCs, there seems
some trouble remaining.

The following result was obtained with Enthogut python 2.3.3 on XP
professional Version 2002 SP1, Japanese.
On other PC with XP SP2, Japanese, I got a similar error.
So I"m afraid it is repeatable to any Japanese Win XP.

Maybe, my WinXPs are not fresh and clean. What do you think?
I"m ready to test the special debugging build which was mentioned in the
list earlier, if the binaries are sent to me.

Yasushi Masuda