Closed eksea closed 3 weeks ago
Yeah, it embeds the entire font without subsetting.
This could technically be solved with switching to subsetting fonts with allsorts and only using the glyphs that are being used.
Yes,i solved the problem with the help of allsorts finally.
I implemented basic font subsetting which was merged in e412845dd5ca798a0e630ce3320ed2a5e6c1df0b . Since you also seem to have used allsorts, I would be curious if you have any comments / improvement ideas. Or even if you did it in a totally different way.
There's a font.rs in example. It read a font from file and then use it write text. I just use allsorts
to generate a small font in memory, and then use the same api get a same font object, just like the example。
let small_font = subset_text(&provider, &all_text).unwrap();
let mut font_reader = std::io::Cursor::new(small_font);
let font = doc.add_external_font(&mut font_reader).unwrap();
In the 0.8
API this is the default behaviour now.
i create a pdf file with just two Chinese characters. But the file size is 56MB. The font i use is 'STHeiti Medium.ttc' on mac which size is 53MB.