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 From c605e2ed0b7d9e91cd9ebfd47adad6ebf99ef6e0 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 11 May 2013 13:11:25 +0200 Subject: rename option ``--flush-cache`` -> ``--flush-lookups`` to avoid confusion with cache control --- luaotfload-tool.lua | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 89d3f78..7baeafd 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -155,7 +155,7 @@ This tool is part of the luaotfload package. Valid options are: -u --update update the database -f --force force re-indexing all fonts - -c --flush-cache empty cache of font requests + -l --flush-lookups empty lookup cache of font requests --find="font name" query the database for a font name -F --fuzzy look for approximate matches if --find fails @@ -533,25 +533,25 @@ local process_cmdline = function ( ) -- unit -> jobspec } local long_options = { - alias = 1, - cache = 1, - ["flush-cache"] = "c", - fields = 1, - find = 1, - force = "f", - fuzzy = "F", - help = "h", - info = "i", - limit = 1, - list = 1, - log = 1, - quiet = "q", - update = "u", - verbose = 1 , - version = "V", + alias = 1, + cache = 1, + ["flush-lookups"] = "l", + fields = 1, + find = 1, + force = "f", + fuzzy = "F", + help = "h", + info = "i", + limit = 1, + list = 1, + log = 1, + quiet = "q", + update = "u", + verbose = 1 , + version = "V", } - local short_options = "cfFiquvVh" + local short_options = "lfFiquvVh" local options, _, optarg = alt_getopt.get_ordered_opts (arg, short_options, long_options) @@ -600,7 +600,7 @@ local process_cmdline = function ( ) -- unit -> jobspec result.show_info = true elseif v == "alias" then config.luaotfload.self = optarg[n] - elseif v == "c" then + elseif v == "l" then action_pending["flush"] = true elseif v == "list" then action_pending["list"] = true -- cgit v1.2.3 From 7b1ed699d2d798b693413f9dcc8bd7dde73f839c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 11 May 2013 13:34:56 +0200 Subject: rename ``flush_cache`` -> ``flush_lookup_cache`` --- luaotfload-tool.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 7baeafd..2942782 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -293,7 +293,7 @@ actions.generate = function (job) end actions.flush = function (job) - local success, lookups = names.flush_cache() + local success, lookups = names.flush_lookup_cache() if success then local success = names.save_lookups() if success then -- cgit v1.2.3 From 3c7d3b4817ea273b48f15e556c5978765a7b981d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 11 May 2013 14:10:56 +0200 Subject: implement ``--dry-run`` for filesystem tracing --- luaotfload-tool.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 2942782..686a343 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -282,7 +282,7 @@ end actions.generate = function (job) local fontnames, savedname - fontnames = names.update(fontnames, job.force_reload) + fontnames = names.update(fontnames, job.force_reload, job.dry_run) logs.names_report("info", 2, "db", "Fonts in the database: %i", #fontnames.mappings) local success = names.save(fontnames) @@ -535,6 +535,7 @@ local process_cmdline = function ( ) -- unit -> jobspec local long_options = { alias = 1, cache = 1, + ["dry-run"] = "D", ["flush-lookups"] = "l", fields = 1, find = 1, @@ -551,7 +552,7 @@ local process_cmdline = function ( ) -- unit -> jobspec version = "V", } - local short_options = "lfFiquvVh" + local short_options = "DfFilquvVh" local options, _, optarg = alt_getopt.get_ordered_opts (arg, short_options, long_options) @@ -610,6 +611,8 @@ local process_cmdline = function ( ) -- unit -> jobspec elseif v == "cache" then action_pending["cache"] = true result.cache = optarg[n] + elseif v == "D" then + result.dry_run = true end end -- cgit v1.2.3 From fb445efa901ca24160bfe79d59f535b767ffa408 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 11 May 2013 14:11:37 +0200 Subject: add ``--dry-run`` to usage info --- luaotfload-tool.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 686a343..882a296 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -156,6 +156,7 @@ This tool is part of the luaotfload package. Valid options are: -u --update update the database -f --force force re-indexing all fonts -l --flush-lookups empty lookup cache of font requests + -D --dry-run skip loading of fonts, just scan --find="font name" query the database for a font name -F --fuzzy look for approximate matches if --find fails -- cgit v1.2.3