Skip to content

Commit 96f025c

Browse files
authored
Merge pull request #76 from rimas-kudelis/feat/add-common-lib-keys
Extract two common lib info keys
2 parents b3ccaba + 1b48adc commit 96f025c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Lib/extractor/formats/opentype.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ def extractOpenTypeInfo(source, destination):
246246
_extractInfoPost(source, info)
247247
_extractInfoCFF(source, info)
248248
_extractInfoGasp(source, info)
249+
_extractLibInfo(source, destination.lib)
249250

250251

251252
def _extractInfoHead(source, info):
@@ -258,10 +259,7 @@ def _extractInfoHead(source, info):
258259
# upm
259260
info.unitsPerEm = head.unitsPerEm
260261
# created
261-
format = "%Y/%m/%d %H:%M:%S"
262-
created = head.created
263-
created = time.gmtime(max(0, created + mac_epoch_diff))
264-
info.openTypeHeadCreated = time.strftime(format, created)
262+
info.openTypeHeadCreated = formatDate(head.created)
265263
# lowestRecPPEM
266264
info.openTypeHeadLowestRecPPEM = head.lowestRecPPEM
267265
# flags
@@ -517,6 +515,13 @@ def _extractInfoGasp(source, info):
517515
info.openTypeGaspRangeRecords = records
518516

519517

518+
def _extractLibInfo(source, lib):
519+
head = source["head"]
520+
lib["public.openTypeHeadModified"] = formatDate(head.modified)
521+
post = source["post"]
522+
lib["public.openTypePostUnderlinePosition"] = post.underlinePosition
523+
524+
520525
# Tools
521526

522527

@@ -531,6 +536,12 @@ def binaryToIntList(value, start=0):
531536
return intList
532537

533538

539+
def formatDate(date):
540+
format = "%Y/%m/%d %H:%M:%S"
541+
date = time.gmtime(max(0, date + mac_epoch_diff))
542+
return time.strftime(format, date)
543+
544+
534545
# --------
535546
# Outlines
536547
# --------

0 commit comments

Comments
 (0)