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

Missing initialisation for pts variable for glyphs #327

Open
peteward opened this issue Feb 2, 2024 · 1 comment
Open

Missing initialisation for pts variable for glyphs #327

peteward opened this issue Feb 2, 2024 · 1 comment

Comments

@peteward
Copy link

peteward commented Feb 2, 2024

Hi! 👋

Firstly, thanks for your work on this project! even if it does seem to be abandoned nowadays 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/fontkit/src/glyph/CFFGlyph.js b/node_modules/fontkit/src/glyph/CFFGlyph.js
index 70c0aab..bab169c 100644
--- a/node_modules/fontkit/src/glyph/CFFGlyph.js
+++ b/node_modules/fontkit/src/glyph/CFFGlyph.js
@@ -546,7 +546,7 @@ export default class CFFGlyph extends Glyph {
                   let startx = x;
                   let starty = y;
 
-                  pts = [];
+                  let pts = [];
                   for (let i = 0; i <= 4; i++) {
                     x += stack.shift();
                     y += stack.shift();

This issue body was partially generated by patch-package.

@peteward
Copy link
Author

peteward commented Feb 2, 2024

This wasn't the right fix.

There are various scoping issues throughout this file that lead to errors for certain fonts.

In the end I moved the initialisation of lots of variables to the top level so that the order in which they hit various case statements didn't matter.

It would probably be better to block scope each case statement instead though and initialize as required within them.

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

1 participant