Skip to content

Commit

Permalink
Remove fixCustomBinaryDataFormatting and fix some unittests
Browse files Browse the repository at this point in the history
Justs openstep-plist takes care of binary_spaces, so need of extra function.
  • Loading branch information
ollimeier committed Jan 28, 2025
1 parent 4ed0ac5 commit eb1a70c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/fontra_glyphs/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

from .utils import (
convertMatchesToTuples,
fixCustomBinaryDataFormatting,
getAssociatedMasterId,
getLocationFromSources,
matchTreeFont,
Expand Down Expand Up @@ -421,11 +420,11 @@ def _writeRawGlyph(self, glyphName, f):
escape_newlines=False,
sort_keys=False,
single_line_empty_objects=False,
binary_spaces=False,
)
+ "\n"
)

out = fixCustomBinaryDataFormatting(out)
self.gsFilePath.write_text(out)

async def aclose(self) -> None:
Expand Down
28 changes: 14 additions & 14 deletions tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,18 @@ async def test_putGlyph(writableTestFont, testFont, glyphName):


async def test_deleteLayer(writableTestFont):
glyphName = "A"
glyphName = "a"
glyphMap = await writableTestFont.getGlyphMap()
glyph = await writableTestFont.getGlyph(glyphName)
numGlyphLayers = len(glyph.layers)

layerName = "3E7589AA-8194-470F-8E2F-13C1C581BE24"
del glyph.layers[layerName]
# delete intermediate layer
del glyph.layers["1FA54028-AD2E-4209-AA7B-72DF2DF16264"]

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."
)
await writableTestFont.putGlyph(glyphName, glyph, glyphMap[glyphName])

savedGlyph = await writableTestFont.getGlyph(glyphName)
assert len(savedGlyph.layers) < numGlyphLayers


async def test_addLayer(writableTestFont):
Expand Down Expand Up @@ -238,14 +237,15 @@ async def test_deleteMasterLayer(writableTestFont):
glyphName = "a"
glyphMap = await writableTestFont.getGlyphMap()
glyph = await writableTestFont.getGlyph(glyphName)
numGlyphLayers = len(glyph.layers)

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

await writableTestFont.putGlyph(glyphName, glyph, glyphMap[glyphName])

savedGlyph = await writableTestFont.getGlyph(glyphName)
assert len(savedGlyph.layers) == numGlyphLayers
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):
Expand Down
4 changes: 1 addition & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from fontra_glyphs.utils import (
convertMatchesToTuples,
fixCustomBinaryDataFormatting,
getAssociatedMasterId,
getLocationFromSources,
matchTreeFont,
Expand Down Expand Up @@ -116,11 +115,10 @@ def test_roundtrip_glyphs_file_dumps(path):
escape_newlines=False,
sort_keys=False,
single_line_empty_objects=False,
binary_spaces=False,
)
+ "\n"
)

out = fixCustomBinaryDataFormatting(out)

for root_line, out_line in zip(path.read_text().splitlines(), out.splitlines()):
assert root_line == out_line

0 comments on commit eb1a70c

Please sign in to comment.