@@ -235,13 +235,12 @@ def OSXFontDirectory():
235235 within them.
236236 """
237237 fontpaths = []
238- def add (arg ,directory ,files ):
239- fontpaths .append (directory )
240238
241239 for fontdir in OSXFontDirectories :
242240 try :
243241 if os .path .isdir (fontdir ):
244- os .path .walk (fontdir , add , None )
242+ for root , dirs , files in os .walk (fontdir ):
243+ fontpaths .append (root )
245244 except (IOError , OSError , TypeError , ValueError ):
246245 pass
247246 return fontpaths
@@ -274,13 +273,12 @@ def x11FontDirectory():
274273 within them.
275274 """
276275 fontpaths = []
277- def add (arg ,directory ,files ):
278- fontpaths .append (directory )
279276
280277 for fontdir in X11FontDirectories :
281278 try :
282279 if os .path .isdir (fontdir ):
283- os .path .walk (fontdir , add , None )
280+ for root , dirs , files in os .walk (fontdir ):
281+ fontpaths .append (root )
284282 except (IOError , OSError , TypeError , ValueError ):
285283 pass
286284 return fontpaths
@@ -304,6 +302,7 @@ def get_fontconfig_fonts(fontext='ttf'):
304302 return fontfiles
305303
306304 if pipe .returncode == 0 :
305+ output = str (output )
307306 for line in output .split ('\n ' ):
308307 fname = line .split (':' )[0 ]
309308 if (os .path .splitext (fname )[1 ][1 :] in fontext and
@@ -945,7 +944,8 @@ def pickle_dump(data, filename):
945944 Equivalent to pickle.dump(data, open(filename, 'w'))
946945 but closes the file to prevent filehandle leakage.
947946 """
948- fh = open (filename , 'w' )
947+ fh = open (filename , 'wb' )
948+ print data
949949 try :
950950 pickle .dump (data , fh )
951951 finally :
@@ -956,7 +956,7 @@ def pickle_load(filename):
956956 Equivalent to pickle.load(open(filename, 'r'))
957957 but closes the file to prevent filehandle leakage.
958958 """
959- fh = open (filename , 'r ' )
959+ fh = open (filename , 'rb ' )
960960 try :
961961 data = pickle .load (fh )
962962 finally :
@@ -975,7 +975,7 @@ class FontManager:
975975 # Increment this version number whenever the font cache data
976976 # format or behavior has changed and requires a existing font
977977 # cache files to be rebuilt.
978- __version__ = 7
978+ __version__ = 8
979979
980980 def __init__ (self , size = None , weight = 'normal' ):
981981 self ._version = self .__version__
@@ -1337,6 +1337,19 @@ def findfont(prop, fontext='ttf'):
13371337 return result
13381338
13391339else :
1340+ if sys .hexversion >= 0x03000000 :
1341+ _fmcache = os .path .join (get_configdir (), 'fontList.py3k.cache' )
1342+ else :
1343+ _fmcache = os .path .join (get_configdir (), 'fontList.py3k.cache' )
1344+
1345+ fontManager = None
1346+
1347+ def _rebuild ():
1348+ global fontManager
1349+ fontManager = FontManager ()
1350+ pickle_dump (fontManager , _fmcache )
1351+ verbose .report ("generated new fontManager" )
1352+
13401353 try :
13411354 fontManager = pickle_load (_fmcache )
13421355 if (not hasattr (fontManager , '_version' ) or
0 commit comments