harfbuzz / harfbuzzjs

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

Add an example of keeping the specified layout-features #75

Open yisibl opened 1 year ago

yisibl commented 1 year ago

--layout-features=list of string table tags or *

KonghaYao commented 10 months ago

I used the .wasm directly. Create the set which will contain user inputs , and put features which you want in the set. @yisibl

const ptr = exports.hb_subset_input_create_or_fail();
const layoutFeatures = exports.hb_subset_input_set(
      ptr,
      6 /** HB_SUBSET_SETS_LAYOUT_FEATURE_TAG **/
  );
exports.hb_set_add(layoutFeatures,hb_tag('smcp'));  // hb_tag function is in the source code of hb.js

https://github.com/harfbuzz/harfbuzzjs/blob/28ae985d871d436e2b0ef2be61157a05d7d19b5c/hbjs.js#L14-L21 image