I notice that when using UFOWriter (aka UFOReaderWriter) on an existing UFO, it unconditionally rewrites the metainfo.plist file. This can cause formatting differences (for example: source files uses tabs, ufoLib writes spaces).
(Context: Fontra is using UFOReaderWriter. When opening a UFO, it can not know whether the user will maybe edit things. The goal is to not touch anything unless the user makes an edit.)
The following would fix it, but is perhaps too naive: the meta info may need updating if we're upgrading from an older format?
diff --git a/Lib/fontTools/ufoLib/__init__.py b/Lib/fontTools/ufoLib/__init__.py
index b0e425ff0..48617b24d 100755
--- a/Lib/fontTools/ufoLib/__init__.py
+++ b/Lib/fontTools/ufoLib/__init__.py
@@ -1102,8 +1102,9 @@ class UFOWriter(UFOReader):
# imply the layer contents
if self.fs.exists(DEFAULT_GLYPHS_DIRNAME):
self.layerContents = {DEFAULT_LAYER_NAME: DEFAULT_GLYPHS_DIRNAME}
- # write the new metainfo
- self._writeMetaInfo()
+ if not self._havePreviousFile:
+ # write the new metainfo
+ self._writeMetaInfo()
# properties
I notice that when using
UFOWriter(akaUFOReaderWriter) on an existing UFO, it unconditionally rewrites the metainfo.plist file. This can cause formatting differences (for example: source files uses tabs, ufoLib writes spaces).(Context: Fontra is using
UFOReaderWriter. When opening a UFO, it can not know whether the user will maybe edit things. The goal is to not touch anything unless the user makes an edit.)The following would fix it, but is perhaps too naive: the meta info may need updating if we're upgrading from an older format?