summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-04-28 21:22:58 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2016-04-28 21:23:01 +0200
commit619d652ec4e23339ed0db2c68dafcbfbcdf90b08 (patch)
tree44c70f77021804bf018d4a426cfa52e9c8d3442c
parent23ff1b009f3b4df6754848196d7556c11c323d83 (diff)
downloadluaotfload-619d652ec4e23339ed0db2c68dafcbfbcdf90b08.tar.gz
[conf,resolvers] add config option to tweak anon lookup sequence
Implements #263 The resolvers have already been decoupled a while ago but the goal of allowing the sequence to be reordered at will was still outstanding. Add a config option “anon-sequence” that is parsed as a comma-delimited list of sequence components.
-rw-r--r--src/luaotfload-configuration.lua31
-rw-r--r--src/luaotfload-resolvers.lua10
2 files changed, 40 insertions, 1 deletions
diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua
index 92de432..a15474c 100644
--- a/src/luaotfload-configuration.lua
+++ b/src/luaotfload-configuration.lua
@@ -92,6 +92,10 @@ local valid_formats = tabletohash {
"otf", "ttc", "ttf", "afm", "pfb"
}
+local default_anon_sequence = {
+ "tex", "path", "name",
+}
+
local feature_presets = {
arab = tabletohash {
"ccmp", "locl", "isol", "fina", "fin2",
@@ -198,6 +202,7 @@ local default_config = {
use_fontforge = false,
},
run = {
+ anon_sequence = default_anon_sequence,
resolver = "cached",
definer = "patch",
log_level = 0,
@@ -502,6 +507,22 @@ local option_spec = {
use_fontforge = { in_t = boolean_t, },
},
run = {
+ anon_sequence = {
+ in_t = string_t,
+ out_t = table_t,
+ transform = function (s)
+ if s ~= "default" then
+ local bits = { lpegmatch (commasplitter, s) }
+ if next (bits) then
+ logreport ("both", 2, "conf",
+ "overriding anon lookup sequence %s.",
+ tableconcat (bits, ","))
+ return bits
+ end
+ end
+ return default_anon_sequence
+ end
+ },
live = { in_t = boolean_t, }, --- false for the tool, true for TeX run
resolver = {
in_t = string_t,
@@ -639,6 +660,15 @@ local format_keyval = function (var, val)
end
end
+local format_list = function (var, val)
+ local elts = { }
+ for i = 1, #val do elts [i] = val [i] end
+ if next (elts) then
+ return stringformat (indent .. "%s = %s",
+ var, tableconcat (elts, ","))
+ end
+end
+
local format_section = function (title)
return stringformat ("[%s]", dashed (title))
end
@@ -693,6 +723,7 @@ local formatters = {
lookups_file = { false, format_string },
},
run = {
+ anon_sequence = { false, format_list },
color_callback = { false, format_string },
definer = { false, format_string },
fontloader = { false, format_string },
diff --git a/src/luaotfload-resolvers.lua b/src/luaotfload-resolvers.lua
index ee3b597..f911101 100644
--- a/src/luaotfload-resolvers.lua
+++ b/src/luaotfload-resolvers.lua
@@ -29,6 +29,7 @@ if not luaotfload then error "this module requires Luaotfload" end
--doc]]--
local next = next
+local tableconcat = table.concat
local kpsefind_file = kpse.find_file
local lfsisfile = lfs.isfile
local stringlower = string.lower
@@ -226,7 +227,14 @@ local default_anon_sequence = {
local resolve_anon
resolve_anon = function (specification)
- return resolve_sequence (default_anon_sequence, specification)
+ local seq = default_anon_sequence
+ if config and config.luaotfload then
+ local anonseq = config.luaotfload.run.anon_sequence
+ if anonseq and next (anonseq) then
+ seq = anonseq
+ end
+ end
+ return resolve_sequence (seq, specification)
end
--[[doc--