From 1b48adce7059e2dc8253c3830284da6e19c8c1ee Mon Sep 17 00:00:00 2001 From: Rimas Kudelis Date: Thu, 10 Oct 2024 23:30:51 +0300 Subject: [PATCH] Extract two common lib info keys --- Lib/extractor/formats/opentype.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Lib/extractor/formats/opentype.py b/Lib/extractor/formats/opentype.py index 88f7600..f32c16e 100644 --- a/Lib/extractor/formats/opentype.py +++ b/Lib/extractor/formats/opentype.py @@ -246,6 +246,7 @@ def extractOpenTypeInfo(source, destination): _extractInfoPost(source, info) _extractInfoCFF(source, info) _extractInfoGasp(source, info) + _extractLibInfo(source, destination.lib) def _extractInfoHead(source, info): @@ -258,10 +259,7 @@ def _extractInfoHead(source, info): # upm info.unitsPerEm = head.unitsPerEm # created - format = "%Y/%m/%d %H:%M:%S" - created = head.created - created = time.gmtime(max(0, created + mac_epoch_diff)) - info.openTypeHeadCreated = time.strftime(format, created) + info.openTypeHeadCreated = formatDate(head.created) # lowestRecPPEM info.openTypeHeadLowestRecPPEM = head.lowestRecPPEM # flags @@ -517,6 +515,13 @@ def _extractInfoGasp(source, info): info.openTypeGaspRangeRecords = records +def _extractLibInfo(source, lib): + head = source["head"] + lib["public.openTypeHeadModified"] = formatDate(head.modified) + post = source["post"] + lib["public.openTypePostUnderlinePosition"] = post.underlinePosition + + # Tools @@ -531,6 +536,12 @@ def binaryToIntList(value, start=0): return intList +def formatDate(date): + format = "%Y/%m/%d %H:%M:%S" + date = time.gmtime(max(0, date + mac_epoch_diff)) + return time.strftime(format, date) + + # -------- # Outlines # --------