Skip to content

Commit

Permalink
Merge pull request #812 from googlefonts/var-path-compat
Browse files Browse the repository at this point in the history
Ensure 'other' argument is also VarPackedPath instance
  • Loading branch information
justvanrossum authored Sep 16, 2023
2 parents 9593eb7 + 70f8fee commit 9886bdb
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/fontra/client/core/var-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,37 +554,26 @@ export class VarPackedPath {
}

addItemwise(other) {
let otherCoordinates;
if (other instanceof VarPackedPath) {
this._ensureCompatibility(other);
otherCoordinates = other.coordinates;
} else {
otherCoordinates = other;
}
this._ensureCompatibility(other);
return new this.constructor(
this.coordinates.addItemwise(otherCoordinates),
this.coordinates.addItemwise(other.coordinates),
this.pointTypes,
this.contourInfo
);
}

subItemwise(other) {
let otherCoordinates;
if (other instanceof VarPackedPath) {
this._ensureCompatibility(other);
otherCoordinates = other.coordinates;
} else {
otherCoordinates = other;
}
this._ensureCompatibility(other);
return new this.constructor(
this.coordinates.subItemwise(otherCoordinates),
this.coordinates.subItemwise(other.coordinates),
this.pointTypes,
this.contourInfo
);
}

_ensureCompatibility(other) {
if (
!(other instanceof VarPackedPath) ||
!arrayEquals(this.contourInfo, other.contourInfo) ||
!pointTypesEquals(this.pointTypes, other.pointTypes)
) {
Expand Down

0 comments on commit 9886bdb

Please sign in to comment.