Skip to content

Commit

Permalink
Extract two common lib info keys
Browse files Browse the repository at this point in the history
  • Loading branch information
rimas-kudelis committed Oct 10, 2024
1 parent b3ccaba commit 1b48adc
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Lib/extractor/formats/opentype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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


Expand All @@ -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
# --------
Expand Down

0 comments on commit 1b48adc

Please sign in to comment.