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

Fonts that trip up LibFont #114

Closed
RoelN opened this issue Apr 14, 2021 · 10 comments
Closed

Fonts that trip up LibFont #114

RoelN opened this issue Apr 14, 2021 · 10 comments
Labels
bug For code that is demonstrably wrong.

Comments

@RoelN
Copy link
Collaborator

RoelN commented Apr 14, 2021

These come back from some automated tests, so for most I haven't dug into what exactly goes wrong. My hunch is something with the name table?

Fonts that don't work 😿

Fonts that work 🎉

For completeness sake, a similar issue over at Wakamai Fondue that uses LibFont under the hood: Wakamai-Fondue/wakamai-fondue-site#21 This contains some more (free/open source) fonts we can test with.

@Pomax
Copy link
Owner

Pomax commented Apr 22, 2021

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.

@Pomax Pomax added the bug For code that is demonstrably wrong. label Apr 22, 2021
@Pomax
Copy link
Owner

Pomax commented Apr 23, 2021

I've filed #115 for fixing woff2 parsing

@Pomax
Copy link
Owner

Pomax commented Apr 23, 2021

@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...

@Pomax
Copy link
Owner

Pomax commented Apr 27, 2021

closing this issue as the code fixes for woff2 support are handled in #115 instead.

@Pomax Pomax closed this as completed Apr 27, 2021
@RoelN
Copy link
Collaborator Author

RoelN commented May 21, 2021

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?

@RoelN RoelN reopened this May 21, 2021
@RoelN
Copy link
Collaborator Author

RoelN commented Jul 5, 2021

I added some more fonts to test with!

@Pomax
Copy link
Owner

Pomax commented Jul 9, 2021

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 =)

@Pomax
Copy link
Owner

Pomax commented Jul 9, 2021

Flaticon investigation issue: #120

@Pomax
Copy link
Owner

Pomax commented Jul 9, 2021

#120 was resolved, with v2.3.0 published to npm: @RoelN this should have fixed all the things, but if not, let me know.

@RoelN
Copy link
Collaborator Author

RoelN commented Jul 14, 2021

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!

@RoelN RoelN closed this as completed Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For code that is demonstrably wrong.
Projects
None yet
Development

No branches or pull requests

2 participants