GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Deprecate setting text kerning factor to any non-None value by QuLogic · Pull Request #30322 · matplotlib/matplotlib

Conversation

@QuLogic

@QuLogic QuLogic commented Jul 17, 2025

Copy link
Copy Markdown
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 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

  • [n/a] "closes #0000" is in the body of the PR description to link the related issue
  • new and changed code is tested
  • [n/a] Plotting related features are demonstrated in an example
  • New Features and API Changes are noted with a directive and release note
  • Documentation complies with general and docstring guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@QuLogic QuLogic added this to the v3.11.0 milestone Jul 17, 2025
@QuLogic QuLogic added the Maintenance label Jul 17, 2025
@github-actions github-actions Bot added topic: rcparams topic: text/fonts Documentation: user guide files in galleries/users_explain or doc/users labels 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
QuLogic
QuLogic commented Jul 17, 2025
View reviewed changes
Comment thread doc/users/prev_whats_new/whats_new_3.2.0.rst
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

@QuLogic QuLogic Jul 17, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/matplotlib/tests/test_ft2font.py

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

@QuLogic QuLogic Jul 17, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@QuLogic QuLogic added this to Font and text overhaul Jul 17, 2025
@github-project-automation github-project-automation Bot moved this to Waiting for other PR in Font and text overhaul Jul 17, 2025
@QuLogic QuLogic moved this from Waiting for other PR to Ready for Review in Font and text overhaul Jul 17, 2025
@timhoffm

timhoffm commented Jul 17, 2025

Copy link
Copy Markdown
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...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic
QuLogic force-pushed the deprecate-kerning branch from 30280d0 to 99d357f Compare July 17, 2025 05:36
@QuLogic

QuLogic commented Jul 17, 2025

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic QuLogic mentioned this pull request Jul 17, 2025
Make PyFT2Font a subclass of FT2Font #30324
Merged
1 task done
timhoffm
timhoffm approved these changes Jul 17, 2025
View reviewed changes
dstansby
dstansby reviewed Jul 17, 2025
View reviewed changes
Comment thread doc/api/next_api_changes/deprecations/30322-ES.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic
QuLogic force-pushed the deprecate-kerning branch from 99d357f to 779af59 Compare July 17, 2025 18:42
@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
@QuLogic
Deprecate setting text kerning factor to any non-None value
42c108a
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 force-pushed the deprecate-kerning branch from 779af59 to 42c108a Compare July 24, 2025 09:41
dstansby
dstansby approved these changes Jul 24, 2025
View reviewed changes
@QuLogic
QuLogic merged commit 42c108a into matplotlib:text-overhaul Jul 24, 2025
@github-project-automation github-project-automation Bot moved this from Ready for Review to Done in Font and text overhaul Jul 24, 2025
@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

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

Documentation: user guide files in galleries/users_explain or doc/users Maintenance topic: rcparams topic: text/fonts

Projects

Font and text overhaul
Status: Done

Milestone

v3.11.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@QuLogic @timhoffm @dstansby
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.