FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support marking a single artist as not-usetex. by anntzer · Pull Request #17485 · matplotlib/matplotlib · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 6 additions & 0 deletions doc/api/api_changes_3.3/behaviour.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,9 @@ When `.cbook.get_sample_data` is used to load a npy or npz file and the
keyword-only parameter ``np_load`` is True, the file is automatically loaded
using `numpy.load`. ``np_load`` defaults to False for backwards compatibility,
but will become True in a later release.

``get_text_width_height_descent`` now checks ``ismath`` rather than :rc:`text.usetex`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... to determine whether a string should be passed to the usetex machinery or
not. This allows single strings to be marked as not-usetex even when the
rcParam is True.
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/_backend_pdf_ps.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_canvas_width_height(self):

def get_text_width_height_descent(self, s, prop, ismath):
# docstring inherited
if mpl.rcParams["text.usetex"]:
if ismath == "TeX":
texmanager = self.get_texmanager()
fontsize = prop.get_size_in_points()
w, h, d = texmanager.get_text_width_height_descent(
Expand Down
16 changes: 14 additions & 2 deletions lib/matplotlib/tests/test_text.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,23 @@ def test_single_artist_usetex():
# Check that a single artist marked with usetex does not get passed through
# the mathtext parser at all (for the Agg backend) (the mathtext parser
# currently fails to parse \frac12, requiring \frac{1}{2} instead).
fig, ax = plt.subplots()
ax.text(.5, .5, r"$\frac12$", usetex=True)
fig = plt.figure()
fig.text(.5, .5, r"$\frac12$", usetex=True)
fig.canvas.draw()


@pytest.mark.parametrize("fmt", ["png", "pdf", "svg"])
def test_single_artist_usenotex(fmt):
# Check that a single artist can be marked as not-usetex even though the
# rcParam is on ("2_2_2" fails if passed to TeX). This currently skips
# postscript output as the ps renderer doesn't support mixing usetex and
# non-usetex.
plt.rcParams["text.usetex"] = True
fig = plt.figure()
fig.text(.5, .5, "2_2_2", usetex=False)
fig.savefig(io.BytesIO(), format=fmt)


@image_comparison(['text_as_path_opacity.svg'])
def test_text_as_path_opacity():
plt.figure()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/textpath.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _get_char_id_ps(self, font, ccode):
return char_id

def get_text_width_height_descent(self, s, prop, ismath):
if rcParams['text.usetex']:
if ismath == "TeX":
texmanager = self.get_texmanager()
fontsize = prop.get_size_in_points()
w, h, d = texmanager.get_text_width_height_descent(s, fontsize,
Expand Down

Back | FazBrowse Home | New Git URL