fschutt / printpdf

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

get_font clones external font data everytime #160

Open lessball opened 1 year ago

lessball commented 1 year ago

I created a PDF with 2000 pages and 40MB ttf file, which took me over ten minutes. After trying to return Option<&DirectFontRef> instead, it changed to a few seconds. And i saw the comment: "(Warning): clones the direct font reference", maybe some optimizations can be done here

https://github.com/fschutt/printpdf/blob/cec012ad726344c31f715ab8c939ad0c11c7fcaf/src/font.rs#L630C59-L630C59

fschutt commented 2 weeks ago

In the 0.8 version, this was changed to ONLY ever use FontId (which are a random 32-bit character string identifying the font), so this will be solved then.