diff options
author | Norbert Preining <preining@logic.at> | 2019-02-24 15:12:57 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2019-02-24 15:12:57 +0000 |
commit | 1314fbe93790c501dc436a5cf99f106b9e5c0f63 (patch) | |
tree | 04dc7734c8be8ffe385d41f4388826ef5857b6f9 /Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua | |
parent | eb80ce7b34f59896a1dfee5ca422495394d6677f (diff) |
Revert "ConTeXt version 2019.02.22 19:35"
This reverts commit 5c6357cdb820b4f628d036ba7b2248f221d50c0b.
git-svn-id: svn://tug.org/texlive/trunk@50112 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua | 107 |
1 files changed, 42 insertions, 65 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua b/Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua index 83eecf6a3b3..b31dc335a4a 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/scrp-cjk.lua @@ -6,24 +6,23 @@ if not modules then modules = { } end modules ['scrp-cjk'] = { license = "see context related readme files" } --- We can speed this up by preallocating nodes and copying them but the gain is not --- that large. --- --- If needed we can speed this up (traversers and prev next and such) but cjk --- documents don't have that many glyphs and certainly not much font processing so --- there not much gain in it. --- --- The input line endings: there is no way to distinguish between inline spaces and --- endofline turned into spaces (would not make sense either because otherwise a --- wanted space at the end of a line would have to be a hard coded ones. +-- We can speed this up by preallocating nodes and copying them but the +-- gain is not that large. + +-- The input line endings: there is no way to distinguish between +-- inline spaces and endofline turned into spaces (would not make +-- sense either because otherwise a wanted space at the end of a +-- line would have to be a hard coded ones. local nuts = nodes.nuts +local tonut = nodes.tonut +local tonode = nodes.tonode local insert_node_after = nuts.insert_after local insert_node_before = nuts.insert_before local copy_node = nuts.copy local remove_node = nuts.remove -local nextglyph = nuts.traversers.glyph +local traverse_id = nuts.traverse_id local getnext = nuts.getnext local getprev = nuts.getprev @@ -42,14 +41,12 @@ local new_kern = nodepool.kern local new_penalty = nodepool.penalty local nodecodes = nodes.nodecodes -local gluecodes = nodes.gluecodes - +local skipcodes = nodes.skipcodes local glyph_code = nodecodes.glyph local glue_code = nodecodes.glue - -local userskip_code = gluecodes.userskip -local spaceskip_code = gluecodes.spaceskip -local xspaceskip_code = gluecodes.xspaceskip +local userskip_code = skipcodes.userskip +local spaceskip_code = skipcodes.spaceskip +local xspaceskip_code = skipcodes.xspaceskip local a_scriptstatus = attributes.private('scriptstatus') local a_scriptinjection = attributes.private('scriptinjection') @@ -442,16 +439,13 @@ local injectors = { -- [previous] [current] local function process(head,first,last) if first ~= last then - local lastfont = nil - local previous = "start" - local last = nil + local lastfont, previous, last = nil, "start", nil while true do - local upcoming = getnext(first) - local id = getid(first) + local upcoming, id = getnext(first), getid(first) if id == glyph_code then - local a = getattr(first,a_scriptstatus) + local a = getattr(first,a_scriptstatus) local current = numbertocategory[a] - local action = injectors[previous] + local action = injectors[previous] if action then action = action[current] if action then @@ -465,16 +459,12 @@ local function process(head,first,last) end previous = current else -- glue - local p = getprev(first) - local n = upcoming + local p, n = getprev(first), upcoming if p and n then - local pid = getid(p) - local nid = getid(n) + local pid, nid = getid(p), getid(n) if pid == glyph_code and nid == glyph_code then - local pa = getattr(p,a_scriptstatus) - local na = getattr(n,a_scriptstatus) - local pcjk = pa and numbertocategory[pa] - local ncjk = na and numbertocategory[na] + local pa, na = getattr(p,a_scriptstatus), getattr(n,a_scriptstatus) + local pcjk, ncjk = pa and numbertocategory[pa], na and numbertocategory[na] if not pcjk or not ncjk or pcjk == "korean" or ncjk == "korean" or pcjk == "other" or ncjk == "other" @@ -519,9 +509,10 @@ scripts.installmethod { } function scripts.decomposehangul(head) + local head = tonut(head) local done = false - for current, char in nextglyph, head do - local lead_consonant, medial_vowel, tail_consonant = decomposed(char) + for current in traverse_id(glyph_code,head) do + local lead_consonant, medial_vowel, tail_consonant = decomposed(getchar(current)) if lead_consonant then setchar(current,lead_consonant) local m = copy_node(current) @@ -535,7 +526,7 @@ function scripts.decomposehangul(head) done = true end end - return head, done + return tonode(head), done end -- nodes.tasks.prependaction("processors","normalizers","scripts.decomposehangul") @@ -704,16 +695,13 @@ local injectors = { -- [previous] [current] local function process(head,first,last) if first ~= last then - local lastfont = nil - local previous = "start" - local last = nil + local lastfont, previous, last = nil, "start", nil while true do - local upcoming = getnext(first) - local id = getid(first) + local upcoming, id = getnext(first), getid(first) if id == glyph_code then - local a = getattr(first,a_scriptstatus) + local a = getattr(first,a_scriptstatus) local current = numbertocategory[a] - local action = injectors[previous] + local action = injectors[previous] if action then action = action[current] if action then @@ -727,16 +715,12 @@ local function process(head,first,last) end previous = current else -- glue - local p = getprev(first) - local n = upcoming + local p, n = getprev(first), upcoming if p and n then - local pid = getid(p) - local nid = getid(n) + local pid, nid = getid(p), getid(n) if pid == glyph_code and nid == glyph_code then - local pa = getattr(p,a_scriptstatus) - local na = getattr(n,a_scriptstatus) - local pcjk = pa and numbertocategory[pa] - local ncjk = na and numbertocategory[na] + local pa, na = getattr(p,a_scriptstatus), getattr(n,a_scriptstatus) + local pcjk, ncjk = pa and numbertocategory[pa], na and numbertocategory[na] if not pcjk or not ncjk or pcjk == "korean" or ncjk == "korean" or pcjk == "other" or ncjk == "other" @@ -933,16 +917,13 @@ local injectors = { -- [previous] [current] local function process(head,first,last) if first ~= last then - local lastfont = nil - local previous = "start" - local last = nil + local lastfont, previous, last = nil, "start", nil while true do - local upcoming = getnext(first) - local id = getid(first) + local upcoming, id = getnext(first), getid(first) if id == glyph_code then - local a = getattr(first,a_scriptstatus) + local a = getattr(first,a_scriptstatus) local current = numbertocategory[a] - local action = injectors[previous] + local action = injectors[previous] if action then action = action[current] if action then @@ -959,16 +940,12 @@ local function process(head,first,last) -- upcoming = getnext(end_of_math(current)) -- previous = "start" else -- glue - local p = getprev(first) - local n = upcoming + local p, n = getprev(first), upcoming -- we should remember prev if p and n then - local pid = getid(p) - local nid = getid(n) + local pid, nid = getid(p), getid(n) if pid == glyph_code and nid == glyph_code then - local pa = getattr(p,a_scriptstatus) - local na = getattr(n,a_scriptstatus) - local pcjk = pa and numbertocategory[pa] - local ncjk = na and numbertocategory[na] + local pa, na = getattr(p,a_scriptstatus), getattr(n,a_scriptstatus) + local pcjk, ncjk = pa and numbertocategory[pa], na and numbertocategory[na] if not pcjk or not ncjk or pcjk == "korean" or ncjk == "korean" or pcjk == "other" or ncjk == "other" |