Skip to content

Commit

Permalink
Merge pull request #1790 from googlefonts/gb-image-delete-etc
Browse files Browse the repository at this point in the history
[background image] delete image, cut/copy/paste
  • Loading branch information
justvanrossum authored Nov 15, 2024
2 parents 89914b5 + 852da42 commit c6e2d3f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/fontra/backends/designspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,8 @@ def populateUFOLayerGlyph(
layerGlyph.image = packBackgroundImage(
staticGlyph.backgroundImage, imageFileName
)
else:
layerGlyph.image = None

for component in staticGlyph.components:
if component.location or forceVariableComponents:
Expand Down
29 changes: 25 additions & 4 deletions src/fontra/views/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1883,11 +1883,13 @@ export class EditorController {
component: componentIndices,
anchor: anchorIndices,
guideline: guidelineIndices,
backgroundImage: backgroundImageIndices,
} = parseSelection(this.sceneController.selection);
let path;
let components;
let anchors;
let guidelines;
let backgroundImage;
const flattenedPathList = wantFlattenedPath ? [] : undefined;
if (pointIndices) {
path = filterPathByPointIndices(editInstance.path, pointIndices, doCut);
Expand Down Expand Up @@ -1920,12 +1922,21 @@ export class EditorController {
}
}
}
if (backgroundImageIndices) {
backgroundImage = editInstance.backgroundImage;
if (doCut) {
// TODO: don't delete if bg images are locked
// (even though we shouldn't be able to select them)
editInstance.backgroundImage = undefined;
}
}
const instance = StaticGlyph.fromObject({
...editInstance,
path: path,
components: components,
anchors: anchors,
guidelines: guidelines,
path,
components,
anchors,
guidelines,
backgroundImage,
});
return {
instance: instance,
Expand Down Expand Up @@ -2148,6 +2159,10 @@ export class EditorController {
layerGlyph.components.push(...pasteGlyph.components.map(copyComponent));
layerGlyph.anchors.push(...pasteGlyph.anchors);
layerGlyph.guidelines.push(...pasteGlyph.guidelines);
if (pasteGlyph.backgroundImage) {
layerGlyph.backgroundImage = pasteGlyph.backgroundImage;
selection.add("backgroundImage/0");
}
}
this.sceneController.selection = selection;
return "Paste";
Expand Down Expand Up @@ -2207,6 +2222,7 @@ export class EditorController {
component: componentSelection,
anchor: anchorSelection,
guideline: guidelineSelection,
backgroundImage: backgroundImageSelection,
//fontGuideline: fontGuidelineSelection,
} = parseSelection(this.sceneController.selection);
// TODO: Font Guidelines
Expand Down Expand Up @@ -2244,6 +2260,11 @@ export class EditorController {
layerGlyph.guidelines.splice(guidelineIndex, 1);
}
}
if (backgroundImageSelection) {
// TODO: don't delete if bg images are locked
// (even though we shouldn't be able to select them)
layerGlyph.backgroundImage = undefined;
}
}
}
this.sceneController.selection = new Set();
Expand Down

0 comments on commit c6e2d3f

Please sign in to comment.