Commit 89859fc
Fix creation and modification time in TTF fonts
Changed files (2)
modifiedlibbirdfont/OpenFontFormat/FontData.valamodifiedlibbirdfont/OpenFontFormat/HeadTable.vala
Diff
@@ -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) {@@ -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;