Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify/speedup type1 font embedding #19584

Open
anntzer opened this issue Feb 25, 2021 · 1 comment
Open

Simplify/speedup type1 font embedding #19584

anntzer opened this issue Feb 25, 2021 · 1 comment

Comments

@anntzer
Copy link
Contributor

anntzer commented Feb 25, 2021

Describe the issue

(I'm mostly writing this up as a possible idea for @aitikgupta to explore -- but if there's another font junkie interested, please have a go).

Summary

The type1font module serves a single purpose: embedding fonts shipped with tex (e.g., cmr10.pfb is computer modern roman), which are in the "type1" format, into pdf output, when using usetex. (In theory, we could also support embedding such fonts in type1 format if someone draws non-mathtext text (fig.text("foo", font=Path("/path/to/cmr10.pfb")), but we don't do that, we always convert things to either type3 or type42.)

Very briefly, embedding a type1 font in a pdf file is "relatively" simple: the font's on-disk representation can be copied mostly "as is", except that we need to provide some additional metadata about the font. Currently, we extract that metadata by actually parsing the font (as done in the type1font module). But in fact, nearly all the relevant metadata is also available from FreeType (via FT_Get_PS_Font_Info and friends), so we could instead rely on FreeType to get the metadata and then dump the font "as is", which should be both faster (as the parser would now be in C) and simpler (less parsing work on our side).

Actually, we'd still need to do a little bit of parsing (to get the "Length1"/"Length2" entries documented in the "Additional entries in an embedded font stream dictionary" table of the pdf spec), as well as to modify the FontMatrix in the (rare) case where pdftex.map specify SlantFont or ExtendFont modifications (see the pdf user manual), but these "should"(?) be doable with a much less general, and thus faster, parser.

The end result would be speedup in type1 font embedding for pdf output (i.e., for pdf+usetex) and less code in the type1font module.

Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Nov 20, 2023
@anntzer anntzer added Performance keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action labels Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant