Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add woffToOTF conversion function that doesn't parse table contents.
Motivation and Context
In a project I need to uncompress woff files to otf/ttf in order to use them with harfbuzzjs which doesn't support woff.
I'm already using opentype.js, however,
Font.toArrayBuffer
relies on parsing the table contents, which results in incomplete translations when opentype.js doesn't support a table.I looked at the python lib hanikesn/woff2otf and the node port mondeja/woff2otf and decided that opentype.js has already all the essential tooling required to do the same, so for me this is much better than adding a new dependency.
I added to
src/opentype.js
I added
checksum
to the result ofparseWOFFTableEntries
.I also repaired(?*) the
./bin/ot
command and added the sub-command$./bin/ot woff_2_otf font-in.woff fount-out.ttf
(?*) imports weren't working for me calling
./bin/ot
with an error(below), so i switched torequire
which is also used by./bin/test-render
:How Has This Been Tested?
It works well in my local project with harfbuzzjs and opentypejs, i.e. both libraries can open and parse the result buffer.
$./bin/ot woff-2-otf
produces the same output as hanikesn/woff2otfTypes of changes
Checklist:
npm run test
and all tests passed green (including code styling checks).