diff --git a/font-src/support/geometry.js b/font-src/support/geometry.js index eb2984211..d207218c5 100644 --- a/font-src/support/geometry.js +++ b/font-src/support/geometry.js @@ -50,6 +50,9 @@ class ContourGeometry extends GeometryBase { return !this.m_points.length; } measureComplexity() { + for (const z of this.m_points) { + if (!isFinite(z.x) || !isFinite(z.y)) return 0xffff; + } return this.m_points.length; } toShapeStringOrNull() { diff --git a/font-src/support/spiro-expand.js b/font-src/support/spiro-expand.js index 74fef3fcc..5712f79be 100644 --- a/font-src/support/spiro-expand.js +++ b/font-src/support/spiro-expand.js @@ -157,10 +157,12 @@ class SpiroExpansionContext2 { if (this.nKnotsProcessed === 1) { const angle = computeNormalAngle(this.gizmo, arc.deriveX0, arc.deriveY0); if (isFinite(angle)) this.controlKnots[0].normalAngle = angle; + else throw new Error("NaN angle detected."); } { const angle = computeNormalAngle(this.gizmo, arc.deriveX1, arc.deriveY1); if (isFinite(angle)) this.controlKnots[this.nKnotsProcessed].normalAngle = angle; + else throw new Error("NaN angle detected."); } this.nKnotsProcessed += 1; }