diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-09-28 11:20:59 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-09-28 11:20:59 +0200 |
commit | 164a98ac4e58ae88de0a83d1eb60583827f4fbab (patch) | |
tree | a9bb80667dcf2dacc511b7c0dd0439e3ece7c274 /tex/context/base/mkiv/font-otc.lua | |
parent | e5c13c74b45e08527dda1d1be1788cccd96b6dac (diff) | |
download | context-164a98ac4e58ae88de0a83d1eb60583827f4fbab.tar.gz |
2017-09-28 10:13:00
Diffstat (limited to 'tex/context/base/mkiv/font-otc.lua')
-rw-r--r-- | tex/context/base/mkiv/font-otc.lua | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/tex/context/base/mkiv/font-otc.lua b/tex/context/base/mkiv/font-otc.lua index 1d0db7b81..8059ad272 100644 --- a/tex/context/base/mkiv/font-otc.lua +++ b/tex/context/base/mkiv/font-otc.lua @@ -10,6 +10,7 @@ local format, insert, sortedkeys, tohash = string.format, table.insert, table.so local type, next = type, next local lpegmatch = lpeg.match local utfbyte, utflen, utfsplit = utf.byte, utf.len, utf.split +local match = string.match -- we assume that the other otf stuff is loaded already @@ -1031,7 +1032,8 @@ registerotffeature { local lookups = { } local protect = { } local revert = { } -local zwj = { 0x200C } +local zwjchar = 0x200C +local zwj = { zwjchar } otf.addfeature { name = "blockligatures", @@ -1075,21 +1077,49 @@ registerotffeature { local settings_to_array = utilities.parsers and utilities.parsers.settings_to_array or function(s) return string.split(s,",") end -- for generic +local splitter = lpeg.splitat(":") + local function blockligatures(str) local t = settings_to_array(str) for i=1,#t do - local ti = utfsplit(t[i]) - if #ti > 1 then - local one = ti[1] - local two = ti[2] - lookups[one] = { one, 0x200C } + local ti = t[i] + local before, current, after = lpegmatch(splitter,ti) + if current and after then -- before is returned when no match + -- experimental joke + if before then + before = utfsplit(before) + for i=1,#before do + before[i] = { before[i] } + end + end + if current then + current = utfsplit(current) + end + if after then + after = utfsplit(after) + for i=1,#after do + after[i] = { after[i] } + end + end + + else + before = nil + current = utfsplit(ti) + after = nil + end + if #current > 1 then + local one = current[1] + local two = current[2] + lookups[one] = { one, zwjchar } local one = { one } local two = { two } local new = #protect + 1 protect[new] = { + before = before, current = { one, two }, + after = after, lookups = { 1 }, -- not shared ! } revert[new] = { @@ -1099,7 +1129,6 @@ local function blockligatures(str) } end end - end -- blockligatures("\0\0") @@ -1108,6 +1137,7 @@ otf.helpers.blockligatures = blockligatures -- blockligatures("fi,ff") -- blockligatures("fl") +-- blockligatures("u:fl:age") if context then |