summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luaotfload-auxiliary.lua2
-rw-r--r--src/luaotfload-colors.lua34
-rw-r--r--src/luaotfload-configuration.lua10
-rw-r--r--src/luaotfload-database.lua2
-rw-r--r--src/luaotfload-diagnostics.lua15
-rw-r--r--src/luaotfload-init.lua13
-rw-r--r--src/luaotfload-loaders.lua30
-rw-r--r--src/luaotfload-main.lua13
-rwxr-xr-xsrc/luaotfload-tool.lua17
-rw-r--r--src/luaotfload.sty1
10 files changed, 86 insertions, 51 deletions
diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua
index 15541af..c50e0cd 100644
--- a/src/luaotfload-auxiliary.lua
+++ b/src/luaotfload-auxiliary.lua
@@ -63,7 +63,7 @@ aux.start_rewrite_fontname = start_rewrite_fontname
local stop_rewrite_fontname = function ()
if rewriting == true then
- luatexbase.remove_fromt_callback
+ luatexbase.remove_from_callback
("luaotfload.patch_font", "luaotfload.rewrite_fontname")
rewriting = false
report ("log", 1, "aux",
diff --git a/src/luaotfload-colors.lua b/src/luaotfload-colors.lua
index ca5a067..c75696a 100644
--- a/src/luaotfload-colors.lua
+++ b/src/luaotfload-colors.lua
@@ -1,7 +1,7 @@
if not modules then modules = { } end modules ['luaotfload-colors'] = {
version = "2.6",
comment = "companion to luaotfload-main.lua (font color)",
- author = "Khaled Hosny, Elie Roux, Philipp Gesang, Dohyun Kim",
+ author = "Khaled Hosny, Elie Roux, Philipp Gesang, Dohyun Kim, David Carlisle",
copyright = "Luaotfload Development Team",
license = "GNU GPL v2.0"
}
@@ -37,11 +37,6 @@ local nodetail = nodedirect.tail
local getattribute = nodedirect.has_attribute
local setattribute = nodedirect.set_attribute
-local texset = tex.set
-local texget = tex.get
-local texsettoks = tex.settoks
-local texgettoks = tex.gettoks
-
local stringformat = string.format
local identifiers = fonts.hashes.identifiers
@@ -274,6 +269,12 @@ node_colorize = function (head, toplevel, current_color)
return head, current_color
end
+local getpageres = pdf.getpageresources or function() return pdf.pageresources end
+local setpageres = pdf.setpageresources or function(s) pdf.pageresources = s end
+local catat11 = luatexbase.registernumber("catcodetable@atletter")
+local gettoks, scantoks = tex.gettoks, tex.scantoks
+local pgf = { bye = "pgfutil@everybye", extgs = "\\pgf@sys@addpdfresource@extgs@plain" }
+
--- node -> node
local color_handler = function (head)
head = todirect(head)
@@ -283,12 +284,11 @@ local color_handler = function (head)
-- now append our page resources
if res then
res["1"] = true
- local tpr = texget("pdfpageresources")
- local no_extgs = not tpr:find("/ExtGState<<.*>>")
- local pgf_loaded = no_extgs and luaotfload.pgf_loaded
- if pgf_loaded then
- tpr = texgettoks(pgf_loaded)
+ if scantoks and pgf.bye and not pgf.loaded then
+ pgf.loaded = token.create(pgf.bye).cmdname == "assign_toks"
+ pgf.bye = pgf.loaded and pgf.bye
end
+ local tpr = pgf.loaded and gettoks(pgf.bye) or getpageres() or ""
local t = ""
for k in pairs(res) do
@@ -298,14 +298,14 @@ local color_handler = function (head)
end
end
if t ~= "" then
- if pgf_loaded then
- texsettoks("global", pgf_loaded, tpr..t)
+ if pgf.loaded then
+ scantoks("global", pgf.bye, catat11, stringformat("%s{%s}%s", pgf.extgs, t, tpr))
else
- if no_extgs then
- tpr = tpr .. "/ExtGState<<>>"
+ local tpr, n = tpr:gsub("/ExtGState<<", "%1"..t)
+ if n == 0 then
+ tpr = stringformat("%s/ExtGState<<%s>>", tpr, t)
end
- tpr = tpr:gsub("/ExtGState<<", "%1"..t)
- texset("global", "pdfpageresources", tpr)
+ setpageres(tpr)
end
end
res = nil -- reset res
diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua
index 57311dc..5e2800d 100644
--- a/src/luaotfload-configuration.lua
+++ b/src/luaotfload-configuration.lua
@@ -3,7 +3,7 @@
-- FILE: luaotfload-configuration.lua
-- DESCRIPTION: config file reader
-- REQUIREMENTS: Luaotfload 2.6 or above
--- AUTHOR: Philipp Gesang (Phg), <phg42.2a@gmail.com>
+-- AUTHOR: Philipp Gesang, <phg@phi-gamma.net>
-- AUTHOR: Dohyun Kim <nomosnomos@gmail.com>
-------------------------------------------------------------------------------
--
@@ -126,8 +126,12 @@ local feature_presets = {
--doc]]--
+local default_fontloader = function ()
+ return luaotfloadstatus and luaotfloadstatus.notes.loader or "reference"
+end
+
local registered_loaders = {
- default = luaotfloadstatus and luaotfloadstatus.notes.loader or "reference",
+ default = default_fontloader (),
reference = "reference",
unpackaged = "unpackaged",
context = "context",
@@ -198,7 +202,7 @@ local default_config = {
definer = "patch",
log_level = 0,
color_callback = "post_linebreak_filter",
- fontloader = "default",
+ fontloader = default_fontloader (),
},
misc = {
bisect = false,
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index 35450b5..881cfe8 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -3414,7 +3414,7 @@ end
local getwritablecachepath = function ( )
--- fonts.handlers.otf doesn’t exist outside a Luatex run,
--- so we have to improvise
- local writable = getwritablepath (config.luaotfload.paths.cache_dir)
+ local writable = getwritablepath (config.luaotfload.paths.cache_dir, "")
if writable then
return writable
end
diff --git a/src/luaotfload-diagnostics.lua b/src/luaotfload-diagnostics.lua
index 582105a..a3a1841 100644
--- a/src/luaotfload-diagnostics.lua
+++ b/src/luaotfload-diagnostics.lua
@@ -3,7 +3,7 @@
-- FILE: luaotfload-diagnostics.lua
-- DESCRIPTION: functionality accessible by the --diagnose option
-- REQUIREMENTS: luaotfload-tool.lua
--- AUTHOR: Philipp Gesang (Phg), <phg42.2a@gmail.com>
+-- AUTHOR: Philipp Gesang <phg@phi-gamma.net>
-----------------------------------------------------------------------
--
local names = fonts.names
@@ -171,6 +171,11 @@ local get_permissions = function (t, location)
location = lpegmatch (stripslashes, location)
end
local attributes = lfsattributes (location)
+ if not attributes then
+ print""
+ print("attr", location, attributes)
+ os.exit()
+ end
if not attributes and t == "f" then
attributes = get_tentative_attributes (location)
@@ -238,12 +243,10 @@ local check_conformance = function (spec, permissions, errcnt)
return errcnt
end
-local desired_permissions
local init_desired_permissions = function ()
- inspect(config.luaotfload.paths)
local paths = config.luaotfload.paths
- desired_permissions = {
- { "d", {"r","w"}, function () return caches.getwritablepath () end },
+ return {
+ { "d", {"r","w"}, function () return caches.getwritablepath ("", "") end },
{ "d", {"r","w"}, paths.prefix },
{ "f", {"r","w"}, paths.index_path_lua .. ".gz" },
{ "f", {"r","w"}, paths.index_path_luc },
@@ -254,7 +257,7 @@ end
local check_permissions = function (errcnt)
out [[=============== file permissions ==============]]
- if not desired_permissions then init_desired_permissions () end
+ local desired_permissions = init_desired_permissions ()
for i = 1, #desired_permissions do
local t, spec, path = unpack (desired_permissions[i])
if type (path) == "function" then
diff --git a/src/luaotfload-init.lua b/src/luaotfload-init.lua
index 0f7464a..a8fc77b 100644
--- a/src/luaotfload-init.lua
+++ b/src/luaotfload-init.lua
@@ -2,7 +2,7 @@
-----------------------------------------------------------------------
-- FILE: luaotfload-init.lua
-- DESCRIPTION: Luaotfload font loader initialization
--- REQUIREMENTS: luatex v.0.80 or later; packages lualibs, luatexbase
+-- REQUIREMENTS: luatex v.0.80 or later; packages lualibs
-- AUTHOR: Philipp Gesang (Phg), <phg@phi-gamma.net>
-----------------------------------------------------------------------
--
@@ -292,10 +292,19 @@ local init_main = function ()
or "reference"
fontloader = tostring (fontloader)
- if fontloader == "reference" or fontloader == "default" then
+ if fontloader == "reference" then
logreport ("log", 4, "init", "Using reference fontloader.")
load_fontloader_module (luaotfload.fontloader_package)
+ elseif fontloader == "default" then
+ --- Same as above but loader name not correctly replaced by the file name
+ --- of our fontloader package. Perhaps something’s wrong with the status
+ --- file which contains the datestamped filename? In any case, it can’t
+ --- hurt reporting it as a bug.
+ logreport ("both", 0, "init", "Fontloader substitution failed, got “default”.")
+ logreport ("log", 4, "init", "Falling back to reference fontloader.")
+ load_fontloader_module (luaotfload.fontloader_package)
+
elseif fontloader == "unpackaged" then
logreport ("both", 4, "init",
"Loading fontloader components individually.")
diff --git a/src/luaotfload-loaders.lua b/src/luaotfload-loaders.lua
index 715aa8a..0f22f46 100644
--- a/src/luaotfload-loaders.lua
+++ b/src/luaotfload-loaders.lua
@@ -2,8 +2,9 @@
-----------------------------------------------------------------------
-- FILE: luaotfload-loaders.lua
-- DESCRIPTION: Luaotfload callback handling
--- REQUIREMENTS: luatex v.0.80 or later; packages lualibs, luatexbase
--- AUTHOR: Philipp Gesang (Phg), <phg@phi-gamma.net>, Hans Hagen, Khaled Hosny, Elie Roux
+-- REQUIREMENTS: luatex v.0.80 or later; package lualibs
+-- AUTHOR: Philipp Gesang <phg@phi-gamma.net>
+-- AUTHOR: Hans Hagen, Khaled Hosny, Elie Roux, David Carlisle
-----------------------------------------------------------------------
--
--- Contains parts of the earlier main script.
@@ -110,13 +111,22 @@ end
--doc]]--
-local function reset_callback(name,make_false)
- for _,v in pairs(luatexbase.callback_descriptions(name))
- do
- luatexbase.remove_from_callback(name,v)
- end
- if make_false == true then
- luatexbase.disable_callback(name)
+local purge_define_font = function ()
+ local cdesc = luatexbase.callback_descriptions "define_font"
+ --- define_font is an “exclusive” callback, meaning that there can
+ --- only ever be one entry. Everything beyond that would indicate
+ --- that something is broken.
+ local _, d = next (cdesc)
+ if d then
+ local i, d2 = next (cdesc, 1)
+ if d2 then --> issue warning
+ logreport ("both", 0, "loaders",
+ "Callback table for define_font contains multiple entries: \z
+ { [%d] = “%s” } -- seems fishy.", i, d2)
+ end
+ logreport ("log", 0, "loaders",
+ "Entry ``%s`` present in define_font callback; overriding.", d)
+ luatexbase.remove_from_callback ("define_font", d)
end
end
@@ -125,7 +135,7 @@ local install_callbacks = function ()
local dummy_function = function () end
create_callback ("luaotfload.patch_font", "simple", dummy_function)
create_callback ("luaotfload.patch_font_unsafe", "simple", dummy_function)
- reset_callback "define_font"
+ purge_define_font ()
local definer = config.luaotfload.run.definer
luatexbase.add_to_callback ("define_font",
definers[definer or "patch"],
diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua
index 17d06d4..b8050e4 100644
--- a/src/luaotfload-main.lua
+++ b/src/luaotfload-main.lua
@@ -1,7 +1,7 @@
-----------------------------------------------------------------------
-- FILE: luaotfload-main.lua
-- DESCRIPTION: Luaotfload entry point
--- REQUIREMENTS: luatex v.0.80 or later; packages lualibs, luatexbase
+-- REQUIREMENTS: luatex v.0.80 or later; packages lualibs
-- AUTHOR: Élie Roux, Khaled Hosny, Philipp Gesang
-----------------------------------------------------------------------
--
@@ -62,8 +62,7 @@ local luatexbase = luatexbase
local require = require
local type = type
-local _error, _warning, _info, _log =
- luatexbase.provides_module(luaotfload.module)
+luatexbase.provides_module (luaotfload.module)
--[[doc--
@@ -99,7 +98,13 @@ end
local make_loader_name = function (prefix, name)
local msg = luaotfload.log and luaotfload.log.report
- or function (...) texio.write_nl ("log", ...) end
+ or function (stream, lvl, cat, ...)
+ if lvl > 1 then --[[not pressing]] return end
+ texio.write_nl ("log",
+ string.format ("luaotfload | %s : ",
+ tostring (cat)))
+ texio.write (string.format (...))
+ end
if not name then
msg ("both", 0, "load",
"Fatal error: make_loader_name (“%s”, “%s”).",
diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua
index ab025b3..ab495a9 100755
--- a/src/luaotfload-tool.lua
+++ b/src/luaotfload-tool.lua
@@ -858,7 +858,7 @@ end
--- bisect mode
-------------------------------------------------------------------------------
-local bisect_status_path = caches.getwritablepath "bisect"
+local bisect_status_path = caches.getwritablepath ("bisect", "")
local bisect_status_file = bisect_status_path .."/" .. "luaotfload-bisect-status.lua"
local bisect_status_fmt = [[
--[==[-------------------------------------------------------------------------
@@ -1174,14 +1174,17 @@ actions.flush = function (job)
return false, false
end
-local cache_directives = {
- ["purge"] = fonts.names.purge_cache,
- ["erase"] = fonts.names.erase_cache,
- ["show"] = fonts.names.show_cache,
-}
+local cache_directives = function ()
+ --- These exist only after initialization.
+ return {
+ ["purge"] = fonts.names.purge_cache,
+ ["erase"] = fonts.names.erase_cache,
+ ["show"] = fonts.names.show_cache,
+ }
+end
actions.cache = function (job)
- local directive = cache_directives[job.cache]
+ local directive = cache_directives()[job.cache]
if not directive or type(directive) ~= "function" then
logreport ("info", 2, "cache",
"Invalid font cache directive %s.", job.cache)
diff --git a/src/luaotfload.sty b/src/luaotfload.sty
index ad4ef2d..c674ab0 100644
--- a/src/luaotfload.sty
+++ b/src/luaotfload.sty
@@ -4,6 +4,7 @@
%% and Khaled Hosny <khaledhosny@eglug.org>
%% and Philipp Gesang <philipp.gesang@alumni.uni-heidelberg.de>
%% and Dohyun Kim <nomosnomos@gmail.com>
+%% and David Carlisle <d.p.carlisle@gmail.com>
%%
%% This file is part of Luaotfload.
%%