[latex3-commits] [git/LaTeX3-latex3-luaotfload] modules: Fix luaotfload-tool (be493b6)
Marcel Fabian Krüger
tex at 2krueger.de
Sun May 24 18:00:31 CEST 2020
Repository : https://github.com/latex3/luaotfload
On branch : modules
Link : https://github.com/latex3/luaotfload/commit/be493b6a6bb7c277247b55c0cc4fd035b607bc41
>---------------------------------------------------------------
commit be493b6a6bb7c277247b55c0cc4fd035b607bc41
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Sun May 24 17:03:52 2020 +0200
Fix luaotfload-tool
>---------------------------------------------------------------
be493b6a6bb7c277247b55c0cc4fd035b607bc41
src/luaotfload-configuration.lua | 14 +++----
src/luaotfload-database.lua | 11 ++---
src/luaotfload-tool.lua | 88 ++++++++++++++++------------------------
3 files changed, 49 insertions(+), 64 deletions(-)
diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua
index 41aca9e..623a72f 100644
--- a/src/luaotfload-configuration.lua
+++ b/src/luaotfload-configuration.lua
@@ -311,6 +311,7 @@ local function check_termwidth ()
end
local function set_font_filter ()
+ if not fonts then return true end
local names = fonts.names
if names and names.set_font_filter then
local formats = config.db.formats
@@ -323,6 +324,7 @@ local function set_font_filter ()
end
local function set_size_dimension ()
+ if not fonts then return true end
local names = fonts.names
if names and names.set_size_dimension then
local dim = config.db.designsize_dimen
@@ -335,25 +337,23 @@ local function set_size_dimension ()
end
local function set_name_resolver ()
+ if not fonts then return true end
local names = fonts.names
if names and names.resolve_cached then
--- replace the resolver from luatex-fonts
if config.db.resolver == "cached" then
logreport ("both", 2, "cache", "Caching of name: lookups active.")
- names.resolvespec = fonts.names.lookup_font_name_cached
+ names.resolvespec = names.lookup_font_name_cached
else
- names.resolvespec = fonts.names.lookup_font_name
+ names.resolvespec = names.lookup_font_name
end
end
return true
end
local function set_loglevel ()
- if luaotfload then
- log.set_loglevel (config.run.log_level)
- return true
- end
- return false
+ log.set_loglevel (config.run.log_level)
+ return true
end
local function build_cache_paths ()
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index 2986e66..e43d36f 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -137,11 +137,6 @@ local next = next
local tonumber = tonumber
local unpack = table.unpack
-local fonts = fonts or { }
-local fontshandlers = fonts.handlers or { }
-local otfhandler = fonts.handlers.otf or { }
-fonts.handlers = fontshandlers
-
local iolines = io.lines
local ioopen = io.open
local kpseexpand_path = kpse.expand_path
@@ -170,7 +165,13 @@ local utf8offset = utf8.offset
--- these come from Lualibs/Context
local context_environment = require'luaotfload-fontloader'
+
+local fonts = fonts or { }
+local fontshandlers = fonts.handlers or { }
+local otfhandler = fonts.handlers.otf or { }
+fonts.handlers = fontshandlers
local caches = context_environment.caches
+
local filebasename = file.basename
local filecollapsepath = file.collapsepath or file.collapse_path
local filedirname = file.dirname
diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua
index b53970d..68a74a5 100755
--- a/src/luaotfload-tool.lua
+++ b/src/luaotfload-tool.lua
@@ -24,7 +24,6 @@ luaotfload = luaotfload or { }
local version = ProvidesLuaModule.version
luaotfload.version = ProvidesLuaModule.version
luaotfload.self = "luaotfload-tool"
-luaotfload.fontloader = _G -- We don't isolate the fontloader here
--[[doc--
@@ -98,56 +97,42 @@ local tablekeys = table.keys
local tableserialize = table.serialize
local tablesortedkeys = table.sortedkeys
local tabletohash = table.tohash
-local splitcomma = require "luaotfload-parsers".splitcomma
-
-local config = require "luaotfload-configuration"
-
---[[doc--
-\fileent{luatex-basics-gen.lua} calls functions from the
-\luafunction{texio.*} library; too much for our taste.
-We intercept them with dummies.
-
-Also, it sets up dummies in place of the tables created by the Context
-libraries. Since we have loaded the lualibs already this would cause
-collateral damage for some libraries whose namespace would be
-overridden. We employ our usual backup-restore strategy to work around
-this. (Postponing the loading of the lualibs code is not an option
-because the functionality is needed by basics-gen itself.)
---doc]]--
-local function dummy_function ( ) end
-local backup = {
- write = texio.write,
- write_nl = texio.write_nl,
- utilities = utilities,
-}
+package.preload["luaotfload-fontloader"] = function()
+ local environment = require'luaotfload-fontloader-base'
+
+ fonts = fonts or { }
+ environment.fonts = fonts
+ local fontsnames = fonts.names or { }
+ fonts.names = fontsnames
+
+ environment.pdf = pdf or {}
+
+ local function load(name)
+ return assert(loadfile(assert(kpsefind_file('fontloader-' .. name, 'lua')), nil, environment))()
+ end
+ load "data-con"
+ load "font-ini"
+ load "font-con"
+ load "fonts-enc"
+ load "font-cid"
+ load "font-map"
+ load "font-oti"
+ load "font-otr"
+ load "font-ott"
+ load "font-cff"
+ load "font-ttf"
+ load "font-dsp"
+ load "font-oup"
+ load "font-onr"
+ load "font-def"
+
+ return environment
+end
-texio.write, texio.write_nl = dummy_function, dummy_function
-require "fontloader-basics-gen.lua"
-texio.write, texio.write_nl = backup.write, backup.write_nl
-utilities = backup.utilities
-
-pdf = pdf or { } --- for fonts-tfm
-
-require "fontloader-data-con"
-require "fontloader-font-ini"
-require "fontloader-font-con"
-require "fontloader-fonts-enc"
-require "fontloader-font-cid"
-require "fontloader-font-map"
-require "fontloader-font-oti"
-require "fontloader-font-otr"
-require "fontloader-font-ott"
-require "fontloader-font-cff"
-require "fontloader-font-ttf"
-require "fontloader-font-dsp"
-require "fontloader-font-oup"
-require "fontloader-font-onr"
-require "fontloader-font-def"
-
-fonts = fonts or { }
-local fontsnames = fonts.names or { }
-fonts.names = fontsnames
+local splitcomma = require "luaotfload-parsers".splitcomma
+local config = require "luaotfload-configuration"
+local fontloader = require "luaotfload-fontloader"
local require_init = { }
@@ -171,7 +156,6 @@ end
require "alt_getopt"
local log = require "luaotfload-log"
-loadmodule "configuration" --- configuration file handling
loadmodule "database"
loadmodule "resolvers" --- Font lookup
@@ -305,7 +289,7 @@ local function help_msg (version)
luaotfload.self,
names_gzip,
names_bin,
- caches.getwritablepath (config.paths.cache_dir, "")))
+ fontloader.caches.getwritablepath (config.paths.cache_dir, "")))
end
local about = [[
@@ -790,7 +774,7 @@ end
--- bisect mode
-------------------------------------------------------------------------------
-local bisect_status_path = caches.getwritablepath ("bisect", "")
+local bisect_status_path = fontloader.caches.getwritablepath ("bisect", "")
local bisect_status_file = bisect_status_path .."/" .. "luaotfload-bisect-status.lua"
local bisect_status_fmt = [[
--[==[-------------------------------------------------------------------------
More information about the latex3-commits
mailing list.