Skip to content

Commit

Permalink
Merge pull request #1007 from googlefonts/font-lib-copy
Browse files Browse the repository at this point in the history
Support writing lib to .designspace and .fontra, make copyFont() copy lib
  • Loading branch information
justvanrossum authored Dec 2, 2023
2 parents 5570e7c + aeff093 commit 4525fe1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/fontra/backends/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ async def copyFont(
sourceBackend, destBackend, *, glyphNames=None, numTasks=1, progressInterval=0
):
await destBackend.putGlobalAxes(await sourceBackend.getGlobalAxes())
await destBackend.putFontLib(await sourceBackend.getFontLib())
glyphMap = await sourceBackend.getGlyphMap()
glyphNamesInFont = set(glyphMap)
glyphNamesToCopy = sorted(
Expand Down
6 changes: 5 additions & 1 deletion src/fontra/backends/designspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,11 @@ async def getUnitsPerEm(self):
return self.defaultFontInfo.unitsPerEm

async def getFontLib(self):
return self.dsDoc.lib
return deepcopy(self.dsDoc.lib)

async def putFontLib(self, lib):
self.dsDoc.lib = deepcopy(lib)
self.dsDoc.write(self.dsDoc.path)

async def watchExternalChanges(self):
ufoPaths = sorted(set(self.ufoLayers.iterAttrs("path")))
Expand Down
6 changes: 5 additions & 1 deletion src/fontra/backends/fontra.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ async def putGlobalAxes(self, axes):
self._scheduler.schedule(self._writeFontData)

async def getFontLib(self):
return {}
return deepcopy(self.fontData.lib)

async def putFontLib(self, lib):
self.fontData.lib = deepcopy(lib)
self._scheduler.schedule(self._writeFontData)

def _readGlyphInfo(self):
with open(self.glyphInfoPath, "r", encoding="utf-8") as file:
Expand Down

0 comments on commit 4525fe1

Please sign in to comment.