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

Remove unused glyphs from embedded fonts? #65

Open
robinkrahl opened this issue Oct 13, 2020 · 2 comments
Open

Remove unused glyphs from embedded fonts? #65

robinkrahl opened this issue Oct 13, 2020 · 2 comments
Milestone

Comments

@robinkrahl
Copy link
Contributor

First of all, thanks for this very useful crate!

I noticed that every embedded fonts adds about ~ 150–200 KiB to the size of the output file. This quickly leads to a quite large file when using multiple fonts. Running the generated file through ps2pdf reduces the file size to some KiB. As far as I see, this is because printpdf embeds every available glyph into the PDF file.

Would it be possible to keep track of the used characters and only embed the glyphs for the required characters?

@fschutt
Copy link
Owner

fschutt commented Jul 14, 2022

That would be possible, but only with a config / feature flag. For my purpose (creating topographic maps) I need to keep the entire font in the PDF because I send out the resulting PDF files to graphic designers and I want to ship the fonts with the PDF (instead of shipping them as separate files), so that graphic designers can edit / create new text with the same font.

For now it would probably be best if you do process::Command::new("ps2pdf") on the final file, if that is possible. What you're asking for is possible, but I'm not interested in implementing it right now, as I have a lot of other things to do. You can take a look at this function: https://docs.rs/allsorts/latest/allsorts/subset/fn.subset.html which takes a font file + glyph IDs and spits out a new .ttf file with the redundant glyph IDs trimmed from the file.

@fschutt fschutt added this to the 0.8 milestone Nov 2, 2024
@fschutt
Copy link
Owner

fschutt commented Nov 2, 2024

Will be solved in 0.8 by default (since it got requested so much).

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

No branches or pull requests

2 participants