From 68d799364579c9552874293f034a22c0efef98a9 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 11 May 2013 13:08:35 +0200 Subject: add controls for font cache to ``luaotfload-tool.lua`` --- luaotfload-tool.lua | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 93d6acf..89d3f78 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -171,6 +171,12 @@ The font database will be saved to %s %s +------------------------------------------------------------------------------- + FONT CACHE + + --cache= operate on font cache, where is + “show”, “purge”, or “erase” + ]], mkluatexfontdb = [[ @@ -246,7 +252,8 @@ set. --]]-- local action_sequence = { - "loglevel", "help", "version", "flush", "generate", "list", "query" + "loglevel", "help", "version", "cache", + "flush", "generate", "list", "query", } local action_pending = table.tohash(action_sequence, false) @@ -290,13 +297,32 @@ actions.flush = function (job) if success then local success = names.save_lookups() if success then - logs.names_report("info", 2, "cache", "Cache emptied") + logs.names_report("info", 2, "cache", "Lookup cache emptied") return true, true end end return false, false end +local cache_directives = { + ["purge"] = names.purge_cache, + ["erase"] = names.erase_cache, + ["show"] = names.show_cache, +} + +actions.cache = function (job) + local directive = cache_directives[job.cache] + if not directive or type(directive) ~= "function" then + logs.names_report("info", 2, "cache", + "Invalid font cache directive %s.", job.cache) + return false, false + end + if directive() then + return true, true + end + return false, false +end + actions.query = function (job) local query = job.query @@ -508,6 +534,7 @@ local process_cmdline = function ( ) -- unit -> jobspec local long_options = { alias = 1, + cache = 1, ["flush-cache"] = "c", fields = 1, find = 1, @@ -580,6 +607,9 @@ local process_cmdline = function ( ) -- unit -> jobspec result.criterion = optarg[n] elseif v == "fields" then result.asked_fields = optarg[n] + elseif v == "cache" then + action_pending["cache"] = true + result.cache = optarg[n] end end -- cgit v1.2.3