Switch Tfm metrics to TrueType-compatible API.#29838
Switch Tfm metrics to TrueType-compatible API.#29838tacaswell merged 2 commits intomatplotlib:mainfrom
Conversation
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: ... |
There was a problem hiding this comment.
| def get_metrics(self, int) -> TexMetrics | None: ... | |
| def get_metrics(self, idx: int) -> TexMetrics | None: ... |
b09d728 to
3f2c7dd
Compare
dstansby
left a comment
There was a problem hiding this comment.
Just one suggestion to make the dataclass keyword argument only
|
sure, done |
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.
|
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 :) |
|
Pushed a commit that fixes it locally. Look like this is a limitation in stubtests that does not correctly handle the |
|
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? |
|
I've got a minimal reproducer, will post an issue upstream |
|
Thanks :) |
|
thank you @dstansby ! |
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