Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Simplify/speedup type1 font embedding #19584

Copy link
Copy link
Open
@anntzer

Description

@anntzer
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.