• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from __future__ import print_function, division, absolute_import
2from fontTools.misc.py23 import *
3from fontTools.misc import sstruct
4from fontTools.misc.textTools import safeEval
5from fontTools.misc.timeTools import timestampFromString, timestampToString
6from . import DefaultTable
7
8FFTMFormat = """
9		>	# big endian
10		version:        I
11		FFTimeStamp:    Q
12		sourceCreated:  Q
13		sourceModified: Q
14"""
15
16class table_F_F_T_M_(DefaultTable.DefaultTable):
17
18	def decompile(self, data, ttFont):
19		dummy, rest = sstruct.unpack2(FFTMFormat, data, self)
20
21	def compile(self, ttFont):
22		data = sstruct.pack(FFTMFormat, self)
23		return data
24
25	def toXML(self, writer, ttFont):
26		writer.comment("FontForge's timestamp, font source creation and modification dates")
27		writer.newline()
28		formatstring, names, fixes = sstruct.getformat(FFTMFormat)
29		for name in names:
30			value = getattr(self, name)
31			if name in ("FFTimeStamp", "sourceCreated", "sourceModified"):
32				value = timestampToString(value)
33			writer.simpletag(name, value=value)
34			writer.newline()
35
36	def fromXML(self, name, attrs, content, ttFont):
37		value = attrs["value"]
38		if name in ("FFTimeStamp", "sourceCreated", "sourceModified"):
39			value = timestampFromString(value)
40		else:
41			value = safeEval(value)
42		setattr(self, name, value)
43