From 5e5f8de85320ba0ed005fc1676e6df4d877845df Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 3 Nov 2013 19:30:46 +0100 Subject: [db,tool] add --compress option for gzipping the index --- luaotfload-database.lua | 17 +++++++++++++++-- luaotfload-tool.lua | 5 ++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index aa1370f..1c694fe 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -31,6 +31,7 @@ local fontloaderinfo = fontloader.info local fontloaderclose = fontloader.close local fontloaderopen = fontloader.open local fontloaderto_table = fontloader.to_table +local gzipsave = gzip.save local iolines = io.lines local ioopen = io.open local kpseexpand_path = kpse.expand_path @@ -83,6 +84,7 @@ local tablecopy = table.copy local tablefastcopy = table.fastcopy local tabletofile = table.tofile local tabletohash = table.tohash +local tableserialize = table.serialize --- the font loader namespace is “fonts”, same as in Context --- we need to put some fallbacks into place for when running @@ -3134,6 +3136,11 @@ save_lookups = function ( ) return false end +local tabletogzip = function (filename, ...) + local serialized = tableserialize(true, ...) + gzipsave (filenmaeserialized) +end + --- save_names() is usually called without the argument --- dbobj? -> bool save_names = function (currentnames) @@ -3143,9 +3150,15 @@ save_names = function (currentnames) local path = names.path.index local luaname, lucname = path.lua, path.luc if fileiswritable (luaname) and fileiswritable (lucname) then - tabletofile (luaname, currentnames, true) osremove (lucname) - caches.compile (currentnames, luaname, lucname) + if luaotfloadconfig.compress then + local serialized = tableserialize (currentnames, true) + gzipsave (luaname, serialized) + caches.compile (currentnames, "", lucname) + else + tabletofile (luaname, currentnames, true) + caches.compile (currentnames, luaname, lucname) + end if lfsisfile (luaname) and lfsisfile (lucname) then report ("info", 1, "db", "Font index saved") report ("info", 3, "db", "Text: " .. luaname) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index e410d44..f2dd98a 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -1065,6 +1065,7 @@ local process_cmdline = function ( ) -- unit -> jobspec local long_options = { alias = 1, cache = 1, + compress = "c", diagnose = 1, ["dry-run"] = "D", ["flush-lookups"] = "l", @@ -1091,7 +1092,7 @@ local process_cmdline = function ( ) -- unit -> jobspec warnings = "w", } - local short_options = "bDfFiIlnpqRSuvVhw" + local short_options = "bcDfFiIlnpqRSuvVhw" local options, _, optarg = alt_getopt.get_ordered_opts (arg, short_options, long_options) @@ -1177,6 +1178,8 @@ local process_cmdline = function ( ) -- unit -> jobspec elseif v == "R" then --- dev only, undocumented luaotfloadconfig.skip_read = true + elseif v == "c" then + luaotfloadconfig.compress = true end end -- cgit v1.2.3