aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2014-05-01 15:13:22 -0700
committerBehdad Esfahbod <behdad@behdad.org>2014-05-01 15:13:22 -0700
commit497863a190b70a51e9f6c8013e19e2424a69acfb (patch)
tree85179962a3596ccbfe5032903cb3a5ebc057824d
parent14f13a993eda70fd97e415cc9a043d5d2416c187 (diff)
downloadfonttools-497863a190b70a51e9f6c8013e19e2424a69acfb.tar.gz
Allow disabling 'head' table modified-timestamp recalculation
Part of: https://github.com/behdad/fonttools/issues/115 https://github.com/behdad/fonttools/issues/46
-rw-r--r--Lib/fontTools/ttLib/__init__.py6
-rw-r--r--Lib/fontTools/ttLib/tables/_h_e_a_d.py3
2 files changed, 7 insertions, 2 deletions
diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py
index 732aa520..9879a4e1 100644
--- a/Lib/fontTools/ttLib/__init__.py
+++ b/Lib/fontTools/ttLib/__init__.py
@@ -72,7 +72,7 @@ class TTFont(object):
def __init__(self, file=None, res_name_or_index=None,
sfntVersion="\000\001\000\000", flavor=None, checkChecksums=False,
verbose=False, recalcBBoxes=True, allowVID=False, ignoreDecompileErrors=False,
- fontNumber=-1, lazy=False, quiet=False):
+ recalcTimestamp=True, fontNumber=-1, lazy=False, quiet=False):
"""The constructor can be called with a few different arguments.
When reading a font from disk, 'file' should be either a pathname
@@ -106,6 +106,9 @@ class TTFont(object):
greatly, and therefore should have some impact on the time needed
to parse/compile large fonts.
+ If the recalcTimestamp argument is false, the modified timestamp in the
+ 'head' table will *not* be recalculated upon save/compile.
+
If the allowVID argument is set to true, then virtual GID's are
supported. Asking for a glyph ID with a glyph name or GID that is not in
the font will return a virtual GID. This is valid for GSUB and cmap
@@ -130,6 +133,7 @@ class TTFont(object):
self.quiet = quiet
self.lazy = lazy
self.recalcBBoxes = recalcBBoxes
+ self.recalcTimestamp = recalcTimestamp
self.tables = {}
self.reader = None
diff --git a/Lib/fontTools/ttLib/tables/_h_e_a_d.py b/Lib/fontTools/ttLib/tables/_h_e_a_d.py
index 97dd1a7c..bf4116db 100644
--- a/Lib/fontTools/ttLib/tables/_h_e_a_d.py
+++ b/Lib/fontTools/ttLib/tables/_h_e_a_d.py
@@ -39,7 +39,8 @@ class table__h_e_a_d(DefaultTable.DefaultTable):
assert rest == "\0\0"
def compile(self, ttFont):
- self.modified = int(time.time() - mac_epoch_diff)
+ if ttFont.recalcTimestamp:
+ self.modified = int(time.time() - mac_epoch_diff)
data = sstruct.pack(headFormat, self)
return data