Movatterモバイル変換


[0]ホーム

URL:


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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
QuLogic wants to merge1 commit intomatplotlib:text-overhaul
base:text-overhaul
Choose a base branch
Loading
fromQuLogic:deprecate-kerning

Conversation

QuLogic
Copy link
Member

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 theFT2Font 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

@QuLogicQuLogic added this to thev3.11.0 milestoneJul 17, 2025
@github-actionsgithub-actionsbot added topic: rcparams topic: text/fonts Documentation: user guidefiles in galleries/users_explain or doc/users labelsJul 17, 2025
@QuLogicQuLogicforce-pushed thedeprecate-kerning branch 2 times, most recently from76132af to30280d0CompareJuly 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
MemberAuthor

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
MemberAuthor

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.

@github-project-automationgithub-project-automationbot moved this toWaiting for other PR inFont and text overhaulJul 17, 2025
@QuLogicQuLogic moved this fromWaiting for other PR toReady for Review inFont and text overhaulJul 17, 2025
@timhoffm
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...

@QuLogic
Copy link
MemberAuthor

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


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 0 is deprecated, and the rcParam will be
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It looks like in the deprecation warning it warns for a value!=None, not a value!=0. Am I missing something, or is this changelog entry wrong with respect to the current code?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No, quite right. It originally warned on non-0, but once I added the rcParam as well, I switched to non-None instead.

This factor existed only to preserve test images, but as ofmatplotlib#29816, itis set to 0 (i.e., disabled and providing default behaviour). In thefuture, with libraqm, it will have no effect no matter its setting(because we won't be applying kerning ourselves at all.)
@QuLogicQuLogic changed the titleDeprecate setting text kerning factor to any non-0 valueDeprecate setting text kerning factor to any non-None valueJul 17, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dstansbydstansbydstansby left review comments

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Labels
Projects
Status: Ready for Review
Milestone
v3.11.0
Development

Successfully merging this pull request may close these issues.

3 participants
@QuLogic@timhoffm@dstansby

[8]ページ先頭

©2009-2025 Movatter.jp