Skip to content

Commit

Permalink
Rename property to be more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Nov 12, 2024
1 parent 9fe7d5f commit 6dd8e03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/fontra/client/core/font-sources-instancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ export class FontSourcesInstancer {
(source) => !source.isSparse
);
this.fontAxesSourceSpace = mapAxesFromUserSpaceToSourceSpace(this.fontAxes);
this.defaultLocation = Object.fromEntries(
this.defaultSourceLocation = Object.fromEntries(
this.fontAxesSourceSpace.map((axis) => [axis.name, axis.defaultValue])
);
this._sourceIdsByLocationString = Object.fromEntries(
Object.entries(this.fontSources).map(([sourceIdentifier, source]) => [
locationToString({ ...this.defaultLocation, ...source.location }),
locationToString({ ...this.defaultSourceLocation, ...source.location }),
sourceIdentifier,
])
);
this.defaultSourceIdentifier =
this._sourceIdsByLocationString[locationToString(this.defaultLocation)];
this._sourceIdsByLocationString[locationToString(this.defaultSourceLocation)];

this._instanceCache = new LRUCache(50);
}

getLocationIdentifierForLocation(location) {
location = { ...this.defaultLocation, ...location };
location = { ...this.defaultSourceLocation, ...location };
return this._sourceIdsByLocationString[locationToString(location)];
}

Expand Down Expand Up @@ -69,7 +69,7 @@ export class FontSourcesInstancer {
if (!this._fontSourcesList.length) {
return undefined;
}
sourceLocation = { ...this.defaultLocation, ...sourceLocation };
sourceLocation = { ...this.defaultSourceLocation, ...sourceLocation };
const locationString = locationToString(sourceLocation);

const sourceIdentifier = this._sourceIdsByLocationString[locationString];
Expand Down
4 changes: 2 additions & 2 deletions test-js/test-font-sources-instancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe("FontSourcesInstancer Tests", () => {
it("Default location identifier", () => {
const fsi = new FontSourcesInstancer(testAxes, testSources);
expect(fsi.defaultSourceIdentifier).to.equal("source1");
expect(fsi.defaultLocation).to.deep.equal({ Weight: 400, Width: 50 });
expect(fsi.defaultSourceLocation).to.deep.equal({ Weight: 400, Width: 50 });
});

parametrize(
Expand Down Expand Up @@ -145,7 +145,7 @@ describe("FontSourcesInstancer Tests", () => {
const sourceInstance = fsi.instantiate({});
expect(sourceInstance).to.deep.equal(undefined);
expect(fsi.defaultSourceIdentifier).to.equal(undefined);
expect(fsi.defaultLocation).to.deep.equal({});
expect(fsi.defaultSourceLocation).to.deep.equal({});
expect(fsi.getLocationIdentifierForLocation({})).to.equal(undefined);
});
});

0 comments on commit 6dd8e03

Please sign in to comment.