[latex3-commits] [git/LaTeX3-latex3-luaotfload] modules: -init-lua -> -fontloader.lua and small changes (156df5b)

Marcel Fabian Krüger tex at 2krueger.de
Sat May 23 16:13:37 CEST 2020


Repository : https://github.com/latex3/luaotfload
On branch  : modules
Link       : https://github.com/latex3/luaotfload/commit/156df5baf534551b9b6bcc09982d72df420ad64d

>---------------------------------------------------------------

commit 156df5baf534551b9b6bcc09982d72df420ad64d
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Sat May 23 16:13:37 2020 +0200

    -init-lua -> -fontloader.lua and small changes


>---------------------------------------------------------------

156df5baf534551b9b6bcc09982d72df420ad64d
 src/luaotfload-filelist.lua                        |  10 +-
 ...aotfload-init.lua => luaotfload-fontloader.lua} | 104 +++++++++++----------
 src/luaotfload-main.lua                            |   9 +-
 3 files changed, 59 insertions(+), 64 deletions(-)

diff --git a/src/luaotfload-filelist.lua b/src/luaotfload-filelist.lua
index 1e3a4ff..b80ffb7 100644
--- a/src/luaotfload-filelist.lua
+++ b/src/luaotfload-filelist.lua
@@ -87,18 +87,16 @@ and a
 
 this script has been already changed to use luaotfload-filelist.lua
    
-### luaotfload-init.lua
+### luaotfload-fontloader.lua
 
-luaotfload-init.lua needs a table
+luaotfload-fontloader.lua needs a table
 --> context_modules
 with the (ordered) entries
 
 {false, "name"}            -- kind_lualibs
 {ctxdir,"ctxprefix+name"} -- kind_essential or kind_merged 
 
-The same list should be used in local init_main = function ()
-but only without the prefix.
-it is unclear how fonts_syn should be handled!!!!
+It is unclear how fonts_syn should be handled!!!!
    
 ### filegraph.tex
 has been already adapted
@@ -232,7 +230,7 @@ luaotfload.filelist.data =
 -- the luaotfload files
     { name = "luaotfload"        ,kind = kind_core, ext =".sty", gitdir=gitdirsrc, texdir=texdirtex, gitpref="",},
     { name = "main"              ,kind = kind_core, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" },
-    { name = "init"              ,kind = kind_core, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" },
+    { name = "fontloader"        ,kind = kind_core, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" },
     { name = "log"               ,kind = kind_core, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" },
     { name = "diagnostics"       ,kind = kind_core, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" },
     
diff --git a/src/luaotfload-init.lua b/src/luaotfload-fontloader.lua
similarity index 92%
rename from src/luaotfload-init.lua
rename to src/luaotfload-fontloader.lua
index 1ee646b..3a6b753 100644
--- a/src/luaotfload-init.lua
+++ b/src/luaotfload-fontloader.lua
@@ -1,12 +1,12 @@
 -----------------------------------------------------------------------
---         FILE:  luaotfload-init.lua
+--         FILE:  luaotfload-fontloader.lua
 --  DESCRIPTION:  part of luaotfload / font loader initialization
 -- REQUIREMENTS:  luatex v.0.80 or later; packages lualibs
 --       AUTHOR:  Philipp Gesang (Phg), <phg at phi-gamma.net>, Marcel Krüger
 -----------------------------------------------------------------------
 
 local ProvidesLuaModule = {
-    name          = "luaotfload-init",
+    name          = "luaotfload-fontloader",
     version       = "3.14",       --TAGVERSION
     date          = "2020-05-06", --TAGDATE
     description   = "luaotfload submodule / initialization",
@@ -148,53 +148,65 @@ local context_modules = {
 
 } --[[context_modules]]
 
-local function load_context_modules (pth)
+local function ignore_module (name)
+    logreport ("log", 3, "load",
+               "Skipping module %q on purpose.",
+               name)
+end
 
+local function load_context_modules (base)
   local load_module   = luaotfload.loaders.context
-  local ignore_module = luaotfload.loaders.ignore
-
-  logreport ("both", 2, "init",
-             "Loading fontloader components from context.")
-  for i = 1, #context_modules do
-    local kind, spec = unpack (context_modules [i])
-    if kind == ignore then
-      ignore_module (spec)
-    else
-      if kind == ltx then
-        spec = 'luatex-' .. spec
-      end
-      local sub = context_module_paths[kind]
-      local tsub = type (sub)
-      if not pth then
+  local resolved_paths = {}
+  if base then
+    for k, path in next, context_module_paths do
+      local found
+      local tpath = type (path)
+      if not path then
         load_module (spec)
-      elseif tsub == "string" then
-        load_module (spec, file.join (pth, sub))
-      elseif tsub == "table" then
-        local pfx
-        local nsub = #sub
-        for j = 1, nsub do
-          local full = file.join (pth, sub [j])
+      elseif tpath == "string" then
+        path = file.join(base, path)
+        if lfsisdir(path) then
+          found = path
+        end
+      elseif tpath == "table" then
+        for j = 1, #path do
+          local full = file.join (base, path[j])
           if lfsisdir (full) then --- pick the first real one
-            pfx = full
+            found = full
             break
           end
         end
-        if pfx then
-          load_module (spec, pfx)
-        else
-          logreport ("both", 0, "init",
-                     "None of the %d search paths for module %q exist; \z
-                      falling back to default path.",
-                     nsub, tostring (spec))
-          load_module (spec) --- maybe we’ll get by after all?
-        end
+      else
+        assert(false)
+      end
+      if found then
+        resolved_paths[j] = found
       else
         logreport ("both", 0, "init",
-                   "Internal error, please report. \z
-                    This is not your fault.")
-        os.exit (-1)
+                   "Search path for ConTeXt modules doesn't exists. \z
+                    Are you sure that this is a ConTeXt path? \z
+                    I will try to interpret the fontloader option in another \z
+                    way now, but please fix your configuration.")
+        return false
       end
     end
+    logreport ("log", 0, "init",
+               "Loading Context files under prefix %q.",
+               fontloader)
+  else
+    logreport ("log", 0, "init",
+               "Loading Context modules in lookup path.")
+  end
+  for i = 1, #context_modules do
+    local kind, spec = unpack (context_modules [i])
+    if kind == ignore then
+      ignore_module (spec)
+    else
+      if kind == ltx then
+        spec = 'luatex-' .. spec
+      end
+      load_module (spec, resolved_paths[kind])
+    end
   end
 
 end
@@ -287,7 +299,6 @@ local function init_main(early_hook)
   font.originaleach = font.each
 
   local load_fontloader_module = luaotfload.loaders.fontloader
-  local ignore_module          = luaotfload.loaders.ignore
 
   load_fontloader_module "basics-gen"
 
@@ -336,17 +347,10 @@ local function init_main(early_hook)
       (mod[1] == ignore and ignore_module or load_fontloader_module)(mod[2])
     end
 
-  elseif fontloader == "context" then
-    logreport ("log", 0, "init",
-               "Loading Context modules in lookup path.")
-    load_context_modules ()
-
-  elseif lfsisdir (fontloader) and verify_context_dir (fontloader) then
-    logreport ("log", 0, "init",
-               "Loading Context files under prefix %q.",
-               fontloader)
-    load_context_modules (fontloader)
-
+  elseif fontloader == "context" and load_context_modules() then
+    ;
+  elseif lfsisdir (fontloader) and load_context_modules (fontloader) then
+    ;
   elseif lfs.isfile (fontloader) then
     logreport ("log", 0, "init",
                "Loading fontloader from absolute path %q.",
diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua
index 932c154..43c3108 100644
--- a/src/luaotfload-main.lua
+++ b/src/luaotfload-main.lua
@@ -177,12 +177,6 @@ end
     called in the expected places.
 --doc]]--
 
-local function dummy_loader (name)
-    logreport ("log", 3, "load",
-               "Skipping module %q on purpose.",
-               name)
-end
-
 local context_environment = setmetatable({}, {__index = _G})
 luaotfload.fontloader = context_environment
 local function context_isolated_load(name)
@@ -233,7 +227,6 @@ local function install_loaders ()
     loaders.luaotfload = loadmodule
     loaders.fontloader = make_loader ("fontloader", context_isolated_load)
     loaders.context    = context_loader
-    loaders.ignore     = dummy_loader
 ----loaders.plaintex   = make_loader "luatex" --=> for Luatex-Plain
 
     function loaders.initialize (name)
@@ -284,7 +277,7 @@ luaotfload.main = function ()
         luaotfload.harfbuzz = harfbuzz
     end
 
-    local init      = loadmodule "init" --- fontloader initialization
+    local init      = loadmodule "fontloader" --- fontloader initialization
     init (function ()
         initialize "parsers"         --- fonts.conf and syntax
         initialize "configuration"   --- configuration options





More information about the latex3-commits mailing list.