Skip to content

Commit

Permalink
Don't raise error if some deletes master layer
Browse files Browse the repository at this point in the history
GlyphsApp will add an empty layer if one is missing.
  • Loading branch information
ollimeier committed Jan 28, 2025
1 parent eb1a70c commit e1452c1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
8 changes: 1 addition & 7 deletions src/fontra_glyphs/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,17 +754,11 @@ def gsVerticalMetricsToFontraLineMetricsHorizontal(gsFont, gsMaster):

def variableGlyphToGSGlyph(variableGlyph, gsGlyph):
# Convert Fontra variableGlyph to GlyphsApp glyph
masterIds = [m.id for m in gsGlyph.parent.masters]
for gsLayerId in [gsLayer.layerId for gsLayer in gsGlyph.layers]:
if gsLayerId in variableGlyph.layers:
# This layer will be modified later.
continue
if gsLayerId in masterIds:
# We don't delete master layers.
raise NotImplementedError(
"Deleting a master layer will cause compatibility issues in GlyphsApp."
)
# Removing non-master-layer:
# Removing layer:
del gsGlyph.layers[gsLayerId]

for layerName, layer in iter(variableGlyph.layers.items()):
Expand Down
17 changes: 0 additions & 17 deletions tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,23 +231,6 @@ async def test_addLayerWithComponent(writableTestFont):
assert layerName in savedGlyph.layers.keys()


async def test_deleteMasterLayer(writableTestFont):
# Removing a "master" layer breaks compatibility within a .glyphs file.
# Therefore we need to make sure, that it will be added afterwords.
glyphName = "a"
glyphMap = await writableTestFont.getGlyphMap()
glyph = await writableTestFont.getGlyph(glyphName)

del glyph.layers["BFFFD157-90D3-4B85-B99D-9A2F366F03CA"]

with pytest.raises(NotImplementedError) as excinfo:
await writableTestFont.putGlyph(glyphName, glyph, glyphMap[glyphName])
assert (
str(excinfo.value)
== "Deleting a master layer will cause compatibility issues in GlyphsApp."
)


async def test_addAnchor(writableTestFont):
glyphName = "a"
glyphMap = await writableTestFont.getGlyphMap()
Expand Down

0 comments on commit e1452c1

Please sign in to comment.