| 83 | |
| 84 | @pytest.mark.parametrize("fontsize", [8, 10, 12]) |
| 85 | def test_minus_no_descent(fontsize): |
| 86 | # Test special-casing of minus descent in DviFont._height_depth_of, by |
| 87 | # checking that overdrawing a 1 and a -1 results in an overall height |
| 88 | # equivalent to drawing either of them separately. |
| 89 | mpl.style.use("mpl20") |
| 90 | mpl.rcParams['font.size'] = fontsize |
| 91 | heights = {} |
| 92 | fig = plt.figure() |
| 93 | for vals in [(1,), (-1,), (-1, 1)]: |
| 94 | fig.clear() |
| 95 | for x in vals: |
| 96 | fig.text(.5, .5, f"${x}$", usetex=True) |
| 97 | fig.canvas.draw() |
| 98 | # The following counts the number of non-fully-blank pixel rows. |
| 99 | heights[vals] = ((np.array(fig.canvas.buffer_rgba())[..., 0] != 255) |
| 100 | .any(axis=1).sum()) |
| 101 | assert len({*heights.values()}) == 1 |
| 102 | |
| 103 | |
| 104 | @pytest.mark.parametrize('pkg', ['xcolor', 'chemformula']) |