Fonttools: How to get font timestamp using fonttools?

Created on 25 Dec 2019  路  4Comments  路  Source: fonttools/fonttools

Hello.
How to get the values of "created" and "modified" using Python and fonttools?

  <head>
    <!-- Most of this table will be recalculated by the compiler -->
    <tableVersion value="1.0"/>
    <fontRevision value="4.0"/>
    <checkSumAdjustment value="0x160025c"/>
    <magicNumber value="0x5f0f3cf5"/>
    <flags value="00000000 00001011"/>
    <unitsPerEm value="1000"/>
    <created value="Thu Jul 25 11:21:21 2013"/>
    <modified value="Thu Apr  5 15:06:34 2018"/>
    <xMin value="-166"/>
    <yMin value="-248"/>
    <xMax value="1085"/>
    <yMax value="973"/>
    <macStyle value="00000000 00000001"/>
    <lowestRecPPEM value="9"/>
    <fontDirectionHint value="2"/>
    <indexToLocFormat value="0"/>
    <glyphDataFormat value="0"/>
  </head>

Thanks in advance for your reply!

All 4 comments

from fontTools.ttLib import TTFont
f = TTFont('path/to/my/font.otf')
print(f['head'].modified)

Thank you, but this way gives the answer - "3605785594"
If we convert it to a "human-readable date", we get "Wed Apr 5 15:06:34 2084".
Date in ttx file - "Thu Apr 5 15:06:34 2018"
Maybe you know why the year is different? (2084 vs 2018)?

Many thanks, Justvanrossum!
For your programs and for your help. You are a great man!
Happy New Year!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cjdunn picture cjdunn  路  11Comments

behdad picture behdad  路  5Comments

laerm0 picture laerm0  路  8Comments

justvanrossum picture justvanrossum  路  9Comments

khaledhosny picture khaledhosny  路  11Comments