Skip to content

Commit

Permalink
Merge pull request #1385 from googlefonts/fix-live-reloading-designsp…
Browse files Browse the repository at this point in the history
…ace-mappings

[avar-2] Fix MultipleAxisMapping behavior on hot reload
  • Loading branch information
justvanrossum authored May 22, 2024
2 parents 838324a + e1756c5 commit 2c41623
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/fontra/client/core/font-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ export class FontController {
}

async reloadEverything() {
delete this._multipleAxisMapping;
this._glyphsPromiseCache.clear();
this._glyphInstancePromiseCache.clear();
this._glyphInstancePromiseCacheKeys = {};
Expand Down
14 changes: 10 additions & 4 deletions src/fontra/views/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2708,9 +2708,7 @@ export class EditorController {
async reloadData(reloadPattern) {
if (!reloadPattern) {
// A reloadPattern of undefined or null means: reload all the things
await this.fontController.reloadEverything();
await this.sceneModel.updateScene();
this.canvasController.requestUpdate();
await this.reloadEverything();
return;
}

Expand All @@ -2722,11 +2720,19 @@ export class EditorController {
}
} else {
// TODO
console.log(`reloading of non-glyph data is not yet implemented: ${rootKey}`);
// console.log(`reloading of non-glyph data is not yet implemented: ${rootKey}`);
await this.reloadEverything();
return;
}
}
}

async reloadEverything() {
await this.fontController.reloadEverything();
await this.sceneModel.updateScene();
this.canvasController.requestUpdate();
}

async reloadGlyphs(glyphNames) {
if (glyphNames.includes(this.sceneSettings.selectedGlyphName)) {
// If the glyph being edited is among the glyphs to be reloaded,
Expand Down
10 changes: 10 additions & 0 deletions src/fontra/views/editor/scene-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ export class SceneController {
true
);

this.fontController.addChangeListener(
{ axes: null },
(change, isExternalChange) => {
// the MultipleAxisMapping may have changed, force to re-sync the location
this.sceneSettings.fontLocationSource = {
...this.sceneSettings.fontLocationSource,
};
}
);

// Set up convenience property "selectedGlyphName"
this.sceneSettingsController.addKeyListener(
["selectedGlyph", "glyphLines"],
Expand Down

0 comments on commit 2c41623

Please sign in to comment.