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

ReferenceError: Cannot access 'index' before initialization at fontkit\lib\fontkit.cjs.js:36896:21 #1606

Open
t-ondrej opened this issue Nov 21, 2021 · 2 comments
Labels

Comments

@t-ondrej
Copy link

Describe the bug
Generating PDF on a server with custom opentype font throws an error.

To Reproduce

  1. Clone https://github.com/t-ondrej/reactpdf-otf-bug
  2. Run npm run dev
  3. Open http://localhost:3000
  4. See error in server console

If you switch font to 'Pecita' (TestDocument.tsx:3) you'll get similar error (ReferenceError: Cannot access 'set' before initialization) from other place.

Expected behavior
Custom opentype fonts are loaded without any issues

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • @react-pdf/renderer@2.0.21

For the index related error, declaration is missing in

index = stack.pop() + gsubrsBias;
and here as well
subr = gsubrs[index];

For the set related error, declaration is missing in

set = table.classSet[index];

@jeetiss jeetiss added the bug label Nov 23, 2021
@tom2strobl
Copy link

Experiencing the same and as it seems this might be a node-specific bug since I'm rendering on nodejs without success, while using the same exact font on https://react-pdf.org/repl seems to work. That being said I've never been able to make a woff2 font work at all, neither in repl nor in node, although the underlying foliojs/fontkit should technically accept it.

@ouya99
Copy link

ouya99 commented May 6, 2022

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants