-
Notifications
You must be signed in to change notification settings - Fork 6
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
Update harfbuzzjs to ^0.2.0 (harfbuzz 3.0.0) #13
Conversation
Pull Request Test Coverage Report for Build 1443083249
💛 - Coveralls |
index.js
Outdated
@@ -57,7 +60,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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that it can return zero, feel free to check it and fail gracefully if it returns 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also maybe on hb_subset_input_create_or_fail
or any API named '_or_fail` meaning they can return zero, but it is very unlikely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense! Is there a way to get a better error than "it failed" when that happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, if the convention here is to return exception as below, that can be done here also, it should be unlikely anyway, still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like bb2a0c5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try { throw... } finally { ... }
construct will see to it that we destroy the input, but don't execute the const result = exports.hb_face_reference_blob(subset);
line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like that, now I regret bringing it up! a cleanup just like below if (subsetByteLength === 0) {
block would be cool I think :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I already did implement it like that? Doesn't it look OK as-is? 😼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant I think before throw these are needed also,
exports.hb_face_destroy(face);
exports.free(fontBuffer);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I get it, fixed in e2deb41
index.js
Outdated
@@ -43,9 +43,17 @@ async function subsetFont( | |||
exports.hb_blob_destroy(blob); | |||
|
|||
const input = exports.hb_subset_input_create_or_fail(); | |||
if (input === 0) { | |||
throw new Error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also can benefit those memory cleanups just for the sake completeness, thanks you very much :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, moved some stuff around so the other things get allocated after input
instead: 2e3baa2
@ebraminio, thanks for the help! I'm still a bit worried about that failing reference image test in the subfont test suite, so I tried creating the subset font before/after upgrading to harfbuzzjs 0.2.0. Here's the diff of the ttx representations as well as the files themselves: https://gist.github.com/papandreou/cca1b1a17adb7f60b1f7794bea608f6f Any idea what's going on? Rendering of the original web page (or when subset with harfbuzzjs 0.1.5)Rendering of the web page when subset with harfbuzzjs 0.2.0
|
…_input_create_or_fail returns 0 #13 (comment)
Unfortunately I'm no longer involved with the upstream :/ comparing fonttools's ttx result of the two should give a good clue. |
@ebraminio, oh, sorry to hear that 😿 The above gist does include a ttx diff, but it's rather big, so it isn't clear to me what the actual issue might be. I guess I'll spend some time looking at it and maybe report it upstream if I can reproduce it with the |
Hmm, I can reproduce it with just the
Passing We can ape what diff --git a/index.js b/index.js
index ba08ff2..e079161 100644
--- a/index.js
+++ b/index.js
@@ -49,6 +49,14 @@ async function subsetFont(
const face = exports.hb_face_create(blob, 0);
exports.hb_blob_destroy(blob);
+ // Do the equivalent of --font-features=*
+ const layoutFeatures = exports.hb_subset_input_set(
+ input,
+ 6 // HB_SUBSET_SETS_LAYOUT_FEATURE_TAG
+ );
+ exports.hb_set_clear(layoutFeatures);
+ exports.hb_set_invert(layoutFeatures);
+
if (preserveNameIds) {
const inputNameIds = exports.hb_subset_input_set(
input, ... but that requires harfbuzzjs to expose |
just published 0.2.1 with them :) |
Released in 1.4.0. Thanks for all the help, @ebraminio 🤗 |
Discussion here: #12