From 497863a190b70a51e9f6c8013e19e2424a69acfb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 1 May 2014 15:13:22 -0700 Subject: Allow disabling 'head' table modified-timestamp recalculation Part of: https://github.com/behdad/fonttools/issues/115 https://github.com/behdad/fonttools/issues/46 --- Lib/fontTools/ttLib/__init__.py | 6 +++++- Lib/fontTools/ttLib/tables/_h_e_a_d.py | 3 ++- 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 -- cgit v1.2.3