Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hb-subset: Ligatures and GDEF/GPOS/GSUB not included in the subset font #2575

Closed
papandreou opened this issue Jul 17, 2020 · 8 comments
Closed
Labels
subset hb-subset related bugs

Comments

@papandreou
Copy link

papandreou commented Jul 17, 2020

Probably a known issue, but I was adviced to open an issue here so it can be tracked 🤗

This Roboto-400.ttf that I downloaded from Google Web Fonts produces an incomplete file when I subset it with hb-subset, resulting in ligatures not rendering. Here's a visual diff with magenta showing where the rendering is different from the original:

waffle_stuffings_hbsubset_diff

I tried using ttx to compare the output of hb-subset to that of pyftsubset invoked with similar options:

pyftsubset --text="Waffle stuffings" --output-file=roboto-pyftsubset.ttf Roboto-400.ttf
../harfbuzz/build/util/hb-subset --output-file=roboto-hbsubset.ttf Roboto-400.ttf "Waffle stuffings"
diff -U1000 <(ttx -o - roboto-pyftsubset.ttf) <(ttx -o - roboto-hbsubset.ttf) > pyftsubset_vs_hbsubset_ttx.diff

The ttx diff shows that the 4 ligature glyphs are missing from <GlyphOrder> and <glyf>, and that the <GDEF>, <GPOS>, and <GSUB> blocks are missing altogether.

Tested on Ubuntu 19.10 with harfbuzz compiled from source (8e5bc53).

@ebraminio ebraminio added the subset hb-subset related bugs label Jul 17, 2020
@ebraminio
Copy link
Collaborator

ebraminio commented Jul 17, 2020

@garretrieger @qxliu76 can you have a look if anything unexpected here, weird that all of the tables are dropped, I thought some GPOS subsetting was implemented.

@garretrieger
Copy link
Collaborator

Since GSUB/GPOS subsetting is not yet fully implemented its disable by default and the two tables are just dropped. You can re-enable subsetting those tables by adding "--drop-tables-=GSUB,GPOS,GDEF" to your subset command. We currently support nearly all lookup types so that should work fine for something like Roboto.

@papandreou
Copy link
Author

@garretrieger, thanks! Adding --drop-tables-=GSUB,GPOS,GDEF to the command line makes all my primitive test cases pass 😌

Does anyone know how to achieve the equivalent of that when using hb-subset.wasm via harfbuzzjs? (context: harfbuzz/harfbuzzjs#9 (comment))

@garretrieger
Copy link
Collaborator

Similar process, use "hb_subset_input_drop_tables_set" to get the set of tables to be dropped and then remove GSUB, GPOS, and GDEF from the set. For example see the subset fuzzer code: https://github.com/harfbuzz/harfbuzz/blob/master/test/fuzzing/hb-subset-fuzzer.cc#L26

@ebraminio
Copy link
Collaborator

ebraminio commented Jul 17, 2020

Oooh, you'll need something like this then,

    exports.hb_set_del(export.hb_subset_input_drop_tables_set(input), HB_TAG('G', 'S', 'U', 'B'));
    exports.hb_set_del(export.hb_subset_input_drop_tables_set(input), HB_TAG('G', 'P', 'O', 'S'));
    exports.hb_set_del(export.hb_subset_input_drop_tables_set(input), HB_TAG('G', 'D', 'E', 'F'));

hb_set_del weren't in hb-subset wasm build harfbuzz/harfbuzzjs@8c27ab1 and this should make it work, the only left part will be a HB_TAG like thing, which you'll need something like this or you can hard code the answer anyway.

@papandreou
Copy link
Author

@ebraminio @garretrieger, thank you so much! It works!

I'm looking forward to feature-parity with pyftsubset and beyond, but this is probably good enough to get the harfbuzz support into subfont and put it behind an "experimental" switch 🚀

(Would be nice with a new harfbuzzjs release soon so I don't have to ship the hb-subset.wasm I compiled myself 🙏)

@ebraminio
Copy link
Collaborator

ebraminio commented Jul 17, 2020

(Would be nice with a new harfbuzzjs release soon so I don't have to ship the hb-subset.wasm I compiled myself pray)

Oh, sure! https://github.com/harfbuzz/harfbuzzjs/releases/tag/0.1.3 and of course the updated hb-subset.wasm is included in npm also.

btw, chunkName.split('').reduce(function (a, x) { return (a << 8) + x.charCodeAt(0); }, 0); also can be used but that may make it too cryptic so use that only if you also feel better with it :)

Guess you can close this and report other issues separately. Thanks! :)

papandreou added a commit to Munter/subfont that referenced this issue Jul 17, 2020
@papandreou
Copy link
Author

Yes, thanks a lot! 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subset hb-subset related bugs
Projects
None yet
Development

No branches or pull requests

3 participants