Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
QuLogic merged 1 commit into matplotlib:text-overhaul from QuLogic:deprecate-kerning
Jul 24, 2025

Conversation

Copy link
Member

@QuLogic QuLogic commented Jul 17, 2025

PR summary

This factor existed only to preserve test images, but as of #29816, it is set to 0 (i.e., disabled and providing default behaviour). In the future, with libraqm, it will have no effect no matter its setting (because we won't be applying kerning ourselves at all.)

Since we seem to have removed most of the rcParam deprecation machinery, instead of warning from there, warn from the FT2Font constructor, which is always passed _kerning_factor in the normal code path (i.e., anywhere outside of direct tests.) This does mean the warning won't occur directly where you set it, nor if you don't use any text, but I think that's a reasonable compromise.

PR checklist

@QuLogic QuLogic added this to the v3.11.0 milestone Jul 17, 2025
@QuLogic QuLogic force-pushed the deprecate-kerning branch 2 times, most recently from 76132af to 30280d0 Compare July 17, 2025 01:27
Comment on lines -61 to -71
.. plot::

import matplotlib.pyplot as plt

# Use old kerning values:
plt.rcParams['text.kerning_factor'] = 6
fig, ax = plt.subplots()
ax.text(0.0, 0.05, 'BRAVO\nAWKWARD\nVAT\nW.Test', fontsize=56)
ax.set_title('Before (text.kerning_factor = 6)')

Note how the spacing between characters is uniform between their bounding boxes
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@@ -188,7 +191,7 @@ def test_ft2font_clear():

def test_ft2font_set_size():
file = fm.findfont('DejaVu Sans')
font = ft2font.FT2Font(file, hinting_factor=1, _kerning_factor=1)
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@QuLogic QuLogic moved this from Waiting for other PR to Ready for Review in Font and text overhaul Jul 17, 2025
Copy link
Member

The rcParams depreciation machinery was removed per #29563. But you can still dreprecate rcParams if you want to

just write custom deprecation logic into setitem/getitem and add corresponding tests whenever we want to deprecate a rcparam...

Copy link
Member Author

QuLogic commented Jul 17, 2025

OK, I've added a deprecation for the rcParam directly, then.

@QuLogic QuLogic changed the title (削除) Deprecate setting text kerning factor to any non-0 value (削除ここまで) (追記) Deprecate setting text kerning factor to any non-None value (追記ここまで) Jul 17, 2025
This factor existed only to preserve test images, but as of matplotlib#29816, it
is set to 0 (i.e., disabled and providing default behaviour). In the
future, with libraqm, it will have no effect no matter its setting
(because we won't be applying kerning ourselves at all.)
@QuLogic QuLogic merged commit 42c108a into matplotlib:text-overhaul Jul 24, 2025
36 of 37 checks passed
@QuLogic QuLogic deleted the deprecate-kerning branch July 24, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@timhoffm timhoffm timhoffm approved these changes

@dstansby dstansby dstansby approved these changes

Assignees
No one assigned
Projects
Status: Done
Milestone
v3.11.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /