Add support for FontForge time stamp table
Fixes https://github.com/behdad/fonttools/issues/56
This commit is contained in:
parent
10a3fff5cb
commit
871495aff5
@ -42,7 +42,7 @@ When using TTX from the command line there are a bunch of extra options, these a
|
||||
The following tables are currently supported:
|
||||
<BLOCKQUOTE><TT>
|
||||
<!-- begin table list -->
|
||||
BASE, CBDT, CBLC, CFF, COLR, CPAL, DSIG, EBDT, EBLC, GDEF, GMAP, GPKG, GPOS, GSUB, JSTF, LTSH, META, OS/2, SING, SVG, TSI0, TSI1, TSI2, TSI3, TSI5, TSIB, TSID, TSIJ, TSIP, TSIS, TSIV, VORG, cmap, cvt, fpgm, gasp, glyf, hdmx, head, hhea, hmtx, kern, loca, maxp, name, post, prep, sbix, vhea and vmtx
|
||||
BASE, CBDT, CBLC, CFF, COLR, CPAL, DSIG, EBDT, EBLC, FFTM, GDEF, GMAP, GPKG, GPOS, GSUB, JSTF, LTSH, META, OS/2, SING, SVG, TSI0, TSI1, TSI2, TSI3, TSI5, TSIB, TSID, TSIJ, TSIP, TSIS, TSIV, VORG, cmap, cvt, fpgm, gasp, glyf, hdmx, head, hhea, hmtx, kern, loca, maxp, name, post, prep, sbix, vhea and vmtx
|
||||
<!-- end table list -->
|
||||
</TT></BLOCKQUOTE>
|
||||
Other tables are dumped as hexadecimal data.
|
||||
|
46
Lib/fontTools/ttLib/tables/F_F_T_M_.py
Normal file
46
Lib/fontTools/ttLib/tables/F_F_T_M_.py
Normal file
@ -0,0 +1,46 @@
|
||||
from fontTools.misc.py23 import *
|
||||
from fontTools.misc import sstruct
|
||||
from fontTools.misc.textTools import safeEval
|
||||
from ._h_e_a_d import mac_epoch_diff
|
||||
from . import DefaultTable
|
||||
import time
|
||||
import calendar
|
||||
|
||||
FFTMFormat = """
|
||||
> # big endian
|
||||
version: I
|
||||
FFTimeStamp: Q
|
||||
sourceCreated: Q
|
||||
sourceModified: Q
|
||||
"""
|
||||
|
||||
class table_F_F_T_M_(DefaultTable.DefaultTable):
|
||||
|
||||
def decompile(self, data, ttFont):
|
||||
dummy, rest = sstruct.unpack2(FFTMFormat, data, self)
|
||||
|
||||
def compile(self, ttFont):
|
||||
data = sstruct.pack(FFTMFormat, self)
|
||||
return data
|
||||
|
||||
def toXML(self, writer, ttFont):
|
||||
writer.comment("FontForge's timestamp, font source creation and modification dates")
|
||||
writer.newline()
|
||||
formatstring, names, fixes = sstruct.getformat(FFTMFormat)
|
||||
for name in names:
|
||||
value = getattr(self, name)
|
||||
if name in ("FFTimeStamp", "sourceCreated", "sourceModified"):
|
||||
try:
|
||||
value = time.asctime(time.gmtime(max(0, value + mac_epoch_diff)))
|
||||
except ValueError:
|
||||
value = time.asctime(time.gmtime(0))
|
||||
writer.simpletag(name, value=value)
|
||||
writer.newline()
|
||||
|
||||
def fromXML(self, name, attrs, content, ttFont):
|
||||
value = attrs["value"]
|
||||
if name in ("FFTimeStamp", "sourceCreated", "sourceModified"):
|
||||
value = calendar.timegm(time.strptime(value)) - mac_epoch_diff
|
||||
else:
|
||||
value = safeEval(value)
|
||||
setattr(self, name, value)
|
@ -12,6 +12,7 @@ def _moduleFinderHint():
|
||||
from . import D_S_I_G_
|
||||
from . import E_B_D_T_
|
||||
from . import E_B_L_C_
|
||||
from . import F_F_T_M_
|
||||
from . import G_D_E_F_
|
||||
from . import G_M_A_P_
|
||||
from . import G_P_K_G_
|
||||
|
Loading…
x
Reference in New Issue
Block a user