Skip to content

Commit 8255ae2

Browse files
committed
Set text hinting to defaults
Namely, `text.hinting` is now `default` instead of `force_autohint` (or `none` for classic tests) and `text.hinting_factor` is now 1, not 8.
1 parent 7b4d725 commit 8255ae2

File tree

8 files changed

+26
-16
lines changed

8 files changed

+26
-16
lines changed

lib/matplotlib/mpl-data/matplotlibrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@
301301
## ("native" is a synonym.)
302302
## - force_autohint: Use FreeType's auto-hinter. ("auto" is a synonym.)
303303
## - no_hinting: Disable hinting. ("none" is a synonym.)
304-
#text.hinting: force_autohint
304+
#text.hinting: default
305305

306-
#text.hinting_factor: 8 # Specifies the amount of softness for hinting in the
306+
#text.hinting_factor: 1 # Specifies the amount of softness for hinting in the
307307
# horizontal direction. A value of 1 will hint to full
308308
# pixels. A value of 2 will hint to half pixels etc.
309309
#text.kerning_factor: 0 # Specifies the scaling factor for kerning values. This

lib/matplotlib/mpl-data/stylelib/_classic_test_patch.mplstyle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
ytick.alignment: center_baseline
55

66
hatch.color: edge
7+
8+
text.hinting: default
9+
text.hinting_factor: 1

lib/matplotlib/testing/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@
1919

2020
def set_font_settings_for_testing():
2121
mpl.rcParams['font.family'] = 'DejaVu Sans'
22-
mpl.rcParams['text.hinting'] = 'none'
23-
mpl.rcParams['text.hinting_factor'] = 8
22+
# We've changed the default for ourselves here, but for backwards-compatibility, use
23+
# the old setting if not called in our own tests (which would set
24+
# `_called_from_pytest` from our `conftest.py`).
25+
if getattr(mpl, '_called_from_pytest', False):
26+
mpl.rcParams['text.hinting'] = 'default'
27+
mpl.rcParams['text.hinting_factor'] = 1
28+
else:
29+
mpl.rcParams['text.hinting'] = 'none'
30+
mpl.rcParams['text.hinting_factor'] = 8
2431

2532

2633
def set_reproducibility_for_testing():

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8272,8 +8272,8 @@ def test_normal_axes():
82728272

82738273
# test the axis bboxes
82748274
target = [
8275-
[123.375, 75.88888888888886, 983.25, 33.0],
8276-
[85.51388888888889, 99.99999999999997, 53.375, 993.0]
8275+
[124.0, 76.89, 982.0, 32.0],
8276+
[86.89, 100.5, 52.0, 992.0],
82778277
]
82788278
for nn, b in enumerate(bbaxis):
82798279
targetbb = mtransforms.Bbox.from_bounds(*target[nn])
@@ -8293,7 +8293,7 @@ def test_normal_axes():
82938293
targetbb = mtransforms.Bbox.from_bounds(*target)
82948294
assert_array_almost_equal(bbax.bounds, targetbb.bounds, decimal=2)
82958295

8296-
target = [85.5138, 75.88888, 1021.11, 1017.11]
8296+
target = [86.89, 76.89, 1019.11, 1015.61]
82978297
targetbb = mtransforms.Bbox.from_bounds(*target)
82988298
assert_array_almost_equal(bbtb.bounds, targetbb.bounds, decimal=2)
82998299

lib/matplotlib/tests/test_figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ def test_tightbbox():
814814
ax.set_xlim(0, 1)
815815
t = ax.text(1., 0.5, 'This dangles over end')
816816
renderer = fig.canvas.get_renderer()
817-
x1Nom0 = 9.035 # inches
817+
x1Nom0 = 8.9375 # inches
818818
assert abs(t.get_tightbbox(renderer).x1 - x1Nom0 * fig.dpi) < 2
819819
assert abs(ax.get_tightbbox(renderer).x1 - x1Nom0 * fig.dpi) < 2
820820
assert abs(fig.get_tightbbox(renderer).x1 - x1Nom0) < 0.05

lib/matplotlib/tests/test_legend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,10 @@ def test_figure_legend_outside():
481481
todos += ['left ' + pos for pos in ['lower', 'center', 'upper']]
482482
todos += ['right ' + pos for pos in ['lower', 'center', 'upper']]
483483

484-
upperext = [20.347556, 27.722556, 790.583, 545.499]
485-
lowerext = [20.347556, 71.056556, 790.583, 588.833]
486-
leftext = [151.681556, 27.722556, 790.583, 588.833]
487-
rightext = [20.347556, 27.722556, 659.249, 588.833]
484+
upperext = [20.722556, 26.722556, 790.333, 545.999]
485+
lowerext = [20.722556, 70.056556, 790.333, 589.333]
486+
leftext = [152.056556, 26.722556, 790.333, 589.333]
487+
rightext = [20.722556, 26.722556, 658.999, 589.333]
488488
axbb = [upperext, upperext, upperext,
489489
lowerext, lowerext, lowerext,
490490
leftext, leftext, leftext,

lib/matplotlib/tests/test_polar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def test_get_tightbbox_polar():
328328
fig.canvas.draw()
329329
bb = ax.get_tightbbox(fig.canvas.get_renderer())
330330
assert_allclose(
331-
bb.extents, [107.7778, 29.2778, 539.7847, 450.7222], rtol=1e-03)
331+
bb.extents, [108.27778, 28.7778, 539.7222, 451.2222], rtol=1e-03)
332332

333333

334334
@check_figures_equal()

lib/matplotlib/tests/test_text.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,14 +720,14 @@ def test_wrap(x, rotation, halign):
720720
s = 'This is a very long text that should be wrapped multiple times.'
721721
text = subfig.text(x, 0.7, s, wrap=True, rotation=rotation, ha=halign)
722722
fig.canvas.draw()
723-
assert text._get_wrapped_text() == ('This is a very long\n'
724-
'text that should be\n'
723+
assert text._get_wrapped_text() == ('This is a very long text\n'
724+
'that should be\n'
725725
'wrapped multiple\n'
726726
'times.')
727727

728728

729729
def test_mathwrap():
730-
fig = plt.figure(figsize=(6, 4))
730+
fig = plt.figure(figsize=(5, 4))
731731
s = r'This is a very $\overline{\mathrm{long}}$ line of Mathtext.'
732732
text = fig.text(0, 0.5, s, size=40, wrap=True)
733733
fig.canvas.draw()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy