Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 782c51a

Browse files
committedJun 4, 2025
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 73340ca commit 782c51a

File tree

8 files changed

+23
-16
lines changed

8 files changed

+23
-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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@
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+
if getattr(mpl, '_called_from_pytest', False):
23+
mpl.rcParams['text.hinting'] = 'default'
24+
mpl.rcParams['text.hinting_factor'] = 1
25+
else:
26+
mpl.rcParams['text.hinting'] = 'none'
27+
mpl.rcParams['text.hinting_factor'] = 8
2428

2529

2630
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
@@ -8153,8 +8153,8 @@ def test_normal_axes():
81538153

81548154
# test the axis bboxes
81558155
target = [
8156-
[123.375, 75.88888888888886, 983.25, 33.0],
8157-
[85.51388888888889, 99.99999999999997, 53.375, 993.0]
8156+
[124.0, 76.89, 982.0, 32.0],
8157+
[86.89, 100.5, 52.0, 992.0],
81588158
]
81598159
for nn, b in enumerate(bbaxis):
81608160
targetbb = mtransforms.Bbox.from_bounds(*target[nn])
@@ -8174,7 +8174,7 @@ def test_normal_axes():
81748174
targetbb = mtransforms.Bbox.from_bounds(*target)
81758175
assert_array_almost_equal(bbax.bounds, targetbb.bounds, decimal=2)
81768176

8177-
target = [85.5138, 75.88888, 1021.11, 1017.11]
8177+
target = [86.89, 76.89, 1019.11, 1015.61]
81788178
targetbb = mtransforms.Bbox.from_bounds(*target)
81798179
assert_array_almost_equal(bbtb.bounds, targetbb.bounds, decimal=2)
81808180

‎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
@@ -704,14 +704,14 @@ def test_wrap(x, rotation, halign):
704704
s = 'This is a very long text that should be wrapped multiple times.'
705705
text = subfig.text(x, 0.7, s, wrap=True, rotation=rotation, ha=halign)
706706
fig.canvas.draw()
707-
assert text._get_wrapped_text() == ('This is a very long\n'
708-
'text that should be\n'
707+
assert text._get_wrapped_text() == ('This is a very long text\n'
708+
'that should be\n'
709709
'wrapped multiple\n'
710710
'times.')
711711

712712

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

0 commit comments

Comments
 (0)
Please sign in to comment.