printpdf
printpdf copied to clipboard
Remove unused glyphs from embedded fonts?
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?
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.