8000 [ttx] add --no-recalc-timestamp option to keep original head.modified by anthrotype · Pull Request #1455 · fonttools/fonttools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[ttx] add --no-recalc-timestamp option to keep original head.modified #1455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Lib/fontTools/ttx.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
file as-is.
--recalc-timestamp Set font 'modified' timestamp to current time.
By default, the modification time of the TTX file will be used.
--no-recalc-timestamp Keep the original font 'modified' timestamp.
--flavor <type> Specify flavor of output font file. May be 'woff'
or 'woff2'. Note that WOFF2 requires the Brotli Python extension,
available at https://github.com/google/brotli
Expand Down Expand Up @@ -123,7 +124,7 @@ class Options(object):
bitmapGlyphDataFormat = 'raw'
unicodedata = None
newlinestr = None
recalcTimestamp = False
recalcTimestamp = None
flavor = None
useZopfli = False

Expand Down Expand Up @@ -204,6 +205,8 @@ def __init__(self, rawOptions, numFiles):
% (value, ", ".join(map(repr, validOptions))))
elif option == "--recalc-timestamp":
self.recalcTimestamp = True
elif option == "--no-recalc-timestamp":
self.recalcTimestamp = False
elif option == "--flavor":
self.flavor = value
elif option == "--with-zopfli":
Expand Down Expand Up @@ -282,7 +285,7 @@ def ttCompile(input, output, options):
allowVID=options.allowVID)
ttf.importXML(input)

if not options.recalcTimestamp and 'head' in ttf:
if options.recalcTimestamp is None and 'head' in ttf:
# use TTX file modification time for head "modified" timestamp
mtime = os.path.getmtime(input)
ttf['head'].modified = timestampSinceEpoch(mtime)
Expand Down
13 changes: 13 additions & 0 deletions Tests/ttx/ttx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ def test_options_recalc_timestamp():
assert tto.recalcTimestamp is True


def test_options_recalc_timestamp():
tto = ttx.Options([("--no-recalc-timestamp", "")], 1)
assert tto.recalcTimestamp is False


def test_options_flavor():
tto = ttx.Options([("--flavor", "woff")], 1)
assert tto.flavor == "woff"
Expand Down Expand Up @@ -789,6 +794,14 @@ def test_ttcompile_timestamp_calcs(inpath, outpath1, outpath2, tmpdir):
ttf = TTFont(str(outttf2))
assert ttf["head"].modified > epochtime

# --no-recalc-timestamp will keep original timestamp
options.recalcTimestamp = False
ttx.ttCompile(inttx, str(outttf2), options)
assert outttf2.check(file=True)
inttf = TTFont()
inttf.importXML(inttx)
assert inttf["head"].modified == TTFont(str(outttf2))["head"].modified


# -------------------------
# ttx.ttList function tests
Expand Down
0