Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Deprecate setting text kerning factor to any non-None value#30322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:text-overhaul
Are you sure you want to change the base?
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Font kerning factor is deprecated | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Due to internal changes to support complex text rendering, the kerning factor on fonts is | ||
no longer used. Setting the ``text.kerning_factor`` rcParam (which existed only for | ||
backwards-compatibility) to any value other than None is deprecated, and the rcParam will | ||
be removed in the future. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -52,26 +52,15 @@ triangle meshes. | ||
Kerning adjustments now use correct values | ||
------------------------------------------ | ||
Comment on lines -61 to -71 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I decided to remove this plot from the old what's new, as it will no longer show any difference between it and the plot below (with the correct results) once we switch to libraqm, and so it might be misleading. | ||
Due to an error in how kerning adjustments were applied, previous versions of Matplotlib | ||
would under-correct kerning. This version will now correctly apply kerning (for fonts | ||
supported by FreeType). To restore the old behavior (e.g., for test images), you may set | ||
the ``text.kerning_factor`` rcParam to 6 (instead of 0). Other values have undefined | ||
behavior. | ||
With corrected kerning (below), slanted characters (e.g., AV or VA) will be spaced closer | ||
together, as well as various other character pairs, depending on font support (e.g., T | ||
and e, or the period after the W). | ||
..plot:: | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -168,6 +168,12 @@ def test_ft2font_invalid_args(tmp_path): | ||
# kerning_factor argument. | ||
withpytest.raises(TypeError,match='incompatible constructor arguments'): | ||
ft2font.FT2Font(file,_kerning_factor=1.3) | ||
withpytest.warns(mpl.MatplotlibDeprecationWarning, | ||
match='text.kerning_factor rcParam was deprecated .+ 3.11'): | ||
mpl.rcParams['text.kerning_factor']=0 | ||
withpytest.warns(mpl.MatplotlibDeprecationWarning, | ||
match='_kerning_factor parameter was deprecated .+ 3.11'): | ||
ft2font.FT2Font(file,_kerning_factor=123) | ||
deftest_ft2font_clear(): | ||
@@ -188,7 +194,7 @@ def test_ft2font_clear(): | ||
deftest_ft2font_set_size(): | ||
file=fm.findfont('DejaVu Sans') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This being 1 seems to have been a typo. Since the test checks relative results, it made no difference here. | ||
font=ft2font.FT2Font(file,hinting_factor=1) | ||
font.set_size(12,72) | ||
font.set_text('ABabCDcd') | ||
orig=font.get_width_height() | ||
@@ -717,7 +723,7 @@ def test_ft2font_get_sfnt_table(font_name, header): | ||
deftest_ft2font_get_kerning(left,right,unscaled,unfitted,default): | ||
file=fm.findfont('DejaVu Sans') | ||
# With unscaled, these settings should produce exact values found in FontForge. | ||
font=ft2font.FT2Font(file,hinting_factor=1) | ||
font.set_size(100,100) | ||
assertfont.get_kerning(font.get_char_index(ord(left)), | ||
font.get_char_index(ord(right)), | ||
@@ -756,7 +762,7 @@ def test_ft2font_get_kerning(left, right, unscaled, unfitted, default): | ||
deftest_ft2font_set_text(): | ||
file=fm.findfont('DejaVu Sans') | ||
font=ft2font.FT2Font(file,hinting_factor=1) | ||
font.set_size(12,72) | ||
xys=font.set_text('') | ||
np.testing.assert_array_equal(xys,np.empty((0,2))) | ||
@@ -778,7 +784,7 @@ def test_ft2font_set_text(): | ||
deftest_ft2font_loading(): | ||
file=fm.findfont('DejaVu Sans') | ||
font=ft2font.FT2Font(file,hinting_factor=1) | ||
font.set_size(12,72) | ||
forglyphin [font.load_char(ord('M')), | ||
font.load_glyph(font.get_char_index(ord('M')))]: | ||
@@ -819,13 +825,13 @@ def test_ft2font_drawing(): | ||
]) | ||
expected*=255 | ||
file=fm.findfont('DejaVu Sans') | ||
font=ft2font.FT2Font(file,hinting_factor=1) | ||
font.set_size(12,72) | ||
font.set_text('M') | ||
font.draw_glyphs_to_bitmap(antialiased=False) | ||
image=font.get_image() | ||
np.testing.assert_array_equal(image,expected) | ||
font=ft2font.FT2Font(file,hinting_factor=1) | ||
font.set_size(12,72) | ||
glyph=font.load_char(ord('M')) | ||
image=np.zeros(expected.shape,np.uint8) | ||
@@ -835,7 +841,7 @@ def test_ft2font_drawing(): | ||
deftest_ft2font_get_path(): | ||
file=fm.findfont('DejaVu Sans') | ||
font=ft2font.FT2Font(file,hinting_factor=1) | ||
font.set_size(12,72) | ||
vertices,codes=font.get_path() | ||
assertvertices.shape== (0,2) | ||
Uh oh!
There was an error while loading.Please reload this page.