summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2015-11-29 22:04:00 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2015-11-29 22:04:03 +0100
commitf7f541616aaf77c5f2ecb40a50f72b2e94575675 (patch)
treebff29315bc9e6f32768b3abf59a58700c83f2fff
parentfb41f30dd8120532307f6ca1c227cd4807d4f719 (diff)
downloadluaotfload-f7f541616aaf77c5f2ecb40a50f72b2e94575675.tar.gz
[loaders] customize define_font reset
This function needn’t be as general for this kind of callback. The new implementation is simpler but also complains about irregularities like multiple registered functions.
-rw-r--r--src/luaotfload-loaders.lua25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/luaotfload-loaders.lua b/src/luaotfload-loaders.lua
index 715aa8a..0ae281e 100644
--- a/src/luaotfload-loaders.lua
+++ b/src/luaotfload-loaders.lua
@@ -110,13 +110,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 +134,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"],