Clone in a terminal:
Commit 89859fc
Johan Mattsson - 2014-04-02T11:37:09+00:00
89859fc284b4ee47ebbe028932965f215d75f2d8johan.mattsson.m@gmail.com

Fix creation and modification time in TTF fonts

Changed files (2)

Diff

diff --git a/libbirdfont/OpenFontFormat/FontData.vala b/libbirdfont/OpenFontFormat/FontData.valaindex ff498b4..cdd49fc 100644--- a/libbirdfont/OpenFontFormat/FontData.vala+++ b/libbirdfont/OpenFontFormat/FontData.vala@@ -1,5 +1,5 @@ /*-    Copyright (C) 2012, 2013 Johan Mattsson+    Copyright (C) 2012, 2013, 2014 Johan Mattsson      This library is free software; you can redistribute it and/or modify      it under the terms of the GNU Lesser General Public License as @@ -335,12 +335,12 @@ public class FontData : Object { 		add_u16 ((uint16) s); 		add_u16 ((uint16) (i - (s << 16))); 	}--	public void add_64(int64 i) {-		int64 s = (int32) (i >> 32);+	+	public void add_u64(uint64 i) {+		uint64 s = (uint32) (i >> 32); 		-		add_u32 ((int32) s);-		add_u32 ((int32)(i - (s << 32)));		+		add_u32 ((uint32) s);+		add_u32 ((uint32)(i - (s << 32))); 	} 	 	public void add_str_littleendian_utf16 (string s) {diff --git a/libbirdfont/OpenFontFormat/HeadTable.vala b/libbirdfont/OpenFontFormat/HeadTable.valaindex 9adfc71..ed68776 100644--- a/libbirdfont/OpenFontFormat/HeadTable.vala+++ b/libbirdfont/OpenFontFormat/HeadTable.vala@@ -160,6 +160,8 @@ public class HeadTable : Table { 		FontData font_data = new FontData (); 		Fixed version = 1 << 16; 		Fixed font_revision = 1 << 16;+		uint64 time = (uint64) Math.rint (GLib.get_real_time () / 1000000.0);+		const uint64 time_diff = 60 * 60 * 24 * (365 * (1970 - 1904) + 17); // FIXME: add leap seconds  		font_data.add_fixed (version); 		font_data.add_fixed (font_revision);@@ -175,8 +177,8 @@ public class HeadTable : Table { 		 		font_data.add_u16 (units_per_em); // units per em (should be a power of two for ttf fonts) 		-		font_data.add_64 (0); // creation time since 1904-01-01-		font_data.add_64 (0); // modified time since 1904-01-01+		font_data.add_u64 (time + time_diff); // creation time since 1901-01-01+		font_data.add_u64 (time + time_diff); // modified time since 1901-01-01  		xmin = glyf_table.xmin; 		ymin = glyf_table.ymin;

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112