From 619d652ec4e23339ed0db2c68dafcbfbcdf90b08 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 28 Apr 2016 21:22:58 +0200 Subject: [conf,resolvers] add config option to tweak anon lookup sequence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/luaotfload-resolvers.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/luaotfload-resolvers.lua') 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-- -- cgit v1.2.3 From 2db9e17e57e306bde452c5d97f976b47b0bf9d78 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 28 Apr 2016 21:57:55 +0200 Subject: [tool,resolvers,conf] switch --find lookups to the actual resolvers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The arguments to “--find” on the command line avoided calling the real index API functions and used crude approximations instead. In order to make “--find” obey the new “anon-sequence” configuration item, it needs to access the normal resolvers instead. This requires certain adaptations to allow for a fallback on the “file:” lookup. --- src/luaotfload-resolvers.lua | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/luaotfload-resolvers.lua') diff --git a/src/luaotfload-resolvers.lua b/src/luaotfload-resolvers.lua index f911101..6fc6ffe 100644 --- a/src/luaotfload-resolvers.lua +++ b/src/luaotfload-resolvers.lua @@ -200,20 +200,26 @@ local resolve_methods = { tex = resolve_tex_format, path = resolve_path_if_exists, name = resolve_name, + file = resolve_file, } local resolve_sequence = function (seq, specification) for i = 1, #seq do local id = seq [i] local mth = resolve_methods [id] - logreport ("both", 3, "resolve", "step %d: apply method %q (%s)", i, id, mth) - if mth (specification) == true then - logreport ("both", 3, "resolve", - "%d: method %q resolved %q -> %s (%s).", - i, id, specification.specification, - specification.name, - specification.forcedname) - return true + if not mth then + logreport ("both", 0, "resolve", + "step %d: invalid lookup method %q", i, id) + else + logreport ("both", 3, "resolve", "step %d: apply method %q (%s)", i, id, mth) + if mth (specification) == true then + logreport ("both", 3, "resolve", + "%d: method %q resolved %q -> %s (%s).", + i, id, specification.specification, + specification.name, + specification.forcedname) + return true + end end end logreport ("both", 0, "resolve", -- cgit v1.2.3 From c306db980b59c03875acebf8a948efe7b7d51b98 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 28 Apr 2016 22:49:58 +0200 Subject: =?UTF-8?q?[resolvers,conf]=20allow=20=E2=80=9Cmy:=E2=80=9D=20look?= =?UTF-8?q?ups=20in=20anon=20sequences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to domesticate packages that quite disrespectfully only use “anon:” lookups. Example from the test repo: \documentclass{scrartcl} \usepackage{fontspec} \directlua{ config.luaotfload = config.actions.apply (config.luaotfload, { run = { anon_sequence = { "my" } } }) } \directlua{ luatexbase.add_to_callback( "luaotfload.resolve_font", function (spec) spec.name = "comic.ttf" end, "user.openbsd_style") } \setmainfont{Adobe Premier Deluxe Overpriced} \begin{document} There is no escape. \end{document} --- src/luaotfload-resolvers.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/luaotfload-resolvers.lua') diff --git a/src/luaotfload-resolvers.lua b/src/luaotfload-resolvers.lua index 6fc6ffe..a1e702b 100644 --- a/src/luaotfload-resolvers.lua +++ b/src/luaotfload-resolvers.lua @@ -196,11 +196,20 @@ local resolve_path_if_exists = function (specification) return false end +--[[doc-- + Custom file resolvers via callback. +--doc]]-- + +local resolve_my = function (specification) + luatexbase.call_callback ("luaotfload.resolve_font", specification) +end + local resolve_methods = { tex = resolve_tex_format, path = resolve_path_if_exists, name = resolve_name, file = resolve_file, + my = resolve_my, } local resolve_sequence = function (seq, specification) @@ -273,16 +282,6 @@ resolve_kpse = function (specification) return false end ---[[doc-- - - Also {\bfseries EXPERIMENTAL}: custom file resolvers via callback. - ---doc]]-- - -local resolve_my = function (specification) - luatexbase.call_callback ("luaotfload.resolve_font", specification) -end - return { init = function ( ) if luatexbase and luatexbase.create_callback then -- cgit v1.2.3