Source: ufo2ft
Version: 1.1.0-1
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: toolchain timestamps
X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0], we noticed
that ufo2ft generates .otf files that are not reproducible.

For example, here is showotf output of fonts-league-spartan:

│ │ │ │ │  HEAD table (at 188)
│ │ │ │ │       Version=1
│ │ │ │ │       fontRevision=2
│ │ │ │ │ -     checksumAdj=e32dbbe4
│ │ │ │ │ +     checksumAdj=e3309724
│ │ │ │ │       magicNumber=5f0f3cf5 (0x5f0f3cf5, diff=0)
│ │ │ │ │       flags=3 baseline_at_0 lsb_at_0 
│ │ │ │ │       unitsPerEm=1250
│ │ │ │ │       create[0]=0
│ │ │ │ │ -      create[1]=d580d7b0
│ │ │ │ │ -     File created: Tue Jul  4 05:27:12 2017
│ │ │ │ │ +      create[1]=d57f6a10
│ │ │ │ │ +     File created: Mon Jul  3 03:27:12 2017

… which shows that it varies on the timezone.

Patch attached:

  --- a/Lib/ufo2ft/fontInfoData.py
  +++ b/Lib/ufo2ft/fontInfoData.py
  @@ -13,6 +13,7 @@ used externally as well.
   
   from __future__ import print_function, division, absolute_import, 
unicode_literals
   
  +import datetime
   import logging
   import math
   import time
  @@ -516,7 +517,8 @@ def intListToNum(intList, start, length):
   
   def dateStringToTimeValue(date):
       try:
  -        t = time.strptime(date, "%Y/%m/%d %H:%M:%S")
  -        return int(time.mktime(t))
  -    except OverflowError:
  +        dt = datetime.datetime.strptime(date, "%Y/%m/%d %H:%M:%S")
  +        dt = dt.replace(tzinfo=datetime.timezone.utc)
  +        return int(dt.timestamp())
  +    except ValueError:
           return 0


 [0] https://reproducible-builds.org/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      la...@debian.org / chris-lamb.co.uk
       `-
diff --git a/Lib/ufo2ft/fontInfoData.py b/Lib/ufo2ft/fontInfoData.py
index 786823a..a487c62 100644
--- a/Lib/ufo2ft/fontInfoData.py
+++ b/Lib/ufo2ft/fontInfoData.py
@@ -13,6 +13,7 @@ used externally as well.
 
 from __future__ import print_function, division, absolute_import, 
unicode_literals
 
+import datetime
 import logging
 import math
 import time
@@ -516,7 +517,8 @@ def intListToNum(intList, start, length):
 
 def dateStringToTimeValue(date):
     try:
-        t = time.strptime(date, "%Y/%m/%d %H:%M:%S")
-        return int(time.mktime(t))
-    except OverflowError:
+        dt = datetime.datetime.strptime(date, "%Y/%m/%d %H:%M:%S")
+        dt = dt.replace(tzinfo=datetime.timezone.utc)
+        return int(dt.timestamp())
+    except ValueError:
         return 0

Reply via email to