-
Notifications
You must be signed in to change notification settings - Fork 254
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
Font subsetting for embedded truetype fonts #17
Comments
@adrg Can you review this proposal? |
I think the proposal looks good. Doing the subsetting at serialization time is a good solution in my opinion. Does the font encoder always record used glyphs and ignores the subset at serialization time if subsetting is not enabled, or does it start recording once Will there also be a global writer/creator option to enable subsetting for all fonts? Could be useful for optimizing PDFs for disk space. |
Current state
Currently, font files are embedded their entirety. This can be somewhat wasteful, as often only a small portion of glyphs are used, and font files can be large especially for unicode fonts with large numbers of glyphs.
There are two use cases:
(2. Optimizing already created PDF files that contain embedded fonts.)
Those two cases may require slightly different approaches to be done efficiently. So it is probably best to keep them separate. Here we will focus on the first use case (for creating PDFs).
Proposed changes
This requires.
use https://github.com/unidoc/unitype to do the subsetting.
This would probably be best to do at serialization time, if the font had been marked for subsetting along with which glyphs to keep. Example use case:
Expected results
Significantly smaller generated PDF files using TTF fonts.
References
Section 9.6.4 Font Subsets (PDF32000_2008):
And in section 9.9 (Embedded Font Programs) it states:
Section 9.6.6.4 (Encodings for TrueType fonts) additionally describes how TrueType cmaps and font dictionary's Encoding are used to map between character codes and glyph descriptions.
The text was updated successfully, but these errors were encountered: