[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Better handle failure during shaping (4d44dcd)

Marcel Fabian Krüger tex at 2krueger.de
Fri Jun 5 19:29:19 CEST 2020


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

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

commit 4d44dcd0e15eb717ecd7824dac74abb361753e72
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Fri Jun 5 19:23:37 2020 +0200

    Better handle failure during shaping


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

4d44dcd0e15eb717ecd7824dac74abb361753e72
 src/luaotfload-harf-plug.lua | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/luaotfload-harf-plug.lua b/src/luaotfload-harf-plug.lua
index 3350a75..484a3b7 100644
--- a/src/luaotfload-harf-plug.lua
+++ b/src/luaotfload-harf-plug.lua
@@ -18,7 +18,8 @@ do -- block to avoid to many local variables error
  end  
 end
 
-local hb = luaotfload.harfbuzz
+local hb                = luaotfload.harfbuzz
+local logreport         = luaotfload.log.report
 
 local assert            = assert
 local next              = next
@@ -265,6 +266,7 @@ local function makesub(run, codes, nodelist)
     nodelist = nil
   end
   nodelist, nodelist, glyphs = shape(nodelist, nodelist, subrun)
+  assert(glyphs, [[Shaping discretionary list failed. This shouldn't happen.]])
   return { glyphs = glyphs, run = subrun, head = nodelist }
 end
 
@@ -550,9 +552,17 @@ function shape(head, firstnode, run)
       end
     end
     return head, firstnode, glyphs, run.len - len
+  else
+    if not fontdata.shaper_warning then
+      local shaper = shapers[1]
+      if shaper then
+        logreport("both", 0, "harf", "Failed to shape text in font %q with shaper %q.\nMaybe you should try the default shaper instead?", fontdata.name, shaper)
+      else
+        logreport("both", 0, "harf", "All shapers failed for font %q.", fontdata.name)
+      end
+      fontdata.shaper_warning = true -- Only warn once for every font
+    end
   end
-
-  return head, firstnode, {}, 0
 end
 
 local function color_to_rgba(color)
@@ -888,10 +898,11 @@ local function shape_run(head, current, run)
     -- shaping.
     local glyphs, offset
     head, current, glyphs, offset = shape(head, current, run)
-    return offset, tonodes(head, current, run, glyphs)
-  else
-    return 0, head, run.after
+    if glyphs then
+      return offset, tonodes(head, current, run, glyphs)
+    end
   end
+  return 0, head, run.after
 end
 
 function process(head, font, _attr, direction)





More information about the latex3-commits mailing list.