Skip to content

Commit

Permalink
Merge pull request #95 from rimas-kudelis/feat-configurable-timestamp…
Browse files Browse the repository at this point in the history
…-updates

Allow to toggle off updating of `openTypeHeadCreated` when other changes occur.
(Note the workflow test failures are unrelated to this merge and so will be looked at separately)
  • Loading branch information
DavidRaymond authored Sep 27, 2024
2 parents e9a3693 + 5dd35c3 commit e99b1de
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Currently only font output parameters can be changed via lib.plist
| plistIndentFirst | Empty string | Different initial indent for plists | (dict is commonly not indented) |
| sortDicts | True | sort all plist dicts | |
| precision | 6 | decimal precision | |
| updateTimestamps | True | Update font timestamps if other changes occur | Controls handling of the `openTypeHeadCreated` field in UFO fontinfo. |
| renameGlifs | True | Name glifs with standard algorithm | |
| UFOversion | (existing) | | Defaults to the version of the UFO when opened |
| format1Glifs | False| Force output of format 1 glifs | Includes UFO2-style anchors; for use with FontForge |
Expand Down
2 changes: 2 additions & 0 deletions src/silfont/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def __init__(self):
("indentML", False), # Should multi-line string values be indented?
("plistIndentFirst", ""), # First indent amount for plists
('precision', 6), # Decimal precision to use in XML output - both for real values and for attributes if float
("updateTimestamps", True), # Update the value of openTypeHeadCreated field in fontinfo.plist if other changes occur
("floatAttribs", ['xScale', 'xyScale', 'yxScale', 'yScale', 'angle']), # Used with precision above
("intAttribs", ['pos', 'width', 'height', 'xOffset', 'yOffset', 'x', 'y']),
("sortDicts", True), # Should dict elements be sorted alphabetically?
Expand Down Expand Up @@ -117,6 +118,7 @@ def __init__(self):
"plistIndentFirst": "First indent amount for plists",
"sortDicts": "Should dict elements be sorted alphabetically?",
"precision": "Decimal precision to use in XML output - both for real values and for attributes if numeric",
"updateTimestamps": "Should font timestamps be updated if other changes occur",
"renameGlifs": "Rename glifs based on UFO3 suggested algorithm",
"UFOversion": "UFOversion to output - defaults to version of the input UFO",
"format1Glifs": "Force output format 1 glifs including UFO2-style anchors (was used with FontForge; no longer needed)",
Expand Down
4 changes: 3 additions & 1 deletion src/silfont/scripts/psfmakewoffmetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def doit(args):
xmlstring += '</array></dict>'
fi.setelem("woffMetadataCredits", ET.fromstring(xmlstring))

fi.setval("openTypeHeadCreated", "string", datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S"))
if font.outparams["updateTimestamps"]:
fi.setval("openTypeHeadCreated", "string", datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S"))

logger.log("Writing updated fontinfo.plist with values from FONTLOG.txt", "P")
exists = True if os.path.isfile(os.path.join(font.ufodir, "fontinfo.plist")) else False
UFO.writeXMLobject(fi, font.outparams, font.ufodir, "fontinfo.plist", exists, fobject=True)
Expand Down
6 changes: 4 additions & 2 deletions src/silfont/scripts/psfsyncmasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def doit(args) :
fipval[field] = pval
if reqmissing: logger.log("Required fontinfo fields missing from " + psource.source.filename, "S")
if changes:
psource.fontinfo.setval("openTypeHeadCreated", "string",
if psource.outparams["updateTimestamps"]:
psource.fontinfo.setval("openTypeHeadCreated", "string",
datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S"))
psource.write("fontinfo")

Expand Down Expand Up @@ -200,7 +201,8 @@ def doit(args) :
dsource.write("lib")
fchanges = True # Force fontinfo to update so openTypeHeadCreated is set
if fchanges:
dsource.fontinfo.setval("openTypeHeadCreated", "string",
if dsource.outparams["updateTimestamps"]:
dsource.fontinfo.setval("openTypeHeadCreated", "string",
datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S"))
dsource.write("fontinfo")

Expand Down
2 changes: 1 addition & 1 deletion src/silfont/ufo.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def write(self, outdir):
self.logger.log("Writing font to " + outdir, "P")

changes = writeToDisk(dtree, outdir, self, odtree)
if changes: # Need to update openTypeHeadCreated if there have been any changes to the font
if changes and self.outparams["updateTimestamps"]: # Need to update openTypeHeadCreated if there have been any changes to the font
if "fontinfo" in self.__dict__:
self.fontinfo.setval("openTypeHeadCreated", "string",
datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S"))
Expand Down

0 comments on commit e99b1de

Please sign in to comment.