diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-05-11 13:08:35 +0200 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-05-11 13:08:35 +0200 |
commit | 68d799364579c9552874293f034a22c0efef98a9 (patch) | |
tree | d49a63dc2a31e1da1fa73894414a982cd63cca83 /luaotfload-tool.lua | |
parent | 8cc3ffd76e9b920f8adb9673fe88196ef7e4f8fb (diff) | |
download | luaotfload-68d799364579c9552874293f034a22c0efef98a9.tar.gz |
add controls for font cache to ``luaotfload-tool.lua``
Diffstat (limited to 'luaotfload-tool.lua')
-rwxr-xr-x | luaotfload-tool.lua | 34 |
1 files changed, 32 insertions, 2 deletions
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=<directive> operate on font cache, where <directive> 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 |