opentypejs / opentype.js

Read and write OpenType fonts using JavaScript.
https://opentype.js.org/
MIT License
4.45k stars 474 forks source link

OpenType.js can't read Google fonts' kerning, eg. EB Garamond #515

Open Typogram opened 2 years ago

Typogram commented 2 years ago

Download the ttf from https://fonts.google.com/specimen/EB+Garamond. use it as a test. The fonts have kerning info, and can be used as regular desktop fonts with proper kerning. However, OpenType.js can't read its kerning data. letter AV kerning should be -140, but OpenType.js returns 0

Steps to Reproduce (for bugs)

  1. go to https://codepen.io/wendyz/pen/PoQJyoX?editors=0011
  2. open the console
  3. OpenType.js return AV Kerning to be 0, where it should be -140 image

When I open the EB Garamond font with Robofont, I can see there is kerning info in the kern center. AV kern should be -140 image

Extra info: I download EB Garamond 8pt (another version) from the type designer's Bitbucket repo, and OpenType.js output proper kerning for that font. Included in the codepen example. cc. @davelab6

It may affect other Google Fonts as well, eg.

Your Environment

Typogram commented 2 years ago

@davelab6 could you provide some insight on this as well? The happens with Google Fonts' version of EB Garamond, but not with the type designer's version of EB Garamond on their bitbucket repo.

Typogram commented 2 years ago

@fdb @fpirsch could you help take a look into this issue?

Connum commented 1 year ago

Could this be related to #546 @ILOVEPIE, or is it something different?

Typogram commented 1 year ago

@Connum to help narrow down the problem area, maybe this information helps: I tested fontkit to read the same problem font (EB Garamond from Google Fonts), the kerning data can be read correctly. Here is fontkit's code for getting kerning data in below link. I think opentype.js must have missed one of the scenarios that were covered by fontkit: https://github.com/foliojs/fontkit/blob/master/src/layout/KernProcessor.js#L16

ILOVEPIE commented 1 year ago

This has already been fixed in the upcoming version.

ILOVEPIE commented 1 year ago

Nevermind, apparently google has changed their fonts they're hosting.

ILOVEPIE commented 1 year ago

I suspect #557 will fix this issue.

ILOVEPIE commented 1 year ago

The issue is the font is missing the old KERN table and has GPOS 9 and 4 entries. This will be fixed by #557.