summaryrefslogtreecommitdiff
path: root/tex/context/base/font-otx.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2014-05-03 13:55:34 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2014-05-03 13:55:34 +0200
commit624cbb5da392e9403984dd1cf368c0d408b1c2a8 (patch)
tree489c049ac849bb5bbce7d32e4df477872c58373d /tex/context/base/font-otx.lua
parent088de88944c1f2254250bb448c7371a87ff7ee39 (diff)
downloadcontext-624cbb5da392e9403984dd1cf368c0d408b1c2a8.tar.gz
2014-01-03 00:42:00
Diffstat (limited to 'tex/context/base/font-otx.lua')
-rw-r--r--tex/context/base/font-otx.lua130
1 files changed, 57 insertions, 73 deletions
diff --git a/tex/context/base/font-otx.lua b/tex/context/base/font-otx.lua
index b7d2ae0bc..f39045223 100644
--- a/tex/context/base/font-otx.lua
+++ b/tex/context/base/font-otx.lua
@@ -30,29 +30,15 @@ analyzers.methods = methods
local a_state = attributes.private('state')
-local nuts = nodes.nuts
-local tonut = nuts.tonut
-
-local getfield = nuts.getfield
-local getnext = nuts.getnext
-local getprev = nuts.getprev
-local getid = nuts.getid
-local getattr = nuts.getattr
-local getfont = nuts.getfont
-local getsubtype = nuts.getsubtype
-local getchar = nuts.getchar
-
-local setattr = nuts.setattr
-
-local traverse_id = nuts.traverse_id
-local traverse_node_list = nuts.traverse
-local end_of_math = nuts.end_of_math
-
local nodecodes = nodes.nodecodes
local glyph_code = nodecodes.glyph
local disc_code = nodecodes.disc
local math_code = nodecodes.math
+local traverse_id = node.traverse_id
+local traverse_node_list = node.traverse
+local end_of_math = node.end_of_math
+
local fontdata = fonts.hashes.identifiers
local categories = characters and characters.categories or { } -- sorry, only in context
local chardata = characters and characters.data
@@ -109,61 +95,60 @@ analyzers.useunicodemarks = false
-- todo: analyzers per script/lang, cross font, so we need an font id hash -> script
-- e.g. latin -> hyphenate, arab -> 1/2/3 analyze -- its own namespace
-function analyzers.setstate(head,font) -- we can skip math
+function analyzers.setstate(head,font)
local useunicodemarks = analyzers.useunicodemarks
local tfmdata = fontdata[font]
local descriptions = tfmdata.descriptions
local first, last, current, n, done = nil, nil, head, 0, false -- maybe make n boolean
- current = tonut(current)
while current do
- local id = getid(current)
- if id == glyph_code and getfont(current) == font then
+ local id = current.id
+ if id == glyph_code and current.font == font then
done = true
- local char = getchar(current)
+ local char = current.char
local d = descriptions[char]
if d then
if d.class == "mark" then
done = true
- setattr(current,a_state,s_mark)
+ current[a_state] = s_mark
elseif useunicodemarks and categories[char] == "mn" then
done = true
- setattr(current,a_state,s_mark)
+ current[a_state] = s_mark
elseif n == 0 then
first, last, n = current, current, 1
- setattr(current,a_state,s_init)
+ current[a_state] = s_init
else
last, n = current, n+1
- setattr(current,a_state,s_medi)
+ current[a_state] = s_medi
end
else -- finish
if first and first == last then
- setattr(last,a_state,s_isol)
+ last[a_state] = s_isol
elseif last then
- setattr(last,a_state,s_fina)
+ last[a_state] = s_fina
end
first, last, n = nil, nil, 0
end
elseif id == disc_code then
-- always in the middle
- setattr(current,a_state,s_medi)
+ current[a_state] = s_medi
last = current
else -- finish
if first and first == last then
- setattr(last,a_state,s_isol)
+ last[a_state] = s_isol
elseif last then
- setattr(last,a_state,s_fina)
+ last[a_state] = s_fina
end
first, last, n = nil, nil, 0
if id == math_code then
current = end_of_math(current)
end
end
- current = getnext(current)
+ current = current.next
end
if first and first == last then
- setattr(last,a_state,s_isol)
+ last[a_state] = s_isol
elseif last then
- setattr(last,a_state,s_fina)
+ last[a_state] = s_fina
end
return head, done
end
@@ -224,7 +209,7 @@ methods.latn = analyzers.setstate
local arab_warned = { }
local function warning(current,what)
- local char = getchar(current)
+ local char = current.char
if not arab_warned[char] then
log.report("analyze","arab: character %C has no %a class",char,what)
arab_warned[char] = true
@@ -276,95 +261,94 @@ function methods.arab(head,font,attr)
local first, last = nil, nil
local c_first, c_last = nil, nil
local current, done = head, false
- current = tonut(current)
while current do
- local id = getid(current)
- if id == glyph_code and getfont(current) == font and getsubtype(current)<256 and not getattr(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 = getchar(current)
+ local char = current.char
local classifier = classifiers[char]
if not classifier then
if last then
if c_last == s_medi or c_last == s_fina then
- setattr(last,a_state,s_fina)
+ last[a_state] = s_fina
else
warning(last,"fina")
- setattr(last,a_state,s_error)
+ last[a_state] = s_error
end
first, last = nil, nil
elseif first then
if c_first == s_medi or c_first == s_fina then
- setattr(first,a_state,s_isol)
+ first[a_state] = s_isol
else
warning(first,"isol")
- setattr(first,a_state,s_error)
+ first[a_state] = s_error
end
first = nil
end
elseif classifier == s_mark then
- setattr(current,a_state,s_mark)
+ current[a_state] = s_mark
elseif classifier == s_isol then
if last then
if c_last == s_medi or c_last == s_fina then
- setattr(last,a_state,s_fina)
+ last[a_state] = s_fina
else
warning(last,"fina")
- setattr(last,a_state,s_error)
+ last[a_state] = s_error
end
first, last = nil, nil
elseif first then
if c_first == s_medi or c_first == s_fina then
- setattr(first,a_state,s_isol)
+ first[a_state] = s_isol
else
warning(first,"isol")
- setattr(first,a_state,s_error)
+ first[a_state] = s_error
end
first = nil
end
- setattr(current,a_state,s_isol)
+ current[a_state] = s_isol
elseif classifier == s_medi then
if first then
last = current
c_last = classifier
- setattr(current,a_state,s_medi)
+ current[a_state] = s_medi
else
- setattr(current,a_state,s_init)
+ current[a_state] = s_init
first = current
c_first = classifier
end
elseif classifier == s_fina then
if last then
- if getattr(last,a_state) ~= s_init then
- setattr(last,a_state,s_medi)
+ if last[a_state] ~= s_init then
+ last[a_state] = s_medi
end
- setattr(current,a_state,s_fina)
+ current[a_state] = s_fina
first, last = nil, nil
elseif first then
- -- if getattr(first,a_state) ~= s_init then
+ -- if first[a_state] ~= s_init then
-- -- needs checking
- -- setattr(first,a_state,s_medi)
+ -- first[a_state] = s_medi
-- end
- setattr(current,a_state,s_fina)
+ current[a_state] = s_fina
first = nil
else
- setattr(current,a_state,s_isol)
+ current[a_state] = s_isol
end
else -- classifier == s_rest
- setattr(current,a_state,s_rest)
+ current[a_state] = s_rest
if last then
if c_last == s_medi or c_last == s_fina then
- setattr(last,a_state,s_fina)
+ last[a_state] = s_fina
else
warning(last,"fina")
- setattr(last,a_state,s_error)
+ last[a_state] = s_error
end
first, last = nil, nil
elseif first then
if c_first == s_medi or c_first == s_fina then
- setattr(first,a_state,s_isol)
+ first[a_state] = s_isol
else
warning(first,"isol")
- setattr(first,a_state,s_error)
+ first[a_state] = s_error
end
first = nil
end
@@ -372,18 +356,18 @@ function methods.arab(head,font,attr)
else
if last then
if c_last == s_medi or c_last == s_fina then
- setattr(last,a_state,s_fina)
+ last[a_state] = s_fina
else
warning(last,"fina")
- setattr(last,a_state,s_error)
+ last[a_state] = s_error
end
first, last = nil, nil
elseif first then
if c_first == s_medi or c_first == s_fina then
- setattr(first,a_state,s_isol)
+ first[a_state] = s_isol
else
warning(first,"isol")
- setattr(first,a_state,s_error)
+ first[a_state] = s_error
end
first = nil
end
@@ -391,21 +375,21 @@ function methods.arab(head,font,attr)
current = end_of_math(current)
end
end
- current = getnext(current)
+ current = current.next
end
if last then
if c_last == s_medi or c_last == s_fina then
- setattr(last,a_state,s_fina)
+ last[a_state] = s_fina
else
warning(last,"fina")
- setattr(last,a_state,s_error)
+ last[a_state] = s_error
end
elseif first then
if c_first == s_medi or c_first == s_fina then
- setattr(first,a_state,s_isol)
+ first[a_state] = s_isol
else
warning(first,"isol")
- setattr(first,a_state,s_error)
+ first[a_state] = s_error
end
end
return head, done