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

Parsing font with potentially faulty GDEF table #789

Open
JonasGruenwald opened this issue Feb 10, 2025 · 0 comments
Open

Parsing font with potentially faulty GDEF table #789

JonasGruenwald opened this issue Feb 10, 2025 · 0 comments

Comments

@JonasGruenwald
Copy link

JonasGruenwald commented Feb 10, 2025

Hello, big fan of the package here!

I've got an issue that's maybe more of a question, not a bug in the package itself:

I'm trying to parse a font file and opentype.js is throwing this error:

'Unsupported GDEF table version.');

Now if I add the parsed tableVersion to the logged error message there, it's showing a value of 0.
It seems that something in the font file is incorrect, as that appears to not be a valid version for the GDEF table according to the spec I could find.

Now my thing is, I'd still like to parse that font file even though it has this inconsistency. I've added a local patch to my project as a workaround:

--- a/dist/opentype.js
+++ b/dist/opentype.js
@@ -13820,8 +13820,10 @@
 	    start = start || 0;
 	    var p = new Parser(data, start);
 	    var tableVersion = p.parseVersion(1);
-	    check.argument(tableVersion === 1 || tableVersion === 1.2 || tableVersion === 1.3,
-	        'Unsupported GDEF table version.');
+	    if(!(tableVersion === 1 || tableVersion === 1.2 || tableVersion === 1.3)){
+        console.warn(`Unsupported GDEF table version: ${tableVersion}, not parsing table!`);
+        return undefined;
+      }
 	    var gdef = {
 	        version: tableVersion,
 	        classDef: p.parsePointer(Parser.classDef),

Also worth noting that any other software seems to be able to open the font file just fine, and FontForge for example does not report any issues when loading the font.

My questions are:

Would some form of fault tolerant parsing be in scope for opentype.js?
Would contributions along those lines be welcome?
Or does the project generally only aim to be able to parse files that 100% adhere to the spec?

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

1 participant