From e05c2e2c2f72788e63da7334e054fd887bd22e70 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 27 Aug 2015 23:08:11 +0200 Subject: [main] install stub for main initialization hook --- src/luaotfload-main.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index b633ed7..36db2c3 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -266,4 +266,12 @@ load_luaotfload_module "auxiliary" --- additional high-level functionality luaotfload.aux.start_rewrite_fontname () --- to be migrated to fontspec +luaotfload.main = function () + local starttime = os.gettimeofday () + --- XXX stub + logreport ("both", 0, "main", + "initialization completed in %0.3f seconds", + os.gettimeofday() - starttime) +end + -- vim:tw=79:sw=4:ts=4:et -- cgit v1.2.3 From 7cd218b920814322d002f915ed5c8bb0132cf40a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 27 Aug 2015 23:28:32 +0200 Subject: [main,loaders] regroup callback handling code with loaders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... changing the meaning of the file’s designation instead of adding yet another file. All the callback manipulation is now contained inside that module which will inject most of its functionality only when its main ``.install()`` method is called. --- src/luaotfload-main.lua | 116 ++++++------------------------------------------ 1 file changed, 14 insertions(+), 102 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 36db2c3..fe27215 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -67,12 +67,6 @@ luaotfload.module = { local luatexbase = luatexbase local require = require local type = type -local add_to_callback = luatexbase.add_to_callback -local create_callback = luatexbase.create_callback -local reset_callback = luatexbase.reset_callback -local call_callback = luatexbase.call_callback - -local dummy_function = function () end --- XXX this will be moved to the luaotfload namespace when we have the init module local error, warning, info, log = luatexbase.provides_module(luaotfload.module) @@ -165,110 +159,28 @@ end luaotfload.init.main (store) -load_luaotfload_module "loaders" --- Type1 font wrappers -load_luaotfload_module "database" --- Font management. -load_luaotfload_module "colors" --- Per-font colors. - -luaotfload.resolvers = load_luaotfload_module "resolvers" --- Font lookup - -luaotfload.resolvers.install () - -if not config.actions.reconfigure () then - logreport ("log", 0, "load", "Post-configuration hooks failed.") -end - ---[[doc-- - - We create callbacks for patching fonts on the fly, to be used by - other packages. In addition to the regular \identifier{patch_font} - callback there is an unsafe variant \identifier{patch_font_unsafe} - that will be invoked even if the target font lacks certain essential - tfmdata tables. - - The callbacks initially contain the empty function that we are going to - override below. - ---doc]]-- - -create_callback("luaotfload.patch_font", "simple", dummy_function) -create_callback("luaotfload.patch_font_unsafe", "simple", dummy_function) - ---[[doc-- - - \subsection{\CONTEXT override} - \label{define-font} - We provide a simplified version of the original font definition - callback. +luaotfload.main = function () + local starttime = os.gettimeofday () ---doc]]-- + luaotfload.loaders = load_luaotfload_module "loaders" --- Font loading; callbacks + luaotfload.loaders.install () + load_luaotfload_module "database" --- Font management. + load_luaotfload_module "colors" --- Per-font colors. -local definers = { } --- (string, spec -> size -> id -> tmfdata) hash_t -do - local read = fonts.definers.read - - local patch = function (specification, size, id) - local fontdata = read (specification, size, id) - if type (fontdata) == "table" and fontdata.shared then - --- We need to test for the “shared” field here - --- or else the fontspec capheight callback will - --- operate on tfm fonts. - call_callback ("luaotfload.patch_font", fontdata, specification) - else - call_callback ("luaotfload.patch_font_unsafe", fontdata, specification) - end - return fontdata - end + luaotfload.resolvers = load_luaotfload_module "resolvers" --- Font lookup + luaotfload.resolvers.install () - local mk_info = function (name) - local definer = name == "patch" and patch or read - return function (specification, size, id) - logreport ("both", 0, "main", "defining font no. %d", id) - logreport ("both", 0, "main", " > active font definer: %q", name) - logreport ("both", 0, "main", " > spec %q", specification) - logreport ("both", 0, "main", " > at size %.2f pt", size / 2^16) - local result = definer (specification, size, id) - if not result then - logreport ("both", 0, "main", " > font definition failed") - return - elseif type (result) == "number" then - logreport ("both", 0, "main", " > font definition yielded id %d", result) - return result - end - logreport ("both", 0, "main", " > font definition successful") - logreport ("both", 0, "main", " > name %q", result.name or "") - logreport ("both", 0, "main", " > fontname %q", result.fontname or "") - logreport ("both", 0, "main", " > fullname %q", result.fullname or "") - return result - end + if not config.actions.reconfigure () then + logreport ("log", 0, "load", "Post-configuration hooks failed.") end - definers.patch = patch - definers.generic = read - definers.info_patch = mk_info "patch" - definers.info_generic = mk_info "generic" -end - -reset_callback "define_font" - ---[[doc-- + load_luaotfload_module "features" --- font request and feature handling + load_luaotfload_module "letterspace" --- extra character kerning + load_luaotfload_module "auxiliary" --- additional high-level functionality - Finally we register the callbacks. + luaotfload.aux.start_rewrite_fontname () --- to be migrated to fontspec ---doc]]-- - -local definer = config.luaotfload.run.definer -add_to_callback ("define_font", definers[definer], "luaotfload.define_font", 1) - -load_luaotfload_module "features" --- font request and feature handling -load_luaotfload_module "letterspace" --- extra character kerning -load_luaotfload_module "auxiliary" --- additional high-level functionality - -luaotfload.aux.start_rewrite_fontname () --- to be migrated to fontspec - -luaotfload.main = function () - local starttime = os.gettimeofday () - --- XXX stub logreport ("both", 0, "main", "initialization completed in %0.3f seconds", os.gettimeofday() - starttime) -- cgit v1.2.3 From c3db46b819beebb892698513bd51341b9a691786 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 27 Aug 2015 23:42:44 +0200 Subject: [main,loaders] adjust noise and check status of loader init --- src/luaotfload-main.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index fe27215..32eb04d 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -163,7 +163,9 @@ luaotfload.main = function () local starttime = os.gettimeofday () luaotfload.loaders = load_luaotfload_module "loaders" --- Font loading; callbacks - luaotfload.loaders.install () + if not luaotfload.loaders.install () then + logreport ("log", 0, "load", "Callback and loader initialization failed.") + end load_luaotfload_module "database" --- Font management. load_luaotfload_module "colors" --- Per-font colors. -- cgit v1.2.3 From 4a76c3abcdf750cbf1e825d0fce637e35f63b10a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 27 Sep 2015 18:28:14 +0200 Subject: [main, parsers] prepare for deferred initialization --- src/luaotfload-main.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 32eb04d..3005f5a 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -150,7 +150,11 @@ local logreport = log.report --doc]]-- -load_luaotfload_module "parsers" --- fonts.conf and syntax +local tmp = load_luaotfload_module "parsers" --- fonts.conf and syntax +if not tmp.init () then + logreport ("log", 0, "load", "Failed to install the parsers.") +end + load_luaotfload_module "configuration" --- configuration options if not config.actions.apply_defaults () then -- cgit v1.2.3 From 974d9c6a280e42d01eb4a7c810900f9b4855e919 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 27 Sep 2015 18:43:41 +0200 Subject: [main, conf] prepare for deferred loading --- src/luaotfload-main.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 3005f5a..73f9a75 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -15,6 +15,7 @@ local initial_log_level = 0 luaotfload = luaotfload or { } +config = config or { } local luaotfload = luaotfload luaotfload.log = luaotfload.log or { } luaotfload.version = "2.6" @@ -150,22 +151,21 @@ local logreport = log.report --doc]]-- -local tmp = load_luaotfload_module "parsers" --- fonts.conf and syntax -if not tmp.init () then - logreport ("log", 0, "load", "Failed to install the parsers.") -end - -load_luaotfload_module "configuration" --- configuration options - -if not config.actions.apply_defaults () then - logreport ("log", 0, "load", "Configuration unsuccessful.") -end - luaotfload.init.main (store) luaotfload.main = function () local starttime = os.gettimeofday () + local tmp = load_luaotfload_module "parsers" --- fonts.conf and syntax + if not tmp.init () then + logreport ("log", 0, "load", "Failed to install the parsers.") + end + + local tmp = load_luaotfload_module "configuration" --- configuration options + if not tmp.init() or not config.actions.apply_defaults () then + logreport ("log", 0, "load", "Configuration unsuccessful.") + end + luaotfload.loaders = load_luaotfload_module "loaders" --- Font loading; callbacks if not luaotfload.loaders.install () then logreport ("log", 0, "load", "Callback and loader initialization failed.") -- cgit v1.2.3 From 145203842d83591fc9e67322472994c481d5aadc Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 27 Sep 2015 18:50:22 +0200 Subject: [main] move toplevel statements into init routine --- src/luaotfload-main.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 73f9a75..9e57dbf 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -139,26 +139,21 @@ local load_fontloader_module = make_loader "fontloader" luaotfload.loaders.luaotfload = load_luaotfload_module luaotfload.loaders.fontloader = load_fontloader_module -luaotfload.init = load_luaotfload_module "init" --- fontloader initialization - -local store = luaotfload.init.early () -local log = luaotfload.log -local logreport = log.report - --[[doc-- Now we load the modules written for \identifier{luaotfload}. --doc]]-- -luaotfload.init.main (store) - luaotfload.main = function () local starttime = os.gettimeofday () + local init = load_luaotfload_module "init" --- fontloader initialization + local store = init.early () --- injects the log module too + local logreport = luaotfload.log.report local tmp = load_luaotfload_module "parsers" --- fonts.conf and syntax if not tmp.init () then - logreport ("log", 0, "load", "Failed to install the parsers.") + logreport ("log", 0, "load", "Failed to install the parsers module.") end local tmp = load_luaotfload_module "configuration" --- configuration options @@ -166,6 +161,10 @@ luaotfload.main = function () logreport ("log", 0, "load", "Configuration unsuccessful.") end + if not init.main (store) then + logreport ("log", 0, "load", "Main fontloader initialization failed.") + end + luaotfload.loaders = load_luaotfload_module "loaders" --- Font loading; callbacks if not luaotfload.loaders.install () then logreport ("log", 0, "load", "Callback and loader initialization failed.") -- cgit v1.2.3 From 780113609ffbb146c1b5a825cb25025246cdba2a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 27 Sep 2015 20:17:02 +0200 Subject: [main, *] convert for centralized initialization routine --- src/luaotfload-main.lua | 96 +++++++++++++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 34 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 9e57dbf..815a2f0 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -13,6 +13,9 @@ --- version 2.4 to 2.5. Thus, the comments are still in TeX (Latex) --- markup. +local os = os +local osgettimeofday = os.gettimeofday + local initial_log_level = 0 luaotfload = luaotfload or { } config = config or { } @@ -125,70 +128,95 @@ local make_loader_name = function (prefix, name) return name end +local timing_info = { + t_load = { }, + t_init = { }, +} + local make_loader = function (prefix) return function (name) + local t_0 = osgettimeofday () local modname = make_loader_name (prefix, name) - return require (modname) + local data = require (modname) + local t_end = osgettimeofday () + timing_info.t_load [name] = t_end - t_0 + return data end end -local load_luaotfload_module = make_loader "luaotfload" ------ load_luaotfload_module = make_loader "luatex" --=> for Luatex-Plain -local load_fontloader_module = make_loader "fontloader" +local install_loaders = function () + local loaders = { } + local loadmodule = make_loader "luaotfload" + loaders.luaotfload = loadmodule + loaders.fontloader = make_loader "fontloader" +----loaders.plaintex = make_loader "luatex" --=> for Luatex-Plain + + loaders.initialize = function (name) + local tmp = loadmodule (name) + local logreport = luaotfload.log.report + if type (tmp) == "table" then + local init = tmp.init + if init and type (init) == "function" then + local t_0 = osgettimeofday () + if not init () then + logreport ("log", 0, "load", + "Failed to load module “%s”.", name) + return + end + local t_end = osgettimeofday () + local d_t = t_end - t_0 + logreport ("log", 4, "load", + "Module “%s” loaded in %d ms.", + d_t) + timing_info.t_init [name] = d_t + end + end + end -luaotfload.loaders.luaotfload = load_luaotfload_module -luaotfload.loaders.fontloader = load_fontloader_module + return loaders +end ---[[doc-- - Now we load the modules written for \identifier{luaotfload}. +luaotfload.main = function () ---doc]]-- + luaotfload.loaders = install_loaders () + local loaders = luaotfload.loaders + local loadmodule = loaders.luaotfload + local initialize = loaders.initialize -luaotfload.main = function () - local starttime = os.gettimeofday () - local init = load_luaotfload_module "init" --- fontloader initialization - local store = init.early () --- injects the log module too + local starttime = osgettimeofday () + local init = loadmodule "init" --- fontloader initialization + local store = init.early () --- injects the log module too local logreport = luaotfload.log.report - local tmp = load_luaotfload_module "parsers" --- fonts.conf and syntax - if not tmp.init () then - logreport ("log", 0, "load", "Failed to install the parsers module.") - end - - local tmp = load_luaotfload_module "configuration" --- configuration options - if not tmp.init() or not config.actions.apply_defaults () then - logreport ("log", 0, "load", "Configuration unsuccessful.") - end + initialize "parsers" --- fonts.conf and syntax + initialize "configuration" --- configuration options if not init.main (store) then logreport ("log", 0, "load", "Main fontloader initialization failed.") end - luaotfload.loaders = load_luaotfload_module "loaders" --- Font loading; callbacks - if not luaotfload.loaders.install () then - logreport ("log", 0, "load", "Callback and loader initialization failed.") - end - - load_luaotfload_module "database" --- Font management. - load_luaotfload_module "colors" --- Per-font colors. + initialize "loaders" --- Font loading; callbacks + initialize "database" --- Font management. + initialize "colors" --- Per-font colors. - luaotfload.resolvers = load_luaotfload_module "resolvers" --- Font lookup + luaotfload.resolvers = loadmodule "resolvers" --- Font lookup luaotfload.resolvers.install () if not config.actions.reconfigure () then logreport ("log", 0, "load", "Post-configuration hooks failed.") end - load_luaotfload_module "features" --- font request and feature handling - load_luaotfload_module "letterspace" --- extra character kerning - load_luaotfload_module "auxiliary" --- additional high-level functionality + initialize "features" --- font request and feature handling + loadmodule "letterspace" --- extra character kerning + loadmodule "auxiliary" --- additional high-level functionality luaotfload.aux.start_rewrite_fontname () --- to be migrated to fontspec logreport ("both", 0, "main", "initialization completed in %0.3f seconds", - os.gettimeofday() - starttime) + osgettimeofday() - starttime) +----inspect (timing_info) end -- vim:tw=79:sw=4:ts=4:et -- cgit v1.2.3 From 120c852ccd7a1579310ed855a4d8b1322a1f9d09 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 28 Oct 2015 06:48:50 +0100 Subject: main: fix module insertion and throw away luatexbase-provided resources --- src/luaotfload-main.lua | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 815a2f0..3d68a17 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -72,16 +72,9 @@ local luatexbase = luatexbase local require = require local type = type -local error, warning, info, log = +local _error, _warning, _info, _log = luatexbase.provides_module(luaotfload.module) -luaotfload.log.tex = { - error = error, - warning = warning, - info = info, - log = log, -} - --[[doc-- We set the minimum version requirement for \LUATEX to v0.76, @@ -167,7 +160,7 @@ local install_loaders = function () local d_t = t_end - t_0 logreport ("log", 4, "load", "Module “%s” loaded in %d ms.", - d_t) + name, d_t) timing_info.t_init [name] = d_t end end -- cgit v1.2.3 From e52df63570da80bf121fd9b9294de5a2d037f1b6 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 29 Oct 2015 07:37:39 +0100 Subject: [main] dejumble module loader message --- src/luaotfload-main.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 3d68a17..ff2b48d 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -109,15 +109,15 @@ end local make_loader_name = function (prefix, name) local msg = luaotfload.log and luaotfload.log.report or print - if prefix then + if prefix and name then msg ("log", 7, "load", - "Composing fontloader name from constitutents %s, %s", + "Composing module name from constituents %s, %s", prefix, name) return prefix .. "-" .. name .. ".lua" end msg ("log", 7, "load", - "Loading fontloader file %s literally.", - name) + "Loading module %s literally.", + tostring (name)) return name end -- cgit v1.2.3 From 6c0c403a3b6fa01604935960a46eb1e10a4586af Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 29 Oct 2015 08:22:36 +0100 Subject: [tool,resolvers,db] fix references to the fonts table This makes the ``--find`` option to luaotfload-too work again. --- src/luaotfload-main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index ff2b48d..98afee0 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -194,7 +194,7 @@ luaotfload.main = function () initialize "colors" --- Per-font colors. luaotfload.resolvers = loadmodule "resolvers" --- Font lookup - luaotfload.resolvers.install () + luaotfload.resolvers.init () if not config.actions.reconfigure () then logreport ("log", 0, "load", "Post-configuration hooks failed.") -- cgit v1.2.3 From 330440f784cb12b0902fd80271e568c59da64771 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 5 Nov 2015 22:05:00 +0100 Subject: [main] clean up unused and irrelevant pieces --- src/luaotfload-main.lua | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 98afee0..5fa316d 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -7,23 +7,15 @@ -- MODIFIED: 2015-06-09 23:08:18+0200 ----------------------------------------------------------------------- -- ---- Note: ---- This file was part of the original luaotfload.dtx and has been ---- converted to a pure Lua file during the transition from Luaotfload ---- version 2.4 to 2.5. Thus, the comments are still in TeX (Latex) ---- markup. -local os = os local osgettimeofday = os.gettimeofday - -local initial_log_level = 0 -luaotfload = luaotfload or { } config = config or { } +luaotfload = luaotfload or { } local luaotfload = luaotfload luaotfload.log = luaotfload.log or { } luaotfload.version = "2.6" luaotfload.loaders = { } -luaotfload.min_luatex_version = 79 --- i. e. 0.79 +luaotfload.min_luatex_version = 80 --- i. e. 0.79 luaotfload.fontloader_package = "reference" --- default: from current Context local authors = "\z @@ -40,7 +32,7 @@ local authors = "\z luaotfload.module = { name = "luaotfload-main", version = 2.60001, - date = "2015/05/26", + date = "2015/11/05", description = "OpenType layout system.", author = authors, copyright = authors, -- cgit v1.2.3 From 8395eb8efec1ac9e311541d9834f1a939b91e710 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 5 Nov 2015 22:08:47 +0100 Subject: [*] kill off file headers We have the VCS info in the status file; these things are just silly. --- src/luaotfload-main.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 5fa316d..85c9cee 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -3,8 +3,6 @@ -- DESCRIPTION: Luaotfload entry point -- REQUIREMENTS: luatex v.0.80 or later; packages lualibs, luatexbase -- AUTHOR: Élie Roux, Khaled Hosny, Philipp Gesang --- VERSION: same as Luaotfload --- MODIFIED: 2015-06-09 23:08:18+0200 ----------------------------------------------------------------------- -- -- cgit v1.2.3 From 389fe13c73832215d8486e43ed3c52f6c96f45ca Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 9 Nov 2015 08:03:29 +0100 Subject: [main,init] add no-op loader for fontloader files --- src/luaotfload-main.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 85c9cee..686ce0e 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -127,11 +127,23 @@ local make_loader = function (prefix) end end +--[[doc-- + Certain files are kept around that aren’t loaded because they are part of + the imported fontloader. In order to keep the initialization structure + intact we also provide a no-op version of the module loader that can be + called in the expected places. +--doc]]-- + +local dummy_loader = function (name) + luaotfload.log.report("log", 3, "load", "Skipping module “%s”.", name) +end + local install_loaders = function () local loaders = { } local loadmodule = make_loader "luaotfload" loaders.luaotfload = loadmodule loaders.fontloader = make_loader "fontloader" + loaders.ignore = dummy_loader ----loaders.plaintex = make_loader "luatex" --=> for Luatex-Plain loaders.initialize = function (name) -- cgit v1.2.3 From a67b8e37ab846a79c69ee26761835934680e41b4 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 10 Nov 2015 08:02:36 +0100 Subject: [main] implement a loader for Context files --- src/luaotfload-main.lua | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 686ce0e..0ed57da 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -99,16 +99,24 @@ end local make_loader_name = function (prefix, name) local msg = luaotfload.log and luaotfload.log.report or print - if prefix and name then - msg ("log", 7, "load", - "Composing module name from constituents %s, %s", - prefix, name) - return prefix .. "-" .. name .. ".lua" + if not name then + msg ("both", 0, "load", + "Fatal error: make_loader_name (“%s”, “%s”).", + tostring (prefix), tostring (name)) + return "dummy-name" end - msg ("log", 7, "load", - "Loading module %s literally.", - tostring (name)) - return name + name = tostring (name) + if prefix == false then + msg ("log", 9, "load", + "No prefix requested, passing module name “%s” unmodified.", + name) + return tostring (name) .. ".lua" + end + prefix = tostring (prefix) + msg ("log", 9, "load", + "Composing module name from constituents %s, %s.", + prefix, name) + return prefix .. "-" .. name .. ".lua" end local timing_info = { @@ -135,7 +143,17 @@ end --doc]]-- local dummy_loader = function (name) - luaotfload.log.report("log", 3, "load", "Skipping module “%s”.", 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 t_0 = osgettimeofday () + local modname = make_loader_name (false, name) + local data = require (modname) + local t_end = osgettimeofday () + timing_info.t_load [name] = t_end - t_0 + return data end local install_loaders = function () @@ -143,6 +161,7 @@ local install_loaders = function () local loadmodule = make_loader "luaotfload" loaders.luaotfload = loadmodule loaders.fontloader = make_loader "fontloader" + loaders.context = context_loader loaders.ignore = dummy_loader ----loaders.plaintex = make_loader "luatex" --=> for Luatex-Plain -- cgit v1.2.3 From 0bfd03b4fcdf1cbf3f1fb8e8afa7a2c4d917715a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 17 Nov 2015 23:56:44 +0100 Subject: [main,init] implement path dependent loading of context modules --- src/luaotfload-main.lua | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'src/luaotfload-main.lua') 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 () -- cgit v1.2.3