Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Font and text overhaul#30161

Merged
QuLogic merged 178 commits intomatplotlib:mainfrom
QuLogic:text-overhaul-figures
Apr 10, 2026
Merged

Font and text overhaul#30161
QuLogic merged 178 commits intomatplotlib:mainfrom
QuLogic:text-overhaul-figures

Conversation

@QuLogic
Copy link
Copy Markdown
Member

@QuLogic QuLogic commented Jun 10, 2025

PR summary

This PR is intended to hold all font and text PRs from the project Font and text overhaul

In order to not overwhelm the main repo with the churn of test image replacements, this PR comes from my fork and should only ever have 1 commit more than the text-overhaul branch with the changes to test images.

This includes images changes for the following pull requests / commits:

PR checklist

QuLogic added 4 commits June 12, 2025 18:46
Glyph indices are specific to each font. It does not make sense to fall
back based on glyph index to another font.

This could only really be populated by calling `FT2Font.set_text`, but
even that was fragile. If a fallback font was used for a character with
the same glyph index as a previous character in the main font, then
these lookups could be overwritten to the fallback instead of the main
font, with a completely different character!

Fortunately, nothing actually uses or requires a fallback through glyph
indices.
Remove ttconv backwards-compatibility code
@QuLogic
Copy link
Copy Markdown
Member Author

QuLogic commented Jun 19, 2025

Also, if you would like to follow along with the figure changes, I've posted a branch that does the changes per merge commit: https://github.com/QuLogic/matplotlib/tree/text-overhaul-figures-per-commit

QuLogic added 8 commits July 7, 2025 19:06
This allows checking that there are no _new_ failures, without
committing the new figures to the repo until the branch is complete.
ci: Preload existing test images from text-overhaul-figures branch
Also, check some expected conditions at parse time instead of somewhere
during use of the data.
ci: Fix image preload with multiple conflicts
@QuLogic QuLogic force-pushed the text-overhaul-figures branch from 2b3f5c5 to b17bef1 Compare July 10, 2025 04:06
QuLogic and others added 20 commits March 27, 2026 14:21
This incorporates our patch, so we can drop it, and adds `tests` option,
which we now disable.
…names

ENH: Allow fonts to be addressed by any of their SFNT family names
BLD: Update bundled libraqm to 0.10.4
* BLD: Update bundled FreeType to 2.14.3

These releases mostly consist of security fixes.

* BLD: adjust upstream url for freetype to nongnu savanah mirror

Co-authored-by: Tim Hoffmann <[email protected]>

---------

Co-authored-by: Thomas A Caswell <[email protected]>
Co-authored-by: Tim Hoffmann <[email protected]>
- Port FreeType symbol visibility patch to 2.14.1
- Add test image preloading to wasm CI workflow
- Temporarily disable testing `test_complex_shaping`, which triggers
  some code path that fails somehow
This test requires a subprocess call, so should be skipped like the
others.
Unfortunately, this was missed in matplotlib#31407.
These tests had previously kept some code or settings to prevent
regenerating the test image, but since they are now going to be
regenerated from the text overhaul, we can remove those.
TST: Cleanup back-compat code in tests touched by text overhaul
Make it clearer that switches are only over 3 possible fonttypes (1, 3,
42).  In draw_text, the logic is easier to follow if one directly
switches over rcParams['pdf.use14corefonts']; this requires putting the
url handling at the end, which doesn't matter.
)

* TST: Set tests touched by text overhaul to mpl20 style

* TST: Tweak some tests to work better in mpl20 style
Clarify fonttype switch in backend_pdf.
If a backend doesn't implement `draw_text`, then we fall back to this
implementation that draws paths. It was previously missing support for
font features and languages.
This exercises complex shaping, font features, and language support.
TST: Reset tolerances on tests changed by text overhaul
Support font features/language in default RendererBase.draw_text
This includes images changes for the following pull requests / commits:

* [Fix center of rotation with
  rotation_mode='anchor'](matplotlib#29199)
  (c44db77)
* [Remove ttconv backwards-compatibility
  code](matplotlib#30145)
  (8caff88)
* [Remove kerning_factor from
  tests](matplotlib#29816)
  (7b4d725)
* [Set text hinting to
  defaults](matplotlib#29816)
  (8255ae2)
* [Update FreeType to
  2.13.3](matplotlib#29816)
  (89c054d)
* [Implement text shaping with
  libraqm](matplotlib#30000)
  (b0ded3a,
  9813523)
* [Add language parameter to Text
  objects](matplotlib#29794)
  (7ce8eae)
* [Fix auto-sized glyphs with BaKoMa
  fonts](matplotlib#29936)
  (3ba2c13)
* [pdf: Improve text with characters outside embedded font
  limits](matplotlib#30512)
  (b70fb88,
  6cedcf7)
* [Prepare `CharacterTracker` for advanced font
  features](matplotlib#30608)
  (8274e17,
  70dc388,
  df670cf,
  ed5e074)
* [Add font feature API to
  Text](matplotlib#29695)
  (972a688)
* [Fix spacing in r"$\max
  f$"](matplotlib#30715)
  (4a99a83)
* [Implement libraqm for vector
  outputs](matplotlib#30607)
  (bd17cd4)
* [Drop the FT2Font intermediate
  buffer](matplotlib#30059)
  (9d7d7b4)
* [Rasterize dvi files without
  dvipng](matplotlib#30039)
  (7627118)
* [Update bundled FreeType and HarfBuzz
  libraries](matplotlib#30938)
  (a161658,
  9619bcc)
* [Fix positioning of wide mathtext
  accents](matplotlib#31069)
  (c2fa7ba)
* [Refactor RendererAgg.draw_{mathtext,text,tex} to use same base
  algorithm](matplotlib#31085)
  (931bcf3)
* [Implement TeX's fraction and script
  alignment](matplotlib#31046)
  (94ff452,
  4bfa0f9,
  1cd8510)
* [Fix confusion between text height and ascent in metrics
  calculations](matplotlib#31107)
  (60f2310)
* [mathtext: Fetch quad width & axis height from font
  metrics](matplotlib#31110)
  (692df3f,
  383028b)
* [mathtext: add mathnormal and distinguish between normal and italic
  family](matplotlib#31121)
  (a6913f3)
* [ENH: Ignore empty text for
  tightbbox](matplotlib#31285)
  (d772043)
* [Drop axis_artist tickdir image compat, due to text-overhaul
  merge](matplotlib#31281)
  (2057583)
* [text: Use font metrics to determine line
  heights](matplotlib#31291)
  (3ab6a27,
  d961462,
  97f4943)
* [ps/pdf: Override font height metrics to support AFM
  files](matplotlib#31371)
  (e0913d4)
* [TST: Cleanup back-compat code in tests touched by text
  overhaul](matplotlib#31295)
  (7c33379)
* [TST: Set tests touched by text overhaul to mpl20
  style](matplotlib#31300)
  (41c4d8d)
@QuLogic
Copy link
Copy Markdown
Member Author

QuLogic commented Apr 10, 2026

I've now rebased the final figures onto the latest text-overhaul commit, compressed all the new PNGs with oxipng, and annotated the last commit/PR description with the sources for the changes.

mpl.rcParams['font.family'] = 'DejaVu Sans'
mpl.rcParams['text.hinting'] = 'none'
mpl.rcParams['text.hinting_factor'] = 8
# We've changed the default for ourselves here, but for backwards-compatibility, use
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want to give downstream a way to control this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

per discussion we can likely always go with the new values.

Comment thread lib/matplotlib/tests/test_axes.py
@tacaswell
Copy link
Copy Markdown
Member

Going to let Elliott click merge on this monster!

@jklymak
Copy link
Copy Markdown
Member

jklymak commented Apr 10, 2026

Congratulations on this @QuLogic and thank you for all your hard work to get this in, and everyone who helped review. This was a heroic effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

10 participants