File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 301301 # Values other than 0 or 6 have no defined meaning.
302302#text.antialiased: True # If True (default), the text will be antialiased.
303303 # This only affects raster outputs.
304+ #text.parse_math: True # Use mathtext if there is an even number of unescaped
305+ # dollar signs.
304306
305307
306308## ***************************************************************************
Original file line number Diff line number Diff line change @@ -932,6 +932,7 @@ def _convert_validator_spec(key, conv):
932932 "text.hinting_factor" : validate_int ,
933933 "text.kerning_factor" : validate_int ,
934934 "text.antialiased" : validate_bool ,
935+ "text.parse_math" : validate_bool ,
935936
936937 "mathtext.cal" : validate_font_properties ,
937938 "mathtext.rm" : validate_font_properties ,
Original file line number Diff line number Diff line change @@ -755,6 +755,20 @@ def test_parse_math():
755755 fig .canvas .draw ()
756756
757757
758+ def test_parse_math_rcparams ():
759+ # Default is True
760+ fig , ax = plt .subplots ()
761+ ax .text (0 , 0 , r"$ \wrong{math} $" )
762+ with pytest .raises (ValueError , match = 'Unknown symbol' ):
763+ fig .canvas .draw ()
764+
765+ # Setting rcParams to False
766+ with mpl .rc_context ({'text.parse_math' : False }):
767+ fig , ax = plt .subplots ()
768+ ax .text (0 , 0 , r"$ \wrong{math} $" )
769+ fig .canvas .draw ()
770+
771+
758772@image_comparison (['text_pdf_font42_kerning.pdf' ], style = 'mpl20' )
759773def test_pdf_font42_kerning ():
760774 plt .rcParams ['pdf.fonttype' ] = 42
Original file line number Diff line number Diff line change @@ -138,11 +138,11 @@ def __init__(self,
138138 rotation = None ,
139139 linespacing = None ,
140140 rotation_mode = None ,
141- usetex = None , # defaults to rcParams['text.usetex']
141+ usetex = None ,
142142 wrap = False ,
143143 transform_rotates_text = False ,
144144 * ,
145- parse_math = True ,
145+ parse_math = None ,
146146 ** kwargs
147147 ):
148148 """
@@ -163,7 +163,8 @@ def __init__(self,
163163 color if color is not None else mpl .rcParams ["text.color" ])
164164 self .set_fontproperties (fontproperties )
165165 self .set_usetex (usetex )
166- self .set_parse_math (parse_math )
166+ self .set_parse_math (parse_math if parse_math is not None else
167+ mpl .rcParams ['text.parse_math' ])
167168 self .set_wrap (wrap )
168169 self .set_verticalalignment (verticalalignment )
169170 self .set_horizontalalignment (horizontalalignment )
You can’t perform that action at this time.
0 commit comments