Skip to content

Commit 997b69e

Browse files
committed
Clear findfont cache when calling addfont().
... as new fonts may invalidate previous searches (e.g. a previous findfont may have chosen to return an approximate match, whereas the newly added font is an exact match). No test, as there is no machinery to *remove* a font from FontManager yet so we add a font just temporarily within the test.
1 parent 8a8dd90 commit 997b69e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/matplotlib/font_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,7 @@ def addfont(self, path):
10921092
font = ft2font.FT2Font(path)
10931093
prop = ttfFontProperty(font)
10941094
self.ttflist.append(prop)
1095+
self._findfont_cached.cache_clear()
10951096

10961097
@property
10971098
def defaultFont(self):

0 commit comments

Comments
 (0)