[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Make node behave more like harf (7d2f829)
Marcel Fabian Krüger
tex at 2krueger.de
Thu Mar 19 12:23:00 CET 2020
Repository : https://github.com/latex3/luaotfload
On branch : dev
Link : https://github.com/latex3/luaotfload/commit/7d2f829c8b93b6a37a218f47a2265e0017345b7e
>---------------------------------------------------------------
commit 7d2f829c8b93b6a37a218f47a2265e0017345b7e
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Thu Mar 19 02:21:48 2020 +0100
Make node behave more like harf
Suppressing default invisible codepoints now replaces them by spaces by
default instead of removing them completly.
>---------------------------------------------------------------
7d2f829c8b93b6a37a218f47a2265e0017345b7e
src/luaotfload-notdef.lua | 53 ++++++++++++++++++++++++++++++++-----------
testfiles/invisible-chars.lvt | 4 ++++
testfiles/invisible-chars.tlg | 19 +++++++++++++++-
3 files changed, 62 insertions(+), 14 deletions(-)
diff --git a/src/luaotfload-notdef.lua b/src/luaotfload-notdef.lua
index d668ee2..88bb554 100644
--- a/src/luaotfload-notdef.lua
+++ b/src/luaotfload-notdef.lua
@@ -30,6 +30,9 @@ local protect_glyph = node.direct.protect_glyph
local remove = node.direct.remove
local setfont = node.direct.setfont
local traverse_char = node.direct.traverse_char
+local setchar = node.direct.setchar
+local getwidth = node.direct.getwidth
+local setmove = luaotfload.fontloader.nodes.injections.setmove
-- According to DerivedCoreProperties.txt, Default_Ignorable_Code_Point
-- is generated from:
@@ -53,7 +56,7 @@ local ignorable_codepoints do
end
return table
end
- local entry = lpeg.Cg(codepoint * ';' * (1-lpeg.P';')^0 * ';Cf;' * lpeg.Cc(true))^-1 * (1-lpeg.P'\n')^0 * '\n'
+ local entry = lpeg.Cg(codepoint * ';' * (1-lpeg.P';')^0 * ';Cf;' * lpeg.Cc'ignore')^-1 * (1-lpeg.P'\n')^0 * '\n'
local file = lpeg.Cf(
lpeg.Ct''
* entry^0
@@ -61,8 +64,8 @@ local ignorable_codepoints do
local f = io.open(kpse.find_file"UnicodeData.txt")
ignorable_codepoints = file:match(f:read'*a')
f:close()
- entry = lpeg.Cg(codepoint_range * sep * ('Other_Default_Ignorable_Code_Point' * lpeg.Cc(true)
- + 'Variation_Selector' * lpeg.Cc(true)
+ entry = lpeg.Cg(codepoint_range * sep * ('Other_Default_Ignorable_Code_Point' * lpeg.Cc'ignore'
+ + 'Variation_Selector' * lpeg.Cc'ignore'
+ 'White_Space' * lpeg.Cc(nil)
+ 'Prepended_Concatenation_Mark' * lpeg.Cc(nil)
) * ' # ' * (1-lpeg.P'Lo'))^-1 * (1-lpeg.P'\n')^0 * '\n'
@@ -155,14 +158,26 @@ otfregister {
}
}
-function fonts.handlers.otf.handlers.gsub_remove(head,char,dataset,sequence,replacement)
- local next
- head, next = remove(head, char)
- flush_node(char)
- if not head and not next then -- Avoid a double free if we were alone
- head = nodenew(kern_id)
+function fonts.handlers.otf.handlers.gsub_remove(head,char,dataset,sequence,kind,rlmode,skiphash,step,injection)
+ local replacement
+ if kind ~= 'ignore' then
+ replacement = false
+ else
+ replacement = tonumber(dataset[1])
+ end
+ if replacement then
+ setchar(char, replacement)
+ setmove(char, 1, rlmode, -getwidth(char), injection)
+ return head, char, true
+ else
+ local next
+ head, next = remove(head, char)
+ flush_node(char)
+ if not head and not next then -- Avoid a double free if we were alone
+ head = nodenew(kern_id)
+ end
+ return head, next, true, true
end
- return head, next, true, true
end
local sequence = {
@@ -177,12 +192,24 @@ local sequence = {
}},
type = "gsub_remove",
}
-local function invisibleinitialiser(tfmdata, value)
+local function invisibleinitialiser(tfmdata, value, features)
local resources = tfmdata.resources
local sequences = resources and resources.sequences
+ if value ~= 'remove' and not tonumber(value) then
+ features.invisible = 32
+ end
if sequences then
- -- Now we get to the interesting part: At which point should our new sequence be inserted? Let's do it at the end, then they are still seen by all features.
- insert(sequences, sequence)
+ local alreadydone
+ for i=1,#sequences do
+ if sequence == sequences[i] then
+ alreadydone = true
+ break
+ end
+ end
+ if not alreadydone then
+ -- Now we get to the interesting part: At which point should our new sequence be inserted? Let's do it at the end, then they are still seen by all features.
+ insert(sequences, sequence)
+ end
end
end
local invisibleinitialiserharf if harfbuzz then
diff --git a/testfiles/invisible-chars.lvt b/testfiles/invisible-chars.lvt
index e9daa16..60b6888 100644
--- a/testfiles/invisible-chars.lvt
+++ b/testfiles/invisible-chars.lvt
@@ -6,6 +6,10 @@
\amiri
\char"200Dي\char"200D
+\font\amiri={file:amiri-regular.ttf:invisible=remove} at 20pt
+\amiri
+\char"200Dي\char"200D
+
\font\amiri={file:amiri-regular.ttf:} at 20pt
\amiri
\char"200Dي\char"200D
diff --git a/testfiles/invisible-chars.tlg b/testfiles/invisible-chars.tlg
index aed392e..75c27ad 100644
--- a/testfiles/invisible-chars.tlg
+++ b/testfiles/invisible-chars.tlg
@@ -9,7 +9,7 @@ Completed box being shipped out [1]
...\hbox(0.0+0.0)x345.0, direction TLT
..\glue 25.0
..\glue(\lineskip) 0.0
-..\vbox(550.0+0.0)x345.0, glue set 516.18488fil, direction TLT
+..\vbox(550.0+0.0)x345.0, glue set 498.38681fil, direction TLT
...\write-{}
...\glue(\topskip) 0.0
...\hbox(12.2+8.76)x345.0, glue set 314.72fil, direction TLT
@@ -38,6 +38,23 @@ Completed box being shipped out [1]
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
+...\glue(\parskip) 0.0 plus 1.0
+...\glue(\lineskip) 1.0
+...\hbox(8.04+8.76)x345.0, glue set 314.72fil, direction TLT
+....\localpar
+.....\localinterlinepenalty=0
+.....\localbrokenpenalty=0
+.....\localleftbox=null
+.....\localrightbox=null
+....\hbox(0.0+0.0)x15.0, direction TLT
+....\kern-5.84 (font)
+....\amiri
+....\amiri ي
+....\kern-5.84 (font)
+....\amiri
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
...\glue -5.0
...\glue 0.0 plus 1.0fil
...\glue 0.0
More information about the latex3-commits
mailing list.