summaryrefslogtreecommitdiff
path: root/luaotfload-database.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-11-03 19:30:46 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2013-11-03 19:30:46 +0100
commit5e5f8de85320ba0ed005fc1676e6df4d877845df (patch)
treebeb24e36b63332f2cb41ad0cb515d50963528cf2 /luaotfload-database.lua
parent31abae6c9f15d75bf0b09be212eef35ae124b4a8 (diff)
downloadluaotfload-5e5f8de85320ba0ed005fc1676e6df4d877845df.tar.gz
[db,tool] add --compress option for gzipping the index
Diffstat (limited to 'luaotfload-database.lua')
-rw-r--r--luaotfload-database.lua17
1 files changed, 15 insertions, 2 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)