diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/typo-fln.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/typo-fln.lua | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-fln.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-fln.lua index 0489807327c..4fb82ce4499 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/typo-fln.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/typo-fln.lua @@ -30,6 +30,7 @@ local context = context local implement = interfaces.implement local nuts = nodes.nuts +local tonut = nuts.tonut local tonode = nuts.tonode local getnext = nuts.getnext @@ -37,6 +38,7 @@ local getprev = nuts.getprev local getboth = nuts.getboth local setboth = nuts.setboth local getid = nuts.getid +local getsubtype = nuts.getsubtype local getwidth = nuts.getwidth local getlist = nuts.getlist local setlist = nuts.setlist @@ -56,16 +58,14 @@ local glue_code = nodecodes.glue local spaceskip_code = nodes.gluecodes.spaceskip -local nextglyph = nuts.traversers.glyph -local nextdisc = nuts.traversers.disc - +local traverse_id = nuts.traverse_id local flush_node_list = nuts.flush_list local flush_node = nuts.flush_node local copy_node_list = nuts.copy_list local insert_node_before = nuts.insert_before local insert_node_after = nuts.insert_after local remove_node = nuts.remove -local getdimensions = nuts.dimensions +local list_dimensions = nuts.dimensions local hpack_node_list = nuts.hpack local nodepool = nuts.pool @@ -136,7 +136,7 @@ actions[v_line] = function(head,setting) local linebreaks = { } local function set(head) - for g in nextglyph, head do + for g in traverse_id(glyph_code,head) do if dynamic > 0 then setattr(g,0,dynamic) end @@ -146,7 +146,7 @@ actions[v_line] = function(head,setting) set(temp) - for g in nextdisc, temp do + for g in traverse_id(disc_code,temp) do local pre, post, replace = getdisc(g) if pre then set(pre) @@ -173,13 +173,17 @@ actions[v_line] = function(head,setting) local function list_dimensions(list,start) local temp = copy_node_list(list,start) + temp = tonode(temp) temp = nodes.handlers.characters(temp) temp = nodes.injections.handler(temp) -- temp = typesetters.fontkerns.handler(temp) -- maybe when enabled - -- nodes.handlers.protectglyphs(temp) -- not needed as we discard + -- nodes.handlers.protectglyphs(temp) -- not needed as we discard -- temp = typesetters.spacings.handler(temp) -- maybe when enabled -- temp = typesetters.kerns.handler(temp) -- maybe when enabled - local width = getdimensions(temp) + temp = tonut(temp) + temp = hpack_node_list(temp) + local width = getwidth(temp) + flush_node_list(temp) return width end @@ -202,7 +206,7 @@ actions[v_line] = function(head,setting) while start do local id = getid(start) if id == glyph_code then - -- go on + n = n + 1 elseif id == disc_code then -- this could be an option n = n + 1 @@ -214,8 +218,7 @@ actions[v_line] = function(head,setting) end elseif id == kern_code then -- todo: fontkern -- this could be an option - elseif id == glue_code then - n = n + 1 + elseif n > 0 then if try() then break end @@ -252,6 +255,7 @@ actions[v_line] = function(head,setting) local id = getid(start) local ok = false if id == glyph_code then + n = n + 1 update(start) elseif id == disc_code then n = n + 1 @@ -260,7 +264,7 @@ actions[v_line] = function(head,setting) if linebreak == n then local p, n = getboth(start) if pre then - for current in nextglyph, pre do + for current in traverse_id(glyph_code,pre) do update(current) end setlink(pretail,n) @@ -280,7 +284,7 @@ actions[v_line] = function(head,setting) else local p, n = getboth(start) if replace then - for current in nextglyph, replace do + for current in traverse_id(glyph_code,replace) do update(current) end setlink(replacetail,n) @@ -295,30 +299,22 @@ actions[v_line] = function(head,setting) setdisc(disc,pre,post,replace) flush_node(disc) elseif id == glue_code then - n = n + 1 - if linebreak ~= n then - head = insert_node_before(head,start,newpenalty(10000)) -- nobreak - end + head = insert_node_before(head,start,newpenalty(10000)) -- nobreak end - local next = getnext(start) if linebreak == n then - if start ~= head then - local where = id == glue_code and getprev(start) or start - if trace_firstlines then - head, where = insert_node_after(head,where,newpenalty(10000)) -- nobreak - head, where = insert_node_after(head,where,newkern(-65536)) - head, where = insert_node_after(head,where,tracerrule(65536,4*65536,2*65536,"darkblue")) - end - head, where = insert_node_after(head,where,newpenalty(-10000)) -- break + if trace_firstlines then + head, start = insert_node_after(head,start,newpenalty(10000)) -- nobreak + head, start = insert_node_after(head,start,newkern(-65536)) + head, start = insert_node_after(head,start,tracerrule(65536,4*65536,2*65536,"darkblue")) end - start = next + head, start = insert_node_after(head,start,newpenalty(-10000)) -- break break end - start = next + start = getnext(start) end end - return head + return head, true end actions[v_word] = function(head,setting) @@ -363,12 +359,13 @@ actions[v_word] = function(head,setting) end start = getnext(start) end - return head + return head, true end actions[v_default] = actions[v_line] function firstlines.handler(head) + head = tonut(head) local start = head local attr = nil while start do @@ -391,10 +388,11 @@ function firstlines.handler(head) if trace_firstlines then report_firstlines("processing firstlines, alternative %a",alternative) end - return action(head,settings) + local head, done = action(head,settings) + return tonode(head), done end end - return head + return tonode(head), false end -- goodie @@ -403,7 +401,7 @@ local function applytofirstcharacter(box,what) local tbox = getbox(box) -- assumes hlist local list = getlist(tbox) local done = nil - for n in nextglyph, list do + for n in traverse_id(glyph_code,list) do list = remove_node(list,n) done = n break |