Skip to content

Commit e4f944b

Browse files
committed
Minor improvement to font_manager -- don't cache directory-specific results.
svn path=/trunk/matplotlib/; revision=8315
1 parent 809b367 commit e4f944b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/matplotlib/font_manager.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,10 +1193,7 @@ def findfont(self, prop, fontext='ttf', directory=None,
11931193
<http://www.w3.org/TR/1998/REC-CSS2-19980512/>`_ documentation
11941194
for a description of the font finding algorithm.
11951195
"""
1196-
debug = False
1197-
if prop is None:
1198-
prop = FontProperties()
1199-
if is_string_like(prop):
1196+
if not isinstance(prop, FontProperties):
12001197
prop = FontProperties(prop)
12011198
fname = prop.get_file()
12021199
if fname is not None:
@@ -1210,9 +1207,10 @@ def findfont(self, prop, fontext='ttf', directory=None,
12101207
font_cache = self.ttf_lookup_cache
12111208
fontlist = self.ttflist
12121209

1213-
cached = font_cache.get(hash(prop))
1214-
if cached:
1215-
return cached
1210+
if directory is None:
1211+
cached = font_cache.get(hash(prop))
1212+
if cached:
1213+
return cached
12161214

12171215
best_score = 1e64
12181216
best_font = None
@@ -1258,7 +1256,8 @@ def findfont(self, prop, fontext='ttf', directory=None,
12581256
(prop, best_font.name, best_font.fname, best_score))
12591257
result = best_font.fname
12601258

1261-
font_cache[hash(prop)] = result
1259+
if directory is None:
1260+
font_cache[hash(prop)] = result
12621261
return result
12631262

12641263

0 commit comments

Comments
 (0)