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

Upgrade harfbuzzjs 0.2.0 / harfbuzz 3.0.0 #12

Closed
ebraminio opened this issue Nov 4, 2021 · 3 comments
Closed

Upgrade harfbuzzjs 0.2.0 / harfbuzz 3.0.0 #12

ebraminio opened this issue Nov 4, 2021 · 3 comments

Comments

@ebraminio
Copy link
Contributor

HarfBuzz 3.0.0 provides a different set of API for its subset functionality, opened this file to let you know about the release and the fact the upgrade needs some intervention. Thanks!

@papandreou
Copy link
Owner

Thanks for the heads up!

I don't know what the equivalent of hb_subset_input_nameid_set is in the new version, but this seems to sort of work:

diff --git a/package.json b/package.json
index 5f2e712..94c684c 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
   "main": "index.js",
   "dependencies": {
     "fontverter": "^2.0.0",
-    "harfbuzzjs": "^0.1.5",
+    "harfbuzzjs": "^0.2.0",
     "lodash": "^4.17.21",
     "p-limit": "^3.1.0"
   },
diff --git a/index.js b/index.js
index 904d287..ad85c42 100644
--- a/index.js
+++ b/index.js
@@ -45,10 +45,10 @@ async function subsetFont(
   const input = exports.hb_subset_input_create_or_fail();
 
   if (preserveNameIds) {
-    const inputNameIds = exports.hb_subset_input_nameid_set(input);
-    for (const nameId of preserveNameIds) {
-      exports.hb_set_add(inputNameIds, nameId);
-    }
+    // const inputNameIds = exports.hb_subset_input_nameid_set(input);
+    // for (const nameId of preserveNameIds) {
+    //   exports.hb_set_add(inputNameIds, nameId);
+    // }
   }
 
   // Add unicodes indices
@@ -57,7 +57,7 @@ async function subsetFont(
     exports.hb_set_add(inputUnicodes, c.codePointAt(0));
   }
 
-  const subset = exports.hb_subset(face, input);
+  const subset = exports.hb_subset_or_fail(face, input);
 
   // Clean up
   exports.hb_subset_input_destroy(input);

When I link it into the subfont test suite, everything seems to work, except that one of the reference image-based tests complains that the web page renders differently before vs. after subsetting. It produces this image diff:

121104-53177-8-10w3kkc esw1

I guess I'll just wait for the updated example 😇

@ebraminio
Copy link
Contributor Author

ebraminio commented Nov 4, 2021

I don't know what the equivalent of hb_subset_input_nameid_set is in the new version

It should be hb_subset_input_set(input, 4/*HB_SUBSET_SETS_NAME_ID*/) IIUC

I guess I'll just wait for the updated example 😇

Guess you had good progress here actually!

@papandreou
Copy link
Owner

Ah yeah, that works, now the (minimal) test suite here passes. I opened a PR here: #13

Would be nice to figure out why that subfont test fails, but I don't really know where to start 🙈

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

No branches or pull requests

2 participants