From 30f3159fa88d4b09f9cfdd71095000d4dcbf6189 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 22 May 2024 21:27:03 +0200 Subject: [PATCH 1/2] Fix MultipleAxisMapping behavior on hot reload; add reloadEverything() method to EditorController --- src/fontra/client/core/font-controller.js | 1 + src/fontra/views/editor/editor.js | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/fontra/client/core/font-controller.js b/src/fontra/client/core/font-controller.js index 3edd956dd..ce2756527 100644 --- a/src/fontra/client/core/font-controller.js +++ b/src/fontra/client/core/font-controller.js @@ -635,6 +635,7 @@ export class FontController { } async reloadEverything() { + delete this._multipleAxisMapping; this._glyphsPromiseCache.clear(); this._glyphInstancePromiseCache.clear(); this._glyphInstancePromiseCacheKeys = {}; diff --git a/src/fontra/views/editor/editor.js b/src/fontra/views/editor/editor.js index c7582fbf5..67dcdc7d8 100644 --- a/src/fontra/views/editor/editor.js +++ b/src/fontra/views/editor/editor.js @@ -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; } @@ -2722,11 +2720,25 @@ 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(); + + // the MultipleAxisMapping may have changed, force to re-sync the location + this.sceneSettings.fontLocationSource = { + ...this.sceneSettings.fontLocationSource, + }; + + 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, From e1756c5c6b94d7d1f26d52af15c14ed07053fa2f Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 22 May 2024 21:36:03 +0200 Subject: [PATCH 2/2] Move re-sync of location to scene-controller, where all location syncing lives --- src/fontra/views/editor/editor.js | 6 ------ src/fontra/views/editor/scene-controller.js | 10 ++++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/fontra/views/editor/editor.js b/src/fontra/views/editor/editor.js index 67dcdc7d8..6c0cbecc1 100644 --- a/src/fontra/views/editor/editor.js +++ b/src/fontra/views/editor/editor.js @@ -2729,12 +2729,6 @@ export class EditorController { async reloadEverything() { await this.fontController.reloadEverything(); - - // the MultipleAxisMapping may have changed, force to re-sync the location - this.sceneSettings.fontLocationSource = { - ...this.sceneSettings.fontLocationSource, - }; - await this.sceneModel.updateScene(); this.canvasController.requestUpdate(); } diff --git a/src/fontra/views/editor/scene-controller.js b/src/fontra/views/editor/scene-controller.js index 771fc01a0..76df18c5c 100644 --- a/src/fontra/views/editor/scene-controller.js +++ b/src/fontra/views/editor/scene-controller.js @@ -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"],