Skip to content

Improve subsetting - #4373

Merged
laurmaedje merged 13 commits into
typst:mainfrom
LaurenzV:subsetter-3
Jun 16, 2024
Merged

laurmaedje merged 13 commits into
typst:mainfrom
LaurenzV:subsetter-3

Conversation

@LaurenzV

@LaurenzV LaurenzV commented Jun 11, 2024 •

Copy link
Copy Markdown
Collaborator

This PR greatly improves the subsetting of Typst. This should lead to decreased PDF files in nearly all cases, even more so when a Typst document contains many fonts. For many big CFF fonts, the file sizes will even be reduced from 1MB+ to just a few KBs.

See the READMEs in typst/subsetter#1 for how we are currently testing the subsetter to ensure that it is correct. Apart from the tests there, I also created a PDF document using typst containing many different fonts and a subset of glyphs. You can find it here:

typst.pdf

I tested it with all major PDF viewers and they all seem to display it fine.

Given this test file and also the tests in subsetter (as well as fuzzing), I do feel pretty confident about the correctness of the subsetter and hopefully there shouldn't be any major issues, but in the end we will only find out by actually trying it and maybe encourage people to especially check their PDF output when releasing the first release candidate. Some manual testing beforehand by volunteers would also be highly appreciated.

Fixes #895.

Merging is blocked by typst/subsetter#1 and typst/svg2pdf#76.

P.S.: The reason I had to split glyph sets and color glyph sets is that it is possible that for a color font, we use both, some glyphs for color fonts and some for normal text (I encountered this issue when fixing a test case with emojis and NZW). However, when subsetting we don't want to subset the glyphs that are only used as part of color fonts (since they will already be written as a type 3 font), and we also can't share the CMAP between the two fonts. This is why they had to be separated.

@laurmaedje
laurmaedje added this pull request to the merge queue Jun 16, 2024
Merged via the queue into typst:main with commit feedfe8 Jun 16, 2024
@LaurenzV
LaurenzV deleted the subsetter-3 branch June 16, 2024 09:54
@LaurenzV LaurenzV mentioned this pull request Aug 9, 2024
1 task done
Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More efficient font subsetting

2 participants