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

Gracefully handle unsupported WOFF2 parsing #518

Merged
merged 1 commit into from Oct 19, 2022
Merged

Gracefully handle unsupported WOFF2 parsing #518

merged 1 commit into from Oct 19, 2022

Conversation

yne
Copy link
Contributor

@yne yne commented Jun 6, 2022

Description

WOFF2 is becoming more and more popular and is now the default font format in font.google.com

So Opentype.js is more and more expected to parse and generate WOFF2.

However WOFF2 compression (as WASM) would bloat the opentype.js dist file by ~1400 KB.

A more modular approach would be to let the end-user do the WOFF compress/decompress wrapping if they need it.

Motivation and Context

This PR aim to solve this lack of support by pointing the user to a wrapping example if they try the directly load a WOFF2 file into opentype.js

How Has This Been Tested?

By loading a WOFF2 into opentype.js without decompresing it beforehand and looking at the reason given by the trown exception.

Screenshots (if appropriate):

image

@yne yne merged commit c37fcdf into master Oct 19, 2022
@yne yne deleted the woff2-message branch October 19, 2022 07:30
@herrstrietzel
Copy link

@yne : Thank you so much for depicting this woff2 workaround – that's kind of a game changer!
First of all, this solution should be at least mentioned in the current documentation.
(I've discovered this approach rather by accident.)

In the long run, it might be better to include the admittedly complex brotli decompression by default – albeit I always appreciated opentype.js approach to keep the core as compact as possible.

Highly subjective: I think font parsing is rather a niche for creating graphics based on fonts.
You rarely need to include opentype.js as a mandatory script asset (like other front end libraries).
My point: the additional increase in file size might be negligible in favor of woff2 support.

@Connum
Copy link
Contributor

Connum commented Mar 30, 2023

This has been discussed before. Brotli decompression will not be integrated into opentype.js, but we do show a console message with a link to a description when trying to load a woff2 file.

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

Successfully merging this pull request may close these issues.

None yet

3 participants