| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -301,3 +301,9 @@ When `.cbook.get_sample_data` is used to load a npy or npz file and the | |||
| 301 | 301 | keyword-only parameter ``np_load`` is True, the file is automatically loaded | |
| 302 | 302 | using `numpy.load`. ``np_load`` defaults to False for backwards compatibility, | |
| 303 | 303 | but will become True in a later release. | |
| 304 | + | ||
| 305 | + ``get_text_width_height_descent`` now checks ``ismath`` rather than :rc:`text.usetex` | ||
| 306 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 307 | + ... to determine whether a string should be passed to the usetex machinery or | ||
| 308 | + not. This allows single strings to be marked as not-usetex even when the | ||
| 309 | + rcParam is True. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,7 +80,7 @@ def get_canvas_width_height(self): | |||
| 80 | 80 | ||
| 81 | 81 | def get_text_width_height_descent(self, s, prop, ismath): | |
| 82 | 82 | # docstring inherited | |
| 83 | - if mpl.rcParams["text.usetex"]: | ||
| 83 | + if ismath == "TeX": | ||
| 84 | 84 | texmanager = self.get_texmanager() | |
| 85 | 85 | fontsize = prop.get_size_in_points() | |
| 86 | 86 | w, h, d = texmanager.get_text_width_height_descent( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -558,11 +558,23 @@ def test_single_artist_usetex(): | |||
| 558 | 558 | # Check that a single artist marked with usetex does not get passed through | |
| 559 | 559 | # the mathtext parser at all (for the Agg backend) (the mathtext parser | |
| 560 | 560 | # currently fails to parse \frac12, requiring \frac{1}{2} instead). | |
| 561 | - fig, ax = plt.subplots() | ||
| 562 | - ax.text(.5, .5, r"$\frac12$", usetex=True) | ||
| 561 | + fig = plt.figure() | ||
| 562 | + fig.text(.5, .5, r"$\frac12$", usetex=True) | ||
| 563 | 563 | fig.canvas.draw() | |
| 564 | 564 | ||
| 565 | 565 | ||
| 566 | + @pytest.mark.parametrize("fmt", ["png", "pdf", "svg"]) | ||
| 567 | + def test_single_artist_usenotex(fmt): | ||
| 568 | + # Check that a single artist can be marked as not-usetex even though the | ||
| 569 | + # rcParam is on ("2_2_2" fails if passed to TeX). This currently skips | ||
| 570 | + # postscript output as the ps renderer doesn't support mixing usetex and | ||
| 571 | + # non-usetex. | ||
| 572 | + plt.rcParams["text.usetex"] = True | ||
| 573 | + fig = plt.figure() | ||
| 574 | + fig.text(.5, .5, "2_2_2", usetex=False) | ||
| 575 | + fig.savefig(io.BytesIO(), format=fmt) | ||
| 576 | + | ||
| 577 | + | ||
| 566 | 578 | @image_comparison(['text_as_path_opacity.svg']) | |
| 567 | 579 | def test_text_as_path_opacity(): | |
| 568 | 580 | plt.figure() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,7 +52,7 @@ def _get_char_id_ps(self, font, ccode): | |||
| 52 | 52 | return char_id | |
| 53 | 53 | ||
| 54 | 54 | def get_text_width_height_descent(self, s, prop, ismath): | |
| 55 | - if rcParams['text.usetex']: | ||
| 55 | + if ismath == "TeX": | ||
| 56 | 56 | texmanager = self.get_texmanager() | |
| 57 | 57 | fontsize = prop.get_size_in_points() | |
| 58 | 58 | w, h, d = texmanager.get_text_width_height_descent(s, fontsize, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments