[latex3-commits] [git/LaTeX3-latex3-luaotfload] flags-dev: Add initial buffer flag support (df24d93)

Marcel Fabian Krüger tex at 2krueger.de
Thu Oct 31 16:01:36 CET 2019


Repository : https://github.com/latex3/luaotfload
On branch  : flags-dev
Link       : https://github.com/latex3/luaotfload/commit/df24d93499f77d755e998c42ccc8a18090df70d9

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

commit df24d93499f77d755e998c42ccc8a18090df70d9
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Thu Oct 31 16:01:36 2019 +0100

    Add initial buffer flag support


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

df24d93499f77d755e998c42ccc8a18090df70d9
 src/luaotfload-harf-define.lua |  8 +++++++-
 src/luaotfload-harf-plug.lua   |  3 +++
 src/luaotfload-main.lua        |  6 +++---
 src/luaotfload-notdef.lua      | 30 ++++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/src/luaotfload-harf-define.lua b/src/luaotfload-harf-define.lua
index 335ef22..d5adba1 100644
--- a/src/luaotfload-harf-define.lua
+++ b/src/luaotfload-harf-define.lua
@@ -23,6 +23,9 @@ local stringupper = string.upper
 
 local hb = luaotfload.harfbuzz
 
+local harf_settings = luaotfload.harf or {}
+luaotfload.harf = harf_settings
+
 local hbfonts = {}
 
 local cfftag  = hb.Tag.new("CFF ")
@@ -31,6 +34,8 @@ local os2tag  = hb.Tag.new("OS/2")
 local posttag = hb.Tag.new("post")
 local glyftag = hb.Tag.new("glyf")
 
+harf_settings.default_buf_flags = hb.Buffer.FLAGS_DEFAULT or 0
+
 local function loadfont(spec)
   local path, sub = spec.resolved, spec.sub or 1
 
@@ -206,7 +211,7 @@ local function scalefont(data, spec)
   local features = spec.features.normal
   features.mode = 'plug'
   features.features = 'harf'
-  fonts.constructors.checkedfeatures("otf", features)
+  features = fonts.constructors.checkedfeatures("otf", features)
   local hbface = data.face
   local hbfont = data.font
   local upem = data.upem
@@ -336,6 +341,7 @@ local function scalefont(data, spec)
       letterspace = letterspace,
       hscale = hscale,
       vscale = vscale,
+      buf_flags = harf_settings.default_buf_flags,
     },
     specification = spec,
     shared = {},
diff --git a/src/luaotfload-harf-plug.lua b/src/luaotfload-harf-plug.lua
index 72274a9..9f4612b 100644
--- a/src/luaotfload-harf-plug.lua
+++ b/src/luaotfload-harf-plug.lua
@@ -327,6 +327,9 @@ function shape(head, node, run)
   local shapers = options.shaper and { options.shaper } or {}
 
   local buf = hb.Buffer.new()
+  if buf.set_flags then
+    buf:set_flags(hbdata.buf_flags)
+  end
   buf:set_direction(dir)
   buf:set_script(script)
   buf:set_language(lang)
diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua
index c17d807..a9216e0 100644
--- a/src/luaotfload-main.lua
+++ b/src/luaotfload-main.lua
@@ -306,15 +306,15 @@ luaotfload.main = function ()
 
     initialize "features"     --- font request and feature handling
 
-    loadmodule "letterspace"  --- extra character kerning
-    loadmodule "embolden"     --- fake bold
-    loadmodule "notdef"       --- missing glyph handling
     local harfstatus, harfbuzz = pcall(require, 'luaharfbuzz')
     if harfstatus then
         luaotfload.harfbuzz = harfbuzz
         loadmodule "harf-define"
         loadmodule "harf-plug"
     end
+    loadmodule "letterspace"  --- extra character kerning
+    loadmodule "embolden"     --- fake bold
+    loadmodule "notdef"       --- missing glyph handling
     initialize "auxiliary"    --- additional high-level functionality
     loadmodule "multiscript"  --- ...
     loadmodule "tounicode"
diff --git a/src/luaotfload-notdef.lua b/src/luaotfload-notdef.lua
index 61512b7..3a5a56e 100644
--- a/src/luaotfload-notdef.lua
+++ b/src/luaotfload-notdef.lua
@@ -16,6 +16,7 @@ if luatexbase and luatexbase.provides_module then
   luatexbase.provides_module (ProvidesLuaModule)
 end  
 
+local harfbuzz           = luaotfload.harfbuzz
 local flush_node         = node.direct.flush_node
 local getfont            = font.getfont
 local getnext            = node.direct.getnext
@@ -184,12 +185,41 @@ local function invisibleinitialiser(tfmdata, value)
     insert(sequences, sequence)
   end
 end
+local invisibleinitialiserharf if harfbuzz then
+  local harf_settings = luaotfload.harf
+  local preserve_flag = harfbuzz.Buffer.FLAG_PRESERVE_DEFAULT_IGNORABLES or 0
+  local remove_flag = harfbuzz.Buffer.FLAG_REMOVE_DEFAULT_IGNORABLES or 0
+  local dotted_circle_flag = harfbuzz.Buffer.FLAG_DO_NOT_INSERT_DOTTED_CIRCLE or 0
+  harf_settings.default_buf_flags = (harf_settings.default_buf_flags & ~remove_flag) | preserve_flag | dotted_circle_flag
+  function invisibleinitialiserharf(tfmdata, value)
+    if not tfmdata.hb then return end
+    local hb = tfmdata.hb
+    hb.buf_flags = hb.buf_flags & ~preserve_flag
+    if value == "remove" then
+      hb.buf_flags = hb.buf_flags | remove_flag
+    end
+  end
+  local function dottedcircleinitialize(tfmdata, value)
+    if not tfmdata.hb then return end
+    local hb = tfmdata.hb
+    hb.buf_flags = hb.buf_flags & ~dotted_circle_flag
+  end
+  otfregister {
+    name = 'dottedcircle',
+    description = 'Insert dotted circle to fix invalid clusters',
+    default = true,
+    initializers = {
+      plug = dottedcircleinitialize,
+    },
+  }
+end
 otfregister {
   name = 'invisible',
   description = 'Remove invisible control characters',
   default = true,
   initializers = {
     node = invisibleinitialiser,
+    plug = invisibleinitialiserharf,
   },
 }
 





More information about the latex3-commits mailing list