-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed the woff2 parsing
- Loading branch information
Showing
10 changed files
with
122 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>LibFont unit tests</title> | ||
<script src="/lib/inflate.js" defer></script> | ||
<script src="/lib/unbrotli.js" defer></script> | ||
<script src="/lib-font.js" type="module" defer></script> | ||
<script src="./index.js" type="module" defer></script> | ||
</head> | ||
<body> | ||
<h1>Please open dev tools for now</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const font = new Font("woff2 testing"); | ||
font.onerror = (evt) => console.error(evt); | ||
font.onload = (evt) => { | ||
let font = evt.detail.font; | ||
|
||
const { GSUB } = font.opentype.tables; | ||
processGSUB(GSUB); | ||
}; | ||
|
||
const fonts = [ | ||
`/fonts/broken/BrushPosterGrotesk.woff2`, | ||
`/fonts/broken/135abd30-1390-4f9c-b6a2-d843157c3468.woff2`, // No GSUB table? | ||
`/fonts/broken/64017d81-9430-4cba-8219-8f5cc28b923e.woff2`, // No GSUB table? | ||
`/fonts/broken/proximanova-regular-webfont.woff2`, | ||
]; | ||
|
||
font.src = fonts[0]; | ||
|
||
function processGSUB(GSUB) { | ||
let scripts = GSUB.getSupportedScripts(); | ||
|
||
scripts.forEach((script) => { | ||
let langsys = GSUB.getSupportedLangSys(script); | ||
|
||
langsys.forEach((lang) => { | ||
let langSysTable = GSUB.getLangSysTable(script, lang); | ||
let features = GSUB.getFeatures(langSysTable); | ||
|
||
features.forEach((feature) => { | ||
const lookupIDs = feature.lookupListIndices; | ||
|
||
lookupIDs.forEach((id) => { | ||
const lookup = GSUB.getLookup(id); | ||
const cnt = lookup.subTableCount; | ||
const s = cnt !== 1 ? "s" : ""; | ||
console.log( | ||
`lookup type ${lookup.lookupType} in ${lang}, lookup ${id}, ${cnt} subtable${s}` | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |