[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Add harf support to multiscript (68f5bba)

Marcel Fabian Krüger tex at 2krueger.de
Wed Dec 11 21:35:19 CET 2019


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

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

commit 68f5bba840d95a96a2648bc8a7cc0d038c3c4017
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Wed Dec 11 21:35:19 2019 +0100

    Add harf support to multiscript


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

68f5bba840d95a96a2648bc8a7cc0d038c3c4017
 src/luaotfload-multiscript.lua | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/luaotfload-multiscript.lua b/src/luaotfload-multiscript.lua
index 4a2af28..590745b 100644
--- a/src/luaotfload-multiscript.lua
+++ b/src/luaotfload-multiscript.lua
@@ -31,6 +31,13 @@ local scripts_lib        = require'luaotfload-scripts'.script
 local script_to_iso      = scripts_lib.to_iso
 local script_to_ot       = scripts_lib.to_ot
 
+local harf = luaotfload.harfbuzz
+local GSUBtag, GPOStag
+if harf then
+  GSUBtag = harf.Tag.new("GSUB")
+  GPOStag = harf.Tag.new("GPOS")
+end
+
 local sep = lpeg.P' '^0 * ';' * lpeg.P' '^0
 local codepoint = lpeg.S'0123456789ABCDEF'^4/function(c)return tonumber(c, 16)end
 local codepoint_range = codepoint * ('..' * codepoint + lpeg.Cc(false))
@@ -117,22 +124,27 @@ local script_mapping do
 end
 
 local function collect_scripts(tfmdata)
+  local script_dict = {}
   local hbdata = tfmdata.hb
   if hbdata then
-    print'HBmulti'
+    local face = hbdata.shared.face
+    for _, tag in next, { GSUBtag, GPOStag } do
+      local script_tags = face:ot_layout_get_script_tags(tag)
+      for i = 1, #script_tags do
+        script_dict[tostring(script_tags[i]):gsub(" +$", "")] = true
+      end
+    end
   else
-    print'nonHBmulti'
-  end
-  local script_dict = {}
-  local features = tfmdata.resources.features
-  for _, feature_table in next, features do
-    for _, scripts in next, feature_table do
-      for script in next, scripts do
-        script_dict[script] = true
+    local features = tfmdata.resources.features
+    for _, feature_table in next, features do
+      for _, scripts in next, feature_table do
+        for script in next, scripts do
+          script_dict[script] = true
+        end
       end
     end
+    script_dict["*"] = nil
   end
-  script_dict["*"] = nil
   return script_dict
 end
 
@@ -268,6 +280,10 @@ otffeatures.register {
   manipulators = {
     node = makecombifont,
   },
+  -- HACK: harf should call manipulators too.
+  initializers = {
+    plug = function(a, b) return makecombifont(a, nil, b) end,
+  },
   -- processors = { -- processors would be nice, but they are applied
   --                -- too late for our purposes
   --   node = donotdef,





More information about the latex3-commits mailing list