Skip to content

Commit

Permalink
Clear findfont cache when calling addfont().
Browse files Browse the repository at this point in the history
... 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.
  • Loading branch information
anntzer committed Oct 4, 2021
1 parent 22bf7d6 commit 4b593ac
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/matplotlib/font_manager.py
Expand Up @@ -1092,6 +1092,7 @@ def addfont(self, path):
font = ft2font.FT2Font(path)
prop = ttfFontProperty(font)
self.ttflist.append(prop)
self._findfont_cached.__func__.cache_clear()

@property
def defaultFont(self):
Expand Down

0 comments on commit 4b593ac

Please sign in to comment.