summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/typo-itc.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-03-26 13:38:18 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-03-26 13:38:18 +0100
commit788487819ccf38a8478cc2afd88e0c0b088d0ec1 (patch)
tree215addbe3b9e293c2958227e7fc8923880b2e71f /tex/context/base/mkiv/typo-itc.lua
parentadfe72d5a0c9d7bdc1bd7bc8faabb4d05e21d70a (diff)
downloadcontext-788487819ccf38a8478cc2afd88e0c0b088d0ec1.tar.gz
2016-03-26 13:07:00
Diffstat (limited to 'tex/context/base/mkiv/typo-itc.lua')
-rw-r--r--tex/context/base/mkiv/typo-itc.lua170
1 files changed, 83 insertions, 87 deletions
diff --git a/tex/context/base/mkiv/typo-itc.lua b/tex/context/base/mkiv/typo-itc.lua
index 62fea3e2e..a46f3e8a0 100644
--- a/tex/context/base/mkiv/typo-itc.lua
+++ b/tex/context/base/mkiv/typo-itc.lua
@@ -37,9 +37,12 @@ local getnext = nuts.getnext
local getid = nuts.getid
local getfont = nuts.getfont
local getchar = nuts.getchar
+local getdisc = nuts.getdisc
local getattr = nuts.getattr
local setattr = nuts.setattr
local setfield = nuts.setfield
+local setdisc = nuts.setdisc
+local isglyph = nuts.isglyph
local insert_node_after = nuts.insert_after
local delete_node = nuts.delete
@@ -173,28 +176,32 @@ function italics.handler(head)
local previtalic = 0
local previnserted = nil
- local replace = nil
- local replacechar = nil
- local replacehead = nil
- local replaceitalic = 0
- local replaceinserted = nil
+ local pre = nil
+ local pretail = nil
local post = nil
+ local posttail = nil
local postchar = nil
local posthead = nil
local postitalic = 0
local postinserted = nil
+ local replace = nil
+ local replacetail = nil
+ local replacechar = nil
+ local replacehead = nil
+ local replaceitalic = 0
+ local replaceinserted = nil
+
local current = prevhead
local done = false
local lastfont = nil
local lastattr = nil
while current do
- local id = getid(current)
- if id == glyph_code then
+ local char, id = isglyph(current)
+ if char then
local font = getfont(current)
- local char = getchar(current)
local data = italicsdata[font]
if font ~= lastfont then
if previtalic ~= 0 then
@@ -275,95 +282,84 @@ function italics.handler(head)
replaceitalic = 0
postinserted = nil
postitalic = 0
- replace = getfield(current,"replace")
+ updated = false
+ pre, post, replace, pretail, posttail, replacetail = getdisc(current)
if replace then
- local current = find_tail(replace)
- if getid(current) ~= glyph_code then
- current = getprev(current)
- end
- if current and getid(current) == glyph_code then
- local font = getfont(current)
- local char = getchar(current)
- local data = italicsdata[font]
- if data then
- local attr = forcedvariant or getattr(current,a_italics)
- if attr and attr > 0 then
- local cd = data[char]
- if not cd then
- -- this really can happen
- replaceitalic = 0
- else
- replaceitalic = cd.italic
- if not replaceitalic then
- replaceitalic = setitalicinfont(font,char) -- calculated once
- -- replaceitalic = 0
- end
- if replaceitalic ~= 0 then
- lastfont = font
- lastattr = attr
- replacechar = char
- replacehead = replace
- replace = current
+ local current = replacetail
+ while current do
+ local char, id = isglyph(current)
+ if char then
+ local font = getfont(current)
+ local data = italicsdata[font]
+ if data then
+ local attr = forcedvariant or getattr(current,a_italics)
+ if attr and attr > 0 then
+ local cd = data[char]
+ if not cd then
+ -- this really can happen
+ replaceitalic = 0
+ else
+ replaceitalic = cd.italic
+ if not replaceitalic then
+ replaceitalic = setitalicinfont(font,char) -- calculated once
+ -- replaceitalic = 0
+ end
+ if replaceitalic ~= 0 then
+ lastfont = font
+ lastattr = attr
+ replacechar = char
+ replacehead = replace
+ replace = current
+ updated = true
+ end
end
end
--- else
--- replaceitalic = 0
end
--- else
--- replaceitalic = 0
+ break
+ else
+ current = getprev(current)
end
--- else
--- replaceitalic = 0
end
--- replaceinserted = nil
--- else
--- replaceitalic = 0
--- replaceinserted = nil
end
- post = getfield(current,"post")
if post then
- local current = find_tail(post)
- if getid(current) ~= glyph_code then
- current = getprev(current)
- end
- if current and getid(current) == glyph_code then
- local font = getfont(current)
- local char = getchar(current)
- local data = italicsdata[font]
- if data then
- local attr = forcedvariant or getattr(current,a_italics)
- if attr and attr > 0 then
- local cd = data[char]
- if not cd then
- -- this really can happen
--- postitalic = 0
- else
- postitalic = cd.italic
- if not postitalic then
- postitalic = setitalicinfont(font,char) -- calculated once
- -- postitalic = 0
- end
- if postitalic ~= 0 then
- lastfont = font
- lastattr = attr
- postchar = char
- posthead = post
- post = current
+ local current = posttail
+ while current do
+ local char, id = isglyph(current)
+ if char then
+ local font = getfont(current)
+ local data = italicsdata[font]
+ if data then
+ local attr = forcedvariant or getattr(current,a_italics)
+ if attr and attr > 0 then
+ local cd = data[char]
+ if not cd then
+ -- this really can happen
+ -- postitalic = 0
+ else
+ postitalic = cd.italic
+ if not postitalic then
+ postitalic = setitalicinfont(font,char) -- calculated once
+ -- postitalic = 0
+ end
+ if postitalic ~= 0 then
+ lastfont = font
+ lastattr = attr
+ postchar = char
+ posthead = post
+ post = current
+ updated = true
+ end
end
end
--- else
--- postitalic = 0
end
--- else
--- postitalic = 0
+ break
+ else
+ current = getprev(current)
end
--- else
--- postitalic = 0
end
--- postinserted = nil
--- else
--- postitalic = 0
--- postinserted = nil
+ end
+ if updated then
+ setdisc(current,pre,post,replace)
end
elseif id == kern_code then -- how about fontkern ?
previnserted = nil
@@ -410,9 +406,9 @@ function italics.handler(head)
postinserted = nil
postitalic = 0
local next = getnext(current)
- if next and getid(next) == glyph_code then
- local char = getchar(next)
- if is_punctuation[char] then
+ if next then
+ local char, id = isglyph(next)
+ if char and is_punctuation[char] then
local kern = getprev(current)
if kern and getid(kern) == kern_code then
local glyph = getprev(kern)