summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2015-11-17 23:56:44 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2015-11-17 23:56:44 +0100
commit0bfd03b4fcdf1cbf3f1fb8e8afa7a2c4d917715a (patch)
tree8f2753b2e91f7bc4322e629db89f6b75cddfc09a
parent2bcb46cfec8b8d988e12f44d6297f4fb5f9e879b (diff)
downloadluaotfload-0bfd03b4fcdf1cbf3f1fb8e8afa7a2c4d917715a.tar.gz
[main,init] implement path dependent loading of context modules
-rw-r--r--src/luaotfload-init.lua61
-rw-r--r--src/luaotfload-main.lua39
2 files changed, 68 insertions, 32 deletions
diff --git a/src/luaotfload-init.lua b/src/luaotfload-init.lua
index a42801f..2755f78 100644
--- a/src/luaotfload-init.lua
+++ b/src/luaotfload-init.lua
@@ -182,6 +182,10 @@ local pop_namespaces = function (normalglobal,
end
end
+--- below paths are relative to the texmf-context
+local ltx = "tex/generic/context/luatex"
+local ctx = "tex/context/base"
+
local context_modules = {
--- Since 2.6 those are directly provided by the Lualibs package.
@@ -197,28 +201,28 @@ local context_modules = {
{ false, "util-str" },
--- These constitute the fontloader proper.
- { true, "luatex-basics-gen" },
- { true, "data-con" },
- { true, "luatex-basics-nod" },
- { true, "font-ini" },
- { true, "font-con" },
- { true, "luatex-fonts-enc" },
- { true, "font-cid" },
- { true, "font-map" },
- { true, "luatex-fonts-syn" },
- { true, "luatex-fonts-tfm" },
- { true, "font-oti" },
- { true, "font-otf" },
- { true, "font-otb" },
- { true, "luatex-fonts-inj" }, --> since 2014-01-07, replaces node-inj.lua
- { true, "luatex-fonts-ota" },
- { true, "luatex-fonts-otn" }, --> since 2014-01-07, replaces font-otn.lua
- { true, "font-otp" }, --> since 2013-04-23
- { true, "luatex-fonts-lua" },
- { true, "font-def" },
- { true, "luatex-fonts-def" },
- { true, "luatex-fonts-ext" },
- { true, "luatex-fonts-cbk" },
+ { ltx, "luatex-basics-gen" },
+ { ctx, "data-con" },
+ { ltx, "luatex-basics-nod" },
+ { ctx, "font-ini" },
+ { ctx, "font-con" },
+ { ltx, "luatex-fonts-enc" },
+ { ctx, "font-cid" },
+ { ctx, "font-map" },
+ { ltx, "luatex-fonts-syn" },
+ { ltx, "luatex-fonts-tfm" },
+ { ctx, "font-oti" },
+ { ctx, "font-otf" },
+ { ctx, "font-otb" },
+ { ltx, "luatex-fonts-inj" }, --> since 2014-01-07, replaces node-inj.lua
+ { ltx, "luatex-fonts-ota" },
+ { ltx, "luatex-fonts-otn" }, --> since 2014-01-07, replaces font-otn.lua
+ { ctx, "font-otp" }, --> since 2013-04-23
+ { ltx, "luatex-fonts-lua" },
+ { ctx, "font-def" },
+ { ltx, "luatex-fonts-def" },
+ { ltx, "luatex-fonts-ext" },
+ { ltx, "luatex-fonts-cbk" },
} --[[context_modules]]
@@ -231,11 +235,16 @@ local load_context_modules = function (pth)
"Loading fontloader components from context.")
local n = #context_modules
for i = 1, n do
- local state, spec = unpack (context_modules [i])
- if state == false then
+ local sub, spec = unpack (context_modules [i])
+ if sub == false then
ignore_module (spec)
- elseif state == true then
- load_context_module (spec)
+ elseif type (sub) == "string" then
+ load_context_module (spec, file.join (pth, sub))
+ else
+ logreport ("both", 0, "init",
+ "Internal error, please report. \z
+ This is not your fault.")
+ os.exit (-1)
end
end
diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua
index 0ed57da..62765e4 100644
--- a/src/luaotfload-main.lua
+++ b/src/luaotfload-main.lua
@@ -98,7 +98,8 @@ end
--doc]]--
local make_loader_name = function (prefix, name)
- local msg = luaotfload.log and luaotfload.log.report or print
+ local msg = luaotfload.log and luaotfload.log.report
+ or function (...) texio.write_nl ("log", ...) end
if not name then
msg ("both", 0, "load",
"Fatal error: make_loader_name (“%s”, “%s”).",
@@ -143,17 +144,43 @@ end
--doc]]--
local dummy_loader = function (name)
- luaotfload.log.report("log", 3, "load", "Skipping module “%s” on purpose.", name)
+ luaotfload.log.report ("log", 3, "load",
+ "Skipping module “%s” on purpose.",
+ name)
end
-local context_loader = function (name)
- luaotfload.log.report("log", 3, "load", "Loading module “%s” from Context.", name)
+local context_loader = function (name, path)
+ luaotfload.log.report ("log", 3, "load",
+ "Loading module “%s” from Context.",
+ name)
local t_0 = osgettimeofday ()
local modname = make_loader_name (false, name)
- local data = require (modname)
+ local modpath = modname
+ if path then
+ if lfs.isdir (path) then
+ luaotfload.log.report ("log", 3, "load",
+ "Prepending path “%s”.",
+ path)
+ modpath = file.join (path, modname)
+ else
+ luaotfload.log.report ("both", 0, "load",
+ "Non-existant path “%s” specified, ignoring.",
+ path)
+ end
+ end
+ local ret = require (modpath)
local t_end = osgettimeofday ()
timing_info.t_load [name] = t_end - t_0
- return data
+
+ if ret ~= true then
+ --- require () returns “true” upon success unless the loaded file
+ --- yields a non-zero exit code. This isn’t per se indicating that
+ --- something isn’t right, but against HH’s coding practices. We’ll
+ --- silently ignore this ever happening on lower log levels.
+ luaotfload.log.report ("log", 4, "load",
+ "Module “%s” returned “%s”.", ret)
+ end
+ return ret
end
local install_loaders = function ()