Hack icon indicating copy to clipboard operation
Hack copied to clipboard

Source cleanliness: remove com.schriftgestaltung.Glyphs.lastChange glyph lib keys

Open madig opened this issue 7 years ago • 5 comments

These are just noise if you're using Git. You can keep Glyphs from inserting them by setting the "Disable Last Change" parameter in the font or inserting the com.schriftgestaltung.customParameter.GSFont.lastChange lib key.

madig avatar Oct 24 '18 22:10 madig

I got this far on automated removal of this glif file library key across all source files and need some guidance on an appropriate pointPen to use in order to capture the contours for the write back to the *.glif source. Thoughts?

from ufoLib import UFOReader


class GlyphObj(object):
    def __init__(self):
        pass

ufo = UFOReader("Test-Regular.ufo")
glyphset = ufo.getGlyphSet()

for glyphname in glyphset.contents:
    gobj = GlyphObj()
    glyph = glyphset.readGlyph(glyphname, gobj, POINTPEN) # <--- HERE

    if hasattr(gobj, "lib"):
        gobj.lib.pop("com.schriftgestaltung.Glyphs.lastChange", None)
        glyphset.writeGlyph(glyphname, gobj, POINTPEN) # <--- AND HERE

chrissimpkins avatar Oct 25 '18 02:10 chrissimpkins

And by the following comment:

inserting the com.schriftgestaltung.customParameter.GSFont.lastChange lib key.

what do you set this key to in order to eliminate Glyphs app time stamps of the *.glif files?

chrissimpkins avatar Oct 25 '18 02:10 chrissimpkins

Try

from pathlib import Path
import defcon

for ufo in Path("src").glob("*.ufo"):
    u = defcon.Font(ufo)
    u.lib["com.schriftgestaltung.customParameter.GSFont.lastChange"] = False
    for layer in u.layers:
        for glyph in layer:
            if "com.schriftgestaltung.Glyphs.lastChange" in glyph.lib:
                del glyph.lib["com.schriftgestaltung.Glyphs.lastChange"]

madig avatar Oct 25 '18 09:10 madig

Thank you!

chrissimpkins avatar Oct 25 '18 11:10 chrissimpkins

Round-trip through Glyphs.app to make sure stuff doesn't sneak back in.

madig avatar Oct 25 '18 11:10 madig