[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Fix ordering and clean up harf callbacks (f590f55)

Marcel Fabian Krüger tex at 2krueger.de
Mon Oct 19 23:55:23 CEST 2020


Repository : https://github.com/latex3/luaotfload
On branch  : dev
Link       : https://github.com/latex3/luaotfload/commit/f590f55439373a678d0ed28cfbc59863af4d70f9

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

commit f590f55439373a678d0ed28cfbc59863af4d70f9
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Mon Oct 19 23:55:23 2020 +0200

    Fix ordering and clean up harf callbacks


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

f590f55439373a678d0ed28cfbc59863af4d70f9
 src/luaotfload-harf-plug.lua        | 32 ++++++--------------------------
 testfiles-harf/arabic-gr.lvt        |  4 ++--
 testfiles-harf/arabic.lvt           |  4 ++--
 testfiles-harf/color.lvt            |  4 ++--
 testfiles-harf/discretionaries.lvt  |  4 ++--
 testfiles-harf/fallback.lvt         |  4 ++--
 testfiles-harf/math.lvt             |  4 ++--
 testfiles-harf/multiscript-auto.lvt |  4 ++--
 testfiles-harf/scripts.lvt          |  4 ++--
 testfiles-harf/story.lvt            |  4 ++--
 10 files changed, 24 insertions(+), 44 deletions(-)

diff --git a/src/luaotfload-harf-plug.lua b/src/luaotfload-harf-plug.lua
index 21ee47a..b85c24f 100644
--- a/src/luaotfload-harf-plug.lua
+++ b/src/luaotfload-harf-plug.lua
@@ -1042,30 +1042,10 @@ end
 
 fonts.handlers.otf.registerplugin('harf', process)
 
--- luatexbase does not know how to handle `wrapup_run` callback, teach it.
--- TODO: Move these into ltluatex
-luatexbase.callbacktypes.wrapup_run = 1 -- simple
-luatexbase.callbacktypes.glyph_info = 1 -- simple
-
-local base_callback_descriptions = luatexbase.callback_descriptions
-local base_add_to_callback = luatexbase.add_to_callback
-local base_remove_from_callback = luatexbase.remove_from_callback
-
--- Remove all existing functions from given callback, insert ours, then
--- reinsert the removed ones, so ours takes a priority.
-local function add_to_callback(name, func)
-  local saved_callbacks = {}, ff, dd
-  for k, v in next, base_callback_descriptions(name) do
-    saved_callbacks[k] = { base_remove_from_callback(name, v) }
-  end
-  base_add_to_callback(name, func, "Harf "..name.." callback")
-  for _, v in next, saved_callbacks do
-    base_add_to_callback(name, v[1], v[2])
-  end
-end
+local add_to_callback = luatexbase.add_to_callback
 
-add_to_callback('post_linebreak_filter', post_process_vlist_nodes)
-add_to_callback('hpack_filter', post_process_nodes)
-add_to_callback('wrapup_run', run_cleanup)
-add_to_callback('finish_pdffile', set_tounicode)
-add_to_callback('glyph_info', get_glyph_info)
+add_to_callback('post_linebreak_filter', post_process_vlist_nodes, 'luaotfload.harf.finalize_vlist')
+add_to_callback('hpack_filter', post_process_nodes, 'luaotfload.harf.finalize_hlist')
+add_to_callback('wrapup_run', run_cleanup, 'luaotfload.cleanup_files')
+add_to_callback('finish_pdffile', set_tounicode, 'luaotfload.harf.finalize_unicode')
+add_to_callback('glyph_info', get_glyph_info, 'luaotfload.glyphinfo')
diff --git a/testfiles-harf/arabic-gr.lvt b/testfiles-harf/arabic-gr.lvt
index b209b1c..ce10be5 100644
--- a/testfiles-harf/arabic-gr.lvt
+++ b/testfiles-harf/arabic-gr.lvt
@@ -7,11 +7,11 @@
 \directlua{
   local cbs = luatexbase.callback_descriptions'glyph_info'
   local desc = cbs[1]
-  assert(desc == "Harf glyph_info callback" and nil == next(cbs, 1))
+  assert(desc == "luaotfload.glyphinfo" and nil == next(cbs, 1))
   local cb = luatexbase.remove_from_callback('glyph_info', desc)
   luatexbase.add_to_callback('glyph_info', function(n)
     return string.format('"\csstring\%s" \csstring\%04X \csstring\%+i:\csstring\%+i', cb(n), n.char, n.xoffset, n.yoffset)
-  end, 'Harf glyph_info callback -- testing variant')
+  end, 'luaotfload.glyphinfo -- testing variant')
 }
 
 \setmainfont{AwamiNastaliq-Regular.ttf}[Renderer=Harfbuzz, Script=Arabic]
diff --git a/testfiles-harf/arabic.lvt b/testfiles-harf/arabic.lvt
index 55a37f7..128d702 100644
--- a/testfiles-harf/arabic.lvt
+++ b/testfiles-harf/arabic.lvt
@@ -7,11 +7,11 @@
 \directlua{
   local cbs = luatexbase.callback_descriptions'glyph_info'
   local desc = cbs[1]
-  assert(desc == "Harf glyph_info callback" and nil == next(cbs, 1))
+  assert(desc == "luaotfload.glyphinfo" and nil == next(cbs, 1))
   local cb = luatexbase.remove_from_callback('glyph_info', desc)
   luatexbase.add_to_callback('glyph_info', function(n)
     return string.format('"\csstring\%s" \csstring\%04X \csstring\%+i:\csstring\%+i', cb(n), n.char, n.xoffset, n.yoffset)
-  end, 'Harf glyph_info callback -- testing variant')
+  end, 'luaotfload.glyphinfo -- testing variant')
 }
 
 \setmainfont{Amiri}[Renderer=Harfbuzz, Script=Arabic]
diff --git a/testfiles-harf/color.lvt b/testfiles-harf/color.lvt
index 26c721f..c3aefb0 100644
--- a/testfiles-harf/color.lvt
+++ b/testfiles-harf/color.lvt
@@ -7,11 +7,11 @@
 \directlua{
   local cbs = luatexbase.callback_descriptions'glyph_info'
   local desc = cbs[1]
-  assert(desc == "Harf glyph_info callback" and nil == next(cbs, 1))
+  assert(desc == "luaotfload.glyphinfo" and nil == next(cbs, 1))
   local cb = luatexbase.remove_from_callback('glyph_info', desc)
   luatexbase.add_to_callback('glyph_info', function(n)
     return string.format('"\csstring\%s" \csstring\%04X \csstring\%+i:\csstring\%+i', cb(n), n.char, n.xoffset, n.yoffset)
-  end, 'Harf glyph_info callback -- testing variant')
+  end, 'luaotfload.glyphinfo -- testing variant')
 }
 
 \setmainfont{Amiri}[Renderer=Harfbuzz, Script=Arabic]
diff --git a/testfiles-harf/discretionaries.lvt b/testfiles-harf/discretionaries.lvt
index f617934..b3489f5 100644
--- a/testfiles-harf/discretionaries.lvt
+++ b/testfiles-harf/discretionaries.lvt
@@ -7,11 +7,11 @@
 \directlua{
   local cbs = luatexbase.callback_descriptions'glyph_info'
   local desc = cbs[1]
-  assert(desc == "Harf glyph_info callback" and nil == next(cbs, 1))
+  assert(desc == "luaotfload.glyphinfo" and nil == next(cbs, 1))
   local cb = luatexbase.remove_from_callback('glyph_info', desc)
   luatexbase.add_to_callback('glyph_info', function(n)
     return string.format('"\csstring\%s" \csstring\%04X \csstring\%+i:\csstring\%+i', cb(n), n.char, n.xoffset, n.yoffset)
-  end, 'Harf glyph_info callback -- testing variant')
+  end, 'luaotfload.glyphinfo -- testing variant')
 }
 
 \setmainfont{NotoSerifCJK-Regular.ttc}[Renderer=Harfbuzz, Script=Latin]
diff --git a/testfiles-harf/fallback.lvt b/testfiles-harf/fallback.lvt
index 56ff340..f92d481 100644
--- a/testfiles-harf/fallback.lvt
+++ b/testfiles-harf/fallback.lvt
@@ -5,11 +5,11 @@
 \directlua{
   local cbs = luatexbase.callback_descriptions'glyph_info'
   local desc = cbs[1]
-  assert(desc == "Harf glyph_info callback" and nil == next(cbs, 1))
+  assert(desc == "luaotfload.glyphinfo" and nil == next(cbs, 1))
   local cb = luatexbase.remove_from_callback('glyph_info', desc)
   luatexbase.add_to_callback('glyph_info', function(n)
     return string.format('"\csstring\%s" \csstring\%04X \csstring\%+i:\csstring\%+i\string\t\csstring\%s', cb(n), n.char, n.xoffset, n.yoffset, font.getfont(n.font).specification.specification:gsub(";fallback=\csstring\%d+",";fallback=..."))
-  end, 'Harf glyph_info callback -- testing variant')
+  end, 'luaotfload.glyphinfo -- testing variant')
   luatexbase.add_to_callback('glyph_not_found', function(id, char)
     texio.write_nl(string.format('Missing character: There is no \csstring\%s (U+\csstring\%04X) in font \csstring\%s!',
                    utf8.char(char), char, font.getfont(id).specification.specification:gsub(";fallback=\csstring\%d*",";fallback=...")))
diff --git a/testfiles-harf/math.lvt b/testfiles-harf/math.lvt
index 87f91a5..c2aa0eb 100644
--- a/testfiles-harf/math.lvt
+++ b/testfiles-harf/math.lvt
@@ -7,11 +7,11 @@
 \directlua{
   local cbs = luatexbase.callback_descriptions'glyph_info'
   local desc = cbs[1]
-  assert(desc == "Harf glyph_info callback" and nil == next(cbs, 1))
+  assert(desc == "luaotfload.glyphinfo" and nil == next(cbs, 1))
   local cb = luatexbase.remove_from_callback('glyph_info', desc)
   luatexbase.add_to_callback('glyph_info', function(n)
     return string.format('"\csstring\%s" \csstring\%04X \csstring\%+i:\csstring\%+i', cb(n), n.char, n.xoffset, n.yoffset)
-  end, 'Harf glyph_info callback -- testing variant')
+  end, 'luaotfload.glyphinfo -- testing variant')
 }
 
 \setmainfont{Amiri}[Renderer=Harfbuzz, Script=Arabic]
diff --git a/testfiles-harf/multiscript-auto.lvt b/testfiles-harf/multiscript-auto.lvt
index 81662dd..7c9696f 100644
--- a/testfiles-harf/multiscript-auto.lvt
+++ b/testfiles-harf/multiscript-auto.lvt
@@ -5,11 +5,11 @@
 \directlua{
   local cbs = luatexbase.callback_descriptions'glyph_info'
   local desc = cbs[1]
-  assert(desc == "Harf glyph_info callback" and nil == next(cbs, 1))
+  assert(desc == "luaotfload.glyphinfo" and nil == next(cbs, 1))
   local cb = luatexbase.remove_from_callback('glyph_info', desc)
   luatexbase.add_to_callback('glyph_info', function(n)
     return string.format('"\csstring\%s" \csstring\%04X \csstring\%+i:\csstring\%+i', cb(n), n.char, n.xoffset, n.yoffset)
-  end, 'Harf glyph_info callback -- testing variant')
+  end, 'luaotfload.glyphinfo -- testing variant')
 }
 
 \begin{document}
diff --git a/testfiles-harf/scripts.lvt b/testfiles-harf/scripts.lvt
index 9c4bd2c..d954449 100644
--- a/testfiles-harf/scripts.lvt
+++ b/testfiles-harf/scripts.lvt
@@ -7,11 +7,11 @@
 \directlua{
   local cbs = luatexbase.callback_descriptions'glyph_info'
   local desc = cbs[1]
-  assert(desc == "Harf glyph_info callback" and nil == next(cbs, 1))
+  assert(desc == "luaotfload.glyphinfo" and nil == next(cbs, 1))
   local cb = luatexbase.remove_from_callback('glyph_info', desc)
   luatexbase.add_to_callback('glyph_info', function(n)
     return string.format('"\csstring\%s" \csstring\%04X \csstring\%+i:\csstring\%+i', cb(n), n.char, n.xoffset, n.yoffset)
-  end, 'Harf glyph_info callback -- testing variant')
+  end, 'luaotfload.glyphinfo -- testing variant')
 }
 
 \setmainfont{amiri-regular.ttf}[Renderer=Harfbuzz, Script=Latin]
diff --git a/testfiles-harf/story.lvt b/testfiles-harf/story.lvt
index 5cf0940..62fc5f7 100644
--- a/testfiles-harf/story.lvt
+++ b/testfiles-harf/story.lvt
@@ -7,11 +7,11 @@
 \directlua{
   local cbs = luatexbase.callback_descriptions'glyph_info'
   local desc = cbs[1]
-  assert(desc == "Harf glyph_info callback" and nil == next(cbs, 1))
+  assert(desc == "luaotfload.glyphinfo" and nil == next(cbs, 1))
   local cb = luatexbase.remove_from_callback('glyph_info', desc)
   luatexbase.add_to_callback('glyph_info', function(n)
     return string.format('"\csstring\%s" \csstring\%04X \csstring\%+i:\csstring\%+i', cb(n), n.char, n.xoffset, n.yoffset)
-  end, 'Harf glyph_info callback -- testing variant')
+  end, 'luaotfload.glyphinfo -- testing variant')
 }
 
 \setmainfont[Renderer=Harfbuzz]{lmroman10-regular.otf}





More information about the latex3-commits mailing list.