[latex3-commits] [git/LaTeX3-latex3-luaotfload] modules: Modulize fontloader (12c95ea)

Marcel Fabian Krüger tex at 2krueger.de
Sun May 24 06:04:06 CEST 2020


Repository : https://github.com/latex3/luaotfload
On branch  : modules
Link       : https://github.com/latex3/luaotfload/commit/12c95ea4615e77a343cb48c3d857b72567bc26cb

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

commit 12c95ea4615e77a343cb48c3d857b72567bc26cb
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Sun May 24 06:04:06 2020 +0200

    Modulize fontloader


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

12c95ea4615e77a343cb48c3d857b72567bc26cb
 src/luaotfload-configuration.lua   |  2 +-
 src/luaotfload-database.lua        |  2 +-
 src/luaotfload-fontloader-base.lua | 42 ++++++++++++++++++++++++++++++++++++++
 src/luaotfload-fontloader.lua      | 41 ++++++++++---------------------------
 src/luaotfload-harf-define.lua     |  2 +-
 src/luaotfload-main.lua            |  4 +---
 src/luaotfload-notdef.lua          |  7 +++++--
 src/luaotfload-resolvers.lua       |  2 +-
 8 files changed, 63 insertions(+), 39 deletions(-)

diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua
index e252612..1719bbe 100644
--- a/src/luaotfload-configuration.lua
+++ b/src/luaotfload-configuration.lua
@@ -64,7 +64,7 @@ local filereplacesuffix       = file.replacesuffix
 local log                     = require'luaotfload-log'
 local logreport               = log.report
 
-local getwritablepath         = luaotfload.fontloader.caches.getwritablepath
+local getwritablepath         = require'luaotfload-fontloader-base'.caches.getwritablepath
 
 local parsers                 = require 'luaotfload-parsers'
 local config_parser           = parsers.config
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index 128b7f6..2986e66 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -169,7 +169,7 @@ local utf8len                  = utf8.len
 local utf8offset               = utf8.offset
 
 --- these come from Lualibs/Context
-local context_environment      = luaotfload.fontloader
+local context_environment      = require'luaotfload-fontloader'
 local caches                   = context_environment.caches
 local filebasename             = file.basename
 local filecollapsepath         = file.collapsepath or file.collapse_path
diff --git a/src/luaotfload-fontloader-base.lua b/src/luaotfload-fontloader-base.lua
new file mode 100644
index 0000000..6dc07a9
--- /dev/null
+++ b/src/luaotfload-fontloader-base.lua
@@ -0,0 +1,42 @@
+-----------------------------------------------------------------------
+--         FILE:  luaotfload-fontloader-base.lua
+--  DESCRIPTION:  part of luaotfload / font loader initialization -- generic
+-- 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-fontloader-base",
+    version       = "3.14",       --TAGVERSION
+    date          = "2020-05-06", --TAGDATE
+    description   = "luaotfload submodule / pre-initialization",
+    license       = "GPL v2.0"
+}
+
+if luatexbase and luatexbase.provides_module then
+  luatexbase.provides_module (ProvidesLuaModule)
+end
+-----------------------------------------------------------------------
+
+
+local kpsefind_file   = kpse.find_file
+
+local log = require'luaotfload-log'
+
+local context_environment = setmetatable({}, {__index = _G})
+
+require "lualibs"
+
+--[[doc--
+
+  The logger needs to be in place prior to loading the fontloader due
+  to order of initialization being crucial for the logger functions
+  that are swapped.
+
+--doc]]--
+log.set_loglevel (default_log_level)
+
+assert(loadfile(kpsefind_file("fontloader-basics-gen", "lua"), nil, context_environment))()
+
+return context_environment
+-- vim:tw=79:sw=2:ts=2:expandtab
diff --git a/src/luaotfload-fontloader.lua b/src/luaotfload-fontloader.lua
index 043c4aa..42696df 100644
--- a/src/luaotfload-fontloader.lua
+++ b/src/luaotfload-fontloader.lua
@@ -154,8 +154,7 @@ local function ignore_module (name)
              name)
 end
 
-local context_environment = luaotfload.fontloader or setmetatable({}, {__index = _G})
-luaotfload.fontloader = context_environment
+local context_environment = require'luaotfload-fontloader-base'
 
 local function context_isolated_load(name)
   local fullname = kpsefind_file(name, 'lua')
@@ -259,24 +258,12 @@ local function verify_context_dir (pth)
   return false
 end
 
-local function init_main(early_hook)
+local function init_main()
   fonts                        = fonts or { }
 
-  require "lualibs"
-
   if not lualibs    then error "this module requires Luaotfload" end
   if not luaotfload then error "this module requires Luaotfload" end
 
-  --[[doc--
-
-    The logger needs to be in place prior to loading the fontloader due
-    to order of initialization being crucial for the logger functions
-    that are swapped.
-
-  --doc]]--
-
-  log.set_loglevel (default_log_level)
-
   logreport ("log", 4, "init", "Concealing callback.register().")
   local trapped_register = callback.register
 
@@ -323,10 +310,6 @@ local function init_main(early_hook)
 
   font.originaleach = font.each
 
-  context_loader "fontloader-basics-gen"
-
-  if early_hook then early_hook() end
-
   --[[doc--
 
       The font loader requires that the attribute with index zero be
@@ -424,7 +407,7 @@ local init_post_install_callbacks = function ()
   local multiscript = require "luaotfload-multiscript".process
 
   -- MK Pass current text direction to simple_font_handler
-  local handler = luaotfload.fontloader.nodes.simple_font_handler
+  local handler = context_environment.nodes.simple_font_handler
   local callback = function(head, groupcode, _, _, direction)
     if not direction then
       direction = tex.get'textdir'
@@ -545,14 +528,12 @@ local function init_post ()
   return n
 end --- [init_post]
 
-return function (early_hook)
-  local starttime = os.gettimeofday ()
-  init_main (early_hook)
-  logreport ("both", 1, "init",
-             "fontloader loaded in %0.3f seconds",
-             os.gettimeofday() - starttime)
-  local n = init_post ()
-  logreport ("both", 5, "init", "post hook terminated, %d actions performed", n)
-  return true
-end
+local starttime = os.gettimeofday ()
+init_main ()
+logreport ("both", 1, "init",
+           "fontloader loaded in %0.3f seconds",
+           os.gettimeofday() - starttime)
+local n = init_post ()
+logreport ("both", 5, "init", "post hook terminated, %d actions performed", n)
+return context_environment
 -- vim:tw=79:sw=2:ts=2:expandtab
diff --git a/src/luaotfload-harf-define.lua b/src/luaotfload-harf-define.lua
index 413a4e9..6f1bea6 100644
--- a/src/luaotfload-harf-define.lua
+++ b/src/luaotfload-harf-define.lua
@@ -74,7 +74,7 @@ local get_designsize do
   end
 end
 
-local containers = luaotfload.fontloader.containers
+local containers = require'luaotfload-fontloader'.containers
 local hbcacheversion = 1.1
 local facecache = containers.define("fonts", "hb", hbcacheversion, true)
 
diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua
index 2d6db61..d6f36f1 100644
--- a/src/luaotfload-main.lua
+++ b/src/luaotfload-main.lua
@@ -179,9 +179,7 @@ luaotfload.main = function ()
         luaotfload.harfbuzz = harfbuzz
     end
 
-    local init      = loadmodule "fontloader" --- fontloader initialization
-    init (function ()
-    end)
+    loadmodule "fontloader" --- fontloader initialization
 
     initialize "loaders"         --- Font loading; callbacks
     initialize "database"        --- Font management.
diff --git a/src/luaotfload-notdef.lua b/src/luaotfload-notdef.lua
index 7d611eb..909316d 100644
--- a/src/luaotfload-notdef.lua
+++ b/src/luaotfload-notdef.lua
@@ -27,7 +27,6 @@ local kern_id            = node.id'kern'
 local disc_id            = node.id'disc'
 local nodenew            = node.direct.new
 local nodecopy           = node.direct.copy
-local otfregister        = fonts.constructors.features.otf.register
 local protect_glyph      = node.direct.protect_glyph
 local remove             = node.direct.remove
 local setfont            = node.direct.setfont
@@ -38,7 +37,11 @@ local getwidth           = node.direct.getwidth
 local setkern            = node.direct.setkern
 local setattributelist   = node.direct.setattributelist
 local getattributelist   = node.direct.getattributelist
-local setmove            = luaotfload.fontloader.nodes.injections.setmove
+
+local fontloader         = require'luaotfload-fontloader'
+
+local otfregister        = fontloader.fonts.constructors.features.otf.register
+local setmove            = fontloader.nodes.injections.setmove
 
 -- According to DerivedCoreProperties.txt, Default_Ignorable_Code_Point
 -- is generated from:
diff --git a/src/luaotfload-resolvers.lua b/src/luaotfload-resolvers.lua
index c9e01c4..00ad607 100644
--- a/src/luaotfload-resolvers.lua
+++ b/src/luaotfload-resolvers.lua
@@ -149,7 +149,7 @@ end
 
 local tex_formats = { "tfm", "ofm" }
 
-local resolvers_findfile = luaotfload.fontloader.resolvers.findfile
+local resolvers_findfile = require'luaotfload-fontloader'.resolvers.findfile
 local function resolve_tex_format (specification)
     local name = specification.name
     for i=1, #tex_formats do





More information about the latex3-commits mailing list.