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 — Update FreeType to 2.13.3 by QuLogic · Pull Request #29816 · matplotlib/matplotlib

Conversation

@QuLogic

@QuLogic QuLogic commented Mar 27, 2025

Copy link
Copy Markdown
Member

PR summary

On the call last week, we considered whether it made sense to do this upgrade. This PR shows the effect of doing so. Note for simplicity, I simply copied the new images from https://github.com/QuLogic/mpl-images, and then updated any new images directly. It's possible that there were some extraneously changed images as a result. I will check this shortly.

The latest FreeType version supports many newer font features, and fixes several CVEs, which we were mostly hoping were not relevant to us, but this may or may not be true. Additionally, I've found that libraqm runs into issues with hinting in older versions. While I'm not entirely sure which of libraqm or FreeType holds that bug, updating libraqm to new versions would also require newer FreeType anyway.

The main concern here was the repo size. Locally, I started with a completely fresh clone before creating this commit. The .git directory increased from 461M to 482M, or an increase of 21M / 4.6%.

PR checklist

  • "closes #0000" is in the body of the PR description to link the related issue
  • new and changed code is tested
  • 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.

anntzer reacted with eyes emoji
All reactions
  • 👀 1 reaction
@QuLogic QuLogic added topic: testing PR: dependencies Pull requests that update a dependency file topic: text/fonts labels Mar 27, 2025
@github-actions github-actions Bot added topic: mplot3d and removed topic: text/fonts labels Mar 27, 2025
@QuLogic QuLogic added the topic: text label Mar 27, 2025
@QuLogic

QuLogic commented Mar 27, 2025

Copy link
Copy Markdown
Member Author

Another size test:

$ git clone https://github.com/matplotlib/matplotlib.git mpl
$ cd mpl
$ du -hsc .git
461M	.git
461M	total

$ git fetch https://github.com/QuLogic/matplotlib.git ft213:ft213
$ du -hsc .git
477M	.git
477M	total

So once everything is repacked and compressed by git, the repo only gains 16M!

All reactions

Sorry, something went wrong.

Uh oh!

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

@anntzer

anntzer commented Mar 27, 2025

Copy link
Copy Markdown
Contributor

If we're going to regen the baselines, we should also take that opportunity to remove some of the backcompat knobs -- at least text.kerning_factor (which clearly only existed to avoid regen'ing the baselines), and possibly text.hinting_factor as well (at least I would switch the default to 1 and generate the images with that amount of hinting, even if we decide to keep this functionality).

All reactions

Sorry, something went wrong.

Uh oh!

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

@tacaswell

tacaswell commented Mar 27, 2025

Copy link
Copy Markdown
Member

Rather than regenerating the images at this point, I would start by pulling the tolerances used by Fedora upstream (so we can backport that to 3.10.x) and then in a second step regenerate the images on main and push the tolerances back to 0.

All reactions

Sorry, something went wrong.

Uh oh!

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

@QuLogic

QuLogic commented Mar 27, 2025

Copy link
Copy Markdown
Member Author

If we're going to regen the baselines, we should also take that opportunity to remove some of the backcompat knobs -- at least text.kerning_factor (which clearly only existed to avoid regen'ing the baselines), and possibly text.hinting_factor as well (at least I would switch the default to 1 and generate the images with that amount of hinting, even if we decide to keep this functionality).

Yes, good point; I will see what effect that has on things.

Rather than regenerating the images at this point, I would start by pulling the tolerances used by Fedora upstream (so we can backport that to 3.10.x) and then in a second step regenerate the images on main and push the tolerances back to 0.

Fedora doesn't have any other tolerances other than the 6 other files already changed (though in this PR I changed the results instead of the tolerance, we could do like in Fedora instead). For image tests, we overlay the correct images from my mpl-images repo and don't change any global tolerance.

All reactions

Sorry, something went wrong.

Uh oh!

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

@QuLogic

QuLogic commented Mar 28, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

Removing kerning_factor from _classic_test.patch causes an additional 100 test failures over this PR. Top 20 RMS are:

  • lib/matplotlib/tests/test_backend_pdf.py::test_kerning[pdf] 23.532
  • lib/matplotlib/tests/test_arrow_patches.py::test_boxarrow[png] 20.492
  • lib/matplotlib/tests/test_constrainedlayout.py::test_constrained_layout9[png] 17.849
  • lib/matplotlib/tests/test_mathtext.py::test_mathtext_rendering_lightweight[png-mathtext1-dejavusans-8] 17.244
  • lib/matplotlib/tests/test_table.py::test_auto_column[png] 16.872
  • lib/matplotlib/tests/test_text.py::test_basic_wrap[png] 15.712
  • lib/matplotlib/tests/test_axes.py::test_pie_nolabel_but_legend[png] 12.626
  • lib/matplotlib/tests/test_tightlayout.py::test_tight_layout7[pdf] 12.406
  • lib/matplotlib/tests/test_mathtext.py::test_mathtext_rendering[pdf-mathtext-dejavusans-46] 11.002
  • lib/matplotlib/tests/test_axes.py::test_stairs_datetime[png] 10.796
  • lib/matplotlib/tests/test_tightlayout.py::test_tight_layout7[png] 10.388
  • lib/matplotlib/tests/test_constrainedlayout.py::test_constrained_layout5[png] 10.191
  • lib/matplotlib/tests/test_constrainedlayout.py::test_constrained_layout2[png] 10.191
  • lib/matplotlib/tests/test_tightlayout.py::test_tight_layout7[svg] 9.704
  • lib/matplotlib/tests/test_constrainedlayout.py::test_constrained_layout4[png] 9.014
  • lib/matplotlib/tests/test_legend.py::test_multiple_keys[png] 8.322
  • lib/matplotlib/tests/test_constrainedlayout.py::test_constrained_layout3[png] 7.658
  • lib/matplotlib/tests/test_mathtext.py::test_mathtext_rendering[pdf-mathtext-dejavuserif-60] 7.572
  • lib/matplotlib/tests/test_text.py::test_font_styles[pdf] 7.355
  • lib/matplotlib/tests/test_constrainedlayout.py::test_constrained_layout15[png] 7.259

I'll commit these all separately to make it easier to review, but we can squash these all together if it's all working fine. The majority of these are things like Te, te, x, er all kern a little bit closer together now.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added topic: styles and removed topic: text labels Mar 28, 2025
@QuLogic

QuLogic commented Mar 28, 2025

Copy link
Copy Markdown
Member Author

On a related note, and I'm not sure which ones are relevant here, but I wonder if we should drop several PDF and SVG test images when they would be changed but don't effectively test anything different from the PNG.

anntzer and jklymak reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

@QuLogic
QuLogic force-pushed the ft213 branch from 7ce1562 to 572db98 Compare March 28, 2025 05:05
@dstansby dstansby mentioned this pull request Mar 28, 2025
Proposal for the baseline images problem #16447
Open
@jklymak

jklymak commented Mar 28, 2025

Copy link
Copy Markdown
Member

For the repo size problem we could provide some guidance for the depth flag so most contributors don't need to download the whole thing. Eg --depth=500 gets you the last two years of commits and is x MB. Most folks don't need the full commit history (or even anything more than depth=1)

All reactions

Sorry, something went wrong.

Uh oh!

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

@greglucas

greglucas commented Mar 28, 2025

Copy link
Copy Markdown
Contributor

The first image comparison that shows up lib/matplotlib/tests/baseline_images/test_agg/agg_filter.png doesn't have any text in it at all so is presumably not an update due to freetype. Is this all images that have had tolerances ever adjusted in the past? If so, do you know if there would be any size difference with just text-based freetype updates versus all others?

Is it beneficial/necessary to grab the images from that other repo you've been keeping, or would it make sense to blow away the images directory on CI and move all the resultant images into the directory to start fresh in a sense?

All reactions

Sorry, something went wrong.

Uh oh!

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

@QuLogic

QuLogic commented Mar 28, 2025

Copy link
Copy Markdown
Member Author

and possibly text.hinting_factor as well (at least I would switch the default to 1 and generate the images with that amount of hinting, even if we decide to keep this functionality).

Surprisingly, this doesn't appear to make any difference to test images. It only affects 9 tests, and only with regards to bboxes and tight layout that are explicitly compared. This doesn't matter whether I try with FreeType 2.6.1 or 2.13.3.

The first image comparison that shows up lib/matplotlib/tests/baseline_images/test_agg/agg_filter.png doesn't have any text in it at all so is presumably not an update due to freetype. Is this all images that have had tolerances ever adjusted in the past? If so, do you know if there would be any size difference with just text-based freetype updates versus all others?

Ah, you're right. I had not done a deep dive into the changes, but likely this was an image that had text that was removed, so it was regenerated from the FreeType changes, but effectively looked the same. I will go through these again and make sure we don't have any extraneous changes like this one.

Is it beneficial/necessary to grab the images from that other repo you've been keeping, or would it make sense to blow away the images directory on CI and move all the resultant images into the directory to start fresh in a sense?

The other repo was useful for tracking purposes and a quick changeover, but it might be best to start fresh and make sure we don't change too many extra images.

All reactions

Sorry, something went wrong.

Uh oh!

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

@QuLogic

QuLogic commented Mar 29, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

I haven't updated this PR for it yet, but going over the diffs, one surprising change is that while the mathtext tests with DejaVu Sans look better (more consistent baselines, tweaks to kerning), the same ones with Computer Modern look worse (mostly due to a wobbly baseline.) But on the other hand, a lot of those had the wobbly baseline before...

I've also opened #29827 to remove most of the redundant PDFs that would be changed here (except the ones from test_backend_pdf, plus a few others noted in that PR).

All reactions

Sorry, something went wrong.

Uh oh!

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

@anntzer

anntzer commented Mar 29, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

See also #14177 (comment) and #22459 re: wobbly baseline. I have some hopes that switching agg+usetex to rasterizing glyphs ourselves (see also #29807) would be one way to fix that.

All reactions

Sorry, something went wrong.

Uh oh!

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

@oscargus

oscargus commented Mar 30, 2025

Copy link
Copy Markdown
Member

Slightly unrelated, but if we decide to update this many PNGs, it should be a good time to add an oxipng pre-commit hook. https://github.com/shssoichiro/oxipng I would expect that the sizes are halved or so on average. (It would be useful independent of this, but I have not gotten around to propose it and it would be unfortunate to change all those images without compression.)

All reactions

Sorry, something went wrong.

Uh oh!

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

@QuLogic QuLogic mentioned this pull request Apr 1, 2025
TST: Remove unnecessary test images #29827
Merged
1 task done
@QuLogic

QuLogic commented Apr 1, 2025

Copy link
Copy Markdown
Member Author

See also #14177 (comment) and #22459 re: wobbly baseline. I have some hopes that switching agg+usetex to rasterizing glyphs ourselves (see also #29807) would be one way to fix that.

But these are not usetex, just plain mathtext. However, thanks to those links, I've come across #5414 which claimed to fix the wobbly baseline. It turns out that that isn't due to changing to external FreeType, but to a change in MathtextBackendAgg.render_glyph. Copying that out fixes all the wobbly baselines, both before and after updating FreeType.

Unfortunately, updating FreeType still causes changes in those test images due to different kerning and metrics (the whole line may move up/down a pixel, but individual glyphs no longer do.) So I'm going to roll that change in here for the changed images to be squashed together.

anntzer reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

@QuLogic
QuLogic force-pushed the ft213 branch from 572db98 to a86e3c9 Compare April 1, 2025 07:26
@github-actions github-actions Bot added the topic: text/mathtext label Apr 1, 2025
@QuLogic QuLogic added the status: waiting for other PR label Apr 1, 2025
@QuLogic

QuLogic commented Apr 1, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

I've now rebased this on top of #29827, and gone through and removed the extra image changes. Now it's about 60% the number it was before.

As I expect this will be squashed, there are a few things here:

  1. Fixing the wobbly baseline in mathtext (e.g., for the Latin alphabet, the t is no longer floating, while for the Greek alphabet, everything shifts down to match theta).
  2. Updating to FreeType 2.13.3.
  3. Removing the kerning_factor setting from the tests (the majority of these are things like Te, te, x, er all kerning a little bit closer.)
  4. Removing any compatibility styling flags on images that were already regenerated.
  5. Compressing everything that was already changed with oxipng; this compresses from about 12M to 7M.
All reactions

Sorry, something went wrong.

Uh oh!

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

@anntzer

anntzer commented Apr 1, 2025

Copy link
Copy Markdown
Contributor

Are the new tests also using hinting_factor=1?

All reactions

Sorry, something went wrong.

Uh oh!

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

@QuLogic

QuLogic commented Apr 1, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

No, as I mentioned earlier, that barely changed anything. I'm trying to see if that's true or whether I didn't set it up right.

All reactions

Sorry, something went wrong.

Uh oh!

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

@QuLogic
Remove kerning_factor from tests
7b4d725
@QuLogic
QuLogic force-pushed the ft213 branch 2 times, most recently from 5dc2aee to f472e52 Compare July 9, 2025 08:36
tacaswell
tacaswell approved these changes Jul 10, 2025
View reviewed changes
story645
story645 approved these changes Jul 10, 2025
View reviewed changes
Comment thread lib/matplotlib/testing/__init__.py
if getattr(mpl, '_called_from_pytest', False):
mpl.rcParams['text.hinting'] = 'default'
mpl.rcParams['text.hinting_factor'] = 1
else:

@story645 story645 Jul 10, 2025

Copy link
Copy Markdown
Member

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.

if this is for backward compatibility, can you please add a comment?

Sorry, something went wrong.

Uh oh!

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

All reactions

@QuLogic QuLogic Jul 15, 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.

Added a comment.

Sorry, something went wrong.

Uh oh!

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

All reactions
@QuLogic
QuLogic force-pushed the ft213 branch from f472e52 to ea59d3a Compare July 11, 2025 22:06
@github-actions github-actions Bot added topic: mpl_toolkit and removed topic: mplot3d labels Jul 11, 2025
@QuLogic QuLogic added the CI: Run cibuildwheel Run wheel building tests on a PR label Jul 12, 2025
@QuLogic

QuLogic commented Jul 12, 2025

Copy link
Copy Markdown
Member Author

I removed the test images here, but I realized that I can pre-populate the text-overhaul-figures branch with the results so that CI on this PR remains "green". I also realized that I never tested cibuildwheel, so I'm pushing another commit to fix that up, hopefully.

All reactions

Sorry, something went wrong.

Uh oh!

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

QuLogic added 4 commits July 15, 2025 05:59
@QuLogic
Set text hinting to defaults
8255ae2
Namely, `text.hinting` is now `default` instead of `force_autohint` (or
`none` for classic tests) and `text.hinting_factor` is now 1, not 8.
@QuLogic
Update FreeType to 2.13.3
89c054d
@QuLogic
Bump minimum meson-python to 0.13.2
7787153
@QuLogic
ci: Purge Strawberry Perl from Windows builders
972a821
We don't use Perl, and it includes a completely busted version of
`patch`.
@QuLogic
QuLogic force-pushed the ft213 branch from 62192f5 to 972a821 Compare July 15, 2025 09:59
@QuLogic
QuLogic merged commit 8839576 into matplotlib:text-overhaul Jul 16, 2025
@github-project-automation github-project-automation Bot moved this from Ready for Review to Done in Font and text overhaul Jul 16, 2025
@QuLogic
QuLogic deleted the ft213 branch July 16, 2025 02:38
QuLogic added a commit to QuLogic/matplotlib that referenced this pull request Jul 17, 2025
@QuLogic
Deprecate setting text kerning factor to any non-0 value
0483a3d
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 added a commit to QuLogic/matplotlib that referenced this pull request Jul 17, 2025
@QuLogic
Deprecate setting text kerning factor to any non-0 value
bee0212
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 added a commit to QuLogic/matplotlib that referenced this pull request Jul 17, 2025
@QuLogic
Deprecate setting text kerning factor to any non-0 value
c4fcd7b
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 mentioned this pull request Jul 17, 2025
Deprecate setting text kerning factor to any non-None value #30322
Merged
3 tasks done
QuLogic added a commit to QuLogic/matplotlib that referenced this pull request Jul 17, 2025
@QuLogic
Deprecate setting text kerning factor to any non-0 value
76132af
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 added a commit to QuLogic/matplotlib that referenced this pull request Jul 17, 2025
@QuLogic
Deprecate setting text kerning factor to any non-0 value
30280d0
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 added a commit to QuLogic/matplotlib that referenced this pull request Jul 17, 2025
@QuLogic
Deprecate setting text kerning factor to any non-0 value
99d357f
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 added a commit to QuLogic/matplotlib that referenced this pull request Jul 17, 2025
@QuLogic
Deprecate setting text kerning factor to any non-None value
779af59
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 added a commit to QuLogic/matplotlib that referenced this pull request Jul 24, 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.)
@ksunden ksunden removed this from the v3.10.4 milestone Jul 31, 2025
@QuLogic QuLogic mentioned this pull request Apr 10, 2026
Font and text overhaul #30161
Merged
4 tasks done
@wshanks wshanks mentioned this pull request Aug 13, 2026
[Bug]: Wheel's freetype binding can conflict with system library #32208
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@anntzer anntzer anntzer left review comments
@tacaswell tacaswell tacaswell approved these changes
@story645 story645 story645 approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

CI: Run cibuildwheel Run wheel building tests on a PR PR: dependencies Pull requests that update a dependency file topic: mpl_toolkit topic: styles topic: testing

Projects

Font and text overhaul
Status: Done

Milestone

v3.11.0

Development

Successfully merging this pull request may close these issues.

tight_layout and font hinting cuts text near the edge [MNT]: Please update freetype version Determine if hinting_factor setting can be dropped

Uh oh!

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

9 participants

@QuLogic @anntzer @tacaswell @jklymak @greglucas @oscargus @timhoffm @story645 @ksunden
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.