[latex3-commits] [git/LaTeX3-latex3-luaotfload] harf-dev: Small stuff (fc971c5)

Marcel Fabian Krüger tex at 2krueger.de
Tue Sep 17 22:14:22 CEST 2019


Repository : https://github.com/latex3/luaotfload
On branch  : harf-dev
Link       : https://github.com/latex3/luaotfload/commit/fc971c5b3a2ad6e0fe0ad7fe66dcee89dd96e54f

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

commit fc971c5b3a2ad6e0fe0ad7fe66dcee89dd96e54f
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Tue Sep 17 22:14:22 2019 +0200

    Small stuff


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

fc971c5b3a2ad6e0fe0ad7fe66dcee89dd96e54f
 src/harf/harf-luaotfload.lua | 20 +++++++-------------
 src/harf/harf-node.lua       | 33 +++++++++++----------------------
 src/harf/harf.lua            | 16 ----------------
 3 files changed, 18 insertions(+), 51 deletions(-)

diff --git a/src/harf/harf-luaotfload.lua b/src/harf/harf-luaotfload.lua
index 6bc1be0..9ab56bc 100644
--- a/src/harf/harf-luaotfload.lua
+++ b/src/harf/harf-luaotfload.lua
@@ -2,14 +2,10 @@ if not pcall(require, "luaharfbuzz") then
   luatexbase.module_error("harf", "'luaharfbuzz' module is required.")
 end
 
-local harf = require("harf")
+local harf = require("harf-base")
 
-local define_font     = harf.callbacks.define_font
-
--- Change luaotfload’s default of preferring system fonts.
-fonts.names.set_location_precedence {
-  "local", "texmf", "system"
-}
+local define_font = require("harf-load")
+local harf_node   = require("harf-node")
 
 local callback_warning = true
 if callback_warning then
@@ -205,9 +201,7 @@ local function add_to_callback(name, func)
   end
 end
 
--- Register all Harf callbacks, except `define_font` which is handled above.
-for name, func in next, harf.callbacks do
-  if name ~= "define_font" then
-    add_to_callback(name, func)
-  end
-end
+add_to_callback('pre_output_filter', harf_node.post_process)
+add_to_callback('wrapup_run', harf_node.cleanup)
+add_to_callback('finish_pdffile', harf_node.set_tounicode)
+add_to_callback('get_glyph_string', harf_node.get_glyph_string)
diff --git a/src/harf/harf-node.lua b/src/harf/harf-node.lua
index e551e25..6e97e03 100644
--- a/src/harf/harf-node.lua
+++ b/src/harf/harf-node.lua
@@ -30,6 +30,9 @@ local getchar           = direct.getchar
 local setchar           = direct.setchar
 local getdir            = direct.getdir
 local setdir            = direct.setdir
+local getdisc           = direct.getdisc
+local setdisc           = direct.setdisc
+local getfont           = direct.getfont
 local getdata           = direct.getdata
 local setdata           = direct.setdata
 local getfont           = direct.getfont
@@ -53,13 +56,6 @@ local getwidth          = direct.getwidth
 local setwidth          = direct.setwidth
 local is_char           = direct.is_char
 
-local getpre            = function (n) return getfield(n, "pre")        end
-local setpre            = function (n, v)     setfield(n, "pre", v)     end
-local getpost           = function (n) return getfield(n, "post")       end
-local setpost           = function (n, v)     setfield(n, "post", v)    end
-local getrep            = function (n) return getfield(n, "replace")    end
-local setrep            = function (n, v)     setfield(n, "replace", v) end
-
 local imgnode           = img.node
 
 local disc_t            = node.id("disc")
@@ -78,13 +74,6 @@ local italiccorr_t      = 3
 local regulardisc_t     = 3
 local spaceskip_t       = 13
 
-local getscript         = hb.unicode.script
-
-local common_s          = hb.Script.new("Zyyy")
-local inherited_s       = hb.Script.new("Zinh")
-local unknown_s         = hb.Script.new("Zzzz")
-local latn_s            = hb.Script.new("Latn")
-
 local invalid_l         = hb.Language.new()
 local invalid_s         = hb.Script.new()
 
@@ -485,7 +474,7 @@ shape = function(run)
             glyphs[j].skip = true
           end
 
-          local pre, post, rep = getpre(disc), getpost(disc), getrep(disc)
+          local pre, post, rep = getdisc(disc)
           glyph.disc = disc
           glyph.replace = makesub(run, startindex, stopindex, rep)
           glyph.pre = makesub(run, startindex, discindex - 1, pre)
@@ -574,9 +563,9 @@ local function tonodes(head, current, run, glyphs, color)
       local disc = glyph.disc
       local rep, pre, post = glyph.replace, glyph.pre, glyph.post
 
-      setrep(disc, tonodes(nil, nil, rep.run, rep.glyphs, color))
-      setpre(disc, tonodes(nil, nil, pre.run, pre.glyphs, color))
-      setpost(disc, tonodes(nil, nil, post.run, post.glyphs, color))
+      setdisc(disc, tonodes(nil, nil, pre.run, pre.glyphs, color),
+                    tonodes(nil, nil, post.run, post.glyphs, color),
+                    tonodes(nil, nil, rep.run, rep.glyphs, color))
 
       head, current = insertafter(head, current, disc)
     elseif not glyph.skip then
@@ -729,10 +718,10 @@ local function tonodes(head, current, run, glyphs, color)
           setfield(n, "replace", current)
           head, current = removenode(head, current)
         end
-        local pre, post, rep = getpre(n), getpost(n), getrep(n)
-        setfield(n, "pre", process(pre, fontid, direction))
-        setfield(n, "post", process(post, fontid, direction))
-        setfield(n, "replace", process(rep, fontid, direction))
+        local pre, post, rep = getdisc(n)
+        setdisc(n, process(pre, fontid, direction),
+                   process(post, fontid, direction),
+                   process(rep, fontid, direction))
 
         head, current = insertafter(head, current, n)
       else
diff --git a/src/harf/harf.lua b/src/harf/harf.lua
deleted file mode 100644
index 082a513..0000000
--- a/src/harf/harf.lua
+++ /dev/null
@@ -1,16 +0,0 @@
-local harf = require("harf-base")
-
-local define_font = require("harf-load")
-local harf_node   = require("harf-node")
-
-harf.callbacks = {
-  define_font = define_font,
-  pre_linebreak_filter = harf_node.process,
-  hpack_filter = harf_node.process,
-  pre_output_filter = harf_node.post_process,
-  wrapup_run = harf_node.cleanup,
-  finish_pdffile = harf_node.set_tounicode,
-  get_glyph_string = harf_node.get_glyph_string,
-}
-
-return harf





More information about the latex3-commits mailing list