Comments (10)
I've filed #115 for fixing woff2 parsing
from lib-font.
closing this issue as the code fixes for woff2 support are handled in #115 instead.
from lib-font.
Hm, running test.js on those fonts reveals that woff2 files aren't actually being decoded properly at all, so that's something to dig into.
from lib-font.
@RoelN so it looks like at least in the browser all those fonts work fine, but the two "numbers only" fonts don't have GSUB tables, so if your testing doesn't check whether font.opentype.tables.GSUB
is undefined
that might cause runtime errors rather than test errors:
$ ttx 135abd30-1390-4f9c-b6a2-d843157c3468.woff2
Dumping "135abd30-1390-4f9c-b6a2-d843157c3468.woff2" to "135abd30-1390-4f9c-b6a2-d843157c3468.ttx"...
Dumping 'GlyphOrder' table...
Dumping 'head' table...
Dumping 'hhea' table...
Dumping 'maxp' table...
Dumping 'OS/2' table...
Dumping 'name' table...
Dumping 'cmap' table...
Dumping 'post' table...
Dumping 'CFF ' table...
Dumping 'GPOS' table...
Dumping 'hmtx' table...
and
$ ttx 64017d81-9430-4cba-8219-8f5cc28b923e.woff2
Dumping "64017d81-9430-4cba-8219-8f5cc28b923e.woff2" to "64017d81-9430-4cba-8219-8f5cc28b923e.ttx"...
Dumping 'GlyphOrder' table...
Dumping 'head' table...
Dumping 'hhea' table...
Dumping 'maxp' table...
Dumping 'OS/2' table...
Dumping 'hmtx' table...
Dumping 'LTSH' table...
Dumping 'VDMX' table...
Dumping 'hdmx' table...
Dumping 'cmap' table...
Dumping 'fpgm' table...
Dumping 'prep' table...
Dumping 'cvt ' table...
Dumping 'loca' table...
Dumping 'glyf' table...
ERROR: 'name' table stringOffset incorrect. Expected: 294; Actual: 354
Dumping 'name' table...
Dumping 'post' table...
Dumping 'gasp' table...
from lib-font.
We might have cheered too soon! Two fonts still trip up LibFont. For instance, the Proxima Nova one:
import { Font } from "./lib-font.js";
const font = new Font("woff2 testing");
// font.src = `./fonts/broken/BrushPosterGrotesk.woff2`;
// font.src = `./fonts/broken/64017d81-9430-4cba-8219-8f5cc28b923e.woff2`;
// font.src = `./fonts/broken/135abd30-1390-4f9c-b6a2-d843157c3468.woff2`;
font.src = `./fonts/broken/proximanova-regular-webfont.woff2`;
font.onerror = (evt) => console.error(evt);
font.onload = (evt) => {
let font = evt.detail.font;
const { name } = font.opentype.tables;
console.log(name);
};
gives:
$ node test.js
parser getUint16 2 Parser {
name: 'name',
length: 1638,
start: 0,
offset: 1640,
data: DataView {
byteLength: 1638,
byteOffset: 0,
buffer: ArrayBuffer {
[Uint8Contents]: <01 7c 01 7d 01 7e 01 7f 01 80 01 81 01 82 01 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8a 01 8b 01 8c 01 8d 01 8e 01 8f 01 90 01 91 01 92 00 d8 00 e1 01 93 01 94 00 db 00 dc 00 dd 00 e0 00 d9 00 df 01 95 01 96 01 97 01 98 01 99 01 9a 01 9b 01 9c 01 9d 01 9e 01 9f 01 a0 01 a1 01 a2 01 a3 01 a4 01 a5 ... 1538 more bytes>,
byteLength: 1638
}
}
}
parser 0 1640
Event {
type: 'error',
detail: RangeError: Offset is outside the bounds of the DataView
at DataView.getUint16 (<anonymous>)
at Parser.getValue (file:///Users/roel/code/lib-font/src/parser.js:60:29)
at Parser.get (file:///Users/roel/code/lib-font/src/parser.js:38:25)
at new NameRecord (file:///Users/roel/code/lib-font/src/opentype/tables/simple/name.js:60:25)
at file:///Users/roel/code/lib-font/src/opentype/tables/simple/name.js:20:14
at Array.map (<anonymous>)
at new name (file:///Users/roel/code/lib-font/src/opentype/tables/simple/name.js:19:51)
at createTable (file:///Users/roel/code/lib-font/src/opentype/tables/createTable.js:88:20)
at file:///Users/roel/code/lib-font/src/opentype/woff2.js:125:14
at Object.get (file:///Users/roel/code/lib-font/src/lazy.js:15:13),
msg: 'Failed to load font at ./fonts/broken/proximanova-regular-webfont.woff2'
}
A similar error is given for BrushPosterGrotesk.woff2
.
Not sure if this is related to the WOFF2 handling, or something to the name table code specifically?
from lib-font.
I added some more fonts to test with!
from lib-font.
I've had to remove some links from your updated list, because they contained a number of heavily licensed fonts that may most certainly not be redistributed =)
from lib-font.
Flaticon investigation issue: #120
from lib-font.
#120 was resolved, with v2.3.0 published to npm: @RoelN this should have fixed all the things, but if not, let me know.
from lib-font.
Thanks @Pomax, this is working nicely! I've integrated it in my local Wakamai Fondue build, and all fond that previously broke it, are now working fine!
from lib-font.
Related Issues (20)
- rollup is broken HOT 4
- rename font.js to lib-font HOT 1
- How to use lookup type 7 (Extension Substitution) HOT 3
- implement extension substitution for gsub lookuptype 7
- Fix woff2 support
- add a github action for PRs that runs the tests HOT 2
- Add support for WOFF2 transformed table data for glyf/loca/htmx
- Flaticon.woff2 is not parsing correctly. HOT 15
- use node's zlib for brotli decode / gunzip HOT 1
- GSUB bug when decoding Castoro HOT 11
- Color font info HOT 1
- Error reading SVG table (ReferenceError: uint16 is not defined) HOT 5
- Investigate test framework not dealing with exceptions properly
- font.opentype.tables is not enumerable HOT 4
- GSUB lookup type 6 sometimes fails on inputGlyphCount HOT 12
- Prebuilt `lib-font.browser.js` bundle throws `Unexpected token 'export'` error HOT 4
- Modify font object HOT 2
- Use the lib-font browser bundle in a webpack project. HOT 4
- Supports CommonJS HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lib-font.