diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-02-17 10:31:56 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-02-17 10:31:56 +0100 |
commit | b14f992ef5f4e868c9959b174278c86516d60dbc (patch) | |
tree | 28587bb46c025ea7b0d27ba93f09c93dcf53c73a /tex/context/base/mkiv/typo-sus.lua | |
parent | 95a1799032dc61dbca4a11e495be34b4397c8fec (diff) | |
download | context-b14f992ef5f4e868c9959b174278c86516d60dbc.tar.gz |
2017-02-17 10:23:00
Diffstat (limited to 'tex/context/base/mkiv/typo-sus.lua')
-rw-r--r-- | tex/context/base/mkiv/typo-sus.lua | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/tex/context/base/mkiv/typo-sus.lua b/tex/context/base/mkiv/typo-sus.lua index d3526bb5d..e81b36b65 100644 --- a/tex/context/base/mkiv/typo-sus.lua +++ b/tex/context/base/mkiv/typo-sus.lua @@ -48,9 +48,11 @@ 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 isglyph = nuts.isglyph -local setfield = nuts.setfield local setattr = nuts.setattr local setlist = nuts.setlist @@ -72,22 +74,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,21 +119,21 @@ 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, height, depth = getWhd(current) + local width, height, depth = getwhd(current) local extra = fonts.hashes.xheights[getfont(current)] / 2 local rule = new_rule(width,height+extra,depth+extra) local hlist = new_hlist(rule) @@ -232,7 +233,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 +293,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) |