Deprecate setting text kerning factor to any non-None value#30322
Merged
QuLogic merged 1 commit intomatplotlib:text-overhaulfrom Jul 24, 2025
Merged
Deprecate setting text kerning factor to any non-None value#30322QuLogic merged 1 commit intomatplotlib:text-overhaulfrom
QuLogic merged 1 commit intomatplotlib:text-overhaulfrom
Conversation
76132af to
30280d0
Compare
QuLogic
commented
Jul 17, 2025
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 |
Member
Author
There was a problem hiding this comment.
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.
|
|
||
| def test_ft2font_set_size(): | ||
| file = fm.findfont('DejaVu Sans') | ||
| font = ft2font.FT2Font(file, hinting_factor=1, _kerning_factor=1) |
Member
Author
There was a problem hiding this comment.
This being 1 seems to have been a typo. Since the test checks relative results, it made no difference here.
Member
|
The rcParams depreciation machinery was removed per #29563. But you can still dreprecate rcParams if you want to
|
30280d0 to
99d357f
Compare
Member
Author
|
OK, I've added a deprecation for the rcParam directly, then. |
1 task
timhoffm
approved these changes
Jul 17, 2025
dstansby
reviewed
Jul 17, 2025
99d357f to
779af59
Compare
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.)
779af59 to
42c108a
Compare
dstansby
approved these changes
Jul 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
FT2Fontconstructor, which is always passed_kerning_factorin 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