diff --git a/Doc/documentation.html b/Doc/documentation.html index 23dfefa5d..e2821fe6e 100644 --- a/Doc/documentation.html +++ b/Doc/documentation.html @@ -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:
-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 vmtxOther tables are dumped as hexadecimal data. diff --git a/Lib/fontTools/ttLib/tables/F_F_T_M_.py b/Lib/fontTools/ttLib/tables/F_F_T_M_.py new file mode 100644 index 000000000..e8b1d29bf --- /dev/null +++ b/Lib/fontTools/ttLib/tables/F_F_T_M_.py @@ -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) \ No newline at end of file diff --git a/Lib/fontTools/ttLib/tables/__init__.py b/Lib/fontTools/ttLib/tables/__init__.py index e1eacc057..bdf8d9662 100644 --- a/Lib/fontTools/ttLib/tables/__init__.py +++ b/Lib/fontTools/ttLib/tables/__init__.py @@ -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_