1818import functools
1919import logging
2020
21+ import matplotlib as mpl
2122from matplotlib import _api , _mathtext
2223from matplotlib .ft2font import LOAD_NO_HINTING
2324from matplotlib .font_manager import FontProperties
@@ -58,7 +59,7 @@ def __init__(self, output):
5859 {"path" : "vector" , "agg" : "raster" , "macosx" : "raster" },
5960 output = output .lower ())
6061
61- def parse (self , s , dpi = 72 , prop = None ):
62+ def parse (self , s , dpi = 72 , prop = None , * , antialiased = None ):
6263 """
6364 Parse the given math expression *s* at the given *dpi*. If *prop* is
6465 provided, it is a `.FontProperties` object specifying the "default"
@@ -74,10 +75,12 @@ def parse(self, s, dpi=72, prop=None):
7475 # is mutable; key the cache using an internal copy (see
7576 # text._get_text_metrics_with_cache for a similar case).
7677 prop = prop .copy () if prop is not None else None
77- return self ._parse_cached (s , dpi , prop )
78+ if antialiased is None :
79+ antialiased = mpl .rcParams ['text.antialiased' ]
80+ return self ._parse_cached (s , dpi , prop , antialiased )
7881
7982 @functools .lru_cache (50 )
80- def _parse_cached (self , s , dpi , prop ):
83+ def _parse_cached (self , s , dpi , prop , antialiased ):
8184 from matplotlib .backends import backend_agg
8285
8386 if prop is None :
@@ -100,7 +103,7 @@ def _parse_cached(self, s, dpi, prop):
100103 if self ._output_type == "vector" :
101104 return output .to_vector ()
102105 elif self ._output_type == "raster" :
103- return output .to_raster ()
106+ return output .to_raster (antialiased = antialiased )
104107
105108
106109def math_to_image (s , filename_or_obj , prop = None , dpi = None , format = None ,
0 commit comments