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-configuration.lua | 57 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'src/luaotfload-configuration.lua') diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index e2cfbd8..263c8ad 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -6,7 +6,6 @@ -- AUTHOR: Philipp Gesang (Phg), -- AUTHOR: Dohyun Kim -- VERSION: same as Luaotfload --- MODIFIED: 2015-05-05 ------------------------------------------------------------------------------- -- @@ -18,17 +17,12 @@ if not modules then modules = { } end modules ["luaotfload-configuration"] = { license = "GNU GPL v2.0" } -luaotfload = luaotfload or { } -config = config or { } -config.luaotfload = { } - local status_file = "luaotfload-status" local luaotfloadstatus = require (status_file) -local stringexplode = string.explode +local string = string local stringfind = string.find local stringformat = string.format -local string = string local stringstrip = string.strip local stringsub = string.sub @@ -55,9 +49,7 @@ local lpegmatch = lpeg.match local commasplitter = lpeg.splitat "," local equalssplitter = lpeg.splitat "=" -local kpse = kpse local kpseexpand_path = kpse.expand_path -local kpselookup = kpse.lookup local lfs = lfs local lfsisfile = lfs.isfile @@ -67,16 +59,12 @@ local file = file local filejoin = file.join local filereplacesuffix = file.replacesuffix +local logreport = print -- overloaded later +local getwritablepath = caches.getwritablepath -local parsers = luaotfload.parsers - -local log = luaotfload.log -local logreport = log.report - -local config_parser = parsers.config -local stripslashes = parsers.stripslashes -local getwritablepath = caches.getwritablepath +local config_parser -- set later during init +local stripslashes -- set later during init ------------------------------------------------------------------------------- --- SETTINGS @@ -301,8 +289,11 @@ local set_name_resolver = function () end local set_loglevel = function () - log.set_loglevel (config.luaotfload.run.log_level) - return true + if luaotfload then + luaotfload.log.set_loglevel (config.luaotfload.run.log_level) + return true + end + return false end local build_cache_paths = function () @@ -846,7 +837,7 @@ local read = function (extra) return false end - local parsed = lpegmatch (parsers.config, raw) + local parsed = lpegmatch (config_parser, raw) if not parsed then logreport ("both", 2, "conf", "Error parsing configuration file %q.", readme) return false @@ -912,13 +903,23 @@ end --- EXPORTS ------------------------------------------------------------------------------- -luaotfload.default_config = default_config - -config.actions = { - read = read, - apply = apply, - apply_defaults = apply_defaults, - reconfigure = reconfigure, - dump = dump, +return { + init = function () + config.luaotfload = { } + logreport = luaotfload.log.report + local parsers = luaotfload.parsers + config_parser = parsers.config + stripslashes = parsers.stripslashes + + luaotfload.default_config = default_config + config.actions = { + read = read, + apply = apply, + apply_defaults = apply_defaults, + reconfigure = reconfigure, + dump = dump, + } + return true + end } -- 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-configuration.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/luaotfload-configuration.lua') diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index 263c8ad..86a302e 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -919,6 +919,10 @@ return { reconfigure = reconfigure, dump = dump, } + if not apply_defaults () then + logreport ("log", 0, "load", + "Configuration unsuccessful: error loading default settings.") + end return true end } -- 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-configuration.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'src/luaotfload-configuration.lua') diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index 86a302e..6f94195 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -5,7 +5,6 @@ -- REQUIREMENTS: Luaotfload 2.6 or above -- AUTHOR: Philipp Gesang (Phg), -- AUTHOR: Dohyun Kim --- VERSION: same as Luaotfload ------------------------------------------------------------------------------- -- -- cgit v1.2.3 From 60f41dfbc13f06a1b43a4e66798a0d043d210eee Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 9 Nov 2015 08:16:19 +0100 Subject: [init,conf] enable direct loading of fontloader components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For now, this pertains only to the modules we ship in Luaotfload. For loading from Context we still need a step to distinguish between the namespaced versions of the files, the pure ones in texmf/…/base, and the Luatex-Fonts ones. But yeah, setting [run] fontloader = unpackaged in the luaotfloadrc now works splendidly. --- src/luaotfload-configuration.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/luaotfload-configuration.lua') diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index 6f94195..1fe30fe 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -127,9 +127,11 @@ local feature_presets = { --doc]]-- local registered_loaders = { - default = luaotfloadstatus and luaotfloadstatus.notes.loader or "reference", - reference = "reference", - tl2014 = "tl2014", + default = luaotfloadstatus and luaotfloadstatus.notes.loader or "reference", + reference = "reference", + unpackaged = "unpackaged", + context = "context", + tl2014 = "tl2014", } --[[doc-- -- cgit v1.2.3 From 54e74772fab02405bf90362d76884e88b63eb381 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 12 Nov 2015 08:15:06 +0100 Subject: [conf] implement path-based fontloader specification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes the config test for paths specified as “context:/path/to/texmf” and return a ("context", path) pair that is intended for use as the base path of the fontloader files. --- src/luaotfload-configuration.lua | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/luaotfload-configuration.lua') diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index 1fe30fe..4ac8c50 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -134,6 +134,33 @@ local registered_loaders = { tl2014 = "tl2014", } +local pick_fontloader = function (s) + local ldr = registered_loaders[s] + if ldr ~= nil and type (ldr) == "string" then + logreport ("log", 2, "conf", "Using predefined fontloader \"%s\".", ldr) + return ldr + end + local idx = stringfind (s, ":") + if idx and idx > 2 then + if stringsub (s, 1, idx - 1) == "context" then + local pth = stringsub (s, idx + 1) + pth = stringstrip (pth) + logreport ("log", 2, "conf", "Context base path specified at \"%s\".", pth) + if lfsisdir (pth) then + logreport ("log", 5, "conf", "Context base path exists at \"%s\".", pth) + return { "context", pth } + end + pth = kpseexpand_path (pth) + if lfsisdir (pth) then + logreport ("log", 5, "conf", "Context base path exists at \"%s\".", pth) + return { "context", pth } + end + logreport ("both", 0, "conf", "Context base path not found at \"%s\".", pth) + end + end + return nil +end + --[[doc-- The ``post_linebreak_filter`` has been made the default callback for @@ -468,10 +495,8 @@ local option_spec = { in_t = string_t, out_t = string_t, transform = function (id) - local ldr = registered_loaders[id] + local ldr = pick_fontloader (id) if ldr ~= nil then - logreport ("log", 2, "conf", - "Using predefined fontloader \"%s\".", ldr) return ldr end logreport ("log", 0, "conf", -- cgit v1.2.3 From d8f160fc0518155a9ae995dfb16fc0d29937aa7c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 17 Nov 2015 22:29:41 +0100 Subject: [conf] correctly set default fontloader --- src/luaotfload-configuration.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/luaotfload-configuration.lua') diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index 4ac8c50..0ce9467 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -198,7 +198,7 @@ local default_config = { definer = "patch", log_level = 0, color_callback = "post_linebreak_filter", - live = true, + fontloader = "default", }, misc = { bisect = false, -- cgit v1.2.3 From 6e2184e0226de1e76e7195493b781b99f56eb879 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 17 Nov 2015 22:33:04 +0100 Subject: [conf] return path instead of pair to prevent type-mismatch The (fontloader, path) return value cannot pass the post-config validation because the value of ``run.fontloader`` is of type string. Since the path is always checked during configuration we can just forward it as-is and attempt a path load later on. --- src/luaotfload-configuration.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/luaotfload-configuration.lua') diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index 0ce9467..efed573 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -148,12 +148,12 @@ local pick_fontloader = function (s) logreport ("log", 2, "conf", "Context base path specified at \"%s\".", pth) if lfsisdir (pth) then logreport ("log", 5, "conf", "Context base path exists at \"%s\".", pth) - return { "context", pth } + return pth end pth = kpseexpand_path (pth) if lfsisdir (pth) then logreport ("log", 5, "conf", "Context base path exists at \"%s\".", pth) - return { "context", pth } + return pth end logreport ("both", 0, "conf", "Context base path not found at \"%s\".", pth) end -- cgit v1.2.3 From 3a12cad2b229d501ef6835d27797a1a18fb981ef Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 20 Nov 2015 00:23:45 +0100 Subject: [conf] plug in the correct resolvers (fallout from db reorganization) --- src/luaotfload-configuration.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/luaotfload-configuration.lua') diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index efed573..57311dc 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -308,9 +308,9 @@ local set_name_resolver = function () --- replace the resolver from luatex-fonts if config.luaotfload.db.resolver == "cached" then logreport ("both", 2, "cache", "Caching of name: lookups active.") - names.resolvespec = names.resolve_cached + names.resolvespec = fonts.names.lookup_font_name_cached else - names.resolvespec = names.resolve_name + names.resolvespec = fonts.names.lookup_font_name end end return true -- cgit v1.2.3