From f7f541616aaf77c5f2ecb40a50f72b2e94575675 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 29 Nov 2015 22:04:00 +0100 Subject: [loaders] customize define_font reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/luaotfload-loaders.lua | 25 +++++++++++++++++-------- 1 file 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"], -- cgit v1.2.3