Missing initialisation for pts variable for glyphs
peteward opened this issue ยท 1 comments
peteward commented
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 fontkit@2.0.2
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 commented
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.