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

fonkit 2.0.0 create from ArrayBuffer returns empty variationAxes and null parameters #330

Open
sulram opened this issue Mar 30, 2024 · 1 comment

Comments

@sulram
Copy link

sulram commented Mar 30, 2024

I'm trying to use fontkit 2.0.0 with a variable font... The first issue was that loading the buffer directly like this:

(async () => {
  try {
    const response = await fetch('/font.woff2')
    const buffer = await response.arrayBuffer()
    font = fontkit.create(buffer)
    console.log(font, font.namedVariations, font.variationAxes)
    generateSvgText()
  } catch (err) {
      console.error(err);
  }
})();

was returning

TypeError: First argument to DataView constructor must be an ArrayBuffer
    at new DataView (<anonymous>)
    at new DecodeStream (fontkit.js?v=18e2d3af:4122:17)
    at Module.$d636bc798e7178db$export$185802fd694ee1f5 (fontkit.js?v=18e2d3af:5242:29)`

Changing this line to font = fontkit.create(new Uint8Array(buffer)) works. But that is not documented anywhere.

The problem I'm facing now is that the font comes with many null parameters, and variationAxes and namedVariations are empty objects.

I've tested with the same fonts that works on this fontkit (1.8.0) demo:

Anyone having problems with Variable Fonts when changing from 1.8.0 to 2.0.0?

Thanks in advance

@sinisterstumble
Copy link

I see the same issue. Thank you for the workaround tip @sulram.

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

2 participants