Skip to content

ps/pdf: Override font height metrics to support AFM files#31371

Open
QuLogic wants to merge 1 commit intomatplotlib:text-overhaulfrom
QuLogic:afm-height-metrics
Open

ps/pdf: Override font height metrics to support AFM files#31371
QuLogic wants to merge 1 commit intomatplotlib:text-overhaulfrom
QuLogic:afm-height-metrics

Conversation

@QuLogic
Copy link
Member

@QuLogic QuLogic commented Mar 25, 2026

PR summary

When outputting files using the "core 14 fonts" (e.g., rcParams['pdf.use14corefonts'] = True), text will be measured using our internal AFM files instead of any external files.

While we don't have a full API decided for how to pass full Text objects through backends, add in a small internal helper to allow the PS/PDF backends to override font height metrics with the AFM files.

Note, because there is still some small difference in how we calculated line spacing, there is some small difference in the result from before. But it no longer changes results depending on whether Helvetica is installed globally.

AI Disclosure

None

PR checklist

When outputting files using the "core 14 fonts" (e.g.,
`rcParams['pdf.use14corefonts'] = True`), text will be measured using
our internal AFM files instead of any external files.

While we don't have a full API decided for how to pass full `Text`
objects through backends, add in a small internal helper to allow the
PS/PDF backends to override font height metrics with the AFM files.
@QuLogic
Copy link
Member Author

QuLogic commented Mar 25, 2026

Test failures should just be from #31343.

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

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

1 participant