summaryrefslogtreecommitdiff
path: root/tex/context/base/font-ota.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2013-03-27 01:20:14 +0200
committerMarius <mariausol@gmail.com>2013-03-27 01:20:14 +0200
commitdb2ce50fc6e6a62a50427e6d5ff1fbdc67af691f (patch)
tree09c4809cb27b5b6c1a1711b0aaf1eed96744f893 /tex/context/base/font-ota.lua
parenta0dd6ec7504ab0e5e2e4130b43de0cd63e646fa8 (diff)
downloadcontext-db2ce50fc6e6a62a50427e6d5ff1fbdc67af691f.tar.gz
beta 2013.03.27 00:08
Diffstat (limited to 'tex/context/base/font-ota.lua')
-rw-r--r--tex/context/base/font-ota.lua120
1 files changed, 83 insertions, 37 deletions
diff --git a/tex/context/base/font-ota.lua b/tex/context/base/font-ota.lua
index 5a50e704c..79fcf3fa2 100644
--- a/tex/context/base/font-ota.lua
+++ b/tex/context/base/font-ota.lua
@@ -194,19 +194,36 @@ registerotffeature {
methods.latn = analyzers.setstate
--- this info eventually will go into char-def and we will have a state
--- table for generic then
-
-local zwnj = 0x200C
-local zwj = 0x200D
-
-local isol = {
+-- This info eventually can go into char-def and we will have a state
+-- table for generic then (unicode recognized all states but in practice
+-- only has only
+--
+-- isolated : isol
+-- final : isol_fina
+-- medial : isol_fina_medi_init
+--
+-- so in practice, without analyzer it's rather useless info which is
+-- why having it in char-def makes only sense for special purposes (like)
+-- like tracing cq. visualizing.
+
+local tatweel = 0x0640
+local zwnj = 0x200C
+local zwj = 0x200D
+
+local isolated = { -- isol
[0x0600] = true, [0x0601] = true, [0x0602] = true, [0x0603] = true,
+ [0x0604] = true,
[0x0608] = true, [0x060B] = true, [0x0621] = true, [0x0674] = true,
- [0x06DD] = true, [zwnj] = true,
+ [0x06DD] = true,
+ -- mandaic
+ [0x0856] = true, [0x0858] = true, [0x0857] = true,
+ -- n'ko
+ [0x07FA] = true,
+ -- also here:
+ [zwnj] = true,
}
-local isol_fina = {
+local final = { -- isol_fina
[0x0622] = true, [0x0623] = true, [0x0624] = true, [0x0625] = true,
[0x0627] = true, [0x0629] = true, [0x062F] = true, [0x0630] = true,
[0x0631] = true, [0x0632] = true, [0x0648] = true, [0x0671] = true,
@@ -222,23 +239,26 @@ local isol_fina = {
[0x06D3] = true, [0x06D5] = true, [0x06EE] = true, [0x06EF] = true,
[0x0759] = true, [0x075A] = true, [0x075B] = true, [0x076B] = true,
[0x076C] = true, [0x0771] = true, [0x0773] = true, [0x0774] = true,
- [0x0778] = true, [0x0779] = true, [0xFEF5] = true, [0xFEF7] = true,
- [0xFEF9] = true, [0xFEFB] = true,
-
+ [0x0778] = true, [0x0779] = true,
+ [0x08AA] = true, [0x08AB] = true, [0x08AC] = true,
+ [0xFEF5] = true, [0xFEF7] = true, [0xFEF9] = true, [0xFEFB] = true,
-- syriac
-
[0x0710] = true, [0x0715] = true, [0x0716] = true, [0x0717] = true,
[0x0718] = true, [0x0719] = true, [0x0728] = true, [0x072A] = true,
[0x072C] = true, [0x071E] = true,
+ [0x072F] = true, [0x074D] = true,
+ -- mandaic
+ [0x0840] = true, [0x0849] = true, [0x0854] = true, [0x0846] = true,
+ [0x084F] = true
}
-local isol_fina_medi_init = {
+local medial = { -- isol_fina_medi_init
[0x0626] = true, [0x0628] = true, [0x062A] = true, [0x062B] = true,
[0x062C] = true, [0x062D] = true, [0x062E] = true, [0x0633] = true,
[0x0634] = true, [0x0635] = true, [0x0636] = true, [0x0637] = true,
[0x0638] = true, [0x0639] = true, [0x063A] = true, [0x063B] = true,
[0x063C] = true, [0x063D] = true, [0x063E] = true, [0x063F] = true,
- [0x0640] = true, [0x0641] = true, [0x0642] = true, [0x0643] = true,
+ [0x0641] = true, [0x0642] = true, [0x0643] = true,
[0x0644] = true, [0x0645] = true, [0x0646] = true, [0x0647] = true,
[0x0649] = true, [0x064A] = true, [0x066E] = true, [0x066F] = true,
[0x0678] = true, [0x0679] = true, [0x067A] = true, [0x067B] = true,
@@ -267,18 +287,35 @@ local isol_fina_medi_init = {
[0x0772] = true, [0x0775] = true, [0x0776] = true, [0x0777] = true,
[0x077A] = true, [0x077B] = true, [0x077C] = true, [0x077D] = true,
[0x077E] = true, [0x077F] = true,
-
+ [0x08A0] = true, [0x08A2] = true, [0x08A4] = true, [0x08A5] = true,
+ [0x08A6] = true, [0x0620] = true, [0x08A8] = true, [0x08A9] = true,
+ [0x08A7] = true, [0x08A3] = true,
-- syriac
-
[0x0712] = true, [0x0713] = true, [0x0714] = true, [0x071A] = true,
[0x071B] = true, [0x071C] = true, [0x071D] = true, [0x071F] = true,
[0x0720] = true, [0x0721] = true, [0x0722] = true, [0x0723] = true,
[0x0724] = true, [0x0725] = true, [0x0726] = true, [0x0727] = true,
- [0x0729] = true, [0x072B] = true,
-
- -- also
-
- [zwj] = true,
+ [0x0729] = true, [0x072B] = true, [0x072D] = true, [0x072E] = true,
+ [0x074E] = true, [0x074F] = true,
+ -- mandaic
+ [0x0841] = true, [0x0842] = true, [0x0843] = true, [0x0844] = true,
+ [0x0845] = true, [0x0847] = true, [0x0848] = true, [0x0855] = true,
+ [0x0851] = true, [0x084E] = true, [0x084D] = true, [0x084A] = true,
+ [0x084B] = true, [0x084C] = true, [0x0850] = true, [0x0852] = true,
+ [0x0853] = true,
+ -- n'ko
+ [0x07D7] = true, [0x07E8] = true, [0x07D9] = true, [0x07EA] = true,
+ [0x07CA] = true, [0x07DB] = true, [0x07CC] = true, [0x07DD] = true,
+ [0x07CE] = true, [0x07DF] = true, [0x07D4] = true, [0x07E5] = true,
+ [0x07E9] = true, [0x07E7] = true, [0x07E3] = true, [0x07E2] = true,
+ [0x07E0] = true, [0x07E1] = true, [0x07DE] = true, [0x07DC] = true,
+ [0x07D1] = true, [0x07DA] = true, [0x07D8] = true, [0x07D6] = true,
+ [0x07D2] = true, [0x07D0] = true, [0x07CF] = true, [0x07CD] = true,
+ [0x07CB] = true, [0x07D3] = true, [0x07E4] = true, [0x07D5] = true,
+ [0x07E6] = true,
+ -- also here:
+ [tatweel]= true,
+ [zwj] = true,
}
local arab_warned = { }
@@ -293,11 +330,13 @@ local function warning(current,what)
end
end
+-- potential optimization: local medial_final = table.merged(medial,final)
+
local function finish(first,last)
if last then
if first == last then
local fc = first.char
- if isol_fina_medi_init[fc] or isol_fina[fc] then
+ if medial[fc] or final[fc] then
first[a_state] = s_isol
else
warning(first,"isol")
@@ -305,8 +344,8 @@ local function finish(first,last)
end
else
local lc = last.char
- if isol_fina_medi_init[lc] or isol_fina[lc] then -- why isol here ?
- -- if laststate == 1 or laststate == 2 or laststate == 4 then
+ if medial[lc] or final[lc] then
+ -- if laststate == 1 or laststate == 2 or laststate == 4 then
last[a_state] = s_fina
else
warning(last,"fina")
@@ -317,7 +356,7 @@ local function finish(first,last)
elseif first then
-- first and last are either both set so we never com here
local fc = first.char
- if isol_fina_medi_init[fc] or isol_fina[fc] then
+ if medial[fc] or final[fc] then
first[a_state] = s_isol
else
warning(first,"isol")
@@ -328,60 +367,67 @@ local function finish(first,last)
return first, last
end
-function methods.arab(head,font,attr) -- maybe make a special version with no trace
+function methods.arab(head,font,attr)
local useunicodemarks = analyzers.useunicodemarks
local tfmdata = fontdata[font]
local marks = tfmdata.resources.marks
local first, last, current, done = nil, nil, head, false
while current do
- if current.id == glyph_code and current.font == font and current.subtype<256 and not current[a_state] then
+ local id = current.id
+ if id == glyph_code and current.font == font and current.subtype<256 and not current[a_state] then
done = true
local char = current.char
if marks[char] or (useunicodemarks and categories[char] == "mn") then
current[a_state] = s_mark
- elseif isol[char] then -- can be zwj or zwnj too
+ elseif isolated[char] then -- can be zwj or zwnj too
first, last = finish(first,last)
current[a_state] = s_isol
first, last = nil, nil
elseif not first then
- if isol_fina_medi_init[char] then
+ if medial[char] then
current[a_state] = s_init
first, last = first or current, current
- elseif isol_fina[char] then
+ elseif final[char] then
current[a_state] = s_isol
first, last = nil, nil
else -- no arab
first, last = finish(first,last)
end
- elseif isol_fina_medi_init[char] then
+ elseif medial[char] then
first, last = first or current, current
current[a_state] = s_medi
- elseif isol_fina[char] then
+ elseif final[char] then
if not last[a_state] == s_init then
-- tricky, we need to check what last may be !
last[a_state] = s_medi
end
current[a_state] = s_fina
first, last = nil, nil
- elseif char >= 0x0600 and char <= 0x06FF then
+ elseif char >= 0x0600 and char <= 0x06FF then -- needs checking
current[a_state] = s_rest
first, last = finish(first,last)
- else --no
+ else -- no
first, last = finish(first,last)
end
else
- first, last = finish(first,last)
+ if first or last then
+ first, last = finish(first,last)
+ end
if id == math_code then
current = end_of_math(current)
end
end
current = current.next
end
- first, last = finish(first,last)
+ if first or last then
+ finish(first,last)
+ end
return head, done
end
methods.syrc = methods.arab
+methods.mand = methods.arab
+methods.nko = methods.arab
directives.register("otf.analyze.useunicodemarks",function(v)
analyzers.useunicodemarks = v