Add text.parse_math rcParams by oscargus · Pull Request #22556 · matplotlib/matplotlib · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/matplotlib/mpl-data/matplotlibrc
1 change: 1 addition & 0 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ def _convert_validator_spec(key, conv):
"text.hinting_factor": validate_int,
"text.kerning_factor": validate_int,
"text.antialiased": validate_bool,
"text.parse_math": validate_bool,

"mathtext.cal": validate_font_properties,
"mathtext.rm": validate_font_properties,
Expand Down
14 changes: 14 additions & 0 deletions lib/matplotlib/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,20 @@ def test_parse_math():
fig.canvas.draw()


def test_parse_math_rcparams():
# Default is True
fig, ax = plt.subplots()
ax.text(0, 0, r"$ \wrong{math} $")
with pytest.raises(ValueError, match='Unknown symbol'):
fig.canvas.draw()

# Setting rcParams to False
with mpl.rc_context({'text.parse_math': False}):
fig, ax = plt.subplots()
ax.text(0, 0, r"$ \wrong{math} $")
fig.canvas.draw()


@image_comparison(['text_pdf_font42_kerning.pdf'], style='mpl20')
def test_pdf_font42_kerning():
plt.rcParams['pdf.fonttype'] = 42
Expand Down
5 changes: 3 additions & 2 deletions lib/matplotlib/text.py