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 — Switch Tfm metrics to TrueType-compatible API. by anntzer · Pull Request #29838 · matplotlib/matplotlib

Conversation

@anntzer

@anntzer anntzer commented Mar 31, 2025

Copy link
Copy Markdown
Contributor

Another small preparatory PR for #29807 ({xe,lua}tex support).

Instead of directly exposing widths, heights, depths dicts, provide a get_metrics method to access a glyph's (tex) metrics. This change is in preparation for {xe,lua}tex support, which would use an alternative metrics-loading class (TtfMetrics) where it would be excessive to load the metrics of all glyphs at once.

PR summary

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.

All reactions
@anntzer anntzer added the topic: text/usetex label Mar 31, 2025
@github-actions github-actions Bot added the backend: pdf label Mar 31, 2025
timhoffm
timhoffm reviewed Mar 31, 2025
View reviewed changes
Comment thread lib/matplotlib/dviread.pyi Outdated
height: dict[int, int]
depth: dict[int, int]
def __init__(self, filename: str | os.PathLike) -> None: ...
def get_metrics(self, int) -> TexMetrics | None: ...

@timhoffm timhoffm Mar 31, 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.

Suggested change
def get_metrics(self, int) -> TexMetrics | None: ...
def get_metrics(self, idx: int) -> TexMetrics | None: ...

Sorry, something went wrong.

Uh oh!

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

All reactions

@anntzer anntzer Mar 31, 2025

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

thanks, fixed

Sorry, something went wrong.

Uh oh!

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

All reactions
@anntzer
anntzer force-pushed the texmetrics branch 2 times, most recently from b09d728 to 3f2c7dd Compare March 31, 2025 11:13
timhoffm
timhoffm approved these changes Mar 31, 2025
View reviewed changes
@tacaswell tacaswell added this to the v3.11.0 milestone Mar 31, 2025
dstansby
dstansby approved these changes Mar 31, 2025
View reviewed changes

@dstansby dstansby left a comment

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.

Just one suggestion to make the dataclass keyword argument only

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread lib/matplotlib/dviread.py Resolved

Uh oh!

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

@anntzer
anntzer force-pushed the texmetrics branch from 3f2c7dd to 734a3dd Compare March 31, 2025 13:19
@anntzer

anntzer commented Mar 31, 2025

Copy link
Copy Markdown
Contributor Author

sure, done

All reactions

Sorry, something went wrong.

Uh oh!

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

@anntzer
anntzer force-pushed the texmetrics branch from 734a3dd to 1801b94 Compare March 31, 2025 15:32
@anntzer
Switch Tfm metrics to TrueType-compatible API.
a18e072
Instead of directly exposing widths, heights, depths dicts, provide a
get_metrics method to access a glyph's (tex) metrics.  This change is in
preparation for {xe,lua}tex support, which would use an alternative
metrics-loading class (`TtfMetrics`) where it would be excessive to load
the metrics of all glyphs at once.
@anntzer
anntzer force-pushed the texmetrics branch from 1801b94 to a18e072 Compare March 31, 2025 20:47
@anntzer

anntzer commented Mar 31, 2025

Copy link
Copy Markdown
Contributor Author

I'm a bit at loss as to how to placate mypy here, so if someone who actually uses typing could have a look, this would be very helpful :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@tacaswell
TYP: work around mypy limitation
5d0adf1
@tacaswell

tacaswell commented Mar 31, 2025

Copy link
Copy Markdown
Member

Pushed a commit that fixes it locally.

Look like this is a limitation in stubtests that does not correctly handle the kw_only=True functionality as __match_args__ is how dataclasses do some of their arg parsing in __init__.

All reactions

Sorry, something went wrong.

Uh oh!

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

@dstansby

dstansby commented Mar 31, 2025

Copy link
Copy Markdown
Member

Looks like it's related to (but not the same as) the fixed python/mypy#15749. Might be worth a minimal reproducer and a issue report upstream in mypy?

All reactions

Sorry, something went wrong.

Uh oh!

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

@dstansby

dstansby commented Mar 31, 2025

Copy link
Copy Markdown
Member

I've got a minimal reproducer, will post an issue upstream

All reactions

Sorry, something went wrong.

Uh oh!

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

@anntzer

anntzer commented Mar 31, 2025

Copy link
Copy Markdown
Contributor Author

Thanks :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@tacaswell
tacaswell merged commit 002661c into matplotlib:main Apr 1, 2025
@tacaswell

tacaswell commented Apr 1, 2025

Copy link
Copy Markdown
Member

thank you @dstansby !

All reactions

Sorry, something went wrong.

Uh oh!

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

@anntzer
anntzer deleted the texmetrics branch April 1, 2025 05:40
@anntzer anntzer mentioned this pull request Apr 1, 2025
Multivariate plotting in imshow, pcolor and pcolormesh #29221
Closed
2 of 5 tasks
@QuLogic QuLogic added this to Font and text overhaul Jun 5, 2025
@QuLogic QuLogic moved this to Done in Font and text overhaul Jun 5, 2025
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

backend: pdf topic: text/usetex

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.

4 participants

@anntzer @tacaswell @dstansby @timhoffm
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.