fschutt / printpdf

A fully-featured PDF library for Rust, WASM-ready
https://fschutt.github.io/printpdf/
MIT License
829 stars 98 forks source link

What can I do to make the font drawn through printpdf not the entire ttf be typed into the pdf, thereby reducing the size of the pdf #195

Closed bianbiandashen closed 1 week ago

bianbiandashen commented 1 week ago

let font_ref = doc.add_external_font(File::open(&font_path).expect("无法打开字体文件")).unwrap(); is bad

bianbiandashen commented 1 week ago
image image
fschutt commented 1 week ago

Use allsorts::subset::subset(font, glyphs) like in this function:

https://github.com/fschutt/printpdf/blob/5109221b158c767e621309d88afe5af56b11b168/src/font.rs#L322

Or wait for the 0.8 release (or use the master branch from GitHub directly).