Skip to content

Commit 8b9cb14

Browse files
authored
Merge pull request matplotlib#28381 from anntzer/mth
Take hinting rcParam into account in MathTextParser cache.
2 parents b19794e + 851e26d commit 8b9cb14

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/matplotlib/mathtext.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,27 @@ def parse(self, s, dpi=72, prop=None, *, antialiased=None):
7171
Depending on the *output* type, this returns either a `VectorParse` or
7272
a `RasterParse`.
7373
"""
74-
# lru_cache can't decorate parse() directly because prop
75-
# is mutable; key the cache using an internal copy (see
76-
# text._get_text_metrics_with_cache for a similar case).
74+
# lru_cache can't decorate parse() directly because prop is
75+
# mutable, so we key the cache using an internal copy (see
76+
# Text._get_text_metrics_with_cache for a similar case); likewise,
77+
# we need to check the mutable state of the text.antialiased and
78+
# text.hinting rcParams.
7779
prop = prop.copy() if prop is not None else None
7880
antialiased = mpl._val_or_rc(antialiased, 'text.antialiased')
79-
return self._parse_cached(s, dpi, prop, antialiased)
80-
81-
@functools.lru_cache(50)
82-
def _parse_cached(self, s, dpi, prop, antialiased):
8381
from matplotlib.backends import backend_agg
82+
load_glyph_flags = {
83+
"vector": LOAD_NO_HINTING,
84+
"raster": backend_agg.get_hinting_flag(),
85+
}[self._output_type]
86+
return self._parse_cached(s, dpi, prop, antialiased, load_glyph_flags)
8487

88+
@functools.lru_cache(50)
89+
def _parse_cached(self, s, dpi, prop, antialiased, load_glyph_flags):
8590
if prop is None:
8691
prop = FontProperties()
8792
fontset_class = _api.check_getitem(
8893
self._font_type_mapping, fontset=prop.get_math_fontfamily())
89-
load_glyph_flags = {
90-
"vector": LOAD_NO_HINTING,
91-
"raster": backend_agg.get_hinting_flag(),
92-
}[self._output_type]
9394
fontset = fontset_class(prop, load_glyph_flags)
94-
9595
fontsize = prop.get_size_in_points()
9696

9797
if self._parser is None: # Cache the parser globally.

0 commit comments

Comments
 (0)