SVG: strip timestamp to make compressed gzip reproducible
we tell GzipFile to write the MTIME field to zero so that the compressed output is reproducible and doesn't change depending on when the data is compressed.
This commit is contained in:
parent
8673073a87
commit
119b7732cc
@ -110,7 +110,9 @@ class table_S_V_G_(DefaultTable.DefaultTable):
|
||||
if (allCompressed or doc.compressed) and not docBytes.startswith(b"\x1f\x8b"):
|
||||
import gzip
|
||||
bytesIO = BytesIO()
|
||||
with gzip.GzipFile(None, "w", fileobj=bytesIO) as gzipper:
|
||||
# mtime=0 strips the useless timestamp and makes gzip output reproducible;
|
||||
# equivalent to `gzip -n`
|
||||
with gzip.GzipFile(None, "w", fileobj=bytesIO, mtime=0) as gzipper:
|
||||
gzipper.write(docBytes)
|
||||
gzipped = bytesIO.getvalue()
|
||||
if len(gzipped) < len(docBytes):
|
||||
|
@ -16,7 +16,7 @@ def dump(table, ttFont=None):
|
||||
|
||||
def compress(data: bytes) -> bytes:
|
||||
buf = io.BytesIO()
|
||||
with gzip.GzipFile(None, "w", fileobj=buf) as gz:
|
||||
with gzip.GzipFile(None, "w", fileobj=buf, mtime=0) as gz:
|
||||
gz.write(data)
|
||||
return buf.getvalue()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user