Skip to content

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

Open
@sulram

Description

@sulram

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions