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

Error reading SVG table (ReferenceError: uint16 is not defined) #127

Closed
darknoon opened this issue Jun 28, 2022 · 5 comments
Closed

Error reading SVG table (ReferenceError: uint16 is not defined) #127

darknoon opened this issue Jun 28, 2022 · 5 comments
Labels
bug For code that is demonstrably wrong.

Comments

@darknoon
Copy link

Context

Compiling a figma plugin (ui code) with esbuild
Trying to read the "SVG" table in an opentype font (Abelone)

Failing code

eg:

import { Font } from "lib-font";


const myFont = new Font("namehere");
await myFont.fromDataBuffer(ab, f.name);
myFont.opentype.tables["SVG"]  crashes here

It looks like this line is meant to say p.uint16 perhaps?

As an aside, when I tried to add a failing test to testing/browser/tests/test.otf.js, throwing an exception seems to just hang the test host until timeout instead of failing the test.

@Pomax
Copy link
Owner

Pomax commented Jun 28, 2022

ah, good find: yeah that should absolutely be p.unt16, not a bare uint6!

@Pomax Pomax added the bug For code that is demonstrably wrong. label Jun 28, 2022
@Pomax
Copy link
Owner

Pomax commented Jun 28, 2022

Created a testcase in testing/manual/custom/issue-127. with code

import { Font } from "../../../lib-font.js";

const font = new Font("SVG testing");
font.src = `./fonts/issue-127/Abelone-FREE.otf`;
font.onerror = (evt) => console.error(evt);
font.onload = (evt) => {
  const font = evt.detail.font;
  const { tables } = font.opentype;
  const SVGTable = tables["SVG"];
  console.log(SVGTable);
};

and result

SVG {
  version: 0,
  offsetToSVGDocumentList: 10,
  documentList: SVGDocumentList {
    numEntries: 96,
    documentRecords: [
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord],
      [SVGDocumentRecord], [SVGDocumentRecord], [SVGDocumentRecord]
    ]
  }
}

@Pomax
Copy link
Owner

Pomax commented Jun 28, 2022

v2.3.6 published

@Pomax
Copy link
Owner

Pomax commented Jun 28, 2022

#128 filed to follow up on the testing issue.

@Pomax Pomax closed this as completed Jun 28, 2022
@darknoon
Copy link
Author

Thanks for the speedy turnaround!

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