diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/typo-sus.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/typo-sus.lua | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-sus.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-sus.lua index ce193333050..f728993f600 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/typo-sus.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/typo-sus.lua @@ -48,9 +48,12 @@ local getfield = nuts.getfield local getattr = nuts.getattr local getfont = nuts.getfont local getlist = nuts.getlist +local getkern = nuts.getkern +local getpenalty = nuts.getpenalty +local getwidth = nuts.getwidth +local getwhd = nuts.getwhd local isglyph = nuts.isglyph -local setfield = nuts.setfield local setattr = nuts.setattr local setlist = nuts.setlist @@ -72,22 +75,21 @@ local a_suspect = attributes.private('suspect') local texsetattribute = tex.setattribute local enabled = false +local enableaction = nodes.tasks.enableaction + local threshold = 65536 / 4 local function special(n) if n then local id = getid(n) if id == kern_code then - local kern = getfield(n,"kern") - return kern < threshold + return getkern(n) < threshold elseif id == penalty_code then return true elseif id == glue_code then - local width = getfield(n,"width") - return width < threshold + return getwidth(n) < threshold elseif id == hlist_code then - local width = getfield(n,"width") - return width < threshold + return getwidth(n) < threshold end else return false @@ -118,23 +120,23 @@ local function mark(head,current,id,color) if id == glue_code then -- the glue can have stretch and/or shrink so the rule can overlap with the -- following glyph .. no big deal as that one then sits on top of the rule - local width = getfield(current,"width") + local width = getwidth(current) local rule = new_rule(width) local kern = new_kern(-width) head = insert_before(head,current,rule) head = insert_before(head,current,kern) setcolor(rule,color) -- elseif id == kern_code then - -- local width = getfield(current,"kern") + -- local width = getkern(current) -- local rule = new_rule(width) -- local kern = new_kern(-width) -- head = insert_before(head,current,rule) -- head = insert_before(head,current,kern) -- setcolor(rule,color) else - local width = getfield(current,"width") + local width, height, depth = getwhd(current) local extra = fonts.hashes.xheights[getfont(current)] / 2 - local rule = new_rule(width,getfield(current,"height")+extra,getfield(current,"depth")+extra) + local rule = new_rule(width,height+extra,depth+extra) local hlist = new_hlist(rule) head = insert_before(head,current,hlist) setcolor(rule,color) @@ -232,7 +234,7 @@ function typesetters.marksuspects(head) local prev = getprev(current) local prid = prev and getid(prev) local done = false - if prid == penalty_code and getfield(prev,"penalty") == 10000 then + if prid == penalty_code and getpenalty(prev) == 10000 then done = 8 -- orange else done = 5 -- darkmagenta @@ -292,19 +294,13 @@ function typesetters.showsuspects(head) end end -nodes.tasks.appendaction ("processors","after", "typesetters.marksuspects") -nodes.tasks.prependaction("shipouts", "normalizers","typesetters.showsuspects") - -nodes.tasks.disableaction("processors","typesetters.marksuspects") -nodes.tasks.disableaction("shipouts", "typesetters.showsuspects") - -- or maybe a directive trackers.register("typesetters.suspects",function(v) texsetattribute(a_suspecting,v and 1 or unsetvalue) if v and not enabled then - nodes.tasks.enableaction("processors","typesetters.marksuspects") - nodes.tasks.enableaction("shipouts", "typesetters.showsuspects") + enableaction("processors","typesetters.marksuspects") + enableaction("shipouts", "typesetters.showsuspects") enabled = true end end) |