summaryrefslogtreecommitdiff
path: root/luaotfload-tool.lua
diff options
context:
space:
mode:
Diffstat (limited to 'luaotfload-tool.lua')
-rwxr-xr-xluaotfload-tool.lua87
1 files changed, 61 insertions, 26 deletions
diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua
index b16fe49..0ee53eb 100755
--- a/luaotfload-tool.lua
+++ b/luaotfload-tool.lua
@@ -169,7 +169,8 @@ 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
+ -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
@@ -185,6 +186,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 = [[
@@ -260,7 +267,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)
@@ -273,6 +281,7 @@ actions.loglevel = function (job)
logs.set_loglevel(job.log_level)
logs.names_report("info", 3, "util",
"setting log level", "%d", job.log_level)
+ logs.names_report("log", 0, "util", "lua=%s", _VERSION)
return true, true
end
@@ -288,28 +297,47 @@ 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)
- savedname = names.save(fontnames)
- if savedname then --- FIXME have names.save return bool
+ local success = names.save(fontnames)
+ if success then
return true, true
end
return false, false
end
actions.flush = function (job)
- local success, lookups = names.flush_cache()
+ local success, lookups = names.flush_lookup_cache()
if success then
- local savedname = names.save_lookups()
- logs.names_report("info", 2, "cache", "Cache emptied")
- if savedname then
+ local success = names.save_lookups()
+ if success then
+ 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
@@ -520,24 +548,26 @@ local process_cmdline = function ( ) -- unit -> jobspec
}
local long_options = {
- alias = 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,
+ ["dry-run"] = "D",
+ ["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 = "DfFilquvVh"
local options, _, optarg =
alt_getopt.get_ordered_opts (arg, short_options, long_options)
@@ -586,13 +616,18 @@ 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
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]
+ elseif v == "D" then
+ result.dry_run = true
end
end