Michael Droettboom wrote:
Just wanted to link up this thread with a question I posed on the cairo
mailing list.
http://lists.cairographics.org/archives/cairo/2007-August/011201.html
Cheers,
Mike
Eric Firing wrote:
Michael Droettboom wrote:
[...]
One middle ground I thought of since my first message is to use
fc-list to get a list of all the fonts on the system, and continue to
use font_manager.py for the font matching. If "fc-list" is not
available, it could fall back to the hard-coded paths it uses now.
Of course, the matching in font_manager.py would still need to be
improved.
Sounds reasonable.
Your change to use fontconfig slightly raised the time for
backend_driver.py Template: 0.50 -> 0.53 minutes.
While you are poking around in font_manager: this is one of the
biggest chunks of mpl script startup time, even with the present
caching. I haven't looked very closely or done any testing, but I
suspect more extensive caching could work fine. Specifically, can the
entire fontManager instance be pickled, and loaded if it exists?
I tried this (svn diff is attached), and it cut the time above to 0.43
minutes. I have not committed it; I very much like doing what we can to
reduce startup time (which is important for applications that run simple
plots as standalone scripts), but perhaps the approach here will cause
too much trouble, or will require better error trapping downstream to
handle the case where the fontManager actually needs to be rebuilt.
Eric
Eric
Cheers,
Mike
Index: font_manager.py
===================================================================
--- font_manager.py (revision 3706)
+++ font_manager.py (working copy)
@@ -231,10 +231,10 @@
if sys.platform == 'darwin':
for f in OSXInstalledFonts():
fontfiles[f] = 1
-
+
for f in get_fontconfig_fonts(fontext):
fontfiles[f] = 1
-
+
elif isinstance(fontpaths, (str, unicode)):
fontpaths = [fontpaths]
@@ -1009,7 +1009,7 @@
return fname
font_family_aliases = ['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace']
-
+
for name in prop.get_family():
if name in font_family_aliases:
for name2 in rcParams['font.' + name]:
@@ -1060,5 +1060,12 @@
return fontdict
+fmcache = os.path.join(get_configdir(), 'fontManager.cache')
-fontManager = FontManager()
+try:
+ fontManager = pickle_load(fmcache)
+except:
+ fontManager = FontManager()
+ pickle_dump(fontManager, fmcache)
+ print "generated new fontManager"
+
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel