Skip to content

Commit a1df646

Browse files
committed
Add an rcParam to restore old kerning behaviour.
This is enabled for the classic test style, so that the 100 or so old images do not need to be regenerated.
1 parent 7f57740 commit a1df646

17 files changed

+75
-5
lines changed

lib/matplotlib/font_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,8 @@ def is_opentype_cff_font(filename):
13271327
def get_font(filename, hinting_factor=None):
13281328
if hinting_factor is None:
13291329
hinting_factor = rcParams['text.hinting_factor']
1330-
return _get_font(os.fspath(filename), hinting_factor)
1330+
return _get_font(os.fspath(filename), hinting_factor,
1331+
_kerning_factor=rcParams['text.kerning_factor'])
13311332

13321333

13331334
def _rebuild():
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# This patch should go on top of the "classic" style and exists solely to avoid
22
# changing baseline images.
33

4+
text.kerning_factor : 6
5+
46
ytick.alignment: center_baseline

lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,7 @@ def _validate_linestyle(ls):
10911091
'text.latex.preview': [False, validate_bool],
10921092
'text.hinting': ['auto', validate_hinting],
10931093
'text.hinting_factor': [8, validate_int],
1094+
'text.kerning_factor': [0, validate_int],
10941095
'text.antialiased': [True, validate_bool],
10951096

10961097
'mathtext.cal': ['cursive', validate_font_properties],

lib/matplotlib/tests/test_artist.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ def test_remove():
201201

202202
@image_comparison(["default_edges.png"], remove_text=True, style='default')
203203
def test_default_edges():
204+
# Remove this line when this test image is regenerated.
205+
plt.rcParams['text.kerning_factor'] = 6
206+
204207
fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2)
205208

206209
ax1.plot(np.arange(10), np.arange(10), 'x',

lib/matplotlib/tests/test_axes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def test_get_labels():
4848

4949
@image_comparison(['acorr.png'], style='mpl20')
5050
def test_acorr():
51+
# Remove this line when this test image is regenerated.
52+
plt.rcParams['text.kerning_factor'] = 6
53+
5154
np.random.seed(19680801)
5255
n = 512
5356
x = np.random.normal(0, 1, n).cumsum()
@@ -5730,6 +5733,9 @@ def test_axisbelow():
57305733

57315734
@image_comparison(['titletwiny.png'], style='mpl20')
57325735
def test_titletwiny():
5736+
# Remove this line when this test image is regenerated.
5737+
plt.rcParams['text.kerning_factor'] = 6
5738+
57335739
# Test that title is put above xlabel if xlabel at top
57345740
fig, ax = plt.subplots()
57355741
fig.subplots_adjust(top=0.8)

lib/matplotlib/tests/test_image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
@image_comparison(['image_interps'], style='mpl20')
2828
def test_image_interps():
2929
'make the basic nearest, bilinear and bicubic interps'
30+
# Remove this line when this test image is regenerated.
31+
plt.rcParams['text.kerning_factor'] = 6
32+
3033
X = np.arange(100)
3134
X = X.reshape(5, 20)
3235

lib/matplotlib/tests/test_legend.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ def test_legend_expand():
188188

189189
@image_comparison(['hatching'], remove_text=True, style='default')
190190
def test_hatching():
191+
# Remove this line when this test image is regenerated.
192+
plt.rcParams['text.kerning_factor'] = 6
193+
191194
fig, ax = plt.subplots()
192195

193196
# Patches

lib/matplotlib/tests/test_text.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ def test_multiline():
130130

131131
@image_comparison(['multiline2'], style='mpl20')
132132
def test_multiline2():
133+
# Remove this line when this test image is regenerated.
134+
plt.rcParams['text.kerning_factor'] = 6
135+
133136
fig, ax = plt.subplots()
134137

135138
ax.set_xlim([0, 1.4])
@@ -580,6 +583,9 @@ def test_annotation_update():
580583

581584
@image_comparison(['large_subscript_title.png'], style='mpl20')
582585
def test_large_subscript_title():
586+
# Remove this line when this test image is regenerated.
587+
plt.rcParams['text.kerning_factor'] = 6
588+
583589
fig, axs = plt.subplots(1, 2, figsize=(9, 2.5), constrained_layout=True)
584590
ax = axs[0]
585591
ax.set_title(r'$\sum_{i} x_i$')

lib/matplotlib/tests/test_widgets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ def test_CheckButtons():
264264

265265
@image_comparison(['check_radio_buttons.png'], style='mpl20', remove_text=True)
266266
def test_check_radio_buttons_image():
267+
# Remove this line when this test image is regenerated.
268+
plt.rcParams['text.kerning_factor'] = 6
269+
267270
get_ax()
268271
plt.subplots_adjust(left=0.3)
269272
rax1 = plt.axes([0.05, 0.7, 0.15, 0.15])

lib/mpl_toolkits/tests/test_axisartist_axis_artist.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def test_ticks():
2626

2727
@image_comparison(['axis_artist_labelbase.png'], style='default')
2828
def test_labelbase():
29+
# Remove this line when this test image is regenerated.
30+
plt.rcParams['text.kerning_factor'] = 6
31+
2932
fig, ax = plt.subplots()
3033

3134
ax.plot([0.5], [0.5], "o")
@@ -40,6 +43,9 @@ def test_labelbase():
4043

4144
@image_comparison(['axis_artist_ticklabels.png'], style='default')
4245
def test_ticklabels():
46+
# Remove this line when this test image is regenerated.
47+
plt.rcParams['text.kerning_factor'] = 6
48+
4349
fig, ax = plt.subplots()
4450

4551
ax.xaxis.set_visible(False)
@@ -72,6 +78,9 @@ def test_ticklabels():
7278

7379
@image_comparison(['axis_artist.png'], style='default')
7480
def test_axis_artist():
81+
# Remove this line when this test image is regenerated.
82+
plt.rcParams['text.kerning_factor'] = 6
83+
7584
fig, ax = plt.subplots()
7685

7786
ax.xaxis.set_visible(False)

0 commit comments

Comments
 (0)