Repository navigation
Description
To reproduce the issue:
- Create a designspace-based project
- Create a variable component in it (a glyph with a local axis and at least one non-default source defined for that axis)
- Go to the Sources panel
- Try to modify any data there, such as the line metrics or global guidelines
- Return to the editor view and try to do anything
Result:
Errors, caused by the fact that the designspace backend replaces its stored sources and layers (self.dsSources, self.ufoLayers) with just the font ones (in putSources), neglecting the glyph-local ones, so when it then tries to get that glyph it's missing the layer for it. Fontra has to be restarted to recover from this.
I considered implementing a fix but I'm not familiar enough with the codebase to be confident that my fix is right, since there's a lot of stuff interacting here and I couldn't find a detailed explanation of how it's architected- so I figured I'd just make this issue and hope it's a trivial problem that a regular contributor can solve easily. 🤞
FWIW, this is a partial fix I wrote before deciding I wasn't confident enough in my understanding of the codebase:
--- a/src/fontra/backends/designspace.py
+++ b/src/fontra/backends/designspace.py
@@ -1030,13 +1030,22 @@ class DesignspaceBackend:
{s.identifier: s for s in self.dsSources if s.identifier not in sources}
)
- self.dsSources = newDSSources
+ # Update stored layers
+ #
+ # Not all layers are associated with a source, since layers exist for
+ # variable components as well, so we can't just replace the list of
+ # ufo layers with one derived from the current dsSources, instead we
+ # selective throw out any layers from removed sources and add layers
+ # from newly added sources.
+
+ addedLayers = [s.layer for s in newDSSources if s not in self.dsSources]
+ removedLayers = [s.layer for s in self.dsSources if s not in newDSSources]
+
+ self.ufoLayers.items = addedLayers + [
+ layer for layer in self.ufoLayers if layer not in removedLayers
+ ]
- # Prune layers
- newLayers = ItemList()
- for dsSource in newDSSources:
- newLayers.append(dsSource.layer)
- self.ufoLayers = newLayers
+ self.dsSources = newDSSources
axisOrder = [axis.name for axis in self.dsDoc.axes]
newSourceDescriptors = [It's definitely incomplete since it doesn't account for self.dsSources, only self.ufoLayers.
Huge props to all the contributors who have worked on this project! Really glad to see it becoming genuinely useful and would love to become more familiar with the codebase so I can help push it even further ^-^
Activity
justvanrossum commentedon Mar 14, 2025
Can reproduce, thanks for the report! I have seen this happen, but didn't realize the presence of variable components is a key part of the problem.
Your analysis is good, too, I'll get on this soon.