harfbuzz / harfbuzzjs

Providing HarfBuzz shaping library for client/server side JavaScript projects
https://harfbuzz.github.io/harfbuzzjs/
Other
204 stars 35 forks source link

Source-Han-Serif subsetting failed #44

Closed yisibl closed 3 years ago

yisibl commented 3 years ago

I use SourceHanSerifCN-Regular in the demo, and the generated size is larger than the original font. image

subset.zip

behdad commented 3 years ago

That doesn't mean it failed. Just that it's not as well optimized. Probably because of subroutinization. Adobe contributed the CFF/CFF2 subsetting code; no one left in the project knows that code base, so I can't be sure currently. cc @garretrieger

yisibl commented 3 years ago
hb-subset SourceHanSerifCN-Medium.ttf --text=你好123 --output-file=subset.ttf

hb-subset is ok.

image

ebraminio commented 3 years ago

So maybe desubroutinize flag is set somehow? We aren't touching it here at least https://github.com/harfbuzz/harfbuzzjs/blob/gh-pages/subset/index.html#L27

garretrieger commented 3 years ago

Do you have a command line which reproduces the problem? I tried:

hb-subset SourceHanSerifCN-Regular.ttf --text=你好123 --output-file=subset.ttf

Which results in a subset of size 2856 bytes.

garretrieger commented 3 years ago

Also that subset.ttf is not a valid font file. How did you produce it?

garretrieger commented 3 years ago

Looks like some sort of bug in the demo. No matter what font I put in it gets a 26 mb download back. Don't think this is related to harfbuzz. Please re-open if you have a reproduction via harfbuzz.

garretrieger commented 3 years ago

Oh sorry, thought this issue was posted in harfbuzz. Re-opening.

yisibl commented 3 years ago

Yes, I dragged and downloaded the font file in the demo, I tried other fonts, and it was always 26MB.

ebraminio commented 3 years ago

@yisibl was a regression on the demo, my fault, Blob needed a concrete buffer to work upon and subarray views weren't enough for it and 26mb was basically whole heap of the wasm machine.

yisibl commented 3 years ago

@ebraminio Thanks for the quick fix.