Skip to content

[ufoLib] Needless writing of metainfo.plist #4068

@justvanrossum

Description

@justvanrossum

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions