#!/usr/bin/env python __doc__ = '''Sync metadata across a family of fonts assuming standard UFO file naming''' __url__ = 'http://github.com/silnrsi/pysilfont' __copyright__ = 'Copyright (c) 2017 SIL International (http://www.sil.org)' __license__ = 'Released under the MIT License (http://opensource.org/licenses/MIT)' __author__ = 'David Raymond' from silfont.core import execute from datetime import datetime import silfont.ufo as UFO import os from xml.etree import ElementTree as ET argspec = [ ('ifont',{'help': 'Input font file'}, {'type': 'infont'}), ('-l','--log',{'help': 'Log file'}, {'type': 'outfile', 'def': '_sync.log'}), ('-s','--single', {'help': 'Sync single UFO against master', 'action': 'store_true', 'default': False},{}), ('-m','--master', {'help': 'Master UFO to sync single UFO against', 'nargs': '?' },{'type': 'infont', 'def': None}), ('-r','--reportonly', {'help': 'Report issues but no updating', 'action': 'store_true', 'default': False},{}), ('-n','--new', {'help': 'append "_new" to file/ufo names', 'action': 'store_true', 'default': False},{}), ('--normalize', {'help': 'output all the fonts to normalize them', 'action': 'store_true', 'default': False},{}), ] def doit(args) : standardstyles = ["Regular", "Italic", "Bold", "BoldItalic"] finfoignore = ["openTypeHeadCreated", "openTypeOS2Panose", "postscriptBlueScale", "postscriptBlueShift", "postscriptBlueValues", "postscriptOtherBlues", "postscriptStemSnapH", "postscriptStemSnapV", "postscriptForceBold"] libfields = ["public.postscriptNames", "public.glyphOrder", "com.schriftgestaltung.glyphOrder"] font = args.ifont logger = args.logger singlefont = args.single mfont = args.master newfile = "_new" if args.new else "" reportonly = args.reportonly updatemessage = " to be updated: " if reportonly else " updated: " params = args.paramsobj precision = font.paramset["precision"] # Increase screen logging level to W unless specific level supplied on command-line if not(args.quiet or "scrlevel" in params.sets["command line"]) : logger.scrlevel = "W" # Process UFO name (path,base) = os.path.split(font.ufodir) (base,ext) = os.path.splitext(base) if '-' not in base : logger.log("Non-standard UFO name - must be -