summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-12-28 11:57:23 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2018-12-28 11:57:23 +0100
commit2f8058544f8a3fead8186bdcb3835f1f67416cc3 (patch)
tree499caa2670374128935c3e4ef663a6a578703df1 /tex
parent979450762f4ef3b885fd63984c91165726494564 (diff)
downloadcontext-2f8058544f8a3fead8186bdcb3835f1f67416cc3.tar.gz
2018-12-28 11:09:00
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/mkii/cont-new.mkii2
-rw-r--r--tex/context/base/mkii/context.mkii2
-rw-r--r--tex/context/base/mkii/mult-pe.mkii3
-rw-r--r--tex/context/base/mkiv/anch-pos.lua2
-rw-r--r--tex/context/base/mkiv/back-exp.lua118
-rw-r--r--tex/context/base/mkiv/back-pdf.lua8
-rw-r--r--tex/context/base/mkiv/back-pdp.lua9
-rw-r--r--tex/context/base/mkiv/cldf-bas.lua6
-rw-r--r--tex/context/base/mkiv/cldf-ini.lua8
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv6
-rw-r--r--tex/context/base/mkiv/core-lmt.mkiv4
-rw-r--r--tex/context/base/mkiv/font-ctx.lua8
-rw-r--r--tex/context/base/mkiv/font-lib.mkvi8
-rw-r--r--tex/context/base/mkiv/font-mps.lua83
-rw-r--r--tex/context/base/mkiv/font-nod.lua4
-rw-r--r--tex/context/base/mkiv/font-ots.lua174
-rw-r--r--tex/context/base/mkiv/font-ott.lua8
-rw-r--r--tex/context/base/mkiv/font-sol.lua40
-rw-r--r--tex/context/base/mkiv/grph-rul.lua46
-rw-r--r--tex/context/base/mkiv/grph-trf.mkiv2
-rw-r--r--tex/context/base/mkiv/l-macro.lua8
-rw-r--r--tex/context/base/mkiv/lang-dis.lua7
-rw-r--r--tex/context/base/mkiv/lang-exp.lua2
-rw-r--r--tex/context/base/mkiv/lang-hyp.lua14
-rw-r--r--tex/context/base/mkiv/lpdf-epd.lua112
-rw-r--r--tex/context/base/mkiv/lpdf-nod.lua77
-rw-r--r--tex/context/base/mkiv/lpdf-pde.lua116
-rw-r--r--tex/context/base/mkiv/math-dir.lua8
-rw-r--r--tex/context/base/mkiv/math-noa.lua526
-rw-r--r--tex/context/base/mkiv/math-spa.lua31
-rw-r--r--tex/context/base/mkiv/math-tag.lua170
-rw-r--r--tex/context/base/mkiv/meta-blb.lua13
-rw-r--r--tex/context/base/mkiv/meta-pdf.lua14
-rw-r--r--tex/context/base/mkiv/mult-aux.mkiv6
-rw-r--r--tex/context/base/mkiv/node-acc.lua8
-rw-r--r--tex/context/base/mkiv/node-bck.lua97
-rw-r--r--tex/context/base/mkiv/node-bck.mkiv2
-rw-r--r--tex/context/base/mkiv/node-fin.lua101
-rw-r--r--tex/context/base/mkiv/node-fin.mkiv4
-rw-r--r--tex/context/base/mkiv/node-fnt.lua17
-rw-r--r--tex/context/base/mkiv/node-ltp.lua3151
-rw-r--r--tex/context/base/mkiv/node-nut.lua2
-rw-r--r--tex/context/base/mkiv/node-ppt.lua7
-rw-r--r--tex/context/base/mkiv/node-pro.lua14
-rw-r--r--tex/context/base/mkiv/node-ref.lua82
-rw-r--r--tex/context/base/mkiv/node-res.lua86
-rw-r--r--tex/context/base/mkiv/node-rul.lua21
-rw-r--r--tex/context/base/mkiv/node-rul.mkiv2
-rw-r--r--tex/context/base/mkiv/node-scn.lua8
-rw-r--r--tex/context/base/mkiv/node-ser.lua1
-rw-r--r--tex/context/base/mkiv/node-shp.lua62
-rw-r--r--tex/context/base/mkiv/node-tra.lua31
-rw-r--r--tex/context/base/mkiv/node-tst.lua10
-rw-r--r--tex/context/base/mkiv/pack-rul.lua99
-rw-r--r--tex/context/base/mkiv/pack-rul.mkiv2
-rw-r--r--tex/context/base/mkiv/page-cst.lua161
-rw-r--r--tex/context/base/mkiv/page-lin.lua17
-rw-r--r--tex/context/base/mkiv/scrp-cjk.lua10
-rw-r--r--tex/context/base/mkiv/spac-ali.lua5
-rw-r--r--tex/context/base/mkiv/spac-ali.mkiv2
-rw-r--r--tex/context/base/mkiv/spac-chr.lua10
-rw-r--r--tex/context/base/mkiv/spac-chr.mkiv2
-rw-r--r--tex/context/base/mkiv/spac-hor.mkiv6
-rw-r--r--tex/context/base/mkiv/spac-prf.lua13
-rw-r--r--tex/context/base/mkiv/spac-ver.lua34
-rw-r--r--tex/context/base/mkiv/spac-ver.mkiv2
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin26300 -> 26061 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin235065 -> 269837 bytes
-rw-r--r--tex/context/base/mkiv/strc-mar.lua105
-rw-r--r--tex/context/base/mkiv/strc-ref.mkvi2
-rw-r--r--tex/context/base/mkiv/supp-box.lua138
-rw-r--r--tex/context/base/mkiv/supp-box.mkiv2
-rw-r--r--tex/context/base/mkiv/tabl-xtb.lua6
-rw-r--r--tex/context/base/mkiv/trac-jus.lua4
-rw-r--r--tex/context/base/mkiv/trac-vis.lua163
-rw-r--r--tex/context/base/mkiv/typo-bld.lua53
-rw-r--r--tex/context/base/mkiv/typo-cap.lua1
-rw-r--r--tex/context/base/mkiv/typo-chr.lua84
-rw-r--r--tex/context/base/mkiv/typo-dha.lua48
-rw-r--r--tex/context/base/mkiv/typo-dua.lua66
-rw-r--r--tex/context/base/mkiv/typo-dub.lua76
-rw-r--r--tex/context/base/mkiv/typo-duc.lua161
-rw-r--r--tex/context/base/mkiv/typo-fln.lua6
-rw-r--r--tex/context/base/mkiv/typo-krn.lua23
-rw-r--r--tex/context/base/mkiv/typo-lin.lua22
-rw-r--r--tex/context/base/mkiv/typo-mar.lua1
-rw-r--r--tex/context/base/mkiv/typo-par.mkiv2
-rw-r--r--tex/context/base/mkiv/typo-rub.lua7
-rw-r--r--tex/context/base/mkiv/typo-tal.lua10
-rw-r--r--tex/context/base/mkiv/typo-wrp.lua18
-rw-r--r--tex/context/base/mkiv/util-lua.lua1
-rw-r--r--tex/context/interface/mkii/keys-pe.xml3
-rw-r--r--tex/context/interface/mkiv/i-context.pdfbin913345 -> 864300 bytes
-rw-r--r--tex/context/interface/mkiv/i-readme.pdfbin25093 -> 60775 bytes
-rw-r--r--tex/generic/context/luatex/luatex-core.lua2
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua98
97 files changed, 3330 insertions, 3488 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii
index fa6af8829..78b1530af 100644
--- a/tex/context/base/mkii/cont-new.mkii
+++ b/tex/context/base/mkii/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2018.12.19 19:22}
+\newcontextversion{2018.12.28 11:01}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii
index bd22d80fe..48a2834fc 100644
--- a/tex/context/base/mkii/context.mkii
+++ b/tex/context/base/mkii/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2018.12.19 19:22}
+\edef\contextversion{2018.12.28 11:01}
%D For those who want to use this:
diff --git a/tex/context/base/mkii/mult-pe.mkii b/tex/context/base/mkii/mult-pe.mkii
index d406f3a95..57cbe5600 100644
--- a/tex/context/base/mkii/mult-pe.mkii
+++ b/tex/context/base/mkii/mult-pe.mkii
@@ -137,6 +137,7 @@
\setinterfacevariable{chemicals}{chemicals}
\setinterfacevariable{chemistry}{chemistry}
\setinterfacevariable{cite}{cite}
+\setinterfacevariable{closed}{closed}
\setinterfacevariable{color}{رنگ}
\setinterfacevariable{column}{ستون}
\setinterfacevariable{columns}{ستونها}
@@ -418,7 +419,7 @@
\setinterfacevariable{positive}{مثبت}
\setinterfacevariable{postponing}{تاخیر}
\setinterfacevariable{postscript}{پست‌اسکریپت}
-\setinterfacevariable{precedingpage}{followingpage}
+\setinterfacevariable{precedingpage}{precedingpage}
\setinterfacevariable{preference}{ترجیح}
\setinterfacevariable{preview}{پیش‌دید}
\setinterfacevariable{previous}{قبلی}
diff --git a/tex/context/base/mkiv/anch-pos.lua b/tex/context/base/mkiv/anch-pos.lua
index 69203a490..3cce01b31 100644
--- a/tex/context/base/mkiv/anch-pos.lua
+++ b/tex/context/base/mkiv/anch-pos.lua
@@ -69,7 +69,7 @@ local getbox = nuts.getbox
local getid = nuts.getid
local getwhd = nuts.getwhd
-local hlist_code = nodes.listcodes.hlist
+local hlist_code = nodes.nodecodes.hlist
local find_tail = nuts.tail
local hpack = nuts.hpack
diff --git a/tex/context/base/mkiv/back-exp.lua b/tex/context/base/mkiv/back-exp.lua
index 04f376d96..86c29966e 100644
--- a/tex/context/base/mkiv/back-exp.lua
+++ b/tex/context/base/mkiv/back-exp.lua
@@ -2856,63 +2856,63 @@ end
local collectresults do -- too many locals otherwise
- local nodecodes = nodes.nodecodes
- local skipcodes = nodes.skipcodes
- local listcodes = nodes.listcodes
- local whatsitcodes = nodes.whatsitcodes
-
- local subtypes = nodes.subtypes
-
- local hlist_code = nodecodes.hlist
- local vlist_code = nodecodes.vlist
- local glyph_code = nodecodes.glyph
- local glue_code = nodecodes.glue
- local kern_code = nodecodes.kern
- local disc_code = nodecodes.disc
- local whatsit_code = nodecodes.whatsit
- local localpar_code = nodecodes.localpar
-
- local userskip_code = skipcodes.userskip
- local rightskip_code = skipcodes.rightskip
- local parfillskip_code = skipcodes.parfillskip
- local spaceskip_code = skipcodes.spaceskip
- local xspaceskip_code = skipcodes.xspaceskip
-
- local line_code = listcodes.line
-
- local userdefined_code = whatsitcodes.userdefined
-
- local privateattribute = attributes.private
- local a_image = privateattribute('image')
- local a_reference = privateattribute('reference')
- local a_destination = privateattribute('destination')
- local a_characters = privateattribute('characters')
- local a_exportstatus = privateattribute('exportstatus')
- local a_tagged = privateattribute('tagged')
- local a_taggedpar = privateattribute("taggedpar")
- local a_textblock = privateattribute("textblock")
-
- local inline_mark = nodes.pool.userids["margins.inline"]
-
- local nuts = nodes.nuts
-
- local getnext = nuts.getnext
- local getsubtype = nuts.getsubtype
- local getfont = nuts.getfont
- local getchar = nuts.getchar
- local getdisc = nuts.getdisc
- local getcomponents = nuts.getcomponents
- local getlist = nuts.getlist
- local getid = nuts.getid
- local getattr = nuts.getattr
- local setattr = nuts.setattr -- maybe use properties
- local isglyph = nuts.isglyph
- local getkern = nuts.getkern
- local getwidth = nuts.getwidth
- local getfield = nuts.getfield
-
- local nexthlist = nuts.traversers.hlist
- local nextnode = nuts.traversers.node
+ local nodecodes = nodes.nodecodes
+ local gluecodes = nodes.gluecodes
+ local listcodes = nodes.listcodes
+ local whatsitcodes = nodes.whatsitcodes
+
+ local subtypes = nodes.subtypes
+
+ local hlist_code = nodecodes.hlist
+ local vlist_code = nodecodes.vlist
+ local glyph_code = nodecodes.glyph
+ local glue_code = nodecodes.glue
+ local kern_code = nodecodes.kern
+ local disc_code = nodecodes.disc
+ local whatsit_code = nodecodes.whatsit
+ local localpar_code = nodecodes.localpar
+
+ local userskip_code = gluecodes.userskip
+ local rightskip_code = gluecodes.rightskip
+ local parfillskip_code = gluecodes.parfillskip
+ local spaceskip_code = gluecodes.spaceskip
+ local xspaceskip_code = gluecodes.xspaceskip
+
+ local linelist_code = listcodes.line
+
+ local userdefinedwhatsit_code = whatsitcodes.userdefined
+
+ local privateattribute = attributes.private
+ local a_image = privateattribute('image')
+ local a_reference = privateattribute('reference')
+ local a_destination = privateattribute('destination')
+ local a_characters = privateattribute('characters')
+ local a_exportstatus = privateattribute('exportstatus')
+ local a_tagged = privateattribute('tagged')
+ local a_taggedpar = privateattribute("taggedpar")
+ local a_textblock = privateattribute("textblock")
+
+ local inline_mark = nodes.pool.userids["margins.inline"]
+
+ local nuts = nodes.nuts
+
+ local getnext = nuts.getnext
+ local getsubtype = nuts.getsubtype
+ local getfont = nuts.getfont
+ local getchar = nuts.getchar
+ local getdisc = nuts.getdisc
+ local getcomponents = nuts.getcomponents
+ local getlist = nuts.getlist
+ local getid = nuts.getid
+ local getattr = nuts.getattr
+ local setattr = nuts.setattr -- maybe use properties
+ local isglyph = nuts.isglyph
+ local getkern = nuts.getkern
+ local getwidth = nuts.getwidth
+ local getfield = nuts.getfield
+
+ local nexthlist = nuts.traversers.hlist
+ local nextnode = nuts.traversers.node
local function addtomaybe(maybewrong,c,case)
if trace_export then
@@ -3274,7 +3274,7 @@ end
end
end
elseif id == whatsit_code then
- if subtype == userdefined_code then
+ if subtype == userdefinedwhatsit_code then
-- similar to images, see above
local at = getattr(n,a_tagged)
if nofcurrentcontent > 0 then
@@ -3322,7 +3322,7 @@ end
function builders.paragraphs.tag(head)
noftextblocks = noftextblocks + 1
for n, subtype in nexthlist, head do
- if subtype == line_code then
+ if subtype == linelist_code then
setattr(n,a_textblock,noftextblocks)
elseif subtype == glue_code or subtype == kern_code then -- no need to set fontkerns
setattr(n,a_textblock,0)
diff --git a/tex/context/base/mkiv/back-pdf.lua b/tex/context/base/mkiv/back-pdf.lua
index 32c364bba..7e4848ef8 100644
--- a/tex/context/base/mkiv/back-pdf.lua
+++ b/tex/context/base/mkiv/back-pdf.lua
@@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['back-pdf'] = {
-- we could do \pdfmatrix sx <> sy <> etc
-local sind, cosd = math.sind, math.cosd
+local sind, cosd, abs = math.sind, math.cosd, math.abs
local insert, remove = table.insert, table.remove
local codeinjections = backends.pdf.codeinjections
@@ -80,6 +80,12 @@ local function pdfstartrotation()
insert(stack,false)
else
local s, c = sind(a), cosd(a)
+ if abs(s) < 0.000001 then
+ s = 0 -- otherwise funny -0.00000
+ end
+ if abs(c) < 0.000001 then
+ c = 0 -- otherwise funny -0.00000
+ end
context(pdfsave())
context(pdfsetmatrix(c,s,-s,c))
insert(stack,restore and { c, -s, s, c } or true)
diff --git a/tex/context/base/mkiv/back-pdp.lua b/tex/context/base/mkiv/back-pdp.lua
index 4087fa354..178fe98fb 100644
--- a/tex/context/base/mkiv/back-pdp.lua
+++ b/tex/context/base/mkiv/back-pdp.lua
@@ -135,12 +135,9 @@ implement { name = "useboxresource", actions = useboxresource }
-- image resources (messy: will move)
-local newrule = nodes.pool.rule
-local image_rule_code = nodes.rulecodes.image
-
-local imageresources = { }
-local lastindex = 0
-local lastpages = 1
+local imageresources = { }
+local lastindex = 0
+local lastpages = 1
local function saveimageresource()
local width, height, depth = scanwhd()
diff --git a/tex/context/base/mkiv/cldf-bas.lua b/tex/context/base/mkiv/cldf-bas.lua
index de436e445..4088348f6 100644
--- a/tex/context/base/mkiv/cldf-bas.lua
+++ b/tex/context/base/mkiv/cldf-bas.lua
@@ -81,12 +81,12 @@ function context.utfchar(k)
end
end
-function context.rule(w,h,d,dir)
+function context.rule(w,h,d,direction)
local rule
if type(w) == "table" then
- rule = new_rule(w.width,w.height,w.depth,w.dir)
+ rule = new_rule(w.width,w.height,w.depth,w.direction)
else
- rule = new_rule(w,h,d,dir)
+ rule = new_rule(w,h,d,direction)
end
setattrlist(rule,true)
context(tonode(rule))
diff --git a/tex/context/base/mkiv/cldf-ini.lua b/tex/context/base/mkiv/cldf-ini.lua
index 943e7e7c1..0f90f058e 100644
--- a/tex/context/base/mkiv/cldf-ini.lua
+++ b/tex/context/base/mkiv/cldf-ini.lua
@@ -711,8 +711,8 @@ local s_cldl_argument_e = "}"
-- local s_cldl_argument_b = "{"
-- local s_cldl_argument_f = "{ "
-local t_cldl_luafunction = createtoken("luafunctioncall")
-local lua_expandable_call_code = token.command_id and token.command_id("lua_expandable_call")
+local t_cldl_luafunction = createtoken("luafunctioncall")
+local lua_expandable_call_token_code = token.command_id and token.command_id("lua_expandable_call")
local function writer(parent,command,...) -- already optimized before call
@@ -830,7 +830,7 @@ local function writer(parent,command,...) -- already optimized before call
ti = storefunction(ti)
if tokenflushmode then
if newtoken then
- flush(currentcatcodes,"{",newtoken(ti,lua_expandable_call_code),"}")
+ flush(currentcatcodes,"{",newtoken(ti,lua_expandable_call_token_code),"}")
else
flush(currentcatcodes,"{",t_cldl_luafunction,ti,"}")
end
@@ -1035,7 +1035,7 @@ local caller = function(parent,f,a,...)
f = storefunction(f)
if tokenflushmode then
if newtoken then
- flush(currentcatcodes,"{",newtoken(f,lua_expandable_call_code),"}")
+ flush(currentcatcodes,"{",newtoken(f,lua_expandable_call_token_code),"}")
else
flush(currentcatcodes,"{",t_cldl_luafunction,f,"}")
end
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index 8fe9caee7..1c6ba3dde 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2018.12.19 19:22}
+\newcontextversion{2018.12.28 11:01}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index 56dca3870..4425ac476 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -42,7 +42,7 @@
%D has to match \type {YYYY.MM.DD HH:MM} format.
\edef\contextformat {\jobname}
-\edef\contextversion{2018.12.19 19:22}
+\edef\contextversion{2018.12.28 11:01}
\edef\contextkind {beta}
%D For those who want to use this:
@@ -136,6 +136,10 @@
\doifelsefileexists{core-lmt.mkiv}{\loadmarkfile{core-lmt}}{}
+% needs more checking for clashes:
+%
+% \doifelsefileexists{l-macro-imp-codes.lua}{\registerctxluafile{l-macro-imp-codes}{}}{}
+
\loadmarkfile{supp-dir}
\loadmarkfile{char-utf} % generic code (i.e. not much tex) ... could become unic-ini
diff --git a/tex/context/base/mkiv/core-lmt.mkiv b/tex/context/base/mkiv/core-lmt.mkiv
index 72199f854..0398537d4 100644
--- a/tex/context/base/mkiv/core-lmt.mkiv
+++ b/tex/context/base/mkiv/core-lmt.mkiv
@@ -13,7 +13,9 @@
\writestatus{loading}{ConTeXt System Macros / Primitives}
-\registerctxluafile{core-lmt}{}
+\ifdefined\textdir \else
+ \registerctxluafile{core-lmt}{}
+\fi
\unprotect
diff --git a/tex/context/base/mkiv/font-ctx.lua b/tex/context/base/mkiv/font-ctx.lua
index b9db940dc..87741bfad 100644
--- a/tex/context/base/mkiv/font-ctx.lua
+++ b/tex/context/base/mkiv/font-ctx.lua
@@ -577,6 +577,12 @@ local function definecontext(name,t) -- can be shared
return number, t
end
+-- {a,b,c} as table (so we don' need to parse again when it gets applied)
+-- we will update this ... when we have foo={a,b,c} then we can keep the table
+
+-- \definefontfeature[demo][a={b,c}]
+-- \definefontfeature[demo][a={b=12,c={34,35}}]
+
local function presetcontext(name,parent,features) -- will go to con and shared
if features == "" and find(parent,"=",1,true) then
features = parent
@@ -592,7 +598,7 @@ local function presetcontext(name,parent,features) -- will go to con and shared
if type(value) == "string" and find(value,"[=]") then
local t = settings_to_hash(value)
if next(t) then
- features[key] = sequenced(normalize_features(t),",")
+ features[key] = sequenced(normalize_features(t,true),",")
end
end
end
diff --git a/tex/context/base/mkiv/font-lib.mkvi b/tex/context/base/mkiv/font-lib.mkvi
index 1f820439f..3cff81751 100644
--- a/tex/context/base/mkiv/font-lib.mkvi
+++ b/tex/context/base/mkiv/font-lib.mkvi
@@ -37,16 +37,16 @@
\registerctxluafile{font-hsh}{} % hashes used by context
\registerctxluafile{font-vfc}{}
\registerctxluafile{font-prv}{} % needs hashes
-\registerctxluafile{font-nod}{}
+\registerctxluafile{font-nod}{optimize}
\registerctxluafile{font-oti}{} % otf initialization
\registerctxluafile{font-ott}{} % otf tables (first)
\registerctxluafile{font-otl}{}
\registerctxluafile{font-oto}{}
-\registerctxluafile{font-otj}{}
+\registerctxluafile{font-otj}{optimize}
\registerctxluafile{font-oup}{}
\registerctxluafile{font-ota}{}
-\registerctxluafile{font-ots}{}
-\registerctxluafile{font-otd}{}
+\registerctxluafile{font-ots}{optimize}
+\registerctxluafile{font-otd}{optimize}
\registerctxluafile{font-otc}{}
\registerctxluafile{font-oth}{}
\registerctxluafile{font-osd}{}
diff --git a/tex/context/base/mkiv/font-mps.lua b/tex/context/base/mkiv/font-mps.lua
index 167d7f214..36f1e4164 100644
--- a/tex/context/base/mkiv/font-mps.lua
+++ b/tex/context/base/mkiv/font-mps.lua
@@ -252,46 +252,47 @@ end
-- right time. It's probably why I like watching https://www.youtube.com/watch?v=c5FqpddnJmc
-- so much: precisely (and perfectly) timed too.
-local nodecodes = nodes.nodecodes -- no nuts yet
-
-local glyph_code = nodecodes.glyph
-local disc_code = nodecodes.disc
-local kern_code = nodecodes.kern
-local glue_code = nodecodes.glue
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local rule_code = nodecodes.rule
-
-local normal_rule = nodes.rulecodes.normal
-
-local nuts = nodes.nuts
-local getnext = nuts.getnext
-local getid = nuts.getid
-local getlist = nuts.getlist
-local getchar = nuts.getchar
-local getfont = nuts.getfont
-local getsubtype = nuts.getsubtype
-local getfield = nuts.getfield
-local getbox = nuts.getbox
-local getwhd = nuts.getwhd
-local getkern = nuts.getkern
-local getshift = nuts.getshift
-local getwidth = nuts.getwidth
-local getheight = nuts.getheight
-local getdepth = nuts.getdepth
-local getexpansion = nuts.getexpansion
-
-local effective_glue = nuts.effective_glue
-
-local characters = fonts.hashes.characters
-local parameters = fonts.hashes.parameters
-local shapes = fonts.hashes.shapes
-local topaths = metapost.paths
-
-local f_code = formatters["mfun_do_outline_text_flush(%q,%i,%.6F,%.6F,%q)(%,t);"]
-local f_rule = formatters["mfun_do_outline_rule_flush(%q,%.6F,%.6F,%.6F,%.6F);"]
-local f_bounds = formatters["checkbounds(%.6F,%.6F,%.6F,%.6F);"]
-local s_nothing = "(origin scaled 10)"
+local nodecodes = nodes.nodecodes -- no nuts yet
+local rulecodes = nodes.rulecodes
+
+local glyph_code = nodecodes.glyph
+local disc_code = nodecodes.disc
+local kern_code = nodecodes.kern
+local glue_code = nodecodes.glue
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local rule_code = nodecodes.rule
+
+local normalrule_code = rulecodes.normal
+
+local nuts = nodes.nuts
+local getnext = nuts.getnext
+local getid = nuts.getid
+local getlist = nuts.getlist
+local getchar = nuts.getchar
+local getfont = nuts.getfont
+local getsubtype = nuts.getsubtype
+local getfield = nuts.getfield
+local getbox = nuts.getbox
+local getwhd = nuts.getwhd
+local getkern = nuts.getkern
+local getshift = nuts.getshift
+local getwidth = nuts.getwidth
+local getheight = nuts.getheight
+local getdepth = nuts.getdepth
+local getexpansion = nuts.getexpansion
+
+local effective_glue = nuts.effective_glue
+
+local characters = fonts.hashes.characters
+local parameters = fonts.hashes.parameters
+local shapes = fonts.hashes.shapes
+local topaths = metapost.paths
+
+local f_code = formatters["mfun_do_outline_text_flush(%q,%i,%.6F,%.6F,%q)(%,t);"]
+local f_rule = formatters["mfun_do_outline_rule_flush(%q,%.6F,%.6F,%.6F,%.6F);"]
+local f_bounds = formatters["checkbounds(%.6F,%.6F,%.6F,%.6F);"]
+local s_nothing = "(origin scaled 10)"
directives.register("metapost.stripzeros", function()
f_code = formatters["mfun_do_outline_text_flush(%q,%i,%.6N,%.6N,%q)(%,t);"]
@@ -394,7 +395,7 @@ function fonts.metapost.boxtomp(n,kind)
dp = getdepth(parent)
end
local hd = (ht + dp) * fc
- if hd ~= 0 and getsubtype(current) == normal_rule then
+ if hd ~= 0 and getsubtype(current) == normalrule_code then
result[#result+1] = f_rule(kind,xoffset+dx+wd/2,yoffset+hd/2,wd,hd)
end
dx = dx + wd
diff --git a/tex/context/base/mkiv/font-nod.lua b/tex/context/base/mkiv/font-nod.lua
index b98534f38..69c1d34dd 100644
--- a/tex/context/base/mkiv/font-nod.lua
+++ b/tex/context/base/mkiv/font-nod.lua
@@ -68,7 +68,7 @@ local getdisc = nuts.getdisc
local getcomponents = nuts.getcomponents
local isglyph = nuts.isglyph
local getkern = nuts.getkern
-local getdir = nuts.getdir
+local getdirection = nuts.getdirection
local getwidth = nuts.getwidth
local setbox = nuts.setbox
@@ -409,7 +409,7 @@ function step_tracers.codes(i,command,space)
if id == glyph_code then
showchar(c)
elseif id == dir_code or id == localpar_code then
- context("[%s]",getdir(c) or "unset")
+ context("[%s]",getdirection(c) or "?")
elseif id == disc_code then
local pre, post, replace = getdisc(c)
if pre or post or replace then
diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua
index 880fbcc1f..a0dab10cb 100644
--- a/tex/context/base/mkiv/font-ots.lua
+++ b/tex/context/base/mkiv/font-ots.lua
@@ -240,8 +240,8 @@ local math_code = nodecodes.math
local dir_code = nodecodes.dir
local localpar_code = nodecodes.localpar
-local discretionary_code = disccodes.discretionary
-local ligature_code = glyphcodes.ligature
+local discretionarydisc_code = disccodes.discretionary
+local ligatureglyph_code = glyphcodes.ligature
local a_state = attributes.private('state')
local a_noligature = attributes.private("noligature")
@@ -465,7 +465,7 @@ local set_components = setcomponents -- we overload here (for now)
local function count_components(start,marks)
if getid(start) ~= glyph_code then
return 0
- elseif getsubtype(start) == ligature_code then
+ elseif getsubtype(start) == ligatureglyph_code then
local i = 0
local components = getcomponents(start)
while components do
@@ -494,7 +494,7 @@ local function markstoligature(head,start,stop,char)
end
resetinjection(base)
setchar(base,char)
- setsubtype(base,ligature_code)
+ setsubtype(base,ligatureglyph_code)
set_components(base,start)
setlink(prev,base,next)
return head, base
@@ -530,7 +530,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou
end
resetinjection(base)
setchar(base,char)
- setsubtype(base,ligature_code)
+ setsubtype(base,ligatureglyph_code)
set_components(base,comp)
setlink(prev,base,next)
if not discfound then
@@ -612,7 +612,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou
set_components(base,copied)
replace = base
if forcediscretionaries then
- setdisc(discfound,pre,post,replace,discretionary_code)
+ setdisc(discfound,pre,post,replace,discretionarydisc_code)
else
setdisc(discfound,pre,post,replace)
end
@@ -3648,126 +3648,58 @@ end
-- to be checked, nowadays we probably can assume properly matched directions
-- so maybe we no longer need a stack
--- local function txtdirstate(start,stack,top,rlparmode)
--- local dir = getdir(start)
--- local new = 1
--- if dir == "+TRT" then
--- top = top + 1
--- stack[top] = dir
--- new = -1
--- elseif dir == "+TLT" then
--- top = top + 1
--- stack[top] = dir
--- elseif dir == "-TRT" or dir == "-TLT" then
--- if top == 1 then
--- top = 0
--- new = rlparmode
--- else
--- top = top - 1
--- if stack[top] == "+TRT" then
--- new = -1
--- end
--- end
--- else
--- new = rlparmode
--- end
--- return getnext(start), top, new
--- end
---
--- local function pardirstate(start)
--- local dir = getdir(start)
--- local new = 0
--- if dir == "TLT" then
--- new = 1
--- elseif dir == "TRT" then
--- new = -1
--- end
--- return getnext(start), new, new
--- end
+local txtdirstate, pardirstate do
-local function txtdirstate(start,stack,top,rlparmode)
- local nxt = getnext(start)
- local dir = getdir(start)
- if dir == "+TRT" then
- top = top + 1
- stack[top] = dir
- return nxt, top, -1
- elseif dir == "+TLT" then
- top = top + 1
- stack[top] = dir
- return nxt, top, 1
- elseif dir == "-TRT" or dir == "-TLT" then
- if top == 1 then
- return nxt, 0, rlparmode
- else
- top = top - 1
- if stack[top] == "+TRT" then
- return nxt, top, -1
+ local getdirection = nuts.getdirection
+ local lefttoright = 0
+ local rightoleft = 1
+
+ txtdirstate = function(start,stack,top,rlparmode)
+ local nxt = getnext(start)
+ local dir, pop = getdirection(start)
+ if pop then
+ if top == 1 then
+ return nxt, 0, rlparmode
else
- return nxt, top, 1
+ top = top - 1
+ if stack[top] == righttoleft then
+ return nxt, top, -1
+ else
+ return nxt, top, 1
+ end
end
+ elseif dir == lefttoright then
+ top = top + 1
+ stack[top] = 0
+ return nxt, top, 1
+ elseif dir == righttoleft then
+ top = top + 1
+ stack[top] = 1
+ return nxt, top, -1
+ else
+ return nxt, top, rlparmode
end
- else
- return nxt, top, rlparmode
end
-end
-local function pardirstate(start)
- local nxt = getnext(start)
- local dir = getdir(start)
- if dir == "TLT" then
- return nxt, 1, 1
- elseif dir == "TRT" then
- return nxt, -1, -1
- else
- return nxt, 0, 0
+ pardirstate = function(start)
+ local nxt = getnext(start)
+ local dir = getdirection(start)
+ if dir == lefttoright then
+ return nxt, 1, 1
+ end
+ if dir == righttoleft then
+ return nxt, -1, -1
+ -- for old times sake we we handle strings too
+ elseif dir == "TRT" then
+ return nxt, 1, 1
+ elseif dir == "TLT" then
+ return nxt, -1, -1
+ else
+ return nxt, 0, 0
+ end
end
-end
--- -- this will become:
---
--- local getdirection = nuts.getdirection
---
--- local function txtdirstate1(start,stack,top,rlparmode)
--- local nxt = getnext(start)
--- local dir, sub = getdirection(start)
--- if sub then
--- if top == 1 then
--- return nxt, 0, rlparmode
--- elseif dir < 2 then
--- top = top - 1
--- if stack[top] == 1 then
--- return nxt, top, -1
--- else
--- return nxt, top, 1
--- end
--- else
--- return nxt, top, rlparmode
--- end
--- elseif dir == 1 then
--- top = top + 1
--- stack[top] = 1
--- return nxt, top, -1
--- elseif dir == 0 then
--- top = top + 1
--- stack[top] = 0
--- return nxt, top, 1
--- else
--- return nxt, top, rlparmode
--- end
--- end
---
--- local function pardirstate1(start)
--- local nxt = getnext(start)
--- local dir = getdirection(start)
--- if dir == 0 then
--- return nxt, 1, 1
--- elseif dir == 1 then
--- return nxt, -1, -1
--- else
--- return nxt, 0, 0
--- end
--- end
+end
otf.helpers = otf.helpers or { }
otf.helpers.txtdirstate = txtdirstate
@@ -3875,8 +3807,7 @@ do
checkstep(head)
end
- local initialrl = direction == "TRT" and -1 or 0
- -- local initialrl = (direction == 1 or direction == "TRT") and -1 or 0
+ local initialrl = (direction == 1 or direction == "TRT") and -1 or 0
-- local done = false
local datasets = otfdataset(tfmdata,font,attr)
@@ -4165,8 +4096,7 @@ do
local done = false
local dirstack = { nil } -- could move outside function but we can have local runs (maybe a few more nils)
local start = head
- local initialrl = direction == "TRT" and -1 or 0
- -- local initialrl = (direction == 1 or direction == "TRT") and -1 or 0
+ local initialrl = (direction == 1 or direction == "TRT") and -1 or 0
local rlmode = initialrl
local rlparmode = initialrl
local topstack = 0
diff --git a/tex/context/base/mkiv/font-ott.lua b/tex/context/base/mkiv/font-ott.lua
index 6f8b85446..10420f6ee 100644
--- a/tex/context/base/mkiv/font-ott.lua
+++ b/tex/context/base/mkiv/font-ott.lua
@@ -1098,7 +1098,7 @@ storage.register("fonts/otf/usedfeatures", usedfeatures, "fonts.handlers.otf.sta
local normalizedaxis = otf.readers.helpers.normalizedaxis or function(s) return s end
-function otffeatures.normalize(features)
+function otffeatures.normalize(features,wrap) -- wrap is for context
if features then
local h = { }
for key, value in next, features do
@@ -1137,7 +1137,11 @@ function otffeatures.normalize(features)
-- value = sequenced(t,",")
-- end
-- end
- uv = lower(value)
+ if wrap and find(value,",") then
+ uv = "{"..lower(value).."}"
+ else
+ uv = lower(value)
+ end
else
uv = b
end
diff --git a/tex/context/base/mkiv/font-sol.lua b/tex/context/base/mkiv/font-sol.lua
index 85f5df8d5..b755a7ade 100644
--- a/tex/context/base/mkiv/font-sol.lua
+++ b/tex/context/base/mkiv/font-sol.lua
@@ -63,7 +63,7 @@ local getattr = nuts.getattr
local getfont = nuts.getfont
local getsubtype = nuts.getsubtype
local getlist = nuts.getlist
-local getdir = nuts.getdir
+local getdirection = nuts.getdirection
local getwidth = nuts.getwidth
local getdata = nuts.getdata
@@ -110,12 +110,12 @@ local whatsit_code = nodecodes.whatsit
local fontkern_code = kerncodes.fontkern
-local userdefined_code = whatsitcodes.userdefined
+local userdefinedwhatsit_code = whatsitcodes.userdefined
local nodepool = nuts.pool
local usernodeids = nodepool.userids
-local new_textdir = nodepool.textdir
+local new_direction = nodepool.direction
local new_usernumber = nodepool.usernumber
local new_glue = nodepool.glue
local new_leftskip = nodepool.leftskip
@@ -345,15 +345,14 @@ directives.register("builders.paragraphs.solutions.splitters.encapsulate", funct
encapsulate = v
end)
-function splitters.split(head)
- local current, rlmode, start, stop, attribute = head, false, nil, nil, 0
+function splitters.split(head) -- best also pass the direction
+ local current, r2l, start, stop, attribute = head, false, nil, nil, 0
cache, max_less, max_more = { }, 0, 0
local function flush() -- we can move this
local font = getfont(start)
local last = getnext(stop)
--- local list = last and copy_node_list(start,last) or copy_node_list(start)
local list = last and copy_node_list(start,stop) or copy_node_list(start)
- local n = #cache + 1
+ local n = #cache + 1
if encapsulate then
local user_one = new_usernumber(splitter_one,n)
local user_two = new_usernumber(splitter_two,n)
@@ -370,9 +369,8 @@ function splitters.split(head)
end
end
end
- local r2l = rlmode == "TRT" or rlmode == "+TRT"
if r2l then
- local dirnode = new_textdir("+TRT")
+ local dirnode = new_direction(righttoleft) -- brrr, we don't pop ... to be done (when used at all)
setlink(dirnode,list)
list = dirnode
end
@@ -421,11 +419,19 @@ function splitters.split(head)
else
start, stop = nil, nil
end
- elseif id == dir_code or id == localpar_code then
+ elseif id == dir_code then
+ -- not tested (to be done by idris when font is ready)
if start then
flush()
end
- rlmode = getdir(current)
+ local direction, pop = getdirection(current)
+ r2l = not pop and direction == righttoleft
+ elseif id == localpar_code then
+ if start then
+ flush() -- very unlikely as this starts a paragraph
+ end
+ local direction = getdirection(current)
+ r2l = direction == righttoleft or direction == "TRT" -- for old times sake
else
if start then
flush()
@@ -445,7 +451,7 @@ local function collect_words(list) -- can be made faster for attributes
local words, w, word = { }, 0, nil
if encapsulate then
for current, subtype in nextwhatsit, list do
- if subtype == userdefined_code then -- hm
+ if subtype == userdefinedwhatsit_code then -- hm
local user_id = getfield(current,"user_id")
if user_id == splitter_one then
word = { getdata(current), current, current }
@@ -752,17 +758,17 @@ function splitters.optimize(head)
end
for current in nexthlist, head do
line = line + 1
- local sign = getfield(current,"glue_sign")
- local dir = getdir(current)
- local width = getwidth(current)
- local list = getlist(current)
+ local sign = getfield(current,"glue_sign")
+ local direction = getdirection(current)
+ local width = getwidth(current)
+ local list = getlist(current)
if not encapsulate and getid(list) == glyph_code then
-- nasty .. we always assume a prev being there .. future luatex will always have a leftskip set
-- is this assignment ok ? .. needs checking
list = insert_node_before(list,list,new_leftskip(0)) -- new_glue(0)
setlist(current,list)
end
- local temp, badness = repack_hlist(list,width,'exactly',dir) -- it would be nice if the badness was stored in the node
+ local temp, badness = repack_hlist(list,width,"exactly",direction) -- it would be nice if the badness was stored in the node
if badness > 0 then
if sign == 0 then
if trace_optimize then
diff --git a/tex/context/base/mkiv/grph-rul.lua b/tex/context/base/mkiv/grph-rul.lua
index eb9c000b3..08edade1f 100644
--- a/tex/context/base/mkiv/grph-rul.lua
+++ b/tex/context/base/mkiv/grph-rul.lua
@@ -8,36 +8,38 @@ if not modules then modules = { } end modules ['grph-rul'] = {
local tonumber, next, type = tonumber, next, type
-local attributes = attributes
-local nodes = nodes
-local context = context
+local attributes = attributes
+local nodes = nodes
+local context = context
-local bpfactor = number.dimenfactors.bp
+local bpfactor = number.dimenfactors.bp
-local nuts = nodes.nuts
-local userrule = nuts.rules.userrule
-local outlinerule = nuts.pool.outlinerule
-local ruleactions = nuts.rules.ruleactions
+local nuts = nodes.nuts
+local userrule = nuts.rules.userrule
+local outlinerule = nuts.pool.outlinerule
+local ruleactions = nuts.rules.ruleactions
-local setattrlist = nuts.setattrlist
-local setattr = nuts.setattr
-local tonode = nuts.tonode
+local setattrlist = nuts.setattrlist
+local setattr = nuts.setattr
+local tonode = nuts.tonode
-local getattribute = tex.getattribute
+local getattribute = tex.getattribute
-local a_color = attributes.private('color')
-local a_transparency = attributes.private('transparency')
-local a_colormodel = attributes.private('colormodel')
+local lefttoright_code = nodes.dirvalues.lefttoright
-local mpcolor = attributes.colors.mpcolor
+local a_color = attributes.private('color')
+local a_transparency = attributes.private('transparency')
+local a_colormodel = attributes.private('colormodel')
-local trace_mp = false trackers.register("rules.mp", function(v) trace_mp = v end)
+local mpcolor = attributes.colors.mpcolor
-local report_mp = logs.reporter("rules","mp")
+local trace_mp = false trackers.register("rules.mp", function(v) trace_mp = v end)
-local floor = math.floor
-local getrandom = utilities.randomizer.get
-local formatters = string.formatters
+local report_mp = logs.reporter("rules","mp")
+
+local floor = math.floor
+local getrandom = utilities.randomizer.get
+local formatters = string.formatters
-- This is very pdf specific. Maybe move some to lpdf-rul.lua some day.
@@ -119,7 +121,7 @@ def RuleColor = %color% enddef ;
line = (p.line or 65536) * bpfactor,
color = mpcolor(p.ma,p.ca,p.ta),
option = p.option or "",
- direction = p.direction or "TLT",
+ direction = p.direction or lefttoright_code,
h = h * bpfactor,
v = v * bpfactor,
}
diff --git a/tex/context/base/mkiv/grph-trf.mkiv b/tex/context/base/mkiv/grph-trf.mkiv
index 454c54700..7b4b69b60 100644
--- a/tex/context/base/mkiv/grph-trf.mkiv
+++ b/tex/context/base/mkiv/grph-trf.mkiv
@@ -871,7 +871,7 @@
\egroup}
\def\grph_rotate_finish_indeed
- {\hbox\bgroup
+ {\hpack\bgroup
\ifx\p_rotation_rotation\empty
\grph_rotate_finish_nop
\else
diff --git a/tex/context/base/mkiv/l-macro.lua b/tex/context/base/mkiv/l-macro.lua
index a3a5bf4d9..24a3d07bc 100644
--- a/tex/context/base/mkiv/l-macro.lua
+++ b/tex/context/base/mkiv/l-macro.lua
@@ -19,8 +19,10 @@ local next, load, type = next, load, type
local newline = S("\n\r")^1
local continue = P("\\") * newline
+local whitespace = S(" \t\n\r")
local spaces = S(" \t") + continue
-local name = R("az","AZ","__","09")^1
+local nametoken = R("az","AZ","__","09")
+local name = nametoken^1
local body = ((continue/"" + 1) - newline)^1
local lparent = P("(")
local rparent = P(")")
@@ -53,7 +55,9 @@ end
-- todo: zero case
-resolve = C(C(name) * arguments^-1) / function(raw,s,a)
+local safeguard = P("local") * whitespace^1 * name * (whitespace + P("="))
+
+resolve = safeguard + C(C(name) * (arguments^-1)) / function(raw,s,a)
local d = definitions[s]
if d then
if a then
diff --git a/tex/context/base/mkiv/lang-dis.lua b/tex/context/base/mkiv/lang-dis.lua
index a45e87e9c..5baaecb87 100644
--- a/tex/context/base/mkiv/lang-dis.lua
+++ b/tex/context/base/mkiv/lang-dis.lua
@@ -50,10 +50,7 @@ local disccodes = nodes.disccodes
local disc_code = nodecodes.disc
local glyph_code = nodecodes.glyph
-local discretionary_code = disccodes.discretionary
-local explicit_code = disccodes.explicit
-local automatic_code = disccodes.automatic
-local regular_code = disccodes.regular
+local explicitdisc_code = disccodes.explicit
local a_visualize = attributes.private("visualizediscretionary")
local setattribute = tex.setattribute
@@ -222,6 +219,6 @@ function languages.explicithyphen(template)
end
end
end
- setdisc(disc,pre,post,nil,explicit_code,tex.exhyphenpenalty)
+ setdisc(disc,pre,post,nil,explicitdisc_code,tex.exhyphenpenalty)
return disc
end
diff --git a/tex/context/base/mkiv/lang-exp.lua b/tex/context/base/mkiv/lang-exp.lua
index e7543c4de..254961ee6 100644
--- a/tex/context/base/mkiv/lang-exp.lua
+++ b/tex/context/base/mkiv/lang-exp.lua
@@ -31,6 +31,8 @@ local expanders -- this will go away
if LUATEXVERSION < 1.005 then -- not loaded any more
+ -- some shortcuts go here
+
expanders = {
[discretionary_code] = function(d,template)
-- \discretionary
diff --git a/tex/context/base/mkiv/lang-hyp.lua b/tex/context/base/mkiv/lang-hyp.lua
index d01f8b581..15d4ca458 100644
--- a/tex/context/base/mkiv/lang-hyp.lua
+++ b/tex/context/base/mkiv/lang-hyp.lua
@@ -626,10 +626,8 @@ if context then
local math_code = nodecodes.math
local hlist_code = nodecodes.hlist
- local discretionary_code = disccodes.discretionary
- local explicit_code = disccodes.explicit
- local automatic_code = disccodes.automatic
- local regular_code = disccodes.regular
+ local automaticdisc_code = disccodes.automatic
+ local regulardisc_code = disccodes.regular
local nuts = nodes.nuts
local tonode = nodes.tonode
@@ -1288,7 +1286,7 @@ featureset.hyphenonly = hyphenonly == v_yes
if leftchar then
post = serialize(true,leftchar)
end
- setdisc(disc,pre,post,nil,regular_code,hyphenpenalty)
+ setdisc(disc,pre,post,nil,regulardisc_code,hyphenpenalty)
if attrnode then
setattrlist(disc,attrnode)
end
@@ -1323,7 +1321,7 @@ featureset.hyphenonly = hyphenonly == v_yes
end
end
-- maybe regular code
- setdisc(disc,pre,post,replace,regular_code,hyphenpenalty)
+ setdisc(disc,pre,post,replace,regulardisc_code,hyphenpenalty)
if attrnode then
setattrlist(disc,attrnode)
end
@@ -1363,7 +1361,7 @@ featureset.hyphenonly = hyphenonly == v_yes
end
pre = copy_node(glyph)
setchar(pre,rightchar and rightchar > 0 and rightchar or code)
- setdisc(disc,pre,post,replace,automatic_code,hyphenpenalty) -- ex ?
+ setdisc(disc,pre,post,replace,automaticdisc_code,hyphenpenalty) -- ex ?
if attrnode then
setattrlist(disc,attrnode)
end
@@ -1385,7 +1383,7 @@ featureset.hyphenonly = hyphenonly == v_yes
local pre = copy_list(start)
local post = nil
local replace = start
- setdisc(disc,pre,post,replace,automatic_code,hyphenpenalty) -- ex ?
+ setdisc(disc,pre,post,replace,automaticdisc_code,hyphenpenalty) -- ex ?
if attrnode then
setattrlist(disc,attrnode)
end
diff --git a/tex/context/base/mkiv/lpdf-epd.lua b/tex/context/base/mkiv/lpdf-epd.lua
index fe94a430b..86aa6f294 100644
--- a/tex/context/base/mkiv/lpdf-epd.lua
+++ b/tex/context/base/mkiv/lpdf-epd.lua
@@ -146,9 +146,7 @@ end
-- we're done with library shortcuts
-local report_epdf = logs.reporter("epdf")
-
-local typenames = { [0] =
+local typenames = { [0] =
"boolean",
"integer",
"real",
@@ -166,10 +164,12 @@ local typenames = { [0] =
"integer64",
}
-local typenumbers = table.swapped(typenames)
+local typenumbers = table.swapped(typenames)
+
+local null_object_code = typenumbers.null
+local ref_object_code = typenumbers.ref
-local null_code = typenumbers.null
-local ref_code = typenumbers.ref
+local report_epdf = logs.reporter("epdf")
local function fatal_error(...)
report_epdf(...)
@@ -242,11 +242,11 @@ local function prepare(document,d,t,n,k,mt,flags)
if v then
local r = dictGetValNF(d,i)
local kind = getType(v)
- if kind == null_code then
+ if kind == null_object_code then
-- ignore
elseif kind then
local key = dictGetKey(d,i)
- if r and getType(r) == ref_code then
+ if r and getType(r) == ref_object_code then
local objnum = getRefNum(r)
local cached = document.__cache__[objnum]
if not cached then
@@ -285,7 +285,7 @@ end
-- if v then
-- local key = dictGetKey(d,i)
-- local kind = getType(v)
--- if kind == ref_code then
+-- if kind == ref_object_code then
-- local objnum = getRefNum(v)
-- local cached = document.__cache__[objnum]
-- if not cached then
@@ -363,11 +363,11 @@ local function prepare(document,a,t,n,k)
local v = arrayGet(a,i)
if v then
local kind = getType(v)
- if kind == null_code then
+ if kind == null_object_code then
-- ignore
elseif kind then
local r = arrayGetNF(a,i)
- if r and getType(r) == ref_code then
+ if r and getType(r) == ref_object_code then
local objnum = getRefNum(r)
local cached = document.__cache__[objnum]
if not cached then
@@ -401,7 +401,7 @@ end
-- local v = arrayGetNF(a,i)
-- if v then
-- local kind = getType(v)
--- if kind == ref_code then
+-- if kind == ref_object_code then
-- local objnum = getRefNum(v)
-- local cached = document.__cache__[objnum]
-- if not cached then
@@ -1073,46 +1073,46 @@ end
if img then do
- local copydictionary = nil
- local copyarray = nil
-
- local ref_code = typenumbers.ref
- local boolean_code = typenumbers.boolean
- local integer_code = typenumbers.integer
- local real_code = typenumbers.real
- local string_code = typenumbers.string
- local name_code = typenumbers.name
- local null_code = typenumbers.null
- local array_code = typenumbers.array
- local dictionary_code = typenumbers.dictionary
- local stream_code = typenumbers.stream
- local cmd_code = typenumbers.cmd
-
- local pdfreserveobject = lpdf.reserveobject
- local pdfflushobject = lpdf.flushobject
- local pdfflushstreamobject = lpdf.flushstreamobject
- local pdfreference = lpdf.reference
- local pdfconstant = lpdf.constant
- local pdfarray = lpdf.array
- local pdfdictionary = lpdf.dictionary
- local pdfunicode = lpdf.unicode
- local pdfstring = lpdf.string
- local pdfnull = lpdf.null
-
- local report = logs.reporter("backend","xobjects")
-
- local factor = 65536 / (7200/7227) -- 1/number.dimenfactors.bp
-
- local createimage = images.create
+ local copydictionary = nil
+ local copyarray = nil
+
+ local ref_object_code = typenumbers.ref
+ local boolean_object_code = typenumbers.boolean
+ local integer_object_code = typenumbers.integer
+ local real_object_code = typenumbers.real
+ local string_object_code = typenumbers.string
+ local name_object_code = typenumbers.name
+ local null_object_code = typenumbers.null
+ local array_object_code = typenumbers.array
+ local dictionary_object_code = typenumbers.dictionary
+ local stream_object_code = typenumbers.stream
+ local cmd_object_code = typenumbers.cmd
+
+ local pdfreserveobject = lpdf.reserveobject
+ local pdfflushobject = lpdf.flushobject
+ local pdfflushstreamobject = lpdf.flushstreamobject
+ local pdfreference = lpdf.reference
+ local pdfconstant = lpdf.constant
+ local pdfarray = lpdf.array
+ local pdfdictionary = lpdf.dictionary
+ local pdfunicode = lpdf.unicode
+ local pdfstring = lpdf.string
+ local pdfnull = lpdf.null
+
+ local report = logs.reporter("backend","xobjects")
+
+ local factor = 65536 / (7200/7227) -- 1/number.dimenfactors.bp
+
+ local createimage = images.create
local function scaledbbox(b)
return { b[1]*factor, b[2]*factor, b[3]*factor, b[4]*factor }
end
local function copyobject(xref,copied,kind,r,v)
- if kind == null_code then
+ if kind == null_object_code then
return pdfnull()
- elseif r and getType(r) == ref_code then
+ elseif r and getType(r) == ref_object_code then
local objnum = getRefNum(r)
local r = copied[objnum]
if r then
@@ -1121,13 +1121,13 @@ if img then do
local o
r = pdfreserveobject()
copied[objnum] = r
- if kind == array_code then
+ if kind == array_object_code then
local a = copyarray(xref,copied,fetch(xref,objnum,0))
pdfflushobject(r,tostring(a))
- elseif kind == dictionary_code then
+ elseif kind == dictionary_object_code then
local d = copydictionary(xref,copied,fetch(xref,objnum,0))
pdfflushobject(r,tostring(d))
- elseif kind == stream_code then
+ elseif kind == stream_object_code then
local f = fetch(xref,objnum,0)
local d = copydictionary(xref,copied,false,streamGetDict(f))
local s = getstream(f)
@@ -1143,17 +1143,17 @@ if img then do
end
end
return pdfreference(r)
- elseif kind == array_code then
+ elseif kind == array_object_code then
return copyarray(xref,copied,v)
- elseif kind == dictionary_code then
+ elseif kind == dictionary_object_code then
return copydictionary(xref,copied,v)
- elseif kind == integer_code then
+ elseif kind == integer_object_code then
return getInt(v)
- elseif kind == real_code then
+ elseif kind == real_object_code then
return getReal(v)
- elseif kind == name_code then
+ elseif kind == name_object_code then
return pdfconstant(getName(v))
- elseif kind == string_code then
+ elseif kind == string_object_code then
local s = getString(v)
if not s or s == "" then
return ""
@@ -1163,9 +1163,9 @@ if img then do
return pdfunicode(s)
end
return pdfstring(s)
- elseif kind == boolean_code then
+ elseif kind == boolean_object_code then
return getBool(v)
- elseif kind == stream_code then
+ elseif kind == stream_object_code then
-- hm ...
return getStream(v)
else
diff --git a/tex/context/base/mkiv/lpdf-nod.lua b/tex/context/base/mkiv/lpdf-nod.lua
index 289567c5d..05736a79f 100644
--- a/tex/context/base/mkiv/lpdf-nod.lua
+++ b/tex/context/base/mkiv/lpdf-nod.lua
@@ -8,38 +8,37 @@ if not modules then modules = { } end modules ['lpdf-nod'] = {
local type = type
-local formatters = string.formatters
+local formatters = string.formatters
-local nodecodes = nodes.nodecodes
-local whatsit_code = nodecodes.whatsit
-local whatsitcodes = nodes.whatsitcodes
-local latelua_code = whatsitcodes.latelua
-local literal_code = whatsitcodes.literal
+local nodecodes = nodes.nodecodes
+local whatsitcodes = nodes.whatsitcodes
-local nodeinjections = backends.nodeinjections
+local nodeinjections = backends.nodeinjections
-local nuts = nodes.nuts
-local tonut = nuts.tonut
+local nuts = nodes.nuts
+local tonut = nuts.tonut
-local setfield = nuts.setfield
-local setdata = nuts.setdata
+local setfield = nuts.setfield
+local setdata = nuts.setdata
-local copy_node = nuts.copy
-local new_node = nuts.new
+local copy_node = nuts.copy
+local new_node = nuts.new
-local nodepool = nuts.pool
-local register = nodepool.register
+local nodepool = nuts.pool
+local register = nodepool.register
-local literalvalues = nodes.literalvalues
-local originliteral = literalvalues.origin
-local pageliteral = literalvalues.page
-local directliteral = literalvalues.direct
-local rawliteral = literalvalues.raw
+local whatsit_code = nodecodes.whatsit
-local literalcode = whatsitcodes.literal
-local savecode = whatsitcodes.save
-local restorecode = whatsitcodes.restore
-local setmatrixcode = whatsitcodes.setmatrix
+local savewhatsit_code = whatsitcodes.save
+local restorewhatsit_code = whatsitcodes.restore
+local setmatrixwhatsit_code = whatsitcodes.setmatrix
+local literalwhatsit_code = whatsitcodes.literal
+
+local literalvalues = nodes.literalvalues
+local originliteral_code = literalvalues.origin
+local pageliteral_code = literalvalues.page
+local directliteral_code = literalvalues.direct
+local rawliteral_code = literalvalues.raw
local s_matrix_0 = "1 0 0 1"
local f_matrix_2 = formatters["%.6F 0 0 %.6F"]
@@ -82,14 +81,14 @@ local function tomatrix(rx,sx,sy,ry,tx,ty) -- todo: tx ty
end
end
-local pdforiginliteral = register(new_node(whatsit_code, literalcode)) setfield(pdforiginliteral,"mode",originliteral)
-local pdfpageliteral = register(new_node(whatsit_code, literalcode)) setfield(pdfpageliteral, "mode",pageliteral)
-local pdfdirectliteral = register(new_node(whatsit_code, literalcode)) setfield(pdfdirectliteral,"mode",directliteral)
-local pdfrawliteral = register(new_node(whatsit_code, literalcode)) setfield(pdfrawliteral, "mode",rawliteral)
+local pdforiginliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdforiginliteral,"mode",originliteral_code)
+local pdfpageliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdfpageliteral, "mode",pageliteral_code)
+local pdfdirectliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdfdirectliteral,"mode",directliteral_code)
+local pdfrawliteral = register(new_node(whatsit_code, literalwhatsit_code)) setfield(pdfrawliteral, "mode",rawliteral_code)
-local pdfsave = register(new_node(whatsit_code, savecode))
-local pdfrestore = register(new_node(whatsit_code, restorecode))
-local pdfsetmatrix = register(new_node(whatsit_code, setmatrixcode))
+local pdfsave = register(new_node(whatsit_code, savewhatsit_code))
+local pdfrestore = register(new_node(whatsit_code, restorewhatsit_code))
+local pdfsetmatrix = register(new_node(whatsit_code, setmatrixwhatsit_code))
function nodepool.pdforiginliteral(str) local t = copy_node(pdforiginliteral) setdata(t,str) return t end
function nodepool.pdfpageliteral (str) local t = copy_node(pdfpageliteral ) setdata(t,str) return t end
@@ -98,15 +97,15 @@ function nodepool.pdfrawliteral (str) local t = copy_node(pdfrawliteral ) se
local pdfliterals = {
-- by number
- [originliteral] = pdforiginliteral,
- [pageliteral] = pdfpageliteral,
- [directliteral] = pdfdirectliteral,
- [rawliteral] = pdfrawliteral,
+ [originliteral_code] = pdforiginliteral,
+ [pageliteral_code] = pdfpageliteral,
+ [directliteral_code] = pdfdirectliteral,
+ [rawliteral_code] = pdfrawliteral,
-- by name
- [literalvalues[originliteral]] = pdforiginliteral,
- [literalvalues[pageliteral]] = pdfpageliteral,
- [literalvalues[directliteral]] = pdfdirectliteral,
- [literalvalues[rawliteral]] = pdfrawliteral,
+ [literalvalues[originliteral_code]] = pdforiginliteral,
+ [literalvalues[pageliteral_code]] = pdfpageliteral,
+ [literalvalues[directliteral_code]] = pdfdirectliteral,
+ [literalvalues[rawliteral_code]] = pdfrawliteral,
}
function nodepool.pdfliteral(mode,str)
diff --git a/tex/context/base/mkiv/lpdf-pde.lua b/tex/context/base/mkiv/lpdf-pde.lua
index 8d8d8f280..9d14f8f5e 100644
--- a/tex/context/base/mkiv/lpdf-pde.lua
+++ b/tex/context/base/mkiv/lpdf-pde.lua
@@ -92,18 +92,18 @@ local allocate = utilities.storage.allocate
local bpfactor = number.dimenfactors.bp
-local objectcodes = {
- [0] = "none",
- "null",
- "bool",
- "integer",
- "number",
- "name",
- "string",
- "array",
- "dictionary",
- "stream",
- "reference",
+local objectcodes = { [0] =
+ "none",
+ "null",
+ "bool",
+ "integer",
+ "number",
+ "name",
+ "string",
+ "array",
+ "dictionary",
+ "stream",
+ "reference",
}
local encryptioncodes = {
@@ -113,26 +113,26 @@ local encryptioncodes = {
[-2] = "failure",
}
-objectcodes = allocate(swapped(objectcodes,objectcodes))
-encryptioncodes = allocate(swapped(encryptioncodes,encryptioncodes))
+objectcodes = allocate(swapped(objectcodes,objectcodes))
+encryptioncodes = allocate(swapped(encryptioncodes,encryptioncodes))
-pdfe.objectcodes = objectcodes
-pdfe.encryptioncodes = encryptioncodes
+pdfe.objectcodes = objectcodes
+pdfe.encryptioncodes = encryptioncodes
-local null_code = objectcodes.null
-local reference_code = objectcodes.reference
+local null_object_code = objectcodes.null
+local reference_object_code = objectcodes.reference
-local none_code = objectcodes.none
-local null_code = objectcodes.null
-local bool_code = objectcodes.bool
-local integer_code = objectcodes.integer
-local number_code = objectcodes.number
-local name_code = objectcodes.name
-local string_code = objectcodes.string
-local array_code = objectcodes.array
-local dictionary_code = objectcodes.dictionary
-local stream_code = objectcodes.stream
-local reference_code = objectcodes.reference
+local none_object_code = objectcodes.none
+local null_object_code = objectcodes.null
+local bool_object_code = objectcodes.bool
+local integer_object_code = objectcodes.integer
+local number_object_code = objectcodes.number
+local name_object_code = objectcodes.name
+local string_object_code = objectcodes.string
+local array_object_code = objectcodes.array
+local dictionary_object_code = objectcodes.dictionary
+local stream_object_code = objectcodes.stream
+local reference_object_code = objectcodes.reference
local checked_access
local get_flagged -- from pdfe -> lpdf
@@ -209,17 +209,17 @@ local function get_value(document,t,key)
end
-- we can assume names to be simple and strings to be tables
local kind = value[1]
- if kind == name_code then
+ if kind == name_object_code then
return value[2]
- elseif kind == string_code then
+ elseif kind == string_object_code then
return some_string(value[2],value[3])
- elseif kind == array_code then
+ elseif kind == array_object_code then
return some_array(value[2],document)
- elseif kind == dictionary_code then
+ elseif kind == dictionary_object_code then
return some_dictionary(value[2],document)
- elseif kind == stream_code then
+ elseif kind == stream_object_code then
return some_stream(value,document)
- elseif kind == reference_code then
+ elseif kind == reference_object_code then
return some_reference(value,document)
end
return value
@@ -227,7 +227,7 @@ end
some_dictionary = function (d,document)
local f = dictionarytotable(d,true)
- local t = setmetatable({ __raw__ = f, __type__ = dictionary_code }, {
+ local t = setmetatable({ __raw__ = f, __type__ = dictionary_object_code }, {
__index = function(t,k)
return get_value(document,f,k)
end,
@@ -241,7 +241,7 @@ end
some_array = function (a,document)
local f = arraytotable(a,true)
local n = #f
- local t = setmetatable({ __raw__ = f, __type__ = array_code, n = n }, {
+ local t = setmetatable({ __raw__ = f, __type__ = array_object_code, n = n }, {
__index = function(t,k)
return get_value(document,f,k)
end,
@@ -257,7 +257,7 @@ end
some_stream = function(s,d,document)
local f = dictionarytotable(d,true)
- local t = setmetatable({ __raw__ = f, __type__ = stream_code }, {
+ local t = setmetatable({ __raw__ = f, __type__ = stream_object_code }, {
__index = function(t,k)
return get_value(document,f,k)
end,
@@ -277,11 +277,11 @@ some_reference = function(r,document)
local cached = document.__cache__[objnum]
if not cached then
local kind, object, b, c = getfromreference(r[2])
- if kind == dictionary_code then
+ if kind == dictionary_object_code then
cached = some_dictionary(object,document)
- elseif kind == array_code then
+ elseif kind == array_object_code then
cached = some_array(object,document)
- elseif kind == stream_code then
+ elseif kind == stream_object_code then
cached = some_stream(object,b,document)
else
cached = { kind, object, b, c }
@@ -848,13 +848,13 @@ if img then do
copied[objnum] = usednum
local entry = value
local kind = entry.__type__
- if kind == array_code then
+ if kind == array_object_code then
local a = copyarray(xref,copied,entry)
pdfflushobject(usednum,tostring(a))
- elseif kind == dictionary_code then
+ elseif kind == dictionary_object_code then
local d = copydictionary(xref,copied,entry)
pdfflushobject(usednum,tostring(d))
- elseif kind == stream_code then
+ elseif kind == stream_object_code then
local d = copydictionary(xref,copied,entry)
local filter = d.Filter
if filter and codecs[filter] and recompress then
@@ -879,13 +879,13 @@ if img then do
elseif t == "table" then
local kind = value[1]
local entry = value[2]
- if kind == name_code then
+ if kind == name_object_code then
value = pdfconstant(entry)
- elseif kind == string_code then
+ elseif kind == string_object_code then
value = pdfliteral(entry,value[3])
- elseif kind == null_code then
+ elseif kind == null_object_code then
value = pdfnull()
- elseif kind == reference_code then
+ elseif kind == reference_object_code then
value = deepcopyobject(xref,copied,entry)
else
value = tostring(entry)
@@ -895,7 +895,7 @@ if img then do
end
end
return pdfreference(usednum)
- elseif kind == stream_code then
+ elseif kind == stream_object_code then
report("stream not done: %s", objectcodes[kind] or "?")
else
report("object not done: %s", objectcodes[kind] or "?")
@@ -913,17 +913,17 @@ if img then do
return value
end
local kind = value[1]
- if kind == name_code then
+ if kind == name_object_code then
return pdfconstant(value[2])
- elseif kind == string_code then
+ elseif kind == string_object_code then
return pdfliteral(value[2],value[3])
- elseif kind == array_code then
+ elseif kind == array_object_code then
return copyarray(xref,copied,object[key])
- elseif kind == dictionary_code then
+ elseif kind == dictionary_object_code then
return copydictionary(xref,copied,object[key])
- elseif kind == null_code then
+ elseif kind == null_object_code then
return pdfnull()
- elseif kind == reference_code then
+ elseif kind == reference_object_code then
-- expand
return deepcopyobject(xref,copied,object[key])
else
@@ -982,7 +982,7 @@ if img then do
--
-- if not Resources then
-- local Parent = page.Parent
- -- while (Parent and (Parent.__type__ == dictionary_code or Parent.__type__ == reference_code) do
+ -- while (Parent and (Parent.__type__ == dictionary_object_code or Parent.__type__ == reference_object_code) do
-- Resources = Parent.Resources
-- if Resources then
-- break
@@ -1064,7 +1064,7 @@ if img then do
local ctype = contents.__type__
-- we always recompress because image object streams can not be
-- influenced (yet)
- if ctype == stream_code then
+ if ctype == stream_object_code then
if stripmarked then
content = contents() -- uncompressed
local stripped = lpdf_epdf.stripcontent(content)
@@ -1086,7 +1086,7 @@ if img then do
content = contents() -- uncompressed
end
end
- elseif ctype == array_code then
+ elseif ctype == array_object_code then
content = { }
for i=1,#contents do
content[i] = contents[i]() -- uncompressed
diff --git a/tex/context/base/mkiv/math-dir.lua b/tex/context/base/mkiv/math-dir.lua
index 0543937f5..38aa44358 100644
--- a/tex/context/base/mkiv/math-dir.lua
+++ b/tex/context/base/mkiv/math-dir.lua
@@ -48,7 +48,9 @@ local vlist_code = nodecodes.vlist
local nodepool = nuts.pool
-local new_textdir = nodepool.textdir
+local new_direction = nodepool.direction
+
+local lefttoright_code = nodes.dirvalues.lefttoright
local chardirections = characters.directions
local charmirrors = characters.mirrors
@@ -63,8 +65,8 @@ local function processmath(head)
local start = nil
local stop = nil
local function capsulate()
- head = insert_node_before(head,start,new_textdir("+TLT"))
- insert_node_after(head,stop,new_textdir("-TLT"))
+ head = insert_node_before(head,start,new_direction(lefttoright_code))
+ insert_node_after(head,stop,new_direction(lefttoright_code,true))
if trace_directions then
report_directions("reversed: %s",nodes.listtoutf(start,false,false,stop))
end
diff --git a/tex/context/base/mkiv/math-noa.lua b/tex/context/base/mkiv/math-noa.lua
index 8d59b474b..7da84980e 100644
--- a/tex/context/base/mkiv/math-noa.lua
+++ b/tex/context/base/mkiv/math-noa.lua
@@ -19,7 +19,7 @@ if not modules then modules = { } end modules ['math-noa'] = {
-- 20D6 -> 2190
-- 20D7 -> 2192
--- todo: most is math_char so we can have simple dedicated loops
+-- todo: most is mathchar_code so we can have simple dedicated loops
-- nota bene: uunderdelimiter uoverdelimiter etc are radicals (we have 5 types)
@@ -31,184 +31,184 @@ local insert, remove = table.insert, table.remove
local div = math.div
local bor, band = bit32.bor, bit32.band
-local fonts = fonts
-local nodes = nodes
-local node = node
-local mathematics = mathematics
-local context = context
-
-local otf = fonts.handlers.otf
-local otffeatures = fonts.constructors.features.otf
-local registerotffeature = otffeatures.register
-
-local privateattribute = attributes.private
-local registertracker = trackers.register
-local registerdirective = directives.register
-local logreporter = logs.reporter
-local setmetatableindex = table.setmetatableindex
-
-local colortracers = nodes.tracers.colors
-
-local trace_remapping = false registertracker("math.remapping", function(v) trace_remapping = v end)
-local trace_processing = false registertracker("math.processing", function(v) trace_processing = v end)
-local trace_analyzing = false registertracker("math.analyzing", function(v) trace_analyzing = v end)
-local trace_normalizing = false registertracker("math.normalizing", function(v) trace_normalizing = v end)
-local trace_collapsing = false registertracker("math.collapsing", function(v) trace_collapsing = v end)
-local trace_fixing = false registertracker("math.fixing", function(v) trace_foxing = v end)
-local trace_patching = false registertracker("math.patching", function(v) trace_patching = v end)
-local trace_goodies = false registertracker("math.goodies", function(v) trace_goodies = v end)
-local trace_variants = false registertracker("math.variants", function(v) trace_variants = v end)
-local trace_alternates = false registertracker("math.alternates", function(v) trace_alternates = v end)
-local trace_italics = false registertracker("math.italics", function(v) trace_italics = v end)
-local trace_kernpairs = false registertracker("math.kernpairs", function(v) trace_kernpairs = v end)
-local trace_domains = false registertracker("math.domains", function(v) trace_domains = v end)
-local trace_families = false registertracker("math.families", function(v) trace_families = v end)
-local trace_fences = false registertracker("math.fences", function(v) trace_fences = v end)
-local trace_unstacking = false registertracker("math.unstack", function(v) trace_unstacking = v end)
-
-local check_coverage = true registerdirective("math.checkcoverage", function(v) check_coverage = v end)
-
-local report_processing = logreporter("mathematics","processing")
-local report_remapping = logreporter("mathematics","remapping")
-local report_normalizing = logreporter("mathematics","normalizing")
-local report_collapsing = logreporter("mathematics","collapsing")
-local report_fixing = logreporter("mathematics","fixing")
-local report_patching = logreporter("mathematics","patching")
-local report_goodies = logreporter("mathematics","goodies")
-local report_variants = logreporter("mathematics","variants")
-local report_alternates = logreporter("mathematics","alternates")
-local report_italics = logreporter("mathematics","italics")
-local report_kernpairs = logreporter("mathematics","kernpairs")
-local report_domains = logreporter("mathematics","domains")
-local report_families = logreporter("mathematics","families")
-local report_fences = logreporter("mathematics","fences")
-local report_unstacking = logreporter("mathematics","unstack")
-
-local a_mathrendering = privateattribute("mathrendering")
-local a_exportstatus = privateattribute("exportstatus")
-
-local nuts = nodes.nuts
-local nodepool = nuts.pool
-local tonut = nuts.tonut
-local nutstring = nuts.tostring
-
-local setfield = nuts.setfield
-local setlink = nuts.setlink
-local setlist = nuts.setlist
-local setnext = nuts.setnext
-local setprev = nuts.setprev
-local setchar = nuts.setchar
-local setfam = nuts.setfam
-local setsubtype = nuts.setsubtype
-local setattr = nuts.setattr
-local setattrlist = nuts.setattrlist
-local setwidth = nuts.setwidth
-local setheight = nuts.setheight
-local setdepth = nuts.setdepth
-
-local getfield = nuts.getfield
-local getnext = nuts.getnext
-local getprev = nuts.getprev
-local getboth = nuts.getboth
-local getid = nuts.getid
-local getsubtype = nuts.getsubtype
-local getchar = nuts.getchar
-local getfont = nuts.getfont
-local getfam = nuts.getfam
-local getattr = nuts.getattr
-local getlist = nuts.getlist
-local getwidth = nuts.getwidth
-local getheight = nuts.getheight
-local getdepth = nuts.getdepth
-
-local getnucleus = nuts.getnucleus
-local getsub = nuts.getsub
-local getsup = nuts.getsup
-
-local setnucleus = nuts.setnucleus
-local setsub = nuts.setsub
-local setsup = nuts.setsup
-
-local flush_node = nuts.flush
-local copy_node = nuts.copy
-local slide_nodes = nuts.slide
-local set_visual = nuts.setvisual
-
-local mlist_to_hlist = nodes.mlist_to_hlist
-
-local font_of_family = node.family_font
-
-local new_kern = nodepool.kern
-local new_submlist = nodepool.submlist
-local new_noad = nodepool.noad
-local new_delimiter = nodepool.delimiter
-local new_fence = nodepool.fence
-
-local fonthashes = fonts.hashes
-local fontdata = fonthashes.identifiers
-local fontcharacters = fonthashes.characters
-local fontitalics = fonthashes.italics
-
-local variables = interfaces.variables
-local texsetattribute = tex.setattribute
-local texgetattribute = tex.getattribute
-local unsetvalue = attributes.unsetvalue
-local implement = interfaces.implement
-
-local v_reset = variables.reset
-
-local chardata = characters.data
-
-noads = noads or { } -- todo: only here
-local noads = noads
-
-noads.processors = noads.processors or { }
-local processors = noads.processors
-
-noads.handlers = noads.handlers or { }
-local handlers = noads.handlers
-
-local tasks = nodes.tasks
-local enableaction = tasks.enableaction
-local setaction = tasks.setaction
-
-local nodecodes = nodes.nodecodes
-local noadcodes = nodes.noadcodes
-local fencecodes = nodes.fencecodes
-
-local noad_ord = noadcodes.ord
-local noad_rel = noadcodes.rel
-local noad_bin = noadcodes.bin
-local noad_open = noadcodes.open
-local noad_close = noadcodes.close
-local noad_punct = noadcodes.punct
-local noad_opdisplaylimits = noadcodes.opdisplaylimits
-local noad_oplimits = noadcodes.oplimits
-local noad_opnolimits = noadcodes.opnolimits
-local noad_inner = noadcodes.inner
-
-local math_noad = nodecodes.noad -- attr nucleus sub sup
-local math_accent = nodecodes.accent -- attr nucleus sub sup accent
-local math_radical = nodecodes.radical -- attr nucleus sub sup left degree
-local math_fraction = nodecodes.fraction -- attr nucleus sub sup left right
-local math_subbox = nodecodes.subbox -- attr list
-local math_submlist = nodecodes.submlist -- attr list
-local math_char = nodecodes.mathchar -- attr fam char
-local math_textchar = nodecodes.mathtextchar -- attr fam char
-local math_delim = nodecodes.delim -- attr small_fam small_char large_fam large_char
------ math_style = nodecodes.style -- attr style
-local math_choice = nodecodes.choice -- attr display text script scriptscript
-local math_fence = nodecodes.fence -- attr subtype
-
-local left_fence_code = fencecodes.left
-local middle_fence_code = fencecodes.middle
-local right_fence_code = fencecodes.right
+local fonts = fonts
+local nodes = nodes
+local node = node
+local mathematics = mathematics
+local context = context
+
+local otf = fonts.handlers.otf
+local otffeatures = fonts.constructors.features.otf
+local registerotffeature = otffeatures.register
+
+local privateattribute = attributes.private
+local registertracker = trackers.register
+local registerdirective = directives.register
+local logreporter = logs.reporter
+local setmetatableindex = table.setmetatableindex
+
+local colortracers = nodes.tracers.colors
+
+local trace_remapping = false registertracker("math.remapping", function(v) trace_remapping = v end)
+local trace_processing = false registertracker("math.processing", function(v) trace_processing = v end)
+local trace_analyzing = false registertracker("math.analyzing", function(v) trace_analyzing = v end)
+local trace_normalizing = false registertracker("math.normalizing", function(v) trace_normalizing = v end)
+local trace_collapsing = false registertracker("math.collapsing", function(v) trace_collapsing = v end)
+local trace_fixing = false registertracker("math.fixing", function(v) trace_foxing = v end)
+local trace_patching = false registertracker("math.patching", function(v) trace_patching = v end)
+local trace_goodies = false registertracker("math.goodies", function(v) trace_goodies = v end)
+local trace_variants = false registertracker("math.variants", function(v) trace_variants = v end)
+local trace_alternates = false registertracker("math.alternates", function(v) trace_alternates = v end)
+local trace_italics = false registertracker("math.italics", function(v) trace_italics = v end)
+local trace_kernpairs = false registertracker("math.kernpairs", function(v) trace_kernpairs = v end)
+local trace_domains = false registertracker("math.domains", function(v) trace_domains = v end)
+local trace_families = false registertracker("math.families", function(v) trace_families = v end)
+local trace_fences = false registertracker("math.fences", function(v) trace_fences = v end)
+local trace_unstacking = false registertracker("math.unstack", function(v) trace_unstacking = v end)
+
+local check_coverage = true registerdirective("math.checkcoverage", function(v) check_coverage = v end)
+
+local report_processing = logreporter("mathematics","processing")
+local report_remapping = logreporter("mathematics","remapping")
+local report_normalizing = logreporter("mathematics","normalizing")
+local report_collapsing = logreporter("mathematics","collapsing")
+local report_fixing = logreporter("mathematics","fixing")
+local report_patching = logreporter("mathematics","patching")
+local report_goodies = logreporter("mathematics","goodies")
+local report_variants = logreporter("mathematics","variants")
+local report_alternates = logreporter("mathematics","alternates")
+local report_italics = logreporter("mathematics","italics")
+local report_kernpairs = logreporter("mathematics","kernpairs")
+local report_domains = logreporter("mathematics","domains")
+local report_families = logreporter("mathematics","families")
+local report_fences = logreporter("mathematics","fences")
+local report_unstacking = logreporter("mathematics","unstack")
+
+local a_mathrendering = privateattribute("mathrendering")
+local a_exportstatus = privateattribute("exportstatus")
+
+local nuts = nodes.nuts
+local nodepool = nuts.pool
+local tonut = nuts.tonut
+local nutstring = nuts.tostring
+
+local setfield = nuts.setfield
+local setlink = nuts.setlink
+local setlist = nuts.setlist
+local setnext = nuts.setnext
+local setprev = nuts.setprev
+local setchar = nuts.setchar
+local setfam = nuts.setfam
+local setsubtype = nuts.setsubtype
+local setattr = nuts.setattr
+local setattrlist = nuts.setattrlist
+local setwidth = nuts.setwidth
+local setheight = nuts.setheight
+local setdepth = nuts.setdepth
+
+local getfield = nuts.getfield
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getboth = nuts.getboth
+local getid = nuts.getid
+local getsubtype = nuts.getsubtype
+local getchar = nuts.getchar
+local getfont = nuts.getfont
+local getfam = nuts.getfam
+local getattr = nuts.getattr
+local getlist = nuts.getlist
+local getwidth = nuts.getwidth
+local getheight = nuts.getheight
+local getdepth = nuts.getdepth
+
+local getnucleus = nuts.getnucleus
+local getsub = nuts.getsub
+local getsup = nuts.getsup
+
+local setnucleus = nuts.setnucleus
+local setsub = nuts.setsub
+local setsup = nuts.setsup
+
+local flush_node = nuts.flush
+local copy_node = nuts.copy
+local slide_nodes = nuts.slide
+local set_visual = nuts.setvisual
+
+local mlist_to_hlist = nodes.mlist_to_hlist
+
+local font_of_family = node.family_font
+
+local new_kern = nodepool.kern
+local new_submlist = nodepool.submlist
+local new_noad = nodepool.noad
+local new_delimiter = nodepool.delimiter
+local new_fence = nodepool.fence
+
+local fonthashes = fonts.hashes
+local fontdata = fonthashes.identifiers
+local fontcharacters = fonthashes.characters
+local fontitalics = fonthashes.italics
+
+local variables = interfaces.variables
+local texsetattribute = tex.setattribute
+local texgetattribute = tex.getattribute
+local unsetvalue = attributes.unsetvalue
+local implement = interfaces.implement
+
+local v_reset = variables.reset
+
+local chardata = characters.data
+
+noads = noads or { } -- todo: only here
+local noads = noads
+
+noads.processors = noads.processors or { }
+local processors = noads.processors
+
+noads.handlers = noads.handlers or { }
+local handlers = noads.handlers
+
+local tasks = nodes.tasks
+local enableaction = tasks.enableaction
+local setaction = tasks.setaction
+
+local nodecodes = nodes.nodecodes
+local noadcodes = nodes.noadcodes
+local fencecodes = nodes.fencecodes
+
+local ordnoad_code = noadcodes.ord
+local relnode_code = noadcodes.rel
+local binnoad_code = noadcodes.bin
+local opennoad_code = noadcodes.open
+local closenoad_code = noadcodes.close
+local punctnoad_code = noadcodes.punct
+local opdisplaylimitsnoad_code = noadcodes.opdisplaylimits
+local oplimitsnoad_code = noadcodes.oplimits
+local opnolimitsnoad_code = noadcodes.opnolimits
+local innernoad_code = noadcodes.inner
+
+local noad_code = nodecodes.noad -- attr nucleus sub sup
+local accent_code = nodecodes.accent -- attr nucleus sub sup accent
+local radical_code = nodecodes.radical -- attr nucleus sub sup left degree
+local fraction_code = nodecodes.fraction -- attr nucleus sub sup left right
+local subbox_code = nodecodes.subbox -- attr list
+local submlist_code = nodecodes.submlist -- attr list
+local mathchar_code = nodecodes.mathchar -- attr fam char
+local mathtextchar_code = nodecodes.mathtextchar -- attr fam char
+local delim_code = nodecodes.delim -- attr small_fam small_char large_fam large_char
+----- style_code = nodecodes.style -- attr style
+local math_choice = nodecodes.choice -- attr display text script scriptscript
+local fence_code = nodecodes.fence -- attr subtype
+
+local leftfence_code = fencecodes.left
+local middlefence_code = fencecodes.middle
+local rightfence_code = fencecodes.right
-- local mathclasses = mathematics.classes
-- local fenceclasses = {
--- [left_fence_code] = mathclasses.open,
--- [middle_fence_code] = mathclasses.middle,
--- [right_fence_code] = mathclasses.close,
+-- [leftfence_code] = mathclasses.open,
+-- [middlefence_code] = mathclasses.middle,
+-- [rightfence_code] = mathclasses.close,
-- }
-- this initial stuff is tricky as we can have removed and new nodes with the same address
@@ -232,9 +232,9 @@ local function process(start,what,n,parent)
while start do
local id = getid(start)
if trace_processing then
- if id == math_noad then
+ if id == noad_code then
report_processing("%w%S, class %a",n*2,nutstring(start),noadcodes[getsubtype(start)])
- elseif id == math_char then
+ elseif id == mathchar_code then
local char = getchar(start)
local font = getfont(start)
local fam = getfam(start)
@@ -264,16 +264,16 @@ local function process(start,what,n,parent)
-- report_processing("stop processing")
end
end
- elseif id == math_noad then
+ elseif id == noad_code then
-- single characters are like this
local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list
noad = getsup (start) if noad then process(noad,what,n,start) end -- list
noad = getsub (start) if noad then process(noad,what,n,start) end -- list
- elseif id == math_char or id == math_textchar or id == math_delim then
+ elseif id == mathchar_code or id == mathtextchar_code or id == delim_code then
break
- elseif id == math_subbox or id == math_submlist then
+ elseif id == subbox_code or id == submlist_code then
local noad = getlist(start) if noad then process(noad,what,n,start) end -- list (not getlist !)
- elseif id == math_fraction then
+ elseif id == fraction_code then
local noad = getfield(start,"num") if noad then process(noad,what,n,start) end -- list
noad = getfield(start,"denom") if noad then process(noad,what,n,start) end -- list
noad = getfield(start,"left") if noad then process(noad,what,n,start) end -- delimiter
@@ -283,21 +283,21 @@ local function process(start,what,n,parent)
noad = getfield(start,"text") if noad then process(noad,what,n,start) end -- list
noad = getfield(start,"script") if noad then process(noad,what,n,start) end -- list
noad = getfield(start,"scriptscript") if noad then process(noad,what,n,start) end -- list
- elseif id == math_fence then
+ elseif id == fence_code then
local noad = getfield(start,"delim") if noad then process(noad,what,n,start) end -- delimiter
- elseif id == math_radical then
+ elseif id == radical_code then
local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list
noad = getsup (start) if noad then process(noad,what,n,start) end -- list
noad = getsub (start) if noad then process(noad,what,n,start) end -- list
noad = getfield(start,"left") if noad then process(noad,what,n,start) end -- delimiter
noad = getfield(start,"degree") if noad then process(noad,what,n,start) end -- list
- elseif id == math_accent then
+ elseif id == accent_code then
local noad = getnucleus(start) if noad then process(noad,what,n,start) end -- list
noad = getsup (start) if noad then process(noad,what,n,start) end -- list
noad = getsub (start) if noad then process(noad,what,n,start) end -- list
noad = getfield(start,"accent") if noad then process(noad,what,n,start) end -- list
noad = getfield(start,"bot_accent") if noad then process(noad,what,n,start) end -- list
- -- elseif id == math_style then
+ -- elseif id == style_code then
-- -- has a next
-- else
-- -- glue, penalty, etc
@@ -312,13 +312,13 @@ end
local function processnested(current,what,n)
local noad = nil
local id = getid(current)
- if id == math_noad then
+ if id == noad_code then
noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list
noad = getsup (current) if noad then process(noad,what,n,current) end -- list
noad = getsub (current) if noad then process(noad,what,n,current) end -- list
- elseif id == math_subbox or id == math_submlist then
+ elseif id == subbox_code or id == submlist_code then
noad = getlist(current) if noad then process(noad,what,n,current) end -- list (not getlist !)
- elseif id == math_fraction then
+ elseif id == fraction_code then
noad = getfield(current,"num") if noad then process(noad,what,n,current) end -- list
noad = getfield(current,"denom") if noad then process(noad,what,n,current) end -- list
noad = getfield(current,"left") if noad then process(noad,what,n,current) end -- delimiter
@@ -328,15 +328,15 @@ local function processnested(current,what,n)
noad = getfield(current,"text") if noad then process(noad,what,n,current) end -- list
noad = getfield(current,"script") if noad then process(noad,what,n,current) end -- list
noad = getfield(current,"scriptscript") if noad then process(noad,what,n,current) end -- list
- elseif id == math_fence then
+ elseif id == fence_code then
noad = getfield(current,"delim") if noad then process(noad,what,n,current) end -- delimiter
- elseif id == math_radical then
+ elseif id == radical_code then
noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list
noad = getsup (current) if noad then process(noad,what,n,current) end -- list
noad = getsub (current) if noad then process(noad,what,n,current) end -- list
noad = getfield(current,"left") if noad then process(noad,what,n,current) end -- delimiter
noad = getfield(current,"degree") if noad then process(noad,what,n,current) end -- list
- elseif id == math_accent then
+ elseif id == accent_code then
noad = getnucleus(current) if noad then process(noad,what,n,current) end -- list
noad = getsup (current) if noad then process(noad,what,n,current) end -- list
noad = getsub (current) if noad then process(noad,what,n,current) end -- list
@@ -348,13 +348,13 @@ end
local function processstep(current,process,n,id)
local noad = nil
local id = id or getid(current)
- if id == math_noad then
+ if id == noad_code then
noad = getnucleus(current) if noad then process(noad,n,current) end -- list
noad = getsup (current) if noad then process(noad,n,current) end -- list
noad = getsub (current) if noad then process(noad,n,current) end -- list
- elseif id == math_subbox or id == math_submlist then
+ elseif id == subbox_code or id == submlist_code then
noad = getlist(current) if noad then process(noad,n,current) end -- list (not getlist !)
- elseif id == math_fraction then
+ elseif id == fraction_code then
noad = getfield(current,"num") if noad then process(noad,n,current) end -- list
noad = getfield(current,"denom") if noad then process(noad,n,current) end -- list
noad = getfield(current,"left") if noad then process(noad,n,current) end -- delimiter
@@ -364,15 +364,15 @@ local function processstep(current,process,n,id)
noad = getfield(current,"text") if noad then process(noad,n,current) end -- list
noad = getfield(current,"script") if noad then process(noad,n,current) end -- list
noad = getfield(current,"scriptscript") if noad then process(noad,n,current) end -- list
- elseif id == math_fence then
+ elseif id == fence_code then
noad = getfield(current,"delim") if noad then process(noad,n,current) end -- delimiter
- elseif id == math_radical then
+ elseif id == radical_code then
noad = getnucleus(current) if noad then process(noad,n,current) end -- list
noad = getsup (current) if noad then process(noad,n,current) end -- list
noad = getsub (current) if noad then process(noad,n,current) end -- list
noad = getfield(current,"left") if noad then process(noad,n,current) end -- delimiter
noad = getfield(current,"degree") if noad then process(noad,n,current) end -- list
- elseif id == math_accent then
+ elseif id == accent_code then
noad = getnucleus(current) if noad then process(noad,n,current) end -- list
noad = getsup (current) if noad then process(noad,n,current) end -- list
noad = getsub (current) if noad then process(noad,n,current) end -- list
@@ -463,7 +463,7 @@ do
"pseudobold",
}
- families[math_fraction] = function(pointer,what,n,parent)
+ families[fraction_code] = function(pointer,what,n,parent)
local a = getattr(pointer,a_mathfamily)
if a and a >= 0 then
if a > 0 then
@@ -477,7 +477,7 @@ do
processnested(pointer,families,n+1)
end
- families[math_noad] = function(pointer,what,n,parent)
+ families[noad_code] = function(pointer,what,n,parent)
local a = getattr(pointer,a_mathfamily)
if a and a >= 0 then
if a > 0 then
@@ -491,7 +491,7 @@ do
processnested(pointer,families,n+1)
end
- families[math_char] = function(pointer)
+ families[mathchar_code] = function(pointer)
if getfam(pointer) == 0 then
local a = getattr(pointer,a_mathfamily)
if a and a > 0 then
@@ -536,7 +536,7 @@ do
end
end
end
- families[math_delim] = function(pointer)
+ families[delim_code] = function(pointer)
if getfield(pointer,"small_fam") == 0 then
local a = getattr(pointer,a_mathfamily)
if a and a > 0 then
@@ -568,7 +568,7 @@ do
-- will become:
- -- families[math_delim] = function(pointer)
+ -- families[delim_code] = function(pointer)
-- if getfam(pointer) == 0 then
-- local a = getattr(pointer,a_mathfamily)
-- if a and a > 0 then
@@ -590,7 +590,7 @@ do
-- end
-- end
- families[math_textchar] = families[math_char]
+ families[mathtextchar_code] = families[mathchar_code]
function handlers.families(head,style,penalties)
processnoads(head,families,"families")
@@ -638,7 +638,7 @@ do
end
end
- relocate[math_char] = function(pointer)
+ relocate[mathchar_code] = function(pointer)
local g = getattr(pointer,a_mathgreek) or 0
local a = getattr(pointer,a_mathalphabet) or 0
local char = getchar(pointer)
@@ -705,13 +705,13 @@ do
end
end
- relocate[math_textchar] = function(pointer)
+ relocate[mathtextchar_code] = function(pointer)
if trace_analyzing then
setnodecolor(pointer,"font:init")
end
end
- relocate[math_delim] = function(pointer)
+ relocate[delim_code] = function(pointer)
if trace_analyzing then
setnodecolor(pointer,"font:fina")
end
@@ -732,7 +732,7 @@ do
local rendersets = mathematics.renderings.numbers or { } -- store
- render[math_char] = function(pointer)
+ render[mathchar_code] = function(pointer)
local attr = getattr(pointer,a_mathrendering)
if attr and attr > 0 then
local char = getchar(pointer)
@@ -773,9 +773,9 @@ do
local a_mathsize = privateattribute("mathsize") -- this might move into other fence code
local resize = { }
- resize[math_fence] = function(pointer)
+ resize[fence_code] = function(pointer)
local subtype = getsubtype(pointer)
- if subtype == left_fence_code or subtype == right_fence_code then
+ if subtype == leftfence_code or subtype == rightfence_code then
local a = getattr(pointer,a_mathsize)
if a and a > 0 then
local method, size = div(a,100), a % 100
@@ -871,7 +871,7 @@ do
local function makelist(noad,f_o,o_next,c_prev,f_c,middle)
local list = new_submlist()
setlist(list,f_o)
- setsubtype(noad,noad_inner)
+ setsubtype(noad,innernoad_code)
setnucleus(noad,list)
setlink(f_o,o_next)
setlink(c_prev,f_c)
@@ -882,7 +882,7 @@ do
local m = middle[current]
if m then
local next = getnext(current)
- local fence = makefence(middle_fence_code,current)
+ local fence = makefence(middlefence_code,current)
setnucleus(current)
flush_node(current)
middle[current] = nil
@@ -904,8 +904,8 @@ do
if o_next == close then
return close
else
- local f_o = makefence(left_fence_code,open)
- local f_c = makefence(right_fence_code,close)
+ local f_o = makefence(leftfence_code,open)
+ local f_c = makefence(rightfence_code,close)
makelist(open,f_o,o_next,c_prev,f_c,middle)
setnucleus(close)
flush_node(close)
@@ -918,8 +918,8 @@ do
end
local function convert_open(open,last,middle)
- local f_o = makefence(left_fence_code,open)
- local f_c = makefence(right_fence_code)
+ local f_o = makefence(leftfence_code,open)
+ local f_c = makefence(rightfence_code)
local o_prev, o_next = getboth(open)
local l_prev, l_next = getboth(last)
makelist(open,f_o,o_next,last,f_c,middle)
@@ -931,8 +931,8 @@ do
end
local function convert_close(close,first,middle)
- local f_o = makefence(left_fence_code)
- local f_c = makefence(right_fence_code,close)
+ local f_o = makefence(leftfence_code)
+ local f_c = makefence(rightfence_code,close)
local c_prev = getprev(close)
makelist(close,f_o,first,c_prev,f_c,middle)
return close
@@ -950,7 +950,7 @@ do
local middle = nil -- todo: use properties
while current do
local id = getid(current)
- if id == math_noad then
+ if id == noad_code then
local a = getattr(current,a_autofence)
if a and a > 0 then
local stack = stacks[n]
@@ -1059,9 +1059,9 @@ do
local next = getnext(pointer)
local start_super, stop_super, start_sub, stop_sub
local mode = "unset"
- while next and getid(next) == math_noad do
+ while next and getid(next) == noad_code do
local nextnucleus = getnucleus(next)
- if nextnucleus and getid(nextnucleus) == math_char and not getsub(next) and not getsup(next) then
+ if nextnucleus and getid(nextnucleus) == mathchar_code and not getsub(next) and not getsup(next) then
local char = getchar(nextnucleus)
local s = superscripts[char]
if s then
@@ -1143,7 +1143,7 @@ do
-- we could return stop
end
- unscript[math_char] = replace -- not noads as we need to recurse
+ unscript[mathchar_code] = replace -- not noads as we need to recurse
function handlers.unscript(head,style,penalties)
processnoads(head,unscript,"unscript")
@@ -1158,7 +1158,7 @@ do
local enabled = false
local a_unstack = privateattribute("mathunstack")
- unstack[math_noad] = function(pointer)
+ unstack[noad_code] = function(pointer)
if getattr(pointer,a_unstack) then
local sup = getsup(pointer)
local sub = getsub(pointer)
@@ -1387,7 +1387,7 @@ do
arguments = { "integer", "string" }
}
- alternate[math_char] = function(pointer) -- slow
+ alternate[mathchar_code] = function(pointer) -- slow
local a = getattr(pointer,a_mathalternate)
if a and a > 0 then
setattr(pointer,a_mathalternate,0)
@@ -1535,7 +1535,7 @@ do
end
- italics[math_char] = function(pointer,what,n,parent)
+ italics[mathchar_code] = function(pointer,what,n,parent)
local method = getattr(pointer,a_mathitalics)
if method and method > 0 and method < 100 then
local char = getchar(pointer)
@@ -1663,7 +1663,7 @@ do
-- no correction after prime because that moved to a superscript
- kernpairs[math_char] = function(pointer,what,n,parent)
+ kernpairs[mathchar_code] = function(pointer,what,n,parent)
if getattr(pointer,a_kernpairs) == 1 then
local font = getfont(pointer)
local list = hash[font]
@@ -1672,7 +1672,7 @@ do
local found = list[first]
if found then
local next = getnext(parent)
- if next and getid(next) == math_noad then
+ if next and getid(next) == noad_code then
pointer = getnucleus(next)
if pointer then
if getfont(pointer) == font then
@@ -1710,20 +1710,20 @@ do
local collapse = { }
local mathlists = characters.mathlists
local validpair = {
- [noad_ord] = true,
- [noad_rel] = true,
- [noad_bin] = true, -- new
- [noad_open] = true, -- new
- [noad_close] = true, -- new
- [noad_punct] = true, -- new
- [noad_opdisplaylimits] = true,
- [noad_oplimits] = true,
- [noad_opnolimits] = true,
+ [ordnoad_code] = true,
+ [relnode_code] = true,
+ [binnoad_code] = true, -- new
+ [opennoad_code] = true, -- new
+ [closenoad_code] = true, -- new
+ [punctnoad_code] = true, -- new
+ [opdisplaylimitsnoad_code] = true,
+ [oplimitsnoad_code] = true,
+ [opnolimitsnoad_code] = true,
}
local reported = setmetatableindex("table")
- collapse[math_char] = function(pointer,what,n,parent)
+ collapse[mathchar_code] = function(pointer,what,n,parent)
if parent and mathlists[getchar(pointer)] then
local found, last, lucleus, lsup, lsub, category
@@ -1865,7 +1865,7 @@ do
-- local function movesubscript(parent,current_nucleus,oldchar,newchar)
-- local prev = getprev(parent)
- -- if prev and getid(prev) == math_noad then
+ -- if prev and getid(prev) == noad_code then
-- local psup = getsup(prev)
-- local psub = getsub(prev)
-- if not psup and not psub then
@@ -1908,7 +1908,7 @@ do
setnucleus(parent,dummy)
end
- fixscripts[math_char] = function(pointer,what,n,parent,nested) -- todo: switch to turn in on and off
+ fixscripts[mathchar_code] = function(pointer,what,n,parent,nested) -- todo: switch to turn in on and off
if parent then
local oldchar = getchar(pointer)
local newchar = movesub[oldchar]
@@ -1927,7 +1927,7 @@ do
-- print("[char] --- sup")
else
local prev = getprev(parent)
- if prev and getid(prev) == math_noad then
+ if prev and getid(prev) == noad_code then
local psub = getsub(prev)
local psup = getsup(prev)
if psub then
@@ -1982,14 +1982,14 @@ do
[0x2ACB] = 0xFE00, [0x2ACC] = 0xFE00,
}
- variants[math_char] = function(pointer,what,n,parent) -- also set export value
+ variants[mathchar_code] = function(pointer,what,n,parent) -- also set export value
local char = getchar(pointer)
local selector = validvariants[char]
if selector then
local next = getnext(parent)
- if next and getid(next) == math_noad then
+ if next and getid(next) == noad_code then
local nucleus = getnucleus(next)
- if nucleus and getid(nucleus) == math_char and getchar(nucleus) == selector then
+ if nucleus and getid(nucleus) == mathchar_code and getchar(nucleus) == selector then
local variant
local tfmdata = fontdata[getfont(pointer)]
local mathvariants = tfmdata.resources.variants -- and variantdata
@@ -2031,25 +2031,25 @@ do
local classes = { }
local colors = {
- [noad_rel] = "trace:dr",
- [noad_ord] = "trace:db",
- [noad_bin] = "trace:dg",
- [noad_open] = "trace:dm",
- [noad_close] = "trace:dm",
- [noad_punct] = "trace:dc",
- -- [noad_opdisplaylimits] = "",
- -- [noad_oplimits] = "",
- -- [noad_opnolimits] = "",
- -- [noad_inner = "",
- -- [noad_under = "",
- -- [noad_over = "",
- -- [noad_vcenter = "",
+ [relnode_code] = "trace:dr",
+ [ordnoad_code] = "trace:db",
+ [binnoad_code] = "trace:dg",
+ [opennoad_code] = "trace:dm",
+ [closenoad_code] = "trace:dm",
+ [punctnoad_code] = "trace:dc",
+ -- [opdisplaylimitsnoad_code] = "",
+ -- [oplimitsnoad_code] = "",
+ -- [opnolimitsnoad_code] = "",
+ -- [innernoad_code = "",
+ -- [undernoad_code] = "",
+ -- [overnoad_code] = "",
+ -- [vcenternoad_code] = "",
}
local setcolor = colortracers.set
local resetcolor = colortracers.reset
- classes[math_char] = function(pointer,what,n,parent)
+ classes[mathchar_code] = function(pointer,what,n,parent)
local color = colors[getsubtype(parent)]
if color then
setcolor(pointer,color)
@@ -2087,11 +2087,11 @@ do
local a_mathdomain = privateattribute("mathdomain")
mathematics.domains = categories
local permitted = {
- ordinary = noad_ord,
- binary = noad_bin,
- relation = noad_rel,
- punctuation = noad_punct,
- inner = noad_inner,
+ ordinary = ordnoad_code,
+ binary = binnoad_code,
+ relation = relnode_code,
+ punctuation = punctnoad_code,
+ inner = innernoad_code,
}
function mathematics.registerdomain(data)
@@ -2194,7 +2194,7 @@ do
return hash
end
- domains[math_char] = function(pointer,what,n,parent)
+ domains[mathchar_code] = function(pointer,what,n,parent)
local attr = getattr(pointer,a_mathdomain)
if attr then
local domain = numbers[attr]
diff --git a/tex/context/base/mkiv/math-spa.lua b/tex/context/base/mkiv/math-spa.lua
index 69f70ded5..33d9501d8 100644
--- a/tex/context/base/mkiv/math-spa.lua
+++ b/tex/context/base/mkiv/math-spa.lua
@@ -8,24 +8,23 @@ if not modules then modules = { } end modules ['math-spa'] = {
-- for the moment (when testing) we use a penalty 1
-local penalty_code = nodes.nodecodes.penalty
-local glue_code = nodes.nodecodes.glue
+local penalty_code = nodes.nodecodes.penalty
+local glue_code = nodes.nodecodes.glue
-local nuts = nodes.nuts
-local tonut = nodes.tonut
-local tonode = nodes.tonode
-local getid = nuts.getid
-local getnext = nuts.getnext
-local getwidth = nuts.getwidth
-local setglue = nuts.setglue
-local getpenalty = nuts.getpenalty
-local setpenalty = nuts.setpenalty
+local nuts = nodes.nuts
+local tonut = nodes.tonut
+local tonode = nodes.tonode
-local get_dimensions = nuts.dimensions
+local getid = nuts.getid
+local getnext = nuts.getnext
+local getwidth = nuts.getwidth
+local setglue = nuts.setglue
+local getpenalty = nuts.getpenalty
+local setpenalty = nuts.setpenalty
+local getdimensions = nuts.dimensions
+local nextglue = nuts.traversers.glue
-local nextglue = nuts.traversers.glue
-
-local texsetdimen = tex.setdimen
+local texsetdimen = tex.setdimen
local v_none = interfaces.variables.none
local v_auto = interfaces.variables.auto
@@ -46,7 +45,7 @@ function noads.handlers.align(h)
s = n
n = getnext(s)
end
- local w = get_dimensions(h,n) + distance
+ local w = getdimensions(h,n) + distance
texsetdimen("global","d_strc_math_indent",w)
break
end
diff --git a/tex/context/base/mkiv/math-tag.lua b/tex/context/base/mkiv/math-tag.lua
index 1cd8e4a7a..97495002a 100644
--- a/tex/context/base/mkiv/math-tag.lua
+++ b/tex/context/base/mkiv/math-tag.lua
@@ -14,92 +14,92 @@ if not modules then modules = { } end modules ['math-tag'] = {
local find, match = string.find, string.match
local insert, remove, concat = table.insert, table.remove, table.concat
-local attributes = attributes
-local nodes = nodes
+local attributes = attributes
+local nodes = nodes
-local nuts = nodes.nuts
-local tonut = nuts.tonut
+local nuts = nodes.nuts
+local tonut = nuts.tonut
-local getnext = nuts.getnext
-local getid = nuts.getid
-local getchar = nuts.getchar
-local getfont = nuts.getfont
-local getlist = nuts.getlist
-local getfield = nuts.getfield
-local getdisc = nuts.getdisc
-local getsubtype = nuts.getsubtype
-local getattr = nuts.getattr
-local getattrlist = nuts.getattrlist
-local setattr = nuts.setattr
-local getcomponents = nuts.getcomponents
-local getwidth = nuts.getwidth
+local getnext = nuts.getnext
+local getid = nuts.getid
+local getchar = nuts.getchar
+local getfont = nuts.getfont
+local getlist = nuts.getlist
+local getfield = nuts.getfield
+local getdisc = nuts.getdisc
+local getsubtype = nuts.getsubtype
+local getattr = nuts.getattr
+local getattrlist = nuts.getattrlist
+local setattr = nuts.setattr
+local getcomponents = nuts.getcomponents
+local getwidth = nuts.getwidth
-local getnucleus = nuts.getnucleus
-local getsub = nuts.getsub
-local getsup = nuts.getsup
+local getnucleus = nuts.getnucleus
+local getsub = nuts.getsub
+local getsup = nuts.getsup
-local set_attributes = nuts.setattributes
+local set_attributes = nuts.setattributes
-local nextnode = nuts.traversers.node
+local nextnode = nuts.traversers.node
-local nodecodes = nodes.nodecodes
+local nodecodes = nodes.nodecodes
-local math_noad_code = nodecodes.noad -- attr nucleus sub sup
-local math_accent_code = nodecodes.accent -- attr nucleus sub sup accent
-local math_radical_code = nodecodes.radical -- attr nucleus sub sup left degree
-local math_fraction_code = nodecodes.fraction -- attr nucleus sub sup left right
-local math_box_code = nodecodes.subbox -- attr list
-local math_sub_code = nodecodes.submlist -- attr list
-local math_char_code = nodecodes.mathchar -- attr fam char
-local math_textchar_code = nodecodes.mathtextchar -- attr fam char
-local math_delim_code = nodecodes.delim -- attr small_fam small_char large_fam large_char
-local math_style_code = nodecodes.style -- attr style
-local math_choice_code = nodecodes.choice -- attr display text script scriptscript
-local math_fence_code = nodecodes.fence -- attr subtype
+local noad_code = nodecodes.noad -- attr nucleus sub sup
+local accent_code = nodecodes.accent -- attr nucleus sub sup accent
+local radical_code = nodecodes.radical -- attr nucleus sub sup left degree
+local fraction_code = nodecodes.fraction -- attr nucleus sub sup left right
+local subbox_code = nodecodes.subbox -- attr list
+local submlist_code = nodecodes.submlist -- attr list
+local mathchar_code = nodecodes.mathchar -- attr fam char
+local mathtextchar_code = nodecodes.mathtextchar -- attr fam char
+local delim_code = nodecodes.delim -- attr small_fam small_char large_fam large_char
+local style_code = nodecodes.style -- attr style
+local choice_code = nodecodes.choice -- attr display text script scriptscript
+local fence_code = nodecodes.fence -- attr subtype
-local accentcodes = nodes.accentcodes
+local accentcodes = nodes.accentcodes
-local math_fixed_top = accentcodes.fixedtop
-local math_fixed_bottom = accentcodes.fixedbottom
-local math_fixed_both = accentcodes.fixedboth
+local fixedtopaccent_code = accentcodes.fixedtop
+local fixedbottomaccent_code = accentcodes.fixedbottom
+local fixedbothaccent_code = accentcodes.fixedboth
-local kerncodes = nodes.kerncodes
+local kerncodes = nodes.kerncodes
-local fontkern_code = kerncodes.fontkern
-local italickern_code = kerncodes.italickern
+local fontkern_code = kerncodes.fontkern
+local italickern_code = kerncodes.italickern
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local glyph_code = nodecodes.glyph
-local disc_code = nodecodes.disc
-local glue_code = nodecodes.glue
-local kern_code = nodecodes.kern
-local math_code = nodecodes.math
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local glyph_code = nodecodes.glyph
+local disc_code = nodecodes.disc
+local glue_code = nodecodes.glue
+local kern_code = nodecodes.kern
+local math_code = nodecodes.math
-local processnoads = noads.process
+local processnoads = noads.process
-local a_tagged = attributes.private('tagged')
-local a_mathcategory = attributes.private('mathcategory')
-local a_mathmode = attributes.private('mathmode')
+local a_tagged = attributes.private('tagged')
+local a_mathcategory = attributes.private('mathcategory')
+local a_mathmode = attributes.private('mathmode')
-local tags = structures.tags
+local tags = structures.tags
-local start_tagged = tags.start
-local restart_tagged = tags.restart
-local stop_tagged = tags.stop
-local taglist = tags.taglist
+local start_tagged = tags.start
+local restart_tagged = tags.restart
+local stop_tagged = tags.stop
+local taglist = tags.taglist
-local chardata = characters.data
+local chardata = characters.data
-local getmathcodes = tex.getmathcodes
-local mathcodes = mathematics.codes
-local ordinary_code = mathcodes.ordinary
-local variable_code = mathcodes.variable
+local getmathcodes = tex.getmathcodes
+local mathcodes = mathematics.codes
+local ordinary_mathcode = mathcodes.ordinary
+local variable_mathcode = mathcodes.variable
-local fromunicode16 = fonts.mappings.fromunicode16
-local fontcharacters = fonts.hashes.characters
+local fromunicode16 = fonts.mappings.fromunicode16
+local fontcharacters = fonts.hashes.characters
-local report_tags = logs.reporter("structure","tags")
+local report_tags = logs.reporter("structure","tags")
local process
@@ -169,7 +169,7 @@ end
local content = { }
local found = false
-content[math_char_code] = function() found = true end
+content[mathchar_code] = function() found = true end
local function hascontent(head)
found = false
@@ -210,11 +210,11 @@ process = function(start) -- we cannot use the processor as we have no finalizer
stop_tagged()
mtexttag = nil
end
- if id == math_char_code then
+ if id == mathchar_code then
local char = getchar(start)
local code = getmathcodes(char)
local tag
- if code == ordinary_code or code == variable_code then
+ if code == ordinary_mathcode or code == variable_mathcode then
local ch = chardata[char]
local mc = ch and ch.mathclass
if mc == "number" then
@@ -236,7 +236,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer
stop_tagged()
-- showtag(start,id,false)
break -- okay?
- elseif id == math_textchar_code then -- or id == glyph_code
+ elseif id == mathtextchar_code then -- or id == glyph_code
-- check for code
local a = getattr(start,a_mathcategory)
if a then
@@ -247,19 +247,19 @@ process = function(start) -- we cannot use the processor as we have no finalizer
stop_tagged()
-- showtag(start,id,false)
break
- elseif id == math_delim_code then
+ elseif id == delim_code then
-- check for code
setattr(start,a_tagged,start_tagged("mo"))
stop_tagged()
-- showtag(start,id,false)
break
- elseif id == math_style_code then
+ elseif id == style_code then
-- has a next
- elseif id == math_noad_code then
+ elseif id == noad_code then
-- setattr(start,a_tagged,tags.current())
processsubsup(start)
- elseif id == math_box_code or id == hlist_code or id == vlist_code then
- -- keep an eye on math_box_code and see what ends up in there
+ elseif id == dubbox_code or id == hlist_code or id == vlist_code then
+ -- keep an eye on subbox_code and see what ends up in there
local attr = getattr(start,a_tagged)
if not attr then
-- just skip
@@ -356,7 +356,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer
end
end
end
- elseif id == math_sub_code then -- normally a hbox
+ elseif id == submlistcode then -- normally a hbox
local list = getlist(start)
if list then
local attr = getattr(start,a_tagged)
@@ -397,7 +397,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer
stop_tagged()
end
end
- elseif id == math_fraction_code then
+ elseif id == fraction_code then
local num = getfield(start,"num")
local denom = getfield(start,"denom")
local left = getfield(start,"left")
@@ -416,7 +416,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer
process(right)
stop_tagged()
end
- elseif id == math_choice_code then
+ elseif id == choice_code then
local display = getfield(start,"display")
local text = getfield(start,"text")
local script = getfield(start,"script")
@@ -433,7 +433,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer
if scriptscript then
process(scriptscript)
end
- elseif id == math_fence_code then
+ elseif id == fence_code then
local delim = getfield(start,"delim")
local subtype = getfield(start,"subtype")
if subtype == 1 then
@@ -490,7 +490,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer
else
-- can't happen
end
- elseif id == math_radical_code then
+ elseif id == radical_code then
local left = getfield(start,"left")
local degree = getfield(start,"degree")
if left then
@@ -508,7 +508,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer
processsubsup(start)
stop_tagged()
end
- elseif id == math_accent_code then
+ elseif id == accent_code then
local accent = getfield(start,"accent")
local bot_accent = getfield(start,"bot_accent")
local subtype = getsubtype(start)
@@ -518,8 +518,8 @@ process = function(start) -- we cannot use the processor as we have no finalizer
accent = true,
top = getunicode(accent),
bottom = getunicode(bot_accent),
- topfixed = subtype == math_fixed_top or subtype == math_fixed_both,
- bottomfixed = subtype == math_fixed_bottom or subtype == math_fixed_both,
+ topfixed = subtype == fixedtopaccent_code or subtype == fixedbothaccent_code,
+ bottomfixed = subtype == fixedbottomaccent_code or subtype == fixedbothaccent_code,
}))
processsubsup(start)
process(bot_accent)
@@ -529,7 +529,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer
setattr(start,a_tagged,start_tagged("munder", {
accent = true,
bottom = getunicode(bot_accent),
- bottomfixed = subtype == math_fixed_bottom or subtype == math_fixed_both,
+ bottomfixed = subtype == fixedbottomaccent_code or subtype == fixedbothaccent_code,
}))
processsubsup(start)
process(bot_accent)
@@ -539,7 +539,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer
setattr(start,a_tagged,start_tagged("mover", {
accent = true,
top = getunicode(accent),
- topfixed = subtype == math_fixed_top or subtype == math_fixed_both,
+ topfixed = subtype == fixedtopaccent_code or subtype == fixedbothaccent_code,
}))
processsubsup(start)
process(accent)
diff --git a/tex/context/base/mkiv/meta-blb.lua b/tex/context/base/mkiv/meta-blb.lua
index 23d069d1e..5fea35f6d 100644
--- a/tex/context/base/mkiv/meta-blb.lua
+++ b/tex/context/base/mkiv/meta-blb.lua
@@ -217,9 +217,10 @@ local kerncodes = nodes.kerncodes
local glue_code = nodecodes.glue
local kern_code = nodecodes.kern
-local c_userkern = kerncodes.userkern
-local c_fontkern = kerncodes.fontkern
-local c_italickern = kerncodes.italickern
+
+local fontkern_code = kerncodes.fontkern
+local italickern_code = kerncodes.italickern
+
local a_fontkern = attributes.private("fontkern")
local takebox = tex.takebox
@@ -230,7 +231,7 @@ local flush_node = nodes.flush
local addblob = mp.mf_blob_add
local newblob = mp.mf_blob_new
-local visible_code = {
+local visible_codes = {
[nodecodes.glyph] = true,
[nodecodes.glue] = true,
[nodecodes.hlist] = true,
@@ -251,13 +252,13 @@ local function initialize(category,box)
local current = head
while current do
local id = current.id
- if visible_code[id] then
+ if visible_codes[id] then
head, current, tail = remove_node(head,current)
s = s + 1
n[s] = tail
elseif id == kern_code then
local subtype = current.subtype
- if subtype == c_fontkern or subtype == italickern then -- or current[a_fontkern]
+ if subtype == fontkern_code or subtype == italickern_code then -- or current[a_fontkern]
head, current, temp = remove_node(head,current)
tail.next = temp
temp.prev = tail
diff --git a/tex/context/base/mkiv/meta-pdf.lua b/tex/context/base/mkiv/meta-pdf.lua
index 3060508b4..2e3a5782a 100644
--- a/tex/context/base/mkiv/meta-pdf.lua
+++ b/tex/context/base/mkiv/meta-pdf.lua
@@ -53,7 +53,7 @@ end)
local m_path, m_stack, m_texts, m_version, m_date, m_shortcuts = { }, { }, { }, 0, 0, false
local m_stack_close, m_stack_path, m_stack_concat = false, { }, nil
-local extra_path_code, ignore_path = nil, false
+local extra_path_data, ignore_path = nil, false
local specials = { }
local function resetpath()
@@ -62,7 +62,7 @@ end
local function resetall()
m_path, m_stack, m_texts, m_version, m_shortcuts = { }, { }, { }, 0, false
- extra_path_code, ignore_path = nil, false
+ extra_path_data, ignore_path = nil, false
specials = { }
resetpath()
end
@@ -81,9 +81,9 @@ local pdfcode = context.pdfliteral
local function mpscode(str)
if ignore_path then
pdfcode("h W n")
- if extra_path_code then
- pdfcode(extra_path_code)
- extra_path_code = nil
+ if extra_path_data then
+ pdfcode(extra_path_data)
+ extra_path_data = nil
end
ignore_path = false
else
@@ -284,7 +284,7 @@ local function linearshade(colorspace,domain,ca,cb,coordinates)
nofshades = nofshades + 1
local name = formatters["MpsSh%s"](nofshades)
lpdf.linearshade(name,domain,ca,cb,1,colorspace,coordinates)
- extra_path_code, ignore_path = formatters["/%s sh Q"](name), true
+ extra_path_data, ignore_path = formatters["/%s sh Q"](name), true
pdfcode("q /Pattern cs")
end
@@ -293,7 +293,7 @@ local function circularshade(colorspace,domain,ca,cb,coordinates)
nofshades = nofshades + 1
local name = formatters["MpsSh%s"](nofshades)
lpdf.circularshade(name,domain,ca,cb,1,colorspace,coordinates)
- extra_path_code, ignore_path = formatters["/%s sh Q"](name), true
+ extra_path_data, ignore_path = formatters["/%s sh Q"](name), true
pdfcode("q /Pattern cs")
end
diff --git a/tex/context/base/mkiv/mult-aux.mkiv b/tex/context/base/mkiv/mult-aux.mkiv
index 8edd0a7bb..5e7de2270 100644
--- a/tex/context/base/mkiv/mult-aux.mkiv
+++ b/tex/context/base/mkiv/mult-aux.mkiv
@@ -227,7 +227,8 @@
{\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing
\def#3##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}%
\def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
- \def#5##1##2{\ifx##1\relax\??empty\else#4{##1}{##2}\fi}% is {} needed around ##1 ?
+ %\def#5##1##2{\ifx##1\relax\??empty\else#4{##1}{##2}\fi}% is {} needed around ##1 ?
+ \def#5##1##2{\ifx##1\relax\??empty\else#4##1{##2}\fi}% is {} needed around ##1 ?
\def#6##1##2{\csname\ifcsname#1##1:##2\endcsname#1##1:##2\else\expandafter#5\csname#1##1:\s!parent\endcsname{##2}\fi\endcsname}%
\def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2:##1\endcsname}}% always root, no backtrack
\def#8##1{\begincsname#1#2:##1\endcsname}}
@@ -259,7 +260,8 @@
{\ifx#2\relax\let#2\empty\fi
\def#3##1{#1#4{#1#2}{##1}:}% leading #1 was missing .. is this one used?
\def#4##1##2{\ifcsname##1:##2\endcsname##1\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
- \def#5##1##2{\ifx##1\relax\else#4{##1}{##2}\fi}%
+ %\def#5##1##2{\ifx##1\relax\else#4{##1}{##2}\fi}%
+ \def#5##1##2{\ifx##1\relax\else#4##1{##2}\fi}%
\def#6{#1#2:}%
\def#7##1{#1##1:}%
\def#8{\ifx#2\empty\else\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi\fi}%
diff --git a/tex/context/base/mkiv/node-acc.lua b/tex/context/base/mkiv/node-acc.lua
index f5cf6a2a1..db8ca8af8 100644
--- a/tex/context/base/mkiv/node-acc.lua
+++ b/tex/context/base/mkiv/node-acc.lua
@@ -36,7 +36,7 @@ local insert_after = nuts.insert_after
local copy_no_components = nuts.copy_no_components
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
local glue_code = nodecodes.glue
----- kern_code = nodecodes.kern
@@ -44,9 +44,9 @@ local glyph_code = nodecodes.glyph
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
-local userskip_code = skipcodes.user
-local spaceskip_code = skipcodes.spaceskip
-local xspaceskip_code = skipcodes.xspaceskip
+local userskip_code = gluecodes.user
+local spaceskip_code = gluecodes.spaceskip
+local xspaceskip_code = gluecodes.xspaceskip
local a_characters = attributes.private("characters")
diff --git a/tex/context/base/mkiv/node-bck.lua b/tex/context/base/mkiv/node-bck.lua
index a378f0476..a19e5e969 100644
--- a/tex/context/base/mkiv/node-bck.lua
+++ b/tex/context/base/mkiv/node-bck.lua
@@ -14,63 +14,64 @@ if not modules then modules = { } end modules ['node-bck'] = {
local attributes, nodes, node = attributes, nodes, node
-local enableaction = nodes.tasks.enableaction
+local enableaction = nodes.tasks.enableaction
-local nodecodes = nodes.nodecodes
-local listcodes = nodes.listcodes
+local nodecodes = nodes.nodecodes
+local listcodes = nodes.listcodes
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local alignment_code = listcodes.alignment
-local cell_code = listcodes.cell
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
-local nuts = nodes.nuts
-local nodepool = nuts.pool
+local alignmentlist_code = listcodes.alignment
+local celllist_code = listcodes.cell
-local getnext = nuts.getnext
-local getprev = nuts.getprev
-local getid = nuts.getid
-local getlist = nuts.getlist
-local getattr = nuts.getattr
-local getsubtype = nuts.getsubtype
-local getwhd = nuts.getwhd
-local getwidth = nuts.getwidth
-local getprop = nuts.getprop
+local nuts = nodes.nuts
+local nodepool = nuts.pool
-local setattr = nuts.setattr
-local setlink = nuts.setlink
-local setlist = nuts.setlist
-local setattributelist = nuts.setattributelist
-local setprop = nuts.setprop
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getid = nuts.getid
+local getlist = nuts.getlist
+local getattr = nuts.getattr
+local getsubtype = nuts.getsubtype
+local getwhd = nuts.getwhd
+local getwidth = nuts.getwidth
+local getprop = nuts.getprop
-local takebox = nuts.takebox
-local findtail = nuts.tail
+local setattr = nuts.setattr
+local setlink = nuts.setlink
+local setlist = nuts.setlist
+local setattributelist = nuts.setattributelist
+local setprop = nuts.setprop
-local nextnode = nuts.traversers.node
-local nexthlist = nuts.traversers.hlist
-local nextlist = nuts.traversers.list
+local takebox = nuts.takebox
+local findtail = nuts.tail
-local flush_node_list = nuts.flush_list
+local nextnode = nuts.traversers.node
+local nexthlist = nuts.traversers.hlist
+local nextlist = nuts.traversers.list
-local new_rule = nodepool.rule
-local new_kern = nodepool.kern
-local new_hlist = nodepool.hlist
+local flush_node_list = nuts.flush_list
-local privateattributes = attributes.private
-local unsetvalue = attributes.unsetvalue
+local new_rule = nodepool.rule
+local new_kern = nodepool.kern
+local new_hlist = nodepool.hlist
-local linefillers = nodes.linefillers
+local privateattributes = attributes.private
+local unsetvalue = attributes.unsetvalue
-local a_color = privateattributes("color")
-local a_transparency = privateattributes("transparency")
-local a_colormodel = privateattributes("colormodel")
-local a_background = privateattributes("background")
-local a_alignbackground = privateattributes("alignbackground")
-local a_linefiller = privateattributes("linefiller")
-local a_ruled = privateattributes("ruled")
+local linefillers = nodes.linefillers
-local trace_alignment = false
-local report_alignment = logs.reporter("backgrounds","alignment")
+local a_color = privateattributes("color")
+local a_transparency = privateattributes("transparency")
+local a_colormodel = privateattributes("colormodel")
+local a_background = privateattributes("background")
+local a_alignbackground = privateattributes("alignbackground")
+local a_linefiller = privateattributes("linefiller")
+local a_ruled = privateattributes("ruled")
+
+local trace_alignment = false
+local report_alignment = logs.reporter("backgrounds","alignment")
trackers.register("backgrounds.alignments",function(v) trace_alignment = v end)
@@ -144,7 +145,7 @@ local alignments = false
local function add_alignbackgrounds(head,list)
for current, id, subtype, list in nextlist, list do
- if list and id == hlist_code and subtype == cell_code then
+ if list and id == hlist_code and subtype == celllist_code then
for template in nexthlist, list do
local background = getattr(template,a_alignbackground)
if background then
@@ -171,7 +172,7 @@ local function add_backgrounds(head,id,list)
if list then
for current, id, subtype, list in nextlist, list do
if list then
- if alignments and subtype == alignment_code then
+ if alignments and subtype == alignmentlist_code then
local l = add_alignbackgrounds(current,list)
if l then
list = l
@@ -206,7 +207,7 @@ function nodes.handlers.backgroundspage(head,where)
if head and where == "alignment" then
for n in nexthlist, head do
local p = getprop(n,"alignmentchecked")
- if not p and getsubtype(n) == alignment_code then
+ if not p and getsubtype(n) == alignmentlist_code then
currentrow = currentrow + 1
local template = templates[currentrow]
if trace_alignment then
@@ -225,7 +226,7 @@ function nodes.handlers.backgroundsvbox(head,where)
if list then
for n in nexthlist, list do
local p = getprop(n,"alignmentchecked")
- if not p and getsubtype(n) == alignment_code then
+ if not p and getsubtype(n) == alignmentlist_code then
currentrow = currentrow + 1
local template = templates[currentrow]
if trace_alignment then
diff --git a/tex/context/base/mkiv/node-bck.mkiv b/tex/context/base/mkiv/node-bck.mkiv
index 47aaa1629..b09327443 100644
--- a/tex/context/base/mkiv/node-bck.mkiv
+++ b/tex/context/base/mkiv/node-bck.mkiv
@@ -19,7 +19,7 @@
\unprotect
-\registerctxluafile{node-bck}{}
+\registerctxluafile{node-bck}{optimize}
% \backgroundvbox[green] {\input tufte } \par
% \backgroundvbox[blue] {\input ward } \par
diff --git a/tex/context/base/mkiv/node-fin.lua b/tex/context/base/mkiv/node-fin.lua
index b8fe389c0..03f0d83bb 100644
--- a/tex/context/base/mkiv/node-fin.lua
+++ b/tex/context/base/mkiv/node-fin.lua
@@ -24,6 +24,7 @@ local getleader = nuts.getleader
local getattr = nuts.getattr
local getwidth = nuts.getwidth
local getwhd = nuts.getwhd
+local gettransform = nuts.gettransform
local setlist = nuts.setlist
local setleader = nuts.setleader
@@ -35,19 +36,18 @@ local insert_node_after = nuts.insert_after
local nextnode = nuts.traversers.node
local nodecodes = nodes.nodecodes
-local whatcodes = nodes.whatcodes
local rulecodes = nodes.rulecodes
--- local normal_rule_code = rulecodes.normal
-local box_rule_code = rulecodes.box
-local image_rule_code = rulecodes.image
-local empty_rule_code = rulecodes.empty
--- local user_rule_code = rulecodes.user
--- local over_rule_code = rulecodes.over
--- local under_rule_code = rulecodes.under
--- local fraction_rule_code = rulecodes.fraction
--- local radical_rule_code = rulecodes.radical
--- local outline_rule_code = rulecodes.outline
+----- normalrule_code = rulecodes.normal
+local boxrule_code = rulecodes.box
+local imagerule_code = rulecodes.image
+local emptyrule_code = rulecodes.empty
+----- userrule_code = rulecodes.user
+----- overrule_code = rulecodes.over
+----- underrule_code = rulecodes.under
+----- fractionrule_code = rulecodes.fraction
+----- radicalrule_code = rulecodes.radical
+----- outlinerule_code = rulecodes.outline
local glyph_code = nodecodes.glyph
local disc_code = nodecodes.disc
@@ -192,10 +192,36 @@ local function process(attribute,head,inheritance,default) -- one attribute
elseif id == hlist_code or id == vlist_code then
local content = getlist(stack)
if content then
+ -- tricky checking
+ local outer
+ if gettransform(stack) then
+ outer = getattr(stack,attribute)
+ if outer then
+ if default and outer == inheritance then
+ if current ~= default then
+ head = insert_node_before(head,stack,copy_node(nsdata[default]))
+ current = default
+ end
+ elseif current ~= outer then
+ head = insert_node_before(head,stack,copy_node(nsdata[c]))
+ current = outer
+ end
+ elseif default and inheritance then
+ if current ~= default then
+ head = insert_node_before(head,stack,copy_node(nsdata[default]))
+ current = default
+ end
+ elseif current > 0 then
+ head = insert_node_before(head,stack,copy_node(nsnone))
+ current = 0
+ end
+ end
-- begin nested --
local list
if nstrigger and getattr(stack,nstrigger) then
- local outer = getattr(stack,attribute)
+ if not outer then
+ outer = getattr(stack,attribute)
+ end
if outer ~= inheritance then
list = process(attribute,content,inheritance,outer)
else
@@ -293,10 +319,44 @@ local function selective(attribute,head,inheritance,default) -- two attributes
elseif id == hlist_code or id == vlist_code then
local content = getlist(stack)
if content then
+ -- tricky checking
+ local outer
+ if gettransform(stack) then
+ outer = getattr(stack,attribute)
+ if outer then
+ if default and outer == inheritance then
+ if current ~= default then
+ local data = nsdata[default]
+ head = insert_node_before(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector]))
+ current = default
+ end
+ else
+ local s = getattr(stack,nsselector)
+ -- local s = nsforced or getattr(stack,nsselector)
+ if current ~= outer or current_selector ~= s then
+ local data = nsdata[outer]
+ head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector]))
+ current = outer
+ current_selector = s
+ end
+ end
+ elseif default and inheritance then
+ if current ~= default then
+ local data = nsdata[default]
+ head = insert_node_before(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector]))
+ current = default
+ end
+ elseif current > 0 then
+ head = insert_node_before(head,stack,copy_node(nsnone))
+ current, current_selector = 0, 0
+ end
+ end
-- begin nested
local list
if nstrigger and getattr(stack,nstrigger) then
- local outer = getattr(stack,attribute)
+ if not outer then
+ outer = getattr(stack,attribute)
+ end
if outer ~= inheritance then
list = selective(attribute,content,inheritance,outer)
else
@@ -311,15 +371,14 @@ local function selective(attribute,head,inheritance,default) -- two attributes
-- end nested
end
elseif id == rule_code then
-if subtype == box_rule_code or subtype == image_rule_code or subtype == empty_rule_code then
- -- so no redundant color stuff (only here, layers for instance should obey)
- check = false
-else
- local wd, ht, dp = getwhd(stack)
- check = wd ~= 0 or (ht+dp) ~= 0
-end
+ if subtype == boxrule_code or subtype == imagerule_code or subtype == emptyrule_code then
+ -- so no redundant color stuff (only here, layers for instance should obey)
+ check = false
+ else
+ local wd, ht, dp = getwhd(stack)
+ check = wd ~= 0 or (ht+dp) ~= 0
+ end
end
-
if check then
local c = getattr(stack,attribute)
if c then
diff --git a/tex/context/base/mkiv/node-fin.mkiv b/tex/context/base/mkiv/node-fin.mkiv
index 4f1ff2aba..086b19ae5 100644
--- a/tex/context/base/mkiv/node-fin.mkiv
+++ b/tex/context/base/mkiv/node-fin.mkiv
@@ -18,8 +18,8 @@
\unprotect
-\registerctxluafile{node-shp}{}
-\registerctxluafile{node-fin}{} % we might generalize this one
+\registerctxluafile{node-shp}{optimize}
+\registerctxluafile{node-fin}{optimize} % we might generalize this one
% we might have two variants at some point (efficiency)
diff --git a/tex/context/base/mkiv/node-fnt.lua b/tex/context/base/mkiv/node-fnt.lua
index 6c77ea1ff..5748312de 100644
--- a/tex/context/base/mkiv/node-fnt.lua
+++ b/tex/context/base/mkiv/node-fnt.lua
@@ -37,6 +37,8 @@ local starttiming = statistics.starttiming
local stoptiming = statistics.stoptiming
local nodecodes = nodes.nodecodes
+local boundarycodes = nodes.boundarycodes
+
local handlers = nodes.handlers
local nuts = nodes.nuts
@@ -70,7 +72,8 @@ local flush_node = nuts.flush
local disc_code = nodecodes.disc
local boundary_code = nodecodes.boundary
-local word_boundary = nodes.boundarycodes.word
+
+local wordboundary_code = boundarycodes.word
local protect_glyphs = nuts.protect_glyphs
local unprotect_glyphs = nuts.unprotect_glyphs
@@ -145,10 +148,10 @@ local kerning = nuts.kerning
-- -- -- this will go away
--
--- local disccodes = nodes.disccodes
--- local explicit_code = disccodes.explicit
--- local automatic_code = disccodes.automatic
--- local expanders = nil
+-- local disccodes = nodes.disccodes
+-- local explicitdisc_code = disccodes.explicit
+-- local automaticdisc_code = disccodes.automatic
+-- local expanders = nil
--
-- function fonts.setdiscexpansion(v)
-- if v == nil or v == true then
@@ -378,7 +381,7 @@ do
-- and kern (a rather context thing)
for b, subtype in nextboundary, head do
- if subtype == word_boundary then
+ if subtype == wordboundary_code then
if redundant then
r = r + 1
redundant[r] = b
@@ -462,7 +465,7 @@ do
end
-- elseif expanders then
-- local subtype = getsubtype(d)
- -- if subtype == automatic_code or subtype == explicit_code then
+ -- if subtype == automaticdisc_code or subtype == explicitdisc_code then
-- expanders[subtype](d)
-- e = e + 1
-- end
diff --git a/tex/context/base/mkiv/node-ltp.lua b/tex/context/base/mkiv/node-ltp.lua
index a8de4d783..97eb62ea2 100644
--- a/tex/context/base/mkiv/node-ltp.lua
+++ b/tex/context/base/mkiv/node-ltp.lua
@@ -134,6 +134,53 @@ if not modules then modules = { } end modules ['node-par'] = {
]]--
+--[[--
+
+#define dir_TLT 0
+#define dir_TRT 1
+#define dir_LTL 2
+#define dir_RTT 3
+
+#define dir_TLT_or_TRT(A) (A < 2)
+#define dir_LTL_or_RTT(A) (A > 1)
+
+#define textdir_parallel(A,B) (\
+(dir_TLT_or_TRT(A) and dir_TLT_or_TRT(B)) or \
+(dir_LTL_or_RTT(A) and dir_LTL_or_RTT(B))\
+)
+
+#define pardir_parallel(A,B) (\
+(dir_TLT_or_TRT(A) and dir_TLT_or_TRT(B)) or \
+(dir_LTL_or_RTT(A) and dir_LTL_or_RTT(B))\
+)
+
+#define pardir_opposite(A,B) (\
+(A == dir_LTL and B == dir_RTT) or \
+(A == dir_RTT and B == dir_LTL)\
+)
+
+#define textdir_opposite(A,B) (\
+(A == dir_TLT and B == dir_TRT) or \
+(A == dir_TRT and B == dir_TLT)\
+)
+
+#define glyphdir_opposite(A,B) 0
+
+#define pardir_equal(A,B) (\
+(dir_TLT_or_TRT(A) and dir_TLT_or_TRT(B)) or \
+(A == dir_LTL and B == dir_LTL) or \
+(A == dir_RTT and B == dir_RTT)\
+)
+
+#define textdir_equal(A,B) (\
+(A == dir_TLT and B == dir_TLT) or \
+(A == dir_TRT and B == dir_TRT) or \
+(A == dir_LTL and dir_LTL_or_RTT(B)) or \
+(A == dir_RTT and dir_LTL_or_RTT(B))\
+)
+
+--]]--
+
local tonumber = tonumber
local utfchar = utf.char
local write, write_nl = texio.write, texio.write_nl
@@ -209,7 +256,7 @@ local getwhd = nuts.getwhd
local getcomponents = nuts.getcomponents
local getkern = nuts.getkern
local getpenalty = nuts.getpenalty
-local getdir = nuts.getdir
+local getdirection = nuts.getdirection
local getshift = nuts.getshift
local getwidth = nuts.getwidth
local getheight = nuts.getheight
@@ -230,7 +277,7 @@ local setsubtype = nuts.setsubtype
local setglue = nuts.setglue
local setwhd = nuts.setwhd
local setkern = nuts.setkern
-local setdir = nuts.setdir
+local setdirection = nuts.setdirection
local setshift = nuts.setshift
local setwidth = nuts.setwidth
----- setheight = nuts.setheight
@@ -248,13 +295,14 @@ local replace_node = nuts.replace
local insert_node_after = nuts.insert_after
local insert_node_before = nuts.insert_before
local is_zero_glue = nuts.is_zero_glue
+local is_skipable = nuts.protrusion_skippable
local nodepool = nuts.pool
local nodecodes = nodes.nodecodes
local kerncodes = nodes.kerncodes
local glyphcodes = nodes.glyphcodes
-local gluecodes = nodes.gluecodes
+local leadercodes = nodes.leadercodes
local margincodes = nodes.margincodes
local disccodes = nodes.disccodes
local mathcodes = nodes.mathcodes
@@ -278,9 +326,9 @@ local marginkern_code = nodecodes.marginkern
local dir_code = nodecodes.dir
local boundary_code = nodecodes.boundary
-local protrusion_code = boundarycodes.protrusion
+local protrusionboundary_code = boundarycodes.protrusion
-local leaders_code = gluecodes.leaders
+local leaders_code = leadercodes.leaders
local localpar_code = nodecodes.localpar
@@ -289,17 +337,17 @@ local italickern_code = kerncodes.italiccorrection
local fontkern_code = kerncodes.fontkern
local accentkern_code = kerncodes.accentkern
-local ligature_code = glyphcodes.ligature
+local ligatureglyph_code = glyphcodes.ligature
-local stretch_orders = nodes.fillcodes
+local fillcodes = nodes.fillcodes
local leftmargin_code = margincodes.left
----- rightmargin_code = margincodes.right
-local automatic_disc_code = disccodes.automatic
-local regular_disc_code = disccodes.regular
-local first_disc_code = disccodes.first
-local second_disc_code = disccodes.second
+local automaticdisc_code = disccodes.automatic
+local regulardisc_code = disccodes.regular
+local firstdisc_code = disccodes.first
+local seconddisc_code = disccodes.second
local endmath_code = mathcodes.endmath
@@ -325,7 +373,7 @@ local fit_decent_class = 2 -- fitness for all other lines
local fit_tight_class = 3 -- fitness for lines shrinking 0.5 to 1.0 of their shrinkability
local new_penalty = nodepool.penalty
-local new_dir = nodepool.textdir
+local new_direction = nodepool.direction
local new_leftmarginkern = nodepool.leftmarginkern
local new_rightmarginkern = nodepool.rightmarginkern
local new_leftskip = nodepool.leftskip
@@ -336,17 +384,6 @@ local new_temp = nodepool.temp
local new_rule = nodepool.rule
local new_hlist = nodepool.hlist
-local is_rotated = nodes.is_rotated
-local is_parallel = nodes.textdir_is_parallel
-local is_opposite = nodes.textdir_is_opposite
-local textdir_is_equal = nodes.textdir_is_equal
-local pardir_is_equal = nodes.pardir_is_equal
-local glyphdir_is_equal = nodes.glyphdir_is_equal
-
-local dir_pops = nodes.dir_is_pop
-local dir_negations = nodes.dir_negation
-local is_skipable = nuts.protrusion_skippable
-
-- helpers --
-- It makes more sense to move the somewhat messy dir state tracking
@@ -361,22 +398,24 @@ end
-- in the parbuilder.
local function checked_line_dir(stack,current)
- if not dir_pops[current] then
+ local direction, pop = getdirection(current)
+ if not pop then
local n = stack.n + 1
stack.n = n
stack[n] = current
- return getdir(current)
+ return direction
elseif n > 0 then
local n = stack.n
local dirnode = stack[n]
dirstack.n = n - 1
- return getdir(dirnode)
+ direction = getdirection(dirnode) -- we could save it
+ return direction
else
report_parbuilders("warning: missing pop node (%a)",1) -- in line ...
end
end
--- The next function checks a dir nodes in a list and appends the negations
+-- The next function checks dir nodes in a list and appends the negations
-- that are currently needed (some day LuaTeX will be more tolerant). We use
-- the negations for the next line.
@@ -384,10 +423,12 @@ local function inject_dirs_at_end_of_line(stack,current,start,stop)
local e = start
local n = stack.n
local h = nil
+ -- todo: traverse
while start and start ~= stop do
local id = getid(start)
if id == dir_code then
- if not dir_pops[getdir(start)] then -- weird, what is this #
+ local direction, pop = getdirection(start)
+ if not pop then
n = n + 1
stack[n] = start
elseif n > 0 then
@@ -399,7 +440,7 @@ local function inject_dirs_at_end_of_line(stack,current,start,stop)
start = getnext(start)
end
for i=n,1,-1 do
- h, current = insert_node_after(current,current,new_dir(dir_negations[getdir(stack[i])]))
+ h, current = insert_node_after(current,current,new_direction(getdirection(stack[i]),true))
end
stack.n = n
return current
@@ -408,7 +449,7 @@ end
local function inject_dirs_at_begin_of_line(stack,current)
local h = nil
for i=stack.n,1,-1 do
- h, current = insert_node_after(current,current,new_dir(stack[i]))
+ h, current = insert_node_after(current,current,new_direction(stack[i]))
end
stack.n = 0
return current
@@ -632,7 +673,7 @@ local function find(head) -- do we really want to recurse into an hlist?
head = getnext(head)
end
elseif id == boundary_code then
- if getsubtype(head) == protrusion_code then
+ if getsubtype(head) == protrusionboundary_code then
local v = getdata(head)
if v == 1 or v == 3 then
head = getnext(head)
@@ -686,7 +727,7 @@ local function find(head,tail)
tail = getprev(tail)
end
elseif id == boundary_code then
- if getsubtype(head) == protrusion_code then
+ if getsubtype(head) == protrusionboundary_code then
local v = getdata(tail)
if v == 2 or v == 3 then
tail = getprev(tail)
@@ -750,7 +791,7 @@ local function add_to_width(line_break_dir,checked_expansion,s) -- split into tw
local char, id = isglyph(s)
if char then
local wd, ht, dp = getwhd(s)
- if is_rotated[line_break_dir] then -- can be shared
+ if is_rotated(line_break_dir) then
size = size + ht + dp
else
size = size + wd
@@ -767,7 +808,7 @@ local function add_to_width(line_break_dir,checked_expansion,s) -- split into tw
end
elseif id == hlist_code or id == vlist_code then
local wd, ht, dp = getwhd(s)
- if is_parallel[getdir(s)][line_break_dir] then
+ if textdir_parallel(getdirection(s),line_break_dir) then
size = size + wd
else
size = size + ht + dp
@@ -798,1707 +839,1710 @@ local function add_to_width(line_break_dir,checked_expansion,s) -- split into tw
return size, adjust_stretch, adjust_shrink
end
-local function compute_break_width(par,break_type,p) -- split in two
- local break_width = par.break_width
- if break_type > unhyphenated_code then
- local disc_width = par.disc_width
- local checked_expansion = par.checked_expansion
- local line_break_dir = par.line_break_dir
- local break_size = break_width.size + disc_width.size
- local break_adjust_stretch = break_width.adjust_stretch + disc_width.adjust_stretch
- local break_adjust_shrink = break_width.adjust_shrink + disc_width.adjust_shrink
- local pre, post, replace = getdisc(p)
- if replace then
- local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,replace)
- break_size = break_size - size
- break_adjust_stretch = break_adjust_stretch - adjust_stretch
- break_adjust_shrink = break_adjust_shrink - adjust_shrink
- end
- if post then
- local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,post)
- break_size = break_size + size
- break_adjust_stretch = break_adjust_stretch + adjust_stretch
- break_adjust_shrink = break_adjust_shrink + adjust_shrink
- end
- break_width.size = break_size
- break_width.adjust_stretch = break_adjust_stretch
- break_width.adjust_shrink = break_adjust_shrink
- if not post then
- p = getnext(p)
- else
- return
+-- We can actually make par local to this module as we never break inside a break call and that way the
+-- array is reused. At some point the information will be part of the paragraph spec as passed.
+
+local hztolerance = 2500
+local hzwarned = false
+
+do
+
+ local function compute_break_width(par,break_type,p) -- split in two
+ local break_width = par.break_width
+ if break_type > unhyphenated_code then
+ local disc_width = par.disc_width
+ local checked_expansion = par.checked_expansion
+ local line_break_dir = par.line_break_dir
+ local break_size = break_width.size + disc_width.size
+ local break_adjust_stretch = break_width.adjust_stretch + disc_width.adjust_stretch
+ local break_adjust_shrink = break_width.adjust_shrink + disc_width.adjust_shrink
+ local pre, post, replace = getdisc(p)
+ if replace then
+ local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,replace)
+ break_size = break_size - size
+ break_adjust_stretch = break_adjust_stretch - adjust_stretch
+ break_adjust_shrink = break_adjust_shrink - adjust_shrink
+ end
+ if post then
+ local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,post)
+ break_size = break_size + size
+ break_adjust_stretch = break_adjust_stretch + adjust_stretch
+ break_adjust_shrink = break_adjust_shrink + adjust_shrink
+ end
+ break_width.size = break_size
+ break_width.adjust_stretch = break_adjust_stretch
+ break_width.adjust_shrink = break_adjust_shrink
+ if not post then
+ p = getnext(p)
+ else
+ return
+ end
end
- end
- while p do -- skip spacing etc
- local id = getid(p)
- if id == glyph_code then
- return -- happens often
- elseif id == glue_code then
- local wd, stretch, shrink, stretch_order = getglue(p)
- local order = stretch_orders[stretch_order]
- break_width.size = break_width.size - wd
- break_width[order] = break_width[order] - stretch
- break_width.shrink = break_width.shrink - shrink
- elseif id == penalty_code then
- -- do nothing
- elseif id == kern_code then
- local s = getsubtype(p)
- if s == userkern_code or s == italickern_code then
- break_width.size = break_width.size - getkern(p)
+ while p do -- skip spacing etc
+ local id = getid(p)
+ if id == glyph_code then
+ return -- happens often
+ elseif id == glue_code then
+ local wd, stretch, shrink, stretch_order = getglue(p)
+ local order = fillcodes[stretch_order]
+ break_width.size = break_width.size - wd
+ break_width[order] = break_width[order] - stretch
+ break_width.shrink = break_width.shrink - shrink
+ elseif id == penalty_code then
+ -- do nothing
+ elseif id == kern_code then
+ local s = getsubtype(p)
+ if s == userkern_code or s == italickern_code then
+ break_width.size = break_width.size - getkern(p)
+ else
+ return
+ end
+ elseif id == math_code then
+ break_width.size = break_width.size - getkern(p) -- surround
+ -- new in luatex
+ local wd, stretch, shrink, stretch_order = getglue(p)
+ local order = fillcodes[stretch_order]
+ break_width.size = break_width.size - wd
+ break_width[order] = break_width[order] - stretch
+ break_width.shrink = break_width.shrink - shrink
else
return
end
- elseif id == math_code then
- break_width.size = break_width.size - getkern(p) -- surround
- -- new in luatex
- local wd, stretch, shrink, stretch_order = getglue(p)
- local order = stretch_orders[stretch_order]
- break_width.size = break_width.size - wd
- break_width[order] = break_width[order] - stretch
- break_width.shrink = break_width.shrink - shrink
- else
- return
+ p = getnext(p)
end
- p = getnext(p)
end
-end
-local function append_to_vlist(par, b)
- local prev_depth = par.prev_depth
- local head_field = par.head_field
- local tail_field = head_field and slide_node_list(head_field) -- todo: find_tail
- local is_hlist = getid(b) == hlist_code
- -- if prev_depth > par.ignored_dimen then
- if prev_depth > ignore_depth then
- if is_hlist then
- local width, stretch, shrink, stretch_order, shrink_order = getglue(par.baseline_skip)
- local delta = width - prev_depth - getheight(b) -- deficiency of space between baselines
- local skip = nil
- if delta < par.line_skip_limit then
- width, stretch, shrink, stretch_order, shrink_order = getglue(par.lineskip)
- skip = new_lineskip(width, stretch, shrink, stretch_order, shrink_order)
- else
- skip = new_baselineskip(delta, stretch, shrink, stretch_order, shrink_order)
- end
- if head_field then
- setlink(tail_field,skip)
- else
- par.head_field = skip
- head_field = skip
+ local function append_to_vlist(par, b)
+ local prev_depth = par.prev_depth
+ local head_field = par.head_field
+ local tail_field = head_field and slide_node_list(head_field) -- todo: find_tail
+ local is_hlist = getid(b) == hlist_code
+ -- if prev_depth > par.ignored_dimen then
+ if prev_depth > ignore_depth then
+ if is_hlist then
+ local width, stretch, shrink, stretch_order, shrink_order = getglue(par.baseline_skip)
+ local delta = width - prev_depth - getheight(b) -- deficiency of space between baselines
+ local skip = nil
+ if delta < par.line_skip_limit then
+ width, stretch, shrink, stretch_order, shrink_order = getglue(par.lineskip)
+ skip = new_lineskip(width, stretch, shrink, stretch_order, shrink_order)
+ else
+ skip = new_baselineskip(delta, stretch, shrink, stretch_order, shrink_order)
+ end
+ if head_field then
+ setlink(tail_field,skip)
+ else
+ par.head_field = skip
+ head_field = skip
+ end
+ tail_field = skip
end
- tail_field = skip
+ end
+ if head_field then
+ setlink(tail_field,b)
+ else
+ par.head_field = b
+ end
+ if is_hlist then
+ local pd = getdepth(b)
+ par.prev_depth = pd
+ texnest[texnest.ptr].prevdepth = pd
end
end
- if head_field then
- setlink(tail_field,b)
- else
- par.head_field = b
- end
- if is_hlist then
- local pd = getdepth(b)
- par.prev_depth = pd
- texnest[texnest.ptr].prevdepth = pd
- end
-end
-local function append_list(par, b)
- local head_field = par.head_field
- if head_field then
- local n = slide_node_list(head_field) -- todo: find_tail
- setlink(n,b)
- else
- par.head_field = b
- end
-end
-
--- We can actually make par local to this module as we never break inside a break call and that way the
--- array is reused. At some point the information will be part of the paragraph spec as passed.
-
-local hztolerance = 2500
-local hzwarned = false
-
-local function used_skip(s)
- return s and not is_zero_glue(s) and s
-end
-
-local function initialize_line_break(head,display)
-
- local hang_indent = tex.hangindent or 0
- local hsize = tex.hsize or 0
- local hang_after = tex.hangafter or 0
- local par_shape_ptr = tex.parshape
- local left_skip = tonut(tex.leftskip) -- nodes
- local right_skip = tonut(tex.rightskip) -- nodes
- local pretolerance = tex.pretolerance
- local tolerance = tex.tolerance
- local adjust_spacing = tex.adjustspacing
- local protrude_chars = tex.protrudechars
- local last_line_fit = tex.lastlinefit
-
- local newhead = new_temp()
- setnext(newhead,head)
-
- local adjust_spacing_status = adjust_spacing > 1 and -1 or 0
-
- -- metatables
-
- local par = {
- head = newhead,
- head_field = nil,
- display = display,
- font_in_short_display = 0,
- no_shrink_error_yet = true, -- have we complained about infinite shrinkage?
- second_pass = false, -- is this our second attempt to break this paragraph?
- final_pass = false, -- is this our final attempt to break this paragraph?
- threshold = 0, -- maximum badness on feasible lines
-
- passive = nil, -- most recent node on passive list
- printed_node = head, -- most recent node that has been printed
- pass_number = 0, -- the number of passive nodes allocated on this pass
- auto_breaking = 0, -- make auto_breaking accessible out of line_break
-
- active_width = { size = 0, stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0, adjust_stretch = 0, adjust_shrink = 0 },
- break_width = { size = 0, stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0, adjust_stretch = 0, adjust_shrink = 0 },
- disc_width = { size = 0, adjust_stretch = 0, adjust_shrink = 0 },
- fill_width = { stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0 },
- background = { size = 0, stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0 },
-
- hang_indent = hang_indent,
- hsize = hsize,
- hang_after = hang_after,
- par_shape_ptr = par_shape_ptr,
- left_skip = left_skip,
- right_skip = right_skip,
- pretolerance = pretolerance,
- tolerance = tolerance,
-
- protrude_chars = protrude_chars,
- adjust_spacing = adjust_spacing,
- max_stretch_ratio = adjust_spacing_status,
- max_shrink_ratio = adjust_spacing_status,
- cur_font_step = adjust_spacing_status,
- checked_expansion = false,
- tracing_paragraphs = tex.tracingparagraphs > 0,
-
- emergency_stretch = tex.emergencystretch or 0,
- looseness = tex.looseness or 0,
- line_penalty = tex.linepenalty or 0,
- hyphen_penalty = tex.hyphenpenalty or 0,
- broken_penalty = tex.brokenpenalty or 0,
- inter_line_penalty = tex.interlinepenalty or 0,
- club_penalty = tex.clubpenalty or 0,
- widow_penalty = tex.widowpenalty or 0,
- display_widow_penalty = tex.displaywidowpenalty or 0,
- ex_hyphen_penalty = tex.exhyphenpenalty or 0,
-
- adj_demerits = tex.adjdemerits or 0,
- double_hyphen_demerits = tex.doublehyphendemerits or 0,
- final_hyphen_demerits = tex.finalhyphendemerits or 0,
-
- first_line = 0, -- texnest[texnest.ptr].modeline, -- 0, -- cur_list.pg_field
-
- -- each_line_height = tex.pdfeachlineheight or 0, -- this will go away
- -- each_line_depth = tex.pdfeachlinedepth or 0, -- this will go away
- -- first_line_height = tex.pdffirstlineheight or 0, -- this will go away
- -- last_line_depth = tex.pdflastlinedepth or 0, -- this will go away
-
- -- ignored_dimen = tex.pdfignoreddimen or 0,
-
- baseline_skip = tonut(tex.baselineskip),
- lineskip = tonut(tex.lineskip),
- line_skip_limit = tex.lineskiplimit,
-
- prev_depth = texnest[texnest.ptr].prevdepth,
-
- final_par_glue = slide_node_list(head), -- todo: we know tail already, slow
-
- par_break_dir = tex.pardir,
- line_break_dir = tex.pardir,
-
- internal_pen_inter = 0, -- running localinterlinepenalty
- internal_pen_broken = 0, -- running localbrokenpenalty
- internal_left_box = nil, -- running localleftbox
- internal_left_box_width = 0, -- running localleftbox width
- init_internal_left_box = nil, -- running localleftbox
- init_internal_left_box_width = 0, -- running localleftbox width
- internal_right_box = nil, -- running localrightbox
- internal_right_box_width = 0, -- running localrightbox width
-
- best_place = { }, -- how to achieve minimal_demerits
- best_pl_line = { }, -- corresponding line number
- easy_line = 0, -- line numbers easy_line are equivalent in break nodes
- last_special_line = 0, -- line numbers last_special_line all have the same width
- first_width = 0, -- the width of all lines last_special_line, if no parshape has been specified
- second_width = 0, -- the width of all lines last_special_line
- first_indent = 0, -- left margin to go with first_width
- second_indent = 0, -- left margin to go with second_width
-
- best_bet = nil, -- use this passive node and its predecessors
- fewest_demerits = 0, -- the demerits associated with best_bet
- best_line = 0, -- line number following the last line of the new paragraph
- line_diff = 0, -- the difference between the current line number and the optimum best_line
-
- -- not yet used
-
- best_pl_short = { }, -- shortfall corresponding to minimal_demerits
- best_pl_glue = { }, -- corresponding glue stretch or shrink
- do_last_line_fit = false,
- last_line_fit = last_line_fit,
-
- minimum_demerits = awful_badness,
-
- minimal_demerits = {
-
- [fit_very_loose_class] = awful_badness,
- [fit_loose_class] = awful_badness,
- [fit_decent_class] = awful_badness,
- [fit_tight_class] = awful_badness,
-
- },
-
- prev_char_p = nil,
-
- statistics = {
-
- noflines = 0,
- nofprotrudedlines = 0,
- nofadjustedlines = 0,
-
- },
-
- -- -- just a thought ... parshape functions ... it would be nice to
- -- -- also store the height so far (probably not too hard) although
- -- -- in most cases we work on grids in such cases
- --
- -- adapt_width = function(par,line)
- -- -- carry attribute, so that we can accumulate
- -- local left = 655360 * (line - 1)
- -- local right = 655360 * (line - 1)
- -- return left, right
- -- end
+ local function append_list(par, b)
+ local head_field = par.head_field
+ if head_field then
+ local n = slide_node_list(head_field) -- todo: find_tail
+ setlink(n,b)
+ else
+ par.head_field = b
+ end
+ end
+
+ local function used_skip(s)
+ return s and not is_zero_glue(s) and s
+ end
+
+ local function initialize_line_break(head,display)
+
+ local hang_indent = tex.hangindent or 0
+ local hsize = tex.hsize or 0
+ local hang_after = tex.hangafter or 0
+ local par_shape_ptr = tex.parshape
+ local left_skip = tonut(tex.leftskip) -- nodes
+ local right_skip = tonut(tex.rightskip) -- nodes
+ local pretolerance = tex.pretolerance
+ local tolerance = tex.tolerance
+ local adjust_spacing = tex.adjustspacing
+ local protrude_chars = tex.protrudechars
+ local last_line_fit = tex.lastlinefit
+ local par_dir = tex.pardirection
+
+ local newhead = new_temp()
+ setnext(newhead,head)
+
+ local adjust_spacing_status = adjust_spacing > 1 and -1 or 0
+
+ -- metatables
+
+ local par = {
+ head = newhead,
+ head_field = nil,
+ display = display,
+ font_in_short_display = 0,
+ no_shrink_error_yet = true, -- have we complained about infinite shrinkage?
+ second_pass = false, -- is this our second attempt to break this paragraph?
+ final_pass = false, -- is this our final attempt to break this paragraph?
+ threshold = 0, -- maximum badness on feasible lines
+
+ passive = nil, -- most recent node on passive list
+ printed_node = head, -- most recent node that has been printed
+ pass_number = 0, -- the number of passive nodes allocated on this pass
+ auto_breaking = 0, -- make auto_breaking accessible out of line_break
+
+ active_width = { size = 0, stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0, adjust_stretch = 0, adjust_shrink = 0 },
+ break_width = { size = 0, stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0, adjust_stretch = 0, adjust_shrink = 0 },
+ disc_width = { size = 0, adjust_stretch = 0, adjust_shrink = 0 },
+ fill_width = { stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0 },
+ background = { size = 0, stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0 },
+
+ hang_indent = hang_indent,
+ hsize = hsize,
+ hang_after = hang_after,
+ par_shape_ptr = par_shape_ptr,
+ left_skip = left_skip,
+ right_skip = right_skip,
+ pretolerance = pretolerance,
+ tolerance = tolerance,
+
+ protrude_chars = protrude_chars,
+ adjust_spacing = adjust_spacing,
+ max_stretch_ratio = adjust_spacing_status,
+ max_shrink_ratio = adjust_spacing_status,
+ cur_font_step = adjust_spacing_status,
+ checked_expansion = false,
+ tracing_paragraphs = tex.tracingparagraphs > 0,
+
+ emergency_stretch = tex.emergencystretch or 0,
+ looseness = tex.looseness or 0,
+ line_penalty = tex.linepenalty or 0,
+ hyphen_penalty = tex.hyphenpenalty or 0,
+ broken_penalty = tex.brokenpenalty or 0,
+ inter_line_penalty = tex.interlinepenalty or 0,
+ club_penalty = tex.clubpenalty or 0,
+ widow_penalty = tex.widowpenalty or 0,
+ display_widow_penalty = tex.displaywidowpenalty or 0,
+ ex_hyphen_penalty = tex.exhyphenpenalty or 0,
+
+ adj_demerits = tex.adjdemerits or 0,
+ double_hyphen_demerits = tex.doublehyphendemerits or 0,
+ final_hyphen_demerits = tex.finalhyphendemerits or 0,
+
+ first_line = 0, -- texnest[texnest.ptr].modeline, -- 0, -- cur_list.pg_field
+
+ -- each_line_height = tex.pdfeachlineheight or 0, -- this will go away
+ -- each_line_depth = tex.pdfeachlinedepth or 0, -- this will go away
+ -- first_line_height = tex.pdffirstlineheight or 0, -- this will go away
+ -- last_line_depth = tex.pdflastlinedepth or 0, -- this will go away
+
+ -- ignored_dimen = tex.pdfignoreddimen or 0,
+
+ baseline_skip = tonut(tex.baselineskip),
+ lineskip = tonut(tex.lineskip),
+ line_skip_limit = tex.lineskiplimit,
+
+ prev_depth = texnest[texnest.ptr].prevdepth,
+
+ final_par_glue = slide_node_list(head), -- todo: we know tail already, slow
+
+ par_break_dir = par_dir,
+ line_break_dir = par_dir,
+
+ internal_pen_inter = 0, -- running localinterlinepenalty
+ internal_pen_broken = 0, -- running localbrokenpenalty
+ internal_left_box = nil, -- running localleftbox
+ internal_left_box_width = 0, -- running localleftbox width
+ init_internal_left_box = nil, -- running localleftbox
+ init_internal_left_box_width = 0, -- running localleftbox width
+ internal_right_box = nil, -- running localrightbox
+ internal_right_box_width = 0, -- running localrightbox width
+
+ best_place = { }, -- how to achieve minimal_demerits
+ best_pl_line = { }, -- corresponding line number
+ easy_line = 0, -- line numbers easy_line are equivalent in break nodes
+ last_special_line = 0, -- line numbers last_special_line all have the same width
+ first_width = 0, -- the width of all lines last_special_line, if no parshape has been specified
+ second_width = 0, -- the width of all lines last_special_line
+ first_indent = 0, -- left margin to go with first_width
+ second_indent = 0, -- left margin to go with second_width
+
+ best_bet = nil, -- use this passive node and its predecessors
+ fewest_demerits = 0, -- the demerits associated with best_bet
+ best_line = 0, -- line number following the last line of the new paragraph
+ line_diff = 0, -- the difference between the current line number and the optimum best_line
+
+ -- not yet used
+
+ best_pl_short = { }, -- shortfall corresponding to minimal_demerits
+ best_pl_glue = { }, -- corresponding glue stretch or shrink
+ do_last_line_fit = false,
+ last_line_fit = last_line_fit,
+
+ minimum_demerits = awful_badness,
+
+ minimal_demerits = {
+
+ [fit_very_loose_class] = awful_badness,
+ [fit_loose_class] = awful_badness,
+ [fit_decent_class] = awful_badness,
+ [fit_tight_class] = awful_badness,
+
+ },
+
+ prev_char_p = nil,
+
+ statistics = {
+
+ noflines = 0,
+ nofprotrudedlines = 0,
+ nofadjustedlines = 0,
+
+ },
+
+ -- -- just a thought ... parshape functions ... it would be nice to
+ -- -- also store the height so far (probably not too hard) although
+ -- -- in most cases we work on grids in such cases
+ --
+ -- adapt_width = function(par,line)
+ -- -- carry attribute, so that we can accumulate
+ -- local left = 655360 * (line - 1)
+ -- local right = 655360 * (line - 1)
+ -- return left, right
+ -- end
- }
+ }
- -- optimizers
+ -- optimizers
- par.used_left_skip = used_skip(par.left_skip)
- par.used_right_skip = used_skip(par.right_skip)
+ par.used_left_skip = used_skip(par.left_skip)
+ par.used_right_skip = used_skip(par.right_skip)
- -- so far
+ -- so far
- if adjust_spacing > 1 then
- local checked_expansion = { par = par }
- setmetatableindex(checked_expansion,check_expand_pars)
- par.checked_expansion = checked_expansion
+ if adjust_spacing > 1 then
+ local checked_expansion = { par = par }
+ setmetatableindex(checked_expansion,check_expand_pars)
+ par.checked_expansion = checked_expansion
- if par.tolerance < hztolerance then
- if not hzwarned then
- report_parbuilders("setting tolerance to %a for hz",hztolerance)
- hzwarned = true
+ if par.tolerance < hztolerance then
+ if not hzwarned then
+ report_parbuilders("setting tolerance to %a for hz",hztolerance)
+ hzwarned = true
+ end
+ par.tolerance = hztolerance
end
- par.tolerance = hztolerance
- end
- expand_kerns = expand_kerns_mode or (adjust_spacing == 2)
+ expand_kerns = expand_kerns_mode or (adjust_spacing == 2)
- end
+ end
- -- we need par for the error message
+ -- we need par for the error message
- local background = par.background
+ local background = par.background
- local l = check_shrinkage(par,left_skip)
- local r = check_shrinkage(par,right_skip)
+ local l = check_shrinkage(par,left_skip)
+ local r = check_shrinkage(par,right_skip)
- local lwidth, lstretch, lshrink, lstretch_order, lshrink_order = getglue(l)
- local rwidth, rstretch, rshrink, rstretch_order, rshrink_order = getglue(r)
+ local lwidth, lstretch, lshrink, lstretch_order, lshrink_order = getglue(l)
+ local rwidth, rstretch, rshrink, rstretch_order, rshrink_order = getglue(r)
- local l_order = stretch_orders[lstretch_order]
- local r_order = stretch_orders[rstretch_order]
+ local l_order = fillcodes[lstretch_order]
+ local r_order = fillcodes[rstretch_order]
- background.size = lwidth + rwidth
- background.shrink = lshrink + rshrink
- background[l_order] = lstretch
- background[r_order] = rstretch + background[r_order]
+ background.size = lwidth + rwidth
+ background.shrink = lshrink + rshrink
+ background[l_order] = lstretch
+ background[r_order] = rstretch + background[r_order]
- -- this will move up so that we can assign the whole par table
+ -- this will move up so that we can assign the whole par table
- if not par_shape_ptr then
- if hang_indent == 0 then
- par.second_width = hsize
- par.second_indent = 0
- else
- local abs_hang_after = hang_after >0 and hang_after or -hang_after
- local abs_hang_indent = hang_indent>0 and hang_indent or -hang_indent
- par.last_special_line = abs_hang_after
- if hang_after < 0 then
- par.first_width = hsize - abs_hang_indent
- if hang_indent >= 0 then
- par.first_indent = hang_indent
- else
- par.first_indent = 0
- end
+ if not par_shape_ptr then
+ if hang_indent == 0 then
par.second_width = hsize
par.second_indent = 0
else
- par.first_width = hsize
- par.first_indent = 0
- par.second_width = hsize - abs_hang_indent
- if hang_indent >= 0 then
- par.second_indent = hang_indent
- else
+ local abs_hang_after = hang_after >0 and hang_after or -hang_after
+ local abs_hang_indent = hang_indent>0 and hang_indent or -hang_indent
+ par.last_special_line = abs_hang_after
+ if hang_after < 0 then
+ par.first_width = hsize - abs_hang_indent
+ if hang_indent >= 0 then
+ par.first_indent = hang_indent
+ else
+ par.first_indent = 0
+ end
+ par.second_width = hsize
par.second_indent = 0
+ else
+ par.first_width = hsize
+ par.first_indent = 0
+ par.second_width = hsize - abs_hang_indent
+ if hang_indent >= 0 then
+ par.second_indent = hang_indent
+ else
+ par.second_indent = 0
+ end
end
end
+ else
+ local last_special_line = #par_shape_ptr
+ par.last_special_line = last_special_line
+ local parshape = par_shape_ptr[last_special_line]
+ par.second_width = parshape[2]
+ par.second_indent = parshape[1]
end
- else
- local last_special_line = #par_shape_ptr
- par.last_special_line = last_special_line
- local parshape = par_shape_ptr[last_special_line]
- par.second_width = parshape[2]
- par.second_indent = parshape[1]
- end
- if par.looseness == 0 then
- par.easy_line = par.last_special_line
- else
- par.easy_line = max_halfword
- end
+ if par.looseness == 0 then
+ par.easy_line = par.last_special_line
+ else
+ par.easy_line = max_halfword
+ end
- if pretolerance >= 0 then
- par.threshold = pretolerance
- par.second_pass = false
- par.final_pass = false
- else
- par.threshold = tolerance
- par.second_pass = true
- par.final_pass = par.emergency_stretch <= 0
- if trace_basic then
- if par.final_pass then
- report_parbuilders("enabling second and final pass")
- else
- report_parbuilders("enabling second pass")
+ if pretolerance >= 0 then
+ par.threshold = pretolerance
+ par.second_pass = false
+ par.final_pass = false
+ else
+ par.threshold = tolerance
+ par.second_pass = true
+ par.final_pass = par.emergency_stretch <= 0
+ if trace_basic then
+ if par.final_pass then
+ report_parbuilders("enabling second and final pass")
+ else
+ report_parbuilders("enabling second pass")
+ end
end
end
- end
- if last_line_fit > 0 then
- local final_par_glue = par.final_par_glue
- local stretch = getfield(final_par_glue,"stretch")
- local stretch_order = getfield(final_par_glue,"stretch_order")
- if stretch > 0 and stretch_order > 0 and background.fi == 0 and background.fil == 0 and background.fill == 0 and background.filll == 0 then
- par.do_last_line_fit = true
- local si = stretch_orders[stretch_order]
- if trace_lastlinefit or trace_basic then
- report_parbuilders("enabling last line fit, stretch order %a set to %a, linefit is %a",si,stretch,last_line_fit)
+ if last_line_fit > 0 then
+ local final_par_glue = par.final_par_glue
+ local stretch = getfield(final_par_glue,"stretch")
+ local stretch_order = getfield(final_par_glue,"stretch_order")
+ if stretch > 0 and stretch_order > 0 and background.fi == 0 and background.fil == 0 and background.fill == 0 and background.filll == 0 then
+ par.do_last_line_fit = true
+ local si = fillcodes[stretch_order]
+ if trace_lastlinefit or trace_basic then
+ report_parbuilders("enabling last line fit, stretch order %a set to %a, linefit is %a",si,stretch,last_line_fit)
+ end
+ par.fill_width[si] = stretch
end
- par.fill_width[si] = stretch
end
- end
- return par
-end
+ return par
+ end
--- there are still all kind of artefacts in here (a side effect I guess of pdftex,
--- etex, omega and other extensions that got obscured by patching)
+ -- there are still all kind of artefacts in here (a side effect I guess of pdftex,
+ -- etex, omega and other extensions that got obscured by patching)
-local function post_line_break(par)
+ local function post_line_break(par)
- local prevgraf = texnest[texnest.ptr].prevgraf
- local current_line = prevgraf + 1 -- the current line number being justified
+ local prevgraf = texnest[texnest.ptr].prevgraf
+ local current_line = prevgraf + 1 -- the current line number being justified
- local adjust_spacing = par.adjust_spacing
- local protrude_chars = par.protrude_chars
- local statistics = par.statistics
+ local adjust_spacing = par.adjust_spacing
+ local protrude_chars = par.protrude_chars
+ local statistics = par.statistics
- local stack = new_dir_stack()
+ local stack = new_dir_stack()
- local leftskip = par.used_left_skip -- used or normal ?
- local rightskip = par.right_skip
- local parshape = par.par_shape_ptr
- ----- ignored_dimen = par.ignored_dimen
+ local leftskip = par.used_left_skip -- used or normal ?
+ local rightskip = par.right_skip
+ local parshape = par.par_shape_ptr
+ ----- ignored_dimen = par.ignored_dimen
- local adapt_width = par.adapt_width
+ local adapt_width = par.adapt_width
- -- reverse the links of the relevant passive nodes, goto first breakpoint
+ -- reverse the links of the relevant passive nodes, goto first breakpoint
- local current_break = nil
+ local current_break = nil
- local break_node = par.best_bet.break_node
- repeat
- local first_break = break_node
- break_node = break_node.prev_break
- first_break.prev_break = current_break
- current_break = first_break
- until not break_node
+ local break_node = par.best_bet.break_node
+ repeat
+ local first_break = break_node
+ break_node = break_node.prev_break
+ first_break.prev_break = current_break
+ current_break = first_break
+ until not break_node
- local head = par.head
+ local head = par.head
- -- maybe : each_...
+ -- maybe : each_...
- while current_break do
+ while current_break do
- inject_dirs_at_begin_of_line(stack,head)
+ inject_dirs_at_begin_of_line(stack,head)
- local disc_break = false
- local post_disc_break = false
- local glue_break = false
+ local disc_break = false
+ local post_disc_break = false
+ local glue_break = false
- local lineend = nil -- q lineend refers to the last node of the line (and paragraph)
- local lastnode = current_break.cur_break -- r lastnode refers to the node after which the dir nodes should be closed
+ local lineend = nil -- lineend : the last node of the line (and paragraph)
+ local lastnode = current_break.cur_break -- lastnode: the node after which the dir nodes should be closed
- if not lastnode then
- -- only at the end
- lastnode = slide_node_list(head) -- todo: find_tail
- if lastnode == par.final_par_glue then
- lineend = lastnode
- lastnode = getprev(lastnode)
- end
- else -- todo: use insert_list_after
- local id = getid(lastnode)
- if id == glue_code then
- -- lastnode is normal skip
- lastnode = replace_node(lastnode,new_rightskip(rightskip))
- glue_break = true
- lineend = lastnode
- lastnode = getprev(lastnode)
- elseif id == disc_code then
- local prevlast = getprev(lastnode)
- local nextlast = getnext(lastnode)
- local subtype = getsubtype(lastnode)
- local pre, post, replace, pretail, posttail, replacetail = getdisc(lastnode,true)
- if subtype == second_disc_code then
- if not (getid(prevlast) == disc_code and getsubtype(prevlast) == first_disc_code) then
- report_parbuilders('unsupported disc at location %a',3)
- end
- if pre then
- flush_node_list(pre)
- pre = nil -- signal
+ if not lastnode then
+ -- only at the end
+ lastnode = slide_node_list(head) -- todo: find_tail
+ if lastnode == par.final_par_glue then
+ lineend = lastnode
+ lastnode = getprev(lastnode)
+ end
+ else -- todo: use insert_list_after
+ local id = getid(lastnode)
+ if id == glue_code then
+ -- lastnode is normal skip
+ lastnode = replace_node(lastnode,new_rightskip(rightskip))
+ glue_break = true
+ lineend = lastnode
+ lastnode = getprev(lastnode)
+ elseif id == disc_code then
+ local prevlast = getprev(lastnode)
+ local nextlast = getnext(lastnode)
+ local subtype = getsubtype(lastnode)
+ local pre, post, replace, pretail, posttail, replacetail = getdisc(lastnode,true)
+ if subtype == seconddisc_code then
+ if not (getid(prevlast) == disc_code and getsubtype(prevlast) == firstdisc_code) then
+ report_parbuilders('unsupported disc at location %a',3)
+ end
+ if pre then
+ flush_node_list(pre)
+ pre = nil -- signal
+ end
+ if replace then
+ setlink(prevlast,replace)
+ setlink(replacetail,lastnode)
+ replace = nil -- signal
+ end
+ setdisc(lastnode,pre,post,replace)
+ local pre, post, replace = getdisc(prevlast)
+ if pre then
+ flush_node_list(pre)
+ end
+ if replace then
+ flush_node_list(replace)
+ end
+ if post then
+ flush_node_list(post)
+ end
+ setdisc(prevlast) -- nil,nil,nil
+ elseif subtype == firstdisc_code then
+ -- what is v ... next probably
+ if not (getid(v) == disc_code and getsubtype(v) == seconddisc_code) then
+ report_parbuilders('unsupported disc at location %a',4)
+ end
+ setsubtype(nextlast,regulardisc_code)
+ setfield(nextlast,"replace",post)
+ setfield(lastnode,"post") -- nil
end
if replace then
- setlink(prevlast,replace)
- setlink(replacetail,lastnode)
- replace = nil -- signal
+ flush_node_list(replace)
end
- setdisc(lastnode,pre,post,replace)
- local pre, post, replace = getdisc(prevlast)
if pre then
- flush_node_list(pre)
- end
- if replace then
- flush_node_list(replace)
+ setlink(prevlast,pre)
+ setlink(pretail,lastnode)
end
if post then
- flush_node_list(post)
- end
- setdisc(prevlast) -- nil,nil,nil
- elseif subtype == first_disc_code then
- -- what is v ... next probably
- if not (getid(v) == disc_code and getsubtype(v) == second_disc_code) then
- report_parbuilders('unsupported disc at location %a',4)
+ setlink(lastnode,post)
+ setlink(posttail,nextlast)
+ post_disc_break = true
end
- setsubtype(nextlast,regular_disc_code)
- setfield(nextlast,"replace",post)
- setfield(lastnode,"post") -- nil
- end
- if replace then
- flush_node_list(replace)
+ setdisc(lastnode) -- nil, nil, nil
+ disc_break = true
+ elseif id == kern_code then
+ setkern(lastnode,0)
+ elseif getid(lastnode) == math_code then
+ setkern(lastnode,0) -- surround
+ -- new in luatex
+ setglue(lastnode) -- zeros
end
- if pre then
- setlink(prevlast,pre)
- setlink(pretail,lastnode)
+ end
+ lastnode = inject_dirs_at_end_of_line(stack,lastnode,getnext(head),current_break.cur_break)
+ local rightbox = current_break.passive_right_box
+ if rightbox then
+ lastnode = insert_node_after(lastnode,lastnode,copy_node(rightbox))
+ end
+ if not lineend then
+ lineend = lastnode
+ end
+ if lineend and lineend ~= head and protrude_chars > 0 then
+ local id = getid(lineend)
+ local c = (disc_break and (id == glyph_code or id ~= disc_code) and lineend) or getprev(lineend)
+ local p = find_protchar_right(getnext(head),c)
+ if p and getid(p) == glyph_code then
+ local w, last_rightmost_char = right_pw(p)
+ if last_rightmost_char and w ~= 0 then
+ -- so we inherit attributes, lineend is new pseudo head
+ lineend, c = insert_node_after(lineend,c,new_rightmarginkern(copy_node(last_rightmost_char),-w))
+ end
end
- if post then
- setlink(lastnode,post)
- setlink(posttail,nextlast)
- post_disc_break = true
+ end
+ -- we finish the line
+ local r = getnext(lineend)
+ setnext(lineend)
+ if not glue_break then
+ if rightskip then
+ insert_node_after(lineend,lineend,new_rightskip(right_skip)) -- lineend moves on as pseudo head
end
- setdisc(lastnode) -- nil, nil, nil
- disc_break = true
- elseif id == kern_code then
- setkern(lastnode,0)
- elseif getid(lastnode) == math_code then
- setkern(lastnode,0) -- surround
- -- new in luatex
- setglue(lastnode) -- zeros
end
- end
- lastnode = inject_dirs_at_end_of_line(stack,lastnode,getnext(head),current_break.cur_break)
- local rightbox = current_break.passive_right_box
- if rightbox then
- lastnode = insert_node_after(lastnode,lastnode,copy_node(rightbox))
- end
- if not lineend then
- lineend = lastnode
- end
- if lineend and lineend ~= head and protrude_chars > 0 then
- local id = getid(lineend)
- local c = (disc_break and (id == glyph_code or id ~= disc_code) and lineend) or getprev(lineend)
- local p = find_protchar_right(getnext(head),c)
- if p and getid(p) == glyph_code then
- local w, last_rightmost_char = right_pw(p)
- if last_rightmost_char and w ~= 0 then
- -- so we inherit attributes, lineend is new pseudo head
- lineend, c = insert_node_after(lineend,c,new_rightmarginkern(copy_node(last_rightmost_char),-w))
+ -- each time ?
+ local q = getnext(head)
+ setlink(head,r)
+ -- insert leftbox (if needed after parindent)
+ local leftbox = current_break.passive_left_box
+ if leftbox then
+ local first = getnext(q)
+ if first and current_line == (par.first_line + 1) and getid(first) == hlist_code and not getlist(first) then
+ insert_node_after(q,q,copy_node(leftbox))
+ else
+ q = insert_node_before(q,q,copy_node(leftbox))
end
end
- end
- -- we finish the line
- local r = getnext(lineend)
- setnext(lineend)
- if not glue_break then
- if rightskip then
- insert_node_after(lineend,lineend,new_rightskip(right_skip)) -- lineend moves on as pseudo head
+ if protrude_chars > 0 then
+ local p = find_protchar_left(q)
+ if p and getid(p) == glyph_code then
+ local w, last_leftmost_char = left_pw(p)
+ if last_leftmost_char and w ~= 0 then
+ -- so we inherit attributes, q is pseudo head and moves back
+ q = insert_node_before(q,q,new_leftmarginkern(copy_node(last_leftmost_char),-w))
+ end
+ end
end
- end
- -- each time ?
- local q = getnext(head)
- setlink(head,r)
- -- insert leftbox (if needed after parindent)
- local leftbox = current_break.passive_left_box
- if leftbox then
- local first = getnext(q)
- if first and current_line == (par.first_line + 1) and getid(first) == hlist_code and not getlist(first) then
- insert_node_after(q,q,copy_node(leftbox))
+ if leftskip then
+ q = insert_node_before(q,q,new_leftskip(leftskip))
+ end
+ local cur_width, cur_indent
+ if current_line > par.last_special_line then
+ cur_indent = par.second_indent
+ cur_width = par.second_width
+ elseif parshape then
+ local shape = parshape[current_line]
+ cur_indent = shape[1]
+ cur_width = shape[2]
else
- q = insert_node_before(q,q,copy_node(leftbox))
- end
- end
- if protrude_chars > 0 then
- local p = find_protchar_left(q)
- if p and getid(p) == glyph_code then
- local w, last_leftmost_char = left_pw(p)
- if last_leftmost_char and w ~= 0 then
- -- so we inherit attributes, q is pseudo head and moves back
- q = insert_node_before(q,q,new_leftmarginkern(copy_node(last_leftmost_char),-w))
- end
+ cur_indent = par.first_indent
+ cur_width = par.first_width
end
- end
- if leftskip then
- q = insert_node_before(q,q,new_leftskip(leftskip))
- end
- local cur_width, cur_indent
- if current_line > par.last_special_line then
- cur_indent = par.second_indent
- cur_width = par.second_width
- elseif parshape then
- local shape = parshape[current_line]
- cur_indent = shape[1]
- cur_width = shape[2]
- else
- cur_indent = par.first_indent
- cur_width = par.first_width
- end
- if adapt_width then -- extension
- local l, r = adapt_width(par,current_line)
- cur_indent = cur_indent + l
- cur_width = cur_width - l - r
- end
+ if adapt_width then -- extension
+ local l, r = adapt_width(par,current_line)
+ cur_indent = cur_indent + l
+ cur_width = cur_width - l - r
+ end
- statistics.noflines = statistics.noflines + 1
- local finished_line = nil
- if adjust_spacing > 0 then
- statistics.nofadjustedlines = statistics.nofadjustedlines + 1
- finished_line = xpack_nodes(q,cur_width,"cal_expand_ratio",par.par_break_dir,par.first_line,current_line) -- ,current_break.analysis)
- else
- finished_line = xpack_nodes(q,cur_width,"exactly",par.par_break_dir,par.first_line,current_line) -- ,current_break.analysis)
- end
- if protrude_chars > 0 then
- statistics.nofprotrudedlines = statistics.nofprotrudedlines + 1
- end
- -- wrong:
- local adjust_head = texlists.adjust_head
- local pre_adjust_head = texlists.pre_adjust_head
- --
- setshift(finished_line,cur_indent)
- --
- -- -- this is gone:
- --
- -- if par.each_line_height ~= ignored_dimen then
- -- setheight(finished_line,par.each_line_height)
- -- end
- -- if par.each_line_depth ~= ignored_dimen then
- -- setdepth(finished_line,par.each_line_depth)
- -- end
- -- if par.first_line_height ~= ignored_dimen and (current_line == par.first_line + 1) then
- -- setheight(finished_line,par.first_line_height)
- -- end
- -- if par.last_line_depth ~= ignored_dimen and current_line + 1 == par.best_line then
- -- setdepth(finished_line,par.last_line_depth)
- -- end
- --
- if texlists.pre_adjust_head ~= pre_adjust_head then
- append_list(par, texlists.pre_adjust_head)
- texlists.pre_adjust_head = pre_adjust_head
- end
- append_to_vlist(par,finished_line)
- if texlists.adjust_head ~= adjust_head then
- append_list(par, texlists.adjust_head)
- texlists.adjust_head = adjust_head
- end
- --
- local pen
- if current_line + 1 ~= par.best_line then
- if current_break.passive_pen_inter then
- pen = current_break.passive_pen_inter
+ statistics.noflines = statistics.noflines + 1
+ local finished_line = nil
+ if adjust_spacing > 0 then
+ statistics.nofadjustedlines = statistics.nofadjustedlines + 1
+ finished_line = xpack_nodes(q,cur_width,"cal_expand_ratio",par.par_break_dir,par.first_line,current_line) -- ,current_break.analysis)
else
- pen = par.inter_line_penalty
- end
- if current_line == prevgraf + 1 then
- pen = pen + par.club_penalty
- end
- if current_line + 2 == par.best_line then
- if par.display then
- pen = pen + par.display_widow_penalty
+ finished_line = xpack_nodes(q,cur_width,"exactly",par.par_break_dir,par.first_line,current_line) -- ,current_break.analysis)
+ end
+ if protrude_chars > 0 then
+ statistics.nofprotrudedlines = statistics.nofprotrudedlines + 1
+ end
+ -- wrong:
+ local adjust_head = texlists.adjust_head
+ local pre_adjust_head = texlists.pre_adjust_head
+ --
+ setshift(finished_line,cur_indent)
+ --
+ -- -- this is gone:
+ --
+ -- if par.each_line_height ~= ignored_dimen then
+ -- setheight(finished_line,par.each_line_height)
+ -- end
+ -- if par.each_line_depth ~= ignored_dimen then
+ -- setdepth(finished_line,par.each_line_depth)
+ -- end
+ -- if par.first_line_height ~= ignored_dimen and (current_line == par.first_line + 1) then
+ -- setheight(finished_line,par.first_line_height)
+ -- end
+ -- if par.last_line_depth ~= ignored_dimen and current_line + 1 == par.best_line then
+ -- setdepth(finished_line,par.last_line_depth)
+ -- end
+ --
+ if texlists.pre_adjust_head ~= pre_adjust_head then
+ append_list(par, texlists.pre_adjust_head)
+ texlists.pre_adjust_head = pre_adjust_head
+ end
+ append_to_vlist(par,finished_line)
+ if texlists.adjust_head ~= adjust_head then
+ append_list(par, texlists.adjust_head)
+ texlists.adjust_head = adjust_head
+ end
+ --
+ local pen
+ if current_line + 1 ~= par.best_line then
+ if current_break.passive_pen_inter then
+ pen = current_break.passive_pen_inter
else
- pen = pen + par.widow_penalty
+ pen = par.inter_line_penalty
end
- end
- if disc_break then
- if current_break.passive_pen_broken ~= 0 then
- pen = pen + current_break.passive_pen_broken
- else
- pen = pen + par.broken_penalty
+ if current_line == prevgraf + 1 then
+ pen = pen + par.club_penalty
end
- end
- if pen ~= 0 then
- append_to_vlist(par,new_penalty(pen))
- end
- end
- current_line = current_line + 1
- current_break = current_break.prev_break
- if current_break and not post_disc_break then
- local current = head
- local next = nil
- while true do
- next = getnext(current)
- if next == current_break.cur_break then
- break
+ if current_line + 2 == par.best_line then
+ if par.display then
+ pen = pen + par.display_widow_penalty
+ else
+ pen = pen + par.widow_penalty
+ end
end
- local id = getid(next)
- if id == glyph_code then
- break
- elseif id == localpar_code then
- -- nothing
- elseif id < math_code then
- -- messy criterium
- break
- elseif id == math_code then
- -- keep the math node
- setkern(next,0) -- surround
- -- new in luatex
- setglue(lastnode) -- zeros
- break
- elseif id == kern_code then
- local subtype = getsubtype(next)
- if subtype == fontkern_code or subtype == accentkern_code then
- -- fontkerns and accent kerns as well as otf injections
- break
+ if disc_break then
+ if current_break.passive_pen_broken ~= 0 then
+ pen = pen + current_break.passive_pen_broken
+ else
+ pen = pen + par.broken_penalty
end
end
- current = next
+ if pen ~= 0 then
+ append_to_vlist(par,new_penalty(pen))
+ end
end
- if current ~= head then
- setnext(current)
- flush_node_list(getnext(head))
- setlink(head,next)
+ current_line = current_line + 1
+ current_break = current_break.prev_break
+ if current_break and not post_disc_break then
+ local current = head
+ local next = nil
+ while true do
+ next = getnext(current)
+ if next == current_break.cur_break then
+ break
+ end
+ local id = getid(next)
+ if id == glyph_code then
+ break
+ elseif id == localpar_code then
+ -- nothing
+ elseif id < math_code then
+ -- messy criterium
+ break
+ elseif id == math_code then
+ -- keep the math node
+ setkern(next,0) -- surround
+ -- new in luatex
+ setglue(lastnode) -- zeros
+ break
+ elseif id == kern_code then
+ local subtype = getsubtype(next)
+ if subtype == fontkern_code or subtype == accentkern_code then
+ -- fontkerns and accent kerns as well as otf injections
+ break
+ end
+ end
+ current = next
+ end
+ if current ~= head then
+ setnext(current)
+ flush_node_list(getnext(head))
+ setlink(head,next)
+ end
end
end
- end
- -- if current_line ~= par.best_line then
- -- report_parbuilders("line breaking")
- -- end
- par.head = nil -- needs checking
- current_line = current_line - 1
- if trace_basic then
- report_parbuilders("paragraph broken into %a lines",current_line)
- end
- texnest[texnest.ptr].prevgraf = current_line
-end
-
-local function wrap_up(par)
- if par.tracing_paragraphs then
- diagnostics.stop()
- end
- if par.do_last_line_fit then
- local best_bet = par.best_bet
- local active_short = best_bet.active_short
- local active_glue = best_bet.active_glue
- if active_short == 0 then
- if trace_lastlinefit then
- report_parbuilders("disabling last line fit, no active_short")
- end
- par.do_last_line_fit = false
- else
- local glue = par.final_par_glue
- setwidth(glue,getwidth(glue) + active_short - active_glue)
- setfield(glue,"stretch",0)
- if trace_lastlinefit then
- report_parbuilders("applying last line fit, short %a, glue %p",active_short,active_glue)
- end
+ -- if current_line ~= par.best_line then
+ -- report_parbuilders("line breaking")
+ -- end
+ par.head = nil -- needs checking
+ current_line = current_line - 1
+ if trace_basic then
+ report_parbuilders("paragraph broken into %a lines",current_line)
end
+ texnest[texnest.ptr].prevgraf = current_line
end
- -- we have a bunch of glue and and temp nodes not freed
- local head = par.head
- if getid(head) == temp_code then
- par.head = getnext(head)
- flush_node(head)
- end
- post_line_break(par)
- reset_meta(par)
- register_statistics(par)
- return par.head_field
-end
--- we could do active nodes differently ... table instead of linked list or a list
--- with prev nodes but it doesn't save much (as we still need to keep indices then
--- in next)
-
-local function deactivate_node(par,prev_prev_r,prev_r,r,cur_active_width,checked_expansion) -- no need for adjust if disabled
- local active = par.active
- local active_width = par.active_width
- prev_r.next = r.next
- -- removes r
- -- r = nil
- if prev_r == active then
- r = active.next
- if r.id == delta_code then
- local aw = active_width.size + r.size active_width.size = aw cur_active_width.size = aw
- local aw = active_width.stretch + r.stretch active_width.stretch = aw cur_active_width.stretch = aw
- local aw = active_width.fi + r.fi active_width.fi = aw cur_active_width.fi = aw
- local aw = active_width.fil + r.fil active_width.fil = aw cur_active_width.fil = aw
- local aw = active_width.fill + r.fill active_width.fill = aw cur_active_width.fill = aw
- local aw = active_width.filll + r.filll active_width.filll = aw cur_active_width.filll = aw
- local aw = active_width.shrink + r.shrink active_width.shrink = aw cur_active_width.shrink = aw
- if checked_expansion then
- local aw = active_width.adjust_stretch + r.adjust_stretch active_width.adjust_stretch = aw cur_active_width.adjust_stretch = aw
- local aw = active_width.adjust_shrink + r.adjust_shrink active_width.adjust_shrink = aw cur_active_width.adjust_shrink = aw
- end
- active.next = r.next
- -- removes r
- -- r = nil
+ local function wrap_up(par)
+ if par.tracing_paragraphs then
+ diagnostics.stop()
end
- elseif prev_r.id == delta_code then
- r = prev_r.next
- if r == active then
- cur_active_width.size = cur_active_width.size - prev_r.size
- cur_active_width.stretch = cur_active_width.stretch - prev_r.stretch
- cur_active_width.fi = cur_active_width.fi - prev_r.fi
- cur_active_width.fil = cur_active_width.fil - prev_r.fil
- cur_active_width.fill = cur_active_width.fill - prev_r.fill
- cur_active_width.filll = cur_active_width.filll - prev_r.filll
- cur_active_width.shrink = cur_active_width.shrink - prev_r.shrink
- if checked_expansion then
- cur_active_width.adjust_stretch = cur_active_width.adjust_stretch - prev_r.adjust_stretch
- cur_active_width.adjust_shrink = cur_active_width.adjust_shrink - prev_r.adjust_shrink
+ if par.do_last_line_fit then
+ local best_bet = par.best_bet
+ local active_short = best_bet.active_short
+ local active_glue = best_bet.active_glue
+ if active_short == 0 then
+ if trace_lastlinefit then
+ report_parbuilders("disabling last line fit, no active_short")
+ end
+ par.do_last_line_fit = false
+ else
+ local glue = par.final_par_glue
+ setwidth(glue,getwidth(glue) + active_short - active_glue)
+ setfield(glue,"stretch",0)
+ if trace_lastlinefit then
+ report_parbuilders("applying last line fit, short %a, glue %p",active_short,active_glue)
+ end
end
- prev_prev_r.next = active
- -- removes prev_r
- -- prev_r = nil
- prev_r = prev_prev_r
- elseif r.id == delta_code then
- local rn = r.size cur_active_width.size = cur_active_width.size + rn prev_r.size = prev_r.size + rn
- local rn = r.stretch cur_active_width.stretch = cur_active_width.stretch + rn prev_r.stretch = prev_r.stretch + rn
- local rn = r.fi cur_active_width.fi = cur_active_width.fi + rn prev_r.fi = prev_r.fi + rn
- local rn = r.fil cur_active_width.fil = cur_active_width.fil + rn prev_r.fil = prev_r.fil + rn
- local rn = r.fill cur_active_width.fill = cur_active_width.fill + rn prev_r.fill = prev_r.fill + rn
- local rn = r.filll cur_active_width.filll = cur_active_width.filll + rn prev_r.filll = prev_r.fill + rn
- local rn = r.shrink cur_active_width.shrink = cur_active_width.shrink + rn prev_r.shrink = prev_r.shrink + rn
- if checked_expansion then
- local rn = r.adjust_stretch cur_active_width.adjust_stretch = cur_active_width.adjust_stretch + rn prev_r.adjust_stretch = prev_r.adjust_stretch + rn
- local rn = r.adjust_shrink cur_active_width.adjust_shrink = cur_active_width.adjust_shrink + rn prev_r.adjust_shrink = prev_r.adjust_shrink + rn
+ end
+ -- we have a bunch of glue and and temp nodes not freed
+ local head = par.head
+ if getid(head) == temp_code then
+ par.head = getnext(head)
+ flush_node(head)
+ end
+ post_line_break(par)
+ reset_meta(par)
+ register_statistics(par)
+ return par.head_field
+ end
+
+ -- we could do active nodes differently ... table instead of linked list or a list
+ -- with prev nodes but it doesn't save much (as we still need to keep indices then
+ -- in next)
+
+ local function deactivate_node(par,prev_prev_r,prev_r,r,cur_active_width,checked_expansion) -- no need for adjust if disabled
+ local active = par.active
+ local active_width = par.active_width
+ prev_r.next = r.next
+ -- removes r
+ -- r = nil
+ if prev_r == active then
+ r = active.next
+ if r.id == delta_code then
+ local aw = active_width.size + r.size active_width.size = aw cur_active_width.size = aw
+ local aw = active_width.stretch + r.stretch active_width.stretch = aw cur_active_width.stretch = aw
+ local aw = active_width.fi + r.fi active_width.fi = aw cur_active_width.fi = aw
+ local aw = active_width.fil + r.fil active_width.fil = aw cur_active_width.fil = aw
+ local aw = active_width.fill + r.fill active_width.fill = aw cur_active_width.fill = aw
+ local aw = active_width.filll + r.filll active_width.filll = aw cur_active_width.filll = aw
+ local aw = active_width.shrink + r.shrink active_width.shrink = aw cur_active_width.shrink = aw
+ if checked_expansion then
+ local aw = active_width.adjust_stretch + r.adjust_stretch active_width.adjust_stretch = aw cur_active_width.adjust_stretch = aw
+ local aw = active_width.adjust_shrink + r.adjust_shrink active_width.adjust_shrink = aw cur_active_width.adjust_shrink = aw
+ end
+ active.next = r.next
+ -- removes r
+ -- r = nil
+ end
+ elseif prev_r.id == delta_code then
+ r = prev_r.next
+ if r == active then
+ cur_active_width.size = cur_active_width.size - prev_r.size
+ cur_active_width.stretch = cur_active_width.stretch - prev_r.stretch
+ cur_active_width.fi = cur_active_width.fi - prev_r.fi
+ cur_active_width.fil = cur_active_width.fil - prev_r.fil
+ cur_active_width.fill = cur_active_width.fill - prev_r.fill
+ cur_active_width.filll = cur_active_width.filll - prev_r.filll
+ cur_active_width.shrink = cur_active_width.shrink - prev_r.shrink
+ if checked_expansion then
+ cur_active_width.adjust_stretch = cur_active_width.adjust_stretch - prev_r.adjust_stretch
+ cur_active_width.adjust_shrink = cur_active_width.adjust_shrink - prev_r.adjust_shrink
+ end
+ prev_prev_r.next = active
+ -- removes prev_r
+ -- prev_r = nil
+ prev_r = prev_prev_r
+ elseif r.id == delta_code then
+ local rn = r.size cur_active_width.size = cur_active_width.size + rn prev_r.size = prev_r.size + rn
+ local rn = r.stretch cur_active_width.stretch = cur_active_width.stretch + rn prev_r.stretch = prev_r.stretch + rn
+ local rn = r.fi cur_active_width.fi = cur_active_width.fi + rn prev_r.fi = prev_r.fi + rn
+ local rn = r.fil cur_active_width.fil = cur_active_width.fil + rn prev_r.fil = prev_r.fil + rn
+ local rn = r.fill cur_active_width.fill = cur_active_width.fill + rn prev_r.fill = prev_r.fill + rn
+ local rn = r.filll cur_active_width.filll = cur_active_width.filll + rn prev_r.filll = prev_r.fill + rn
+ local rn = r.shrink cur_active_width.shrink = cur_active_width.shrink + rn prev_r.shrink = prev_r.shrink + rn
+ if checked_expansion then
+ local rn = r.adjust_stretch cur_active_width.adjust_stretch = cur_active_width.adjust_stretch + rn prev_r.adjust_stretch = prev_r.adjust_stretch + rn
+ local rn = r.adjust_shrink cur_active_width.adjust_shrink = cur_active_width.adjust_shrink + rn prev_r.adjust_shrink = prev_r.adjust_shrink + rn
+ end
+ prev_r.next = r.next
+ -- removes r
+ -- r = nil
end
- prev_r.next = r.next
- -- removes r
- -- r = nil
end
+ return prev_r, r
end
- return prev_r, r
-end
-local function lastlinecrap(shortfall,active_short,active_glue,cur_active_width,fill_width,last_line_fit)
- if active_short == 0 or active_glue <= 0 then
- return false, 0, fit_decent_class, 0, 0
- end
- if cur_active_width.fi ~= fill_width.fi or cur_active_width.fil ~= fill_width.fil or cur_active_width.fill ~= fill_width.fill or cur_active_width.filll ~= fill_width.filll then
- return false, 0, fit_decent_class, 0, 0
- end
- local adjustment = active_short > 0 and cur_active_width.stretch or cur_active_width.shrink
- if adjustment <= 0 then
- return false, 0, fit_decent_class, adjustment, 0
- end
- adjustment = calculate_fraction(adjustment,active_short,active_glue,maxdimen)
- if last_line_fit < 1000 then
- adjustment = calculate_fraction(adjustment,last_line_fit,1000,maxdimen) -- uses previous adjustment
- end
- local fit_class = fit_decent_class
- if adjustment > 0 then
- local stretch = cur_active_width.stretch
- if adjustment > shortfall then
- adjustment = shortfall
- end
- if adjustment > 7230584 and stretch < 1663497 then
- return true, fit_very_loose_class, shortfall, adjustment, infinite_badness
+ local function lastlinecrap(shortfall,active_short,active_glue,cur_active_width,fill_width,last_line_fit)
+ if active_short == 0 or active_glue <= 0 then
+ return false, 0, fit_decent_class, 0, 0
end
- -- if adjustment == 0 then -- badness = 0
- -- return true, shortfall, fit_decent_class, 0, 0
- -- elseif stretch <= 0 then -- badness = 10000
- -- return true, shortfall, fit_very_loose_class, adjustment, 10000
- -- end
- -- local badness = (adjustment == 0 and 0) or (stretch <= 0 and 10000) or calculate_badness(adjustment,stretch)
- local badness = calculate_badness(adjustment,stretch)
- if badness > 99 then
- return true, shortfall, fit_very_loose_class, adjustment, badness
- elseif badness > 12 then
- return true, shortfall, fit_loose_class, adjustment, badness
- else
- return true, shortfall, fit_decent_class, adjustment, badness
+ if cur_active_width.fi ~= fill_width.fi or cur_active_width.fil ~= fill_width.fil or cur_active_width.fill ~= fill_width.fill or cur_active_width.filll ~= fill_width.filll then
+ return false, 0, fit_decent_class, 0, 0
end
- elseif adjustment < 0 then
- local shrink = cur_active_width.shrink
- if -adjustment > shrink then
- adjustment = -shrink
+ local adjustment = active_short > 0 and cur_active_width.stretch or cur_active_width.shrink
+ if adjustment <= 0 then
+ return false, 0, fit_decent_class, adjustment, 0
end
- local badness = calculate_badness(-adjustment,shrink)
- if badness > 12 then
- return true, shortfall, fit_tight_class, adjustment, badness
- else
- return true, shortfall, fit_decent_class, adjustment, badness
+ adjustment = calculate_fraction(adjustment,active_short,active_glue,maxdimen)
+ if last_line_fit < 1000 then
+ adjustment = calculate_fraction(adjustment,last_line_fit,1000,maxdimen) -- uses previous adjustment
end
- else
- return false, 0, fit_decent_class, 0, 0
- end
-end
-
--- todo: statistics .. count tries and so
-
-local trialcount = 0
-
-local function try_break(pi, break_type, par, first_p, current, checked_expansion)
-
--- trialcount = trialcount + 1
--- print(trialcount,pi,break_type,current,nuts.tostring(current))
-
- if pi >= infinite_penalty then -- this breakpoint is inhibited by infinite penalty
- local p_active = par.active
- return p_active, p_active and p_active.next
- elseif pi <= -infinite_penalty then -- this breakpoint will be forced
- pi = eject_penalty
- end
-
- local prev_prev_r = nil -- a step behind prev_r, if type(prev_r)=delta_code
- local prev_r = par.active -- stays a step behind r
- local r = nil -- runs through the active list
- local no_break_yet = true -- have we found a feasible break at current?
- local node_r_stays_active = false -- should node r remain in the active list?
- local line_width = 0 -- the current line will be justified to this width
- local line_number = 0 -- line number of current active node
- local old_line_number = 0 -- maximum line number in current equivalence class of lines
-
- local protrude_chars = par.protrude_chars
- local checked_expansion = par.checked_expansion
- local break_width = par.break_width
- local active_width = par.active_width
- local background = par.background
- local minimal_demerits = par.minimal_demerits
- local best_place = par.best_place
- local best_pl_line = par.best_pl_line
- local best_pl_short = par.best_pl_short
- local best_pl_glue = par.best_pl_glue
- local do_last_line_fit = par.do_last_line_fit
- local final_pass = par.final_pass
- local tracing_paragraphs = par.tracing_paragraphs
- -- local par_active = par.active
-
- local adapt_width = par.adapt_width
-
- local parshape = par.par_shape_ptr
-
- local cur_active_width = checked_expansion and { -- distance from current active node
- size = active_width.size,
- stretch = active_width.stretch,
- fi = active_width.fi,
- fil = active_width.fil,
- fill = active_width.fill,
- filll = active_width.filll,
- shrink = active_width.shrink,
- adjust_stretch = active_width.adjust_stretch,
- adjust_shrink = active_width.adjust_shrink,
- } or {
- size = active_width.size,
- stretch = active_width.stretch,
- fi = active_width.fi,
- fil = active_width.fil,
- fill = active_width.fill,
- filll = active_width.filll,
- shrink = active_width.shrink,
- }
-
- while true do
- r = prev_r.next
- if r.id == delta_code then
- cur_active_width.size = cur_active_width.size + r.size
- cur_active_width.stretch = cur_active_width.stretch + r.stretch
- cur_active_width.fi = cur_active_width.fi + r.fi
- cur_active_width.fil = cur_active_width.fil + r.fil
- cur_active_width.fill = cur_active_width.fill + r.fill
- cur_active_width.filll = cur_active_width.filll + r.filll
- cur_active_width.shrink = cur_active_width.shrink + r.shrink
- if checked_expansion then
- cur_active_width.adjust_stretch = cur_active_width.adjust_stretch + r.adjust_stretch
- cur_active_width.adjust_shrink = cur_active_width.adjust_shrink + r.adjust_shrink
+ local fit_class = fit_decent_class
+ if adjustment > 0 then
+ local stretch = cur_active_width.stretch
+ if adjustment > shortfall then
+ adjustment = shortfall
+ end
+ if adjustment > 7230584 and stretch < 1663497 then
+ return true, fit_very_loose_class, shortfall, adjustment, infinite_badness
+ end
+ -- if adjustment == 0 then -- badness = 0
+ -- return true, shortfall, fit_decent_class, 0, 0
+ -- elseif stretch <= 0 then -- badness = 10000
+ -- return true, shortfall, fit_very_loose_class, adjustment, 10000
+ -- end
+ -- local badness = (adjustment == 0 and 0) or (stretch <= 0 and 10000) or calculate_badness(adjustment,stretch)
+ local badness = calculate_badness(adjustment,stretch)
+ if badness > 99 then
+ return true, shortfall, fit_very_loose_class, adjustment, badness
+ elseif badness > 12 then
+ return true, shortfall, fit_loose_class, adjustment, badness
+ else
+ return true, shortfall, fit_decent_class, adjustment, badness
+ end
+ elseif adjustment < 0 then
+ local shrink = cur_active_width.shrink
+ if -adjustment > shrink then
+ adjustment = -shrink
+ end
+ local badness = calculate_badness(-adjustment,shrink)
+ if badness > 12 then
+ return true, shortfall, fit_tight_class, adjustment, badness
+ else
+ return true, shortfall, fit_decent_class, adjustment, badness
end
- prev_prev_r = prev_r
- prev_r = r
else
- line_number = r.line_number
- if line_number > old_line_number then
- local minimum_demerits = par.minimum_demerits
- if minimum_demerits < awful_badness and (old_line_number ~= par.easy_line or r == par.active) then
- if no_break_yet then
- no_break_yet = false
- break_width.size = background.size
- break_width.stretch = background.stretch
- break_width.fi = background.fi
- break_width.fil = background.fil
- break_width.fill = background.fill
- break_width.filll = background.filll
- break_width.shrink = background.shrink
- if checked_expansion then
- break_width.adjust_stretch = 0
- break_width.adjust_shrink = 0
+ return false, 0, fit_decent_class, 0, 0
+ end
+ end
+
+ -- todo: statistics .. count tries and so
+
+ local trialcount = 0
+
+ local function try_break(pi, break_type, par, first_p, current, checked_expansion)
+
+ -- trialcount = trialcount + 1
+ -- print(trialcount,pi,break_type,current,nuts.tostring(current))
+
+ if pi >= infinite_penalty then -- this breakpoint is inhibited by infinite penalty
+ local p_active = par.active
+ return p_active, p_active and p_active.next
+ elseif pi <= -infinite_penalty then -- this breakpoint will be forced
+ pi = eject_penalty
+ end
+
+ local prev_prev_r = nil -- a step behind prev_r, if type(prev_r)=delta_code
+ local prev_r = par.active -- stays a step behind r
+ local r = nil -- runs through the active list
+ local no_break_yet = true -- have we found a feasible break at current?
+ local node_r_stays_active = false -- should node r remain in the active list?
+ local line_width = 0 -- the current line will be justified to this width
+ local line_number = 0 -- line number of current active node
+ local old_line_number = 0 -- maximum line number in current equivalence class of lines
+
+ local protrude_chars = par.protrude_chars
+ local checked_expansion = par.checked_expansion
+ local break_width = par.break_width
+ local active_width = par.active_width
+ local background = par.background
+ local minimal_demerits = par.minimal_demerits
+ local best_place = par.best_place
+ local best_pl_line = par.best_pl_line
+ local best_pl_short = par.best_pl_short
+ local best_pl_glue = par.best_pl_glue
+ local do_last_line_fit = par.do_last_line_fit
+ local final_pass = par.final_pass
+ local tracing_paragraphs = par.tracing_paragraphs
+ -- local par_active = par.active
+
+ local adapt_width = par.adapt_width
+
+ local parshape = par.par_shape_ptr
+
+ local cur_active_width = checked_expansion and { -- distance from current active node
+ size = active_width.size,
+ stretch = active_width.stretch,
+ fi = active_width.fi,
+ fil = active_width.fil,
+ fill = active_width.fill,
+ filll = active_width.filll,
+ shrink = active_width.shrink,
+ adjust_stretch = active_width.adjust_stretch,
+ adjust_shrink = active_width.adjust_shrink,
+ } or {
+ size = active_width.size,
+ stretch = active_width.stretch,
+ fi = active_width.fi,
+ fil = active_width.fil,
+ fill = active_width.fill,
+ filll = active_width.filll,
+ shrink = active_width.shrink,
+ }
+
+ while true do
+ r = prev_r.next
+ if r.id == delta_code then
+ cur_active_width.size = cur_active_width.size + r.size
+ cur_active_width.stretch = cur_active_width.stretch + r.stretch
+ cur_active_width.fi = cur_active_width.fi + r.fi
+ cur_active_width.fil = cur_active_width.fil + r.fil
+ cur_active_width.fill = cur_active_width.fill + r.fill
+ cur_active_width.filll = cur_active_width.filll + r.filll
+ cur_active_width.shrink = cur_active_width.shrink + r.shrink
+ if checked_expansion then
+ cur_active_width.adjust_stretch = cur_active_width.adjust_stretch + r.adjust_stretch
+ cur_active_width.adjust_shrink = cur_active_width.adjust_shrink + r.adjust_shrink
+ end
+ prev_prev_r = prev_r
+ prev_r = r
+ else
+ line_number = r.line_number
+ if line_number > old_line_number then
+ local minimum_demerits = par.minimum_demerits
+ if minimum_demerits < awful_badness and (old_line_number ~= par.easy_line or r == par.active) then
+ if no_break_yet then
+ no_break_yet = false
+ break_width.size = background.size
+ break_width.stretch = background.stretch
+ break_width.fi = background.fi
+ break_width.fil = background.fil
+ break_width.fill = background.fill
+ break_width.filll = background.filll
+ break_width.shrink = background.shrink
+ if checked_expansion then
+ break_width.adjust_stretch = 0
+ break_width.adjust_shrink = 0
+ end
+ if current then
+ compute_break_width(par,break_type,current)
+ end
end
- if current then
- compute_break_width(par,break_type,current)
+ if prev_r.id == delta_code then
+ prev_r.size = prev_r.size - cur_active_width.size + break_width.size
+ prev_r.stretch = prev_r.stretch - cur_active_width.stretc + break_width.stretch
+ prev_r.fi = prev_r.fi - cur_active_width.fi + break_width.fi
+ prev_r.fil = prev_r.fil - cur_active_width.fil + break_width.fil
+ prev_r.fill = prev_r.fill - cur_active_width.fill + break_width.fill
+ prev_r.filll = prev_r.filll - cur_active_width.filll + break_width.filll
+ prev_r.shrink = prev_r.shrink - cur_active_width.shrink + break_width.shrink
+ if checked_expansion then
+ prev_r.adjust_stretch = prev_r.adjust_stretch - cur_active_width.adjust_stretch + break_width.adjust_stretch
+ prev_r.adjust_shrink = prev_r.adjust_shrink - cur_active_width.adjust_shrink + break_width.adjust_shrink
+ end
+ elseif prev_r == par.active then
+ active_width.size = break_width.size
+ active_width.stretch = break_width.stretch
+ active_width.fi = break_width.fi
+ active_width.fil = break_width.fil
+ active_width.fill = break_width.fill
+ active_width.filll = break_width.filll
+ active_width.shrink = break_width.shrink
+ if checked_expansion then
+ active_width.adjust_stretch = break_width.adjust_stretch
+ active_width.adjust_shrink = break_width.adjust_shrink
+ end
+ else
+ local q = checked_expansion and {
+ id = delta_code,
+ subtype = nosubtype_code,
+ next = r,
+ size = break_width.size - cur_active_width.size,
+ stretch = break_width.stretch - cur_active_width.stretch,
+ fi = break_width.fi - cur_active_width.fi,
+ fil = break_width.fil - cur_active_width.fil,
+ fill = break_width.fill - cur_active_width.fill,
+ filll = break_width.filll - cur_active_width.filll,
+ shrink = break_width.shrink - cur_active_width.shrink,
+ adjust_stretch = break_width.adjust_stretch - cur_active_width.adjust_stretch,
+ adjust_shrink = break_width.adjust_shrink - cur_active_width.adjust_shrink,
+ } or {
+ id = delta_code,
+ subtype = nosubtype_code,
+ next = r,
+ size = break_width.size - cur_active_width.size,
+ stretch = break_width.stretch - cur_active_width.stretch,
+ fi = break_width.fi - cur_active_width.fi,
+ fil = break_width.fil - cur_active_width.fil,
+ fill = break_width.fill - cur_active_width.fill,
+ filll = break_width.filll - cur_active_width.filll,
+ shrink = break_width.shrink - cur_active_width.shrink,
+ }
+ prev_r.next = q
+ prev_prev_r = prev_r
+ prev_r = q
end
- end
- if prev_r.id == delta_code then
- prev_r.size = prev_r.size - cur_active_width.size + break_width.size
- prev_r.stretch = prev_r.stretch - cur_active_width.stretc + break_width.stretch
- prev_r.fi = prev_r.fi - cur_active_width.fi + break_width.fi
- prev_r.fil = prev_r.fil - cur_active_width.fil + break_width.fil
- prev_r.fill = prev_r.fill - cur_active_width.fill + break_width.fill
- prev_r.filll = prev_r.filll - cur_active_width.filll + break_width.filll
- prev_r.shrink = prev_r.shrink - cur_active_width.shrink + break_width.shrink
- if checked_expansion then
- prev_r.adjust_stretch = prev_r.adjust_stretch - cur_active_width.adjust_stretch + break_width.adjust_stretch
- prev_r.adjust_shrink = prev_r.adjust_shrink - cur_active_width.adjust_shrink + break_width.adjust_shrink
+ local adj_demerits = par.adj_demerits
+ local abs_adj_demerits = adj_demerits > 0 and adj_demerits or -adj_demerits
+ if abs_adj_demerits >= awful_badness - minimum_demerits then
+ minimum_demerits = awful_badness - 1
+ else
+ minimum_demerits = minimum_demerits + abs_adj_demerits
end
- elseif prev_r == par.active then
- active_width.size = break_width.size
- active_width.stretch = break_width.stretch
- active_width.fi = break_width.fi
- active_width.fil = break_width.fil
- active_width.fill = break_width.fill
- active_width.filll = break_width.filll
- active_width.shrink = break_width.shrink
- if checked_expansion then
- active_width.adjust_stretch = break_width.adjust_stretch
- active_width.adjust_shrink = break_width.adjust_shrink
+ for fit_class = fit_very_loose_class, fit_tight_class do
+ if minimal_demerits[fit_class] <= minimum_demerits then
+ -- insert a new active node from best_place[fit_class] to current
+ par.pass_number = par.pass_number + 1
+ local prev_break = best_place[fit_class]
+ local passive = {
+ id = passive_code,
+ subtype = nosubtype_code,
+ next = par.passive,
+ cur_break = current,
+ serial = par.pass_number,
+ prev_break = prev_break,
+ passive_pen_inter = par.internal_pen_inter,
+ passive_pen_broken = par.internal_pen_broken,
+ passive_last_left_box = par.internal_left_box,
+ passive_last_left_box_width = par.internal_left_box_width,
+ passive_left_box = prev_break and prev_break.passive_last_left_box or par.init_internal_left_box,
+ passive_left_box_width = prev_break and prev_break.passive_last_left_box_width or par.init_internal_left_box_width,
+ passive_right_box = par.internal_right_box,
+ passive_right_box_width = par.internal_right_box_width,
+ -- analysis = table.fastcopy(cur_active_width),
+ }
+ par.passive = passive
+ local q = {
+ id = break_type,
+ subtype = fit_class,
+ break_node = passive,
+ line_number = best_pl_line[fit_class] + 1,
+ total_demerits = minimal_demerits[fit_class], -- or 0,
+ next = r,
+ }
+ if do_last_line_fit then
+ local active_short = best_pl_short[fit_class]
+ local active_glue = best_pl_glue[fit_class]
+ q.active_short = active_short
+ q.active_glue = active_glue
+ if trace_lastlinefit then
+ report_parbuilders("setting short to %i and glue to %p using class %a",active_short,active_glue,fit_class)
+ end
+ end
+ -- q.next = r -- already done
+ prev_r.next = q
+ prev_r = q
+ if tracing_paragraphs then
+ diagnostics.break_node(par,q,fit_class,break_type,current)
+ end
+ end
+ minimal_demerits[fit_class] = awful_badness
end
- else
- local q = checked_expansion and {
- id = delta_code,
- subtype = nosubtype_code,
- next = r,
- size = break_width.size - cur_active_width.size,
- stretch = break_width.stretch - cur_active_width.stretch,
- fi = break_width.fi - cur_active_width.fi,
- fil = break_width.fil - cur_active_width.fil,
- fill = break_width.fill - cur_active_width.fill,
- filll = break_width.filll - cur_active_width.filll,
- shrink = break_width.shrink - cur_active_width.shrink,
- adjust_stretch = break_width.adjust_stretch - cur_active_width.adjust_stretch,
- adjust_shrink = break_width.adjust_shrink - cur_active_width.adjust_shrink,
- } or {
- id = delta_code,
- subtype = nosubtype_code,
- next = r,
- size = break_width.size - cur_active_width.size,
- stretch = break_width.stretch - cur_active_width.stretch,
- fi = break_width.fi - cur_active_width.fi,
- fil = break_width.fil - cur_active_width.fil,
- fill = break_width.fill - cur_active_width.fill,
- filll = break_width.filll - cur_active_width.filll,
- shrink = break_width.shrink - cur_active_width.shrink,
- }
- prev_r.next = q
- prev_prev_r = prev_r
- prev_r = q
- end
- local adj_demerits = par.adj_demerits
- local abs_adj_demerits = adj_demerits > 0 and adj_demerits or -adj_demerits
- if abs_adj_demerits >= awful_badness - minimum_demerits then
- minimum_demerits = awful_badness - 1
- else
- minimum_demerits = minimum_demerits + abs_adj_demerits
- end
- for fit_class = fit_very_loose_class, fit_tight_class do
- if minimal_demerits[fit_class] <= minimum_demerits then
- -- insert a new active node from best_place[fit_class] to current
- par.pass_number = par.pass_number + 1
- local prev_break = best_place[fit_class]
- local passive = {
- id = passive_code,
- subtype = nosubtype_code,
- next = par.passive,
- cur_break = current,
- serial = par.pass_number,
- prev_break = prev_break,
- passive_pen_inter = par.internal_pen_inter,
- passive_pen_broken = par.internal_pen_broken,
- passive_last_left_box = par.internal_left_box,
- passive_last_left_box_width = par.internal_left_box_width,
- passive_left_box = prev_break and prev_break.passive_last_left_box or par.init_internal_left_box,
- passive_left_box_width = prev_break and prev_break.passive_last_left_box_width or par.init_internal_left_box_width,
- passive_right_box = par.internal_right_box,
- passive_right_box_width = par.internal_right_box_width,
--- analysis = table.fastcopy(cur_active_width),
- }
- par.passive = passive
- local q = {
- id = break_type,
- subtype = fit_class,
- break_node = passive,
- line_number = best_pl_line[fit_class] + 1,
- total_demerits = minimal_demerits[fit_class], -- or 0,
+ par.minimum_demerits = awful_badness
+ if r ~= par.active then
+ local q = checked_expansion and {
+ id = delta_code,
+ subtype = nosubtype_code,
+ next = r,
+ size = cur_active_width.size - break_width.size,
+ stretch = cur_active_width.stretch - break_width.stretch,
+ fi = cur_active_width.fi - break_width.fi,
+ fil = cur_active_width.fil - break_width.fil,
+ fill = cur_active_width.fill - break_width.fill,
+ filll = cur_active_width.filll - break_width.filll,
+ shrink = cur_active_width.shrink - break_width.shrink,
+ adjust_stretch = cur_active_width.adjust_stretch - break_width.adjust_stretch,
+ adjust_shrink = cur_active_width.adjust_shrink - break_width.adjust_shrink,
+ } or {
+ id = delta_code,
+ subtype = nosubtype_code,
next = r,
+ size = cur_active_width.size - break_width.size,
+ stretch = cur_active_width.stretch - break_width.stretch,
+ fi = cur_active_width.fi - break_width.fi,
+ fil = cur_active_width.fil - break_width.fil,
+ fill = cur_active_width.fill - break_width.fill,
+ filll = cur_active_width.filll - break_width.filll,
+ shrink = cur_active_width.shrink - break_width.shrink,
}
- if do_last_line_fit then
- local active_short = best_pl_short[fit_class]
- local active_glue = best_pl_glue[fit_class]
- q.active_short = active_short
- q.active_glue = active_glue
- if trace_lastlinefit then
- report_parbuilders("setting short to %i and glue to %p using class %a",active_short,active_glue,fit_class)
- end
- end
-- q.next = r -- already done
prev_r.next = q
+ prev_prev_r = prev_r
prev_r = q
- if tracing_paragraphs then
- diagnostics.break_node(par,q,fit_class,break_type,current)
- end
end
- minimal_demerits[fit_class] = awful_badness
- end
- par.minimum_demerits = awful_badness
- if r ~= par.active then
- local q = checked_expansion and {
- id = delta_code,
- subtype = nosubtype_code,
- next = r,
- size = cur_active_width.size - break_width.size,
- stretch = cur_active_width.stretch - break_width.stretch,
- fi = cur_active_width.fi - break_width.fi,
- fil = cur_active_width.fil - break_width.fil,
- fill = cur_active_width.fill - break_width.fill,
- filll = cur_active_width.filll - break_width.filll,
- shrink = cur_active_width.shrink - break_width.shrink,
- adjust_stretch = cur_active_width.adjust_stretch - break_width.adjust_stretch,
- adjust_shrink = cur_active_width.adjust_shrink - break_width.adjust_shrink,
- } or {
- id = delta_code,
- subtype = nosubtype_code,
- next = r,
- size = cur_active_width.size - break_width.size,
- stretch = cur_active_width.stretch - break_width.stretch,
- fi = cur_active_width.fi - break_width.fi,
- fil = cur_active_width.fil - break_width.fil,
- fill = cur_active_width.fill - break_width.fill,
- filll = cur_active_width.filll - break_width.filll,
- shrink = cur_active_width.shrink - break_width.shrink,
- }
- -- q.next = r -- already done
- prev_r.next = q
- prev_prev_r = prev_r
- prev_r = q
end
- end
- if r == par.active then
- return r, r and r.next -- p_active, n_active
- end
- if line_number > par.easy_line then
- old_line_number = max_halfword - 1
- line_width = par.second_width
- else
- old_line_number = line_number
- if line_number > par.last_special_line then
+ if r == par.active then
+ return r, r and r.next -- p_active, n_active
+ end
+ if line_number > par.easy_line then
+ old_line_number = max_halfword - 1
line_width = par.second_width
- elseif parshape then
- line_width = parshape[line_number][2]
else
- line_width = par.first_width
+ old_line_number = line_number
+ if line_number > par.last_special_line then
+ line_width = par.second_width
+ elseif parshape then
+ line_width = parshape[line_number][2]
+ else
+ line_width = par.first_width
+ end
end
- end
- if adapt_width then
- local l, r = adapt_width(par,line_number)
- line_width = line_width - l - r
- end
- end
- local artificial_demerits = false -- has d been forced to zero
- local shortfall = line_width - cur_active_width.size - par.internal_right_box_width -- used in badness calculations
- if not r.break_node then
- shortfall = shortfall - par.init_internal_left_box_width
- else
- shortfall = shortfall - (r.break_node.passive_last_left_box_width or 0)
- end
- local pw, lp, rp -- used later on
- if protrude_chars > 1 then
- -- this is quite time consuming
- local b = r.break_node
- local l = b and b.cur_break or first_p
- local o = current and getprev(current)
- if current and getid(current) == disc_code then
- local pre, _, _, pretail = getdisc(current,true)
- if pre then
- o = pretail
- else
- o = find_protchar_right(l,o)
+ if adapt_width then
+ local l, r = adapt_width(par,line_number)
+ line_width = line_width - l - r
end
- else
- o = find_protchar_right(l,o)
end
- if o and getid(o) == glyph_code then
- pw, rp = right_pw(o)
- shortfall = shortfall + pw
- end
- local id = getid(l)
- if id == glyph_code then
- -- ok ?
- elseif id == disc_code and getfield(l,"post") then
- l = getfield(l,"post") -- TODO: first char could be a disc
+ local artificial_demerits = false -- has d been forced to zero
+ local shortfall = line_width - cur_active_width.size - par.internal_right_box_width -- used in badness calculations
+ if not r.break_node then
+ shortfall = shortfall - par.init_internal_left_box_width
else
- l = find_protchar_left(l)
- end
- if l and getid(l) == glyph_code then
- pw, lp = left_pw(l)
- shortfall = shortfall + pw
+ shortfall = shortfall - (r.break_node.passive_last_left_box_width or 0)
end
- end
- if checked_expansion and shortfall ~= 0 then
- local margin_kern_stretch = 0
- local margin_kern_shrink = 0
+ local pw, lp, rp -- used later on
if protrude_chars > 1 then
- if lp then
- local data = expansions[getfont(lp)][getchar(lp)]
- if data then
- margin_kern_stretch, margin_kern_shrink = data.glyphstretch, data.glyphshrink
+ -- this is quite time consuming
+ local b = r.break_node
+ local l = b and b.cur_break or first_p
+ local o = current and getprev(current)
+ if current and getid(current) == disc_code then
+ local pre, _, _, pretail = getdisc(current,true)
+ if pre then
+ o = pretail
+ else
+ o = find_protchar_right(l,o)
end
+ else
+ o = find_protchar_right(l,o)
end
- if rp then
- local data = expansions[getfont(lp)][getchar(lp)]
- if data then
- margin_kern_stretch = margin_kern_stretch + data.glyphstretch
- margin_kern_shrink = margin_kern_shrink + data.glyphshrink
- end
+ if o and getid(o) == glyph_code then
+ pw, rp = right_pw(o)
+ shortfall = shortfall + pw
end
- end
- local total = cur_active_width.adjust_stretch + margin_kern_stretch
- if shortfall > 0 and total > 0 then
- if total > shortfall then
- shortfall = total / (par.max_stretch_ratio / par.cur_font_step) / 2
+ local id = getid(l)
+ if id == glyph_code then
+ -- ok ?
+ elseif id == disc_code and getfield(l,"post") then
+ l = getfield(l,"post") -- TODO: first char could be a disc
else
- shortfall = shortfall - total
+ l = find_protchar_left(l)
end
- else
- total = cur_active_width.adjust_shrink + margin_kern_shrink
- if shortfall < 0 and total > 0 then
- if total > - shortfall then
- shortfall = - total / (par.max_shrink_ratio / par.cur_font_step) / 2
- else
- shortfall = shortfall + total
- end
+ if l and getid(l) == glyph_code then
+ pw, lp = left_pw(l)
+ shortfall = shortfall + pw
end
end
- end
- local b = 0
- local g = 0
- local fit_class = fit_decent_class
- local found = false
- if shortfall > 0 then
- if cur_active_width.fi ~= 0 or cur_active_width.fil ~= 0 or cur_active_width.fill ~= 0 or cur_active_width.filll ~= 0 then
- if not do_last_line_fit then
- -- okay
- elseif not current then
- found, shortfall, fit_class, g, b = lastlinecrap(shortfall,r.active_short,r.active_glue,cur_active_width,par.fill_width,par.last_line_fit)
+ if checked_expansion and shortfall ~= 0 then
+ local margin_kern_stretch = 0
+ local margin_kern_shrink = 0
+ if protrude_chars > 1 then
+ if lp then
+ local data = expansions[getfont(lp)][getchar(lp)]
+ if data then
+ margin_kern_stretch, margin_kern_shrink = data.glyphstretch, data.glyphshrink
+ end
+ end
+ if rp then
+ local data = expansions[getfont(lp)][getchar(lp)]
+ if data then
+ margin_kern_stretch = margin_kern_stretch + data.glyphstretch
+ margin_kern_shrink = margin_kern_shrink + data.glyphshrink
+ end
+ end
+ end
+ local total = cur_active_width.adjust_stretch + margin_kern_stretch
+ if shortfall > 0 and total > 0 then
+ if total > shortfall then
+ shortfall = total / (par.max_stretch_ratio / par.cur_font_step) / 2
+ else
+ shortfall = shortfall - total
+ end
else
- shortfall = 0
+ total = cur_active_width.adjust_shrink + margin_kern_shrink
+ if shortfall < 0 and total > 0 then
+ if total > - shortfall then
+ shortfall = - total / (par.max_shrink_ratio / par.cur_font_step) / 2
+ else
+ shortfall = shortfall + total
+ end
+ end
end
- else
- local stretch = cur_active_width.stretch
- if shortfall > 7230584 and stretch < 1663497 then
- b = infinite_badness
- fit_class = fit_very_loose_class
+ end
+ local b = 0
+ local g = 0
+ local fit_class = fit_decent_class
+ local found = false
+ if shortfall > 0 then
+ if cur_active_width.fi ~= 0 or cur_active_width.fil ~= 0 or cur_active_width.fill ~= 0 or cur_active_width.filll ~= 0 then
+ if not do_last_line_fit then
+ -- okay
+ elseif not current then
+ found, shortfall, fit_class, g, b = lastlinecrap(shortfall,r.active_short,r.active_glue,cur_active_width,par.fill_width,par.last_line_fit)
+ else
+ shortfall = 0
+ end
else
- b = calculate_badness(shortfall,stretch)
- if b > 99 then
+ local stretch = cur_active_width.stretch
+ if shortfall > 7230584 and stretch < 1663497 then
+ b = infinite_badness
fit_class = fit_very_loose_class
- elseif b > 12 then
- fit_class = fit_loose_class
else
- fit_class = fit_decent_class
+ b = calculate_badness(shortfall,stretch)
+ if b > 99 then
+ fit_class = fit_very_loose_class
+ elseif b > 12 then
+ fit_class = fit_loose_class
+ else
+ fit_class = fit_decent_class
+ end
end
end
- end
- else
- local shrink = cur_active_width.shrink
- if -shortfall > shrink then
- b = infinite_badness + 1
- else
- b = calculate_badness(-shortfall,shrink)
- end
- if b > 12 then
- fit_class = fit_tight_class
- else
- fit_class = fit_decent_class
- end
- end
- if do_last_line_fit and not found then
- if not current then
- -- g = 0
- shortfall = 0
- elseif shortfall > 0 then
- g = cur_active_width.stretch
- elseif shortfall < 0 then
- g = cur_active_width.shrink
else
- g = 0
+ local shrink = cur_active_width.shrink
+ if -shortfall > shrink then
+ b = infinite_badness + 1
+ else
+ b = calculate_badness(-shortfall,shrink)
+ end
+ if b > 12 then
+ fit_class = fit_tight_class
+ else
+ fit_class = fit_decent_class
+ end
end
- end
- -- ::FOUND::
- local continue_only = false -- brrr
- if b > infinite_badness or pi == eject_penalty then
- if final_pass and par.minimum_demerits == awful_badness and r.next == par.active and prev_r == par.active then
- artificial_demerits = true -- set demerits zero, this break is forced
- node_r_stays_active = false
- elseif b > par.threshold then
- prev_r, r = deactivate_node(par,prev_prev_r,prev_r,r,cur_active_width,checked_expansion)
- continue_only = true
- else
- node_r_stays_active = false
+ if do_last_line_fit and not found then
+ if not current then
+ -- g = 0
+ shortfall = 0
+ elseif shortfall > 0 then
+ g = cur_active_width.stretch
+ elseif shortfall < 0 then
+ g = cur_active_width.shrink
+ else
+ g = 0
+ end
end
- else
- prev_r = r
- if b > par.threshold then
- continue_only = true
+ -- ::FOUND::
+ local continue_only = false -- brrr
+ if b > infinite_badness or pi == eject_penalty then
+ if final_pass and par.minimum_demerits == awful_badness and r.next == par.active and prev_r == par.active then
+ artificial_demerits = true -- set demerits zero, this break is forced
+ node_r_stays_active = false
+ elseif b > par.threshold then
+ prev_r, r = deactivate_node(par,prev_prev_r,prev_r,r,cur_active_width,checked_expansion)
+ continue_only = true
+ else
+ node_r_stays_active = false
+ end
else
- node_r_stays_active = true
- end
- end
- if not continue_only then
- local d = 0
- if not artificial_demerits then
- d = par.line_penalty + b
- if (d >= 0 and d or -d) >= 10000 then -- abs(d)
- d = 100000000
+ prev_r = r
+ if b > par.threshold then
+ continue_only = true
else
- d = d * d
+ node_r_stays_active = true
end
- if pi == 0 then
- -- nothing
- elseif pi > 0 then
- d = d + pi * pi
- elseif pi > eject_penalty then
- d = d - pi * pi
- end
- if break_type == hyphenated_code and r.id == hyphenated_code then
- if current then
- d = d + par.double_hyphen_demerits
+ end
+ if not continue_only then
+ local d = 0
+ if not artificial_demerits then
+ d = par.line_penalty + b
+ if (d >= 0 and d or -d) >= 10000 then -- abs(d)
+ d = 100000000
else
- d = d + par.final_hyphen_demerits
+ d = d * d
+ end
+ if pi == 0 then
+ -- nothing
+ elseif pi > 0 then
+ d = d + pi * pi
+ elseif pi > eject_penalty then
+ d = d - pi * pi
+ end
+ if break_type == hyphenated_code and r.id == hyphenated_code then
+ if current then
+ d = d + par.double_hyphen_demerits
+ else
+ d = d + par.final_hyphen_demerits
+ end
+ end
+ local delta = fit_class - r.subtype
+ if (delta >= 0 and delta or -delta) > 1 then -- abs(delta)
+ d = d + par.adj_demerits
end
end
- local delta = fit_class - r.subtype
- if (delta >= 0 and delta or -delta) > 1 then -- abs(delta)
- d = d + par.adj_demerits
+ if tracing_paragraphs then
+ diagnostics.feasible_break(par,current,r,b,pi,d,artificial_demerits)
end
- end
- if tracing_paragraphs then
- diagnostics.feasible_break(par,current,r,b,pi,d,artificial_demerits)
- end
- d = d + r.total_demerits -- this is the minimum total demerits from the beginning to current via r
- if d <= minimal_demerits[fit_class] then
- minimal_demerits[fit_class] = d
- best_place [fit_class] = r.break_node
- best_pl_line [fit_class] = line_number
- if do_last_line_fit then
- best_pl_short[fit_class] = shortfall
- best_pl_glue [fit_class] = g
- if trace_lastlinefit then
- report_parbuilders("storing last line fit short %a and glue %p in class %a",shortfall,g,fit_class)
+ d = d + r.total_demerits -- this is the minimum total demerits from the beginning to current via r
+ if d <= minimal_demerits[fit_class] then
+ minimal_demerits[fit_class] = d
+ best_place [fit_class] = r.break_node
+ best_pl_line [fit_class] = line_number
+ if do_last_line_fit then
+ best_pl_short[fit_class] = shortfall
+ best_pl_glue [fit_class] = g
+ if trace_lastlinefit then
+ report_parbuilders("storing last line fit short %a and glue %p in class %a",shortfall,g,fit_class)
+ end
+ end
+ if d < par.minimum_demerits then
+ par.minimum_demerits = d
end
end
- if d < par.minimum_demerits then
- par.minimum_demerits = d
+ if not node_r_stays_active then
+ prev_r, r = deactivate_node(par,prev_prev_r,prev_r,r,cur_active_width,checked_expansion)
end
end
- if not node_r_stays_active then
- prev_r, r = deactivate_node(par,prev_prev_r,prev_r,r,cur_active_width,checked_expansion)
- end
end
end
end
-end
-
--- we can call the normal one for simple box building in the otr so we need
--- frequent enabling/disabling
-local dcolor = { [0] = "red", "green", "blue", "magenta", "cyan", "gray" }
+ -- we can call the normal one for simple box building in the otr so we need
+ -- frequent enabling/disabling
-local temp_head = new_temp()
+ local temp_head = new_temp()
-function constructors.methods.basic(head,d)
- if trace_basic then
- report_parbuilders("starting at %a",head)
- end
+ function constructors.methods.basic(head,d)
+ if trace_basic then
+ report_parbuilders("starting at %a",head)
+ end
- local par = initialize_line_break(head,d)
+ local par = initialize_line_break(head,d)
- local checked_expansion = par.checked_expansion
- local active_width = par.active_width
- local disc_width = par.disc_width
- local background = par.background
- local tracing_paragraphs = par.tracing_paragraphs
+ local checked_expansion = par.checked_expansion
+ local active_width = par.active_width
+ local disc_width = par.disc_width
+ local background = par.background
+ local tracing_paragraphs = par.tracing_paragraphs
- local dirstack = new_dir_stack()
+ local dirstack = new_dir_stack()
- if tracing_paragraphs then
- diagnostics.start()
- if par.pretolerance >= 0 then
- diagnostics.current_pass(par,"firstpass")
+ if tracing_paragraphs then
+ diagnostics.start()
+ if par.pretolerance >= 0 then
+ diagnostics.current_pass(par,"firstpass")
+ end
end
- end
- while true do
- reset_meta(par)
- if par.threshold > infinite_badness then
- par.threshold = infinite_badness
- end
- par.active.next = {
- id = unhyphenated_code,
- subtype = fit_decent_class,
- next = par.active,
- break_node = nil,
- line_number = par.first_line + 1,
- total_demerits = 0,
- active_short = 0,
- active_glue = 0,
- }
- active_width.size = background.size
- active_width.stretch = background.stretch
- active_width.fi = background.fi
- active_width.fil = background.fil
- active_width.fill = background.fill
- active_width.filll = background.filll
- active_width.shrink = background.shrink
-
- if checked_expansion then
- active_width.adjust_stretch = 0
- active_width.adjust_shrink = 0
- end
+ while true do
+ reset_meta(par)
+ if par.threshold > infinite_badness then
+ par.threshold = infinite_badness
+ end
+ par.active.next = {
+ id = unhyphenated_code,
+ subtype = fit_decent_class,
+ next = par.active,
+ break_node = nil,
+ line_number = par.first_line + 1,
+ total_demerits = 0,
+ active_short = 0,
+ active_glue = 0,
+ }
+ active_width.size = background.size
+ active_width.stretch = background.stretch
+ active_width.fi = background.fi
+ active_width.fil = background.fil
+ active_width.fill = background.fill
+ active_width.filll = background.filll
+ active_width.shrink = background.shrink
- par.passive = nil -- = 0
- par.printed_node = temp_head -- only when tracing, shared
- par.pass_number = 0
--- par.auto_breaking = true
+ if checked_expansion then
+ active_width.adjust_stretch = 0
+ active_width.adjust_shrink = 0
+ end
- setnext(temp_head,head)
+ par.passive = nil -- = 0
+ par.printed_node = temp_head -- only when tracing, shared
+ par.pass_number = 0
+ -- par.auto_breaking = true
- local current = head
- local first_p = current
+ setnext(temp_head,head)
- local auto_breaking = true
+ local current = head
+ local first_p = current
- par.font_in_short_display = 0
+ local auto_breaking = true
- if current then
- local id = getid(current)
- if id == localpar_code then
- par.init_internal_left_box = getfield(current,"box_left")
- par.init_internal_left_box_width = getfield(current,"box_left_width")
- par.internal_pen_inter = getfield(current,"pen_inter")
- par.internal_pen_broken = getfield(current,"pen_broken")
- par.internal_left_box = par.init_internal_left_box
- par.internal_left_box_width = par.init_internal_left_box_width
- par.internal_right_box = getfield(current,"box_right")
- par.internal_right_box_width = getfield(current,"box_right_width")
+ par.font_in_short_display = 0
+
+ if current then
+ local id = getid(current)
+ if id == localpar_code then
+ par.init_internal_left_box = getfield(current,"box_left")
+ par.init_internal_left_box_width = getfield(current,"box_left_width")
+ par.internal_pen_inter = getfield(current,"pen_inter")
+ par.internal_pen_broken = getfield(current,"pen_broken")
+ par.internal_left_box = par.init_internal_left_box
+ par.internal_left_box_width = par.init_internal_left_box_width
+ par.internal_right_box = getfield(current,"box_right")
+ par.internal_right_box_width = getfield(current,"box_right_width")
+ end
end
- end
- -- all passes are combined in this loop so maybe we should split this into
- -- three function calls; we then also need to do the wrap_up elsewhere
+ -- all passes are combined in this loop so maybe we should split this into
+ -- three function calls; we then also need to do the wrap_up elsewhere
- -- split into normal and expansion loop
+ -- split into normal and expansion loop
- -- use an active local
+ -- use an active local
- local fontexp, lastfont -- we can pass fontexp to calculate width if needed
+ local fontexp, lastfont -- we can pass fontexp to calculate width if needed
- -- i flattened the inner loop over glyphs .. it looks nicer and the extra p_active ~= n_active
- -- test is fast enough (and try_break now returns the updated values); the kern helper has been
- -- inlined as it did a double check on id so in fact we had hardly any code to share
+ -- i flattened the inner loop over glyphs .. it looks nicer and the extra p_active ~= n_active
+ -- test is fast enough (and try_break now returns the updated values); the kern helper has been
+ -- inlined as it did a double check on id so in fact we had hardly any code to share
- local p_active = par.active
- local n_active = p_active and p_active.next
- local second_pass = par.second_pass
+ local p_active = par.active
+ local n_active = p_active and p_active.next
+ local second_pass = par.second_pass
- trialcount = 0
+ trialcount = 0
- while current and p_active ~= n_active do
- local char, id = isglyph(current)
- if char then
- local wd, ht, dp = getwhd(current)
- if is_rotated[par.line_break_dir] then
- active_width.size = active_width.size + ht + dp
- else
- active_width.size = active_width.size + wd
- end
- if checked_expansion then
- local currentfont = getfont(current)
- local data = checked_expansion[currentfont]
- if data then
- if currentfont ~= lastfont then
- fontexps = checked_expansion[currentfont] -- a bit redundant for the par line packer
- lastfont = currentfont
- end
- if fontexps then
- local expansion = fontexps[char]
- if expansion then
- active_width.adjust_stretch = active_width.adjust_stretch + expansion.glyphstretch
- active_width.adjust_shrink = active_width.adjust_shrink + expansion.glyphshrink
+ while current and p_active ~= n_active do
+ local char, id = isglyph(current)
+ if char then
+ local wd, ht, dp = getwhd(current)
+ if is_rotated(par.line_break_dir) then
+ active_width.size = active_width.size + ht + dp
+ else
+ active_width.size = active_width.size + wd
+ end
+ if checked_expansion then
+ local currentfont = getfont(current)
+ local data = checked_expansion[currentfont]
+ if data then
+ if currentfont ~= lastfont then
+ fontexps = checked_expansion[currentfont] -- a bit redundant for the par line packer
+ lastfont = currentfont
+ end
+ if fontexps then
+ local expansion = fontexps[char]
+ if expansion then
+ active_width.adjust_stretch = active_width.adjust_stretch + expansion.glyphstretch
+ active_width.adjust_shrink = active_width.adjust_shrink + expansion.glyphshrink
+ end
end
end
end
- end
- elseif id == hlist_code or id == vlist_code then
- local wd, ht, dp = getwhd(current)
- if is_parallel[getdir(current)][par.line_break_dir] then
- active_width.size = active_width.size + wd
- else
- active_width.size = active_width.size + ht + dp
- end
- elseif id == glue_code then
--- if par.auto_breaking then
- if auto_breaking then
- local prev_p = getprev(current)
- if prev_p and prev_p ~= temp_head then
- local id = getid(prev_p)
- -- we need to check this with the latest patches to the tex kernel
- if (id == glyph_code) or (id < math_code) then
- p_active, n_active = try_break(0, unhyphenated_code, par, first_p, current, checked_expansion)
- elseif id == kern_code then
- local s = getsubtype(prev_p)
- if s ~= userkern_code and s ~= italickern_code then
+ elseif id == hlist_code or id == vlist_code then
+ local wd, ht, dp = getwhd(current)
+ if textdir_parallel(getdirection(current),par.line_break_dir) then
+ active_width.size = active_width.size + wd
+ else
+ active_width.size = active_width.size + ht + dp
+ end
+ elseif id == glue_code then
+ -- if par.auto_breaking then
+ if auto_breaking then
+ local prev_p = getprev(current)
+ if prev_p and prev_p ~= temp_head then
+ local id = getid(prev_p)
+ -- we need to check this with the latest patches to the tex kernel
+ if (id == glyph_code) or (id < math_code) then
p_active, n_active = try_break(0, unhyphenated_code, par, first_p, current, checked_expansion)
+ elseif id == kern_code then
+ local s = getsubtype(prev_p)
+ if s ~= userkern_code and s ~= italickern_code then
+ p_active, n_active = try_break(0, unhyphenated_code, par, first_p, current, checked_expansion)
+ end
end
end
end
- end
- check_shrinkage(par,current)
- local width, stretch, shrink, stretch_order = getglue(current)
- local order = stretch_orders[stretch_order]
- active_width.size = active_width.size + width
- active_width[order] = active_width[order] + stretch
- active_width.shrink = active_width.shrink + shrink
- elseif id == disc_code then
- local subtype = getsubtype(current)
- if subtype ~= second_disc_code then
- local line_break_dir = par.line_break_dir
- if second_pass or subtype <= automatic_disc_code then
- local actual_pen = subtype == automatic_disc_code and par.ex_hyphen_penalty or par.hyphen_penalty
- -- 0.81 :
- -- local actual_pen = getpenalty(current)
- --
- local pre, post, replace = getdisc(current)
- if not pre then -- trivial pre-break
- disc_width.size = 0
- if checked_expansion then
- disc_width.adjust_stretch = 0
- disc_width.adjust_shrink = 0
- end
- p_active, n_active = try_break(actual_pen, hyphenated_code, par, first_p, current, checked_expansion)
- else
- local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,pre)
- disc_width.size = size
- active_width.size = active_width.size + size
- if checked_expansion then
- disc_width.adjust_stretch = adjust_stretch
- disc_width.adjust_shrink = adjust_shrink
- active_width.adjust_stretch = active_width.adjust_stretch + adjust_stretch
- active_width.adjust_shrink = active_width.adjust_shrink + adjust_shrink
+ check_shrinkage(par,current)
+ local width, stretch, shrink, stretch_order = getglue(current)
+ local order = fillcodes[stretch_order]
+ active_width.size = active_width.size + width
+ active_width[order] = active_width[order] + stretch
+ active_width.shrink = active_width.shrink + shrink
+ elseif id == disc_code then
+ local subtype = getsubtype(current)
+ if subtype ~= seconddisc_code then
+ local line_break_dir = par.line_break_dir
+ if second_pass or subtype <= automaticdisc_code then
+ local actual_pen = subtype == automaticdisc_code and par.ex_hyphen_penalty or par.hyphen_penalty
+ -- 0.81 :
+ -- local actual_pen = getpenalty(current)
+ --
+ local pre, post, replace = getdisc(current)
+ if not pre then -- trivial pre-break
+ disc_width.size = 0
+ if checked_expansion then
+ disc_width.adjust_stretch = 0
+ disc_width.adjust_shrink = 0
+ end
+ p_active, n_active = try_break(actual_pen, hyphenated_code, par, first_p, current, checked_expansion)
else
- -- disc_width.adjust_stretch = 0
- -- disc_width.adjust_shrink = 0
- end
- p_active, n_active = try_break(actual_pen, hyphenated_code, par, first_p, current, checked_expansion)
- if subtype == first_disc_code then
- local cur_p_next = getnext(current)
- if getid(cur_p_next) ~= disc_code or getsubtype(cur_p_next) ~= second_disc_code then
- report_parbuilders("unsupported disc at location %a",1)
+ local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,pre)
+ disc_width.size = size
+ active_width.size = active_width.size + size
+ if checked_expansion then
+ disc_width.adjust_stretch = adjust_stretch
+ disc_width.adjust_shrink = adjust_shrink
+ active_width.adjust_stretch = active_width.adjust_stretch + adjust_stretch
+ active_width.adjust_shrink = active_width.adjust_shrink + adjust_shrink
else
- local pre = getfield(cur_p_next,"pre")
- if pre then
- local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,pre)
- disc_width.size = disc_width.size + size
- if checked_expansion then
- disc_width.adjust_stretch = disc_width.adjust_stretch + adjust_stretch
- disc_width.adjust_shrink = disc_width.adjust_shrink + adjust_shrink
- end
- p_active, n_active = try_break(actual_pen, hyphenated_code, par, first_p, cur_p_next, checked_expansion)
- --
- -- I will look into this some day ... comment in linebreak.w says that this fails,
- -- maybe this is what Taco means with his comment in the luatex manual.
- --
- -- do_one_seven_eight(sub_disc_width_from_active_width);
- -- do_one_seven_eight(reset_disc_width);
- -- s = vlink_no_break(vlink(current));
- -- add_to_widths(s, line_break_dir, adjust_spacing,disc_width);
- -- ext_try_break(...,first_p,vlink(current));
- --
+ -- disc_width.adjust_stretch = 0
+ -- disc_width.adjust_shrink = 0
+ end
+ p_active, n_active = try_break(actual_pen, hyphenated_code, par, first_p, current, checked_expansion)
+ if subtype == firstdisc_code then
+ local cur_p_next = getnext(current)
+ if getid(cur_p_next) ~= disc_code or getsubtype(cur_p_next) ~= seconddisc_code then
+ report_parbuilders("unsupported disc at location %a",1)
else
- report_parbuilders("unsupported disc at location %a",2)
+ local pre = getfield(cur_p_next,"pre")
+ if pre then
+ local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,pre)
+ disc_width.size = disc_width.size + size
+ if checked_expansion then
+ disc_width.adjust_stretch = disc_width.adjust_stretch + adjust_stretch
+ disc_width.adjust_shrink = disc_width.adjust_shrink + adjust_shrink
+ end
+ p_active, n_active = try_break(actual_pen, hyphenated_code, par, first_p, cur_p_next, checked_expansion)
+ --
+ -- I will look into this some day ... comment in linebreak.w says that this fails,
+ -- maybe this is what Taco means with his comment in the luatex manual.
+ --
+ -- do_one_seven_eight(sub_disc_width_from_active_width);
+ -- do_one_seven_eight(reset_disc_width);
+ -- s = vlink_no_break(vlink(current));
+ -- add_to_widths(s, line_break_dir, adjust_spacing,disc_width);
+ -- ext_try_break(...,first_p,vlink(current));
+ --
+ else
+ report_parbuilders("unsupported disc at location %a",2)
+ end
end
end
+ -- beware, we cannot restore to a saved value as the try_break adapts active_width
+ active_width.size = active_width.size - disc_width.size
+ if checked_expansion then
+ active_width.adjust_stretch = active_width.adjust_stretch - disc_width.adjust_stretch
+ active_width.adjust_shrink = active_width.adjust_shrink - disc_width.adjust_shrink
+ end
end
- -- beware, we cannot restore to a saved value as the try_break adapts active_width
- active_width.size = active_width.size - disc_width.size
+ end
+ if replace then
+ local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,replace)
+ active_width.size = active_width.size + size
if checked_expansion then
- active_width.adjust_stretch = active_width.adjust_stretch - disc_width.adjust_stretch
- active_width.adjust_shrink = active_width.adjust_shrink - disc_width.adjust_shrink
+ active_width.adjust_stretch = active_width.adjust_stretch + adjust_stretch
+ active_width.adjust_shrink = active_width.adjust_shrink + adjust_shrink
end
end
end
- if replace then
- local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,replace)
- active_width.size = active_width.size + size
- if checked_expansion then
- active_width.adjust_stretch = active_width.adjust_stretch + adjust_stretch
- active_width.adjust_shrink = active_width.adjust_shrink + adjust_shrink
+ elseif id == kern_code then
+ local s = getsubtype(current)
+ if s == userkern_code or s == italickern_code then
+ local v = getnext(current)
+ -- if par.auto_breaking and getid(v) == glue_code then
+ if auto_breaking and getid(v) == glue_code then
+ p_active, n_active = try_break(0, unhyphenated_code, par, first_p, current, checked_expansion)
+ end
+ local active_width = par.active_width
+ active_width.size = active_width.size + getkern(current)
+ else
+ local kern = getkern(current)
+ if kern ~= 0 then
+ active_width.size = active_width.size + kern
+ if checked_expansion and expand_kerns and getsubtype(current) == fontkern_code then
+ local stretch, shrink = kern_stretch_shrink(current,kern)
+ if expand_kerns == "stretch" then
+ active_width.adjust_stretch = active_width.adjust_stretch + stretch
+ elseif expand_kerns == "shrink" then
+ active_width.adjust_shrink = active_width.adjust_shrink + shrink
+ else
+ active_width.adjust_stretch = active_width.adjust_stretch + stretch
+ active_width.adjust_shrink = active_width.adjust_shrink + shrink
+ end
+ end
end
end
- end
- elseif id == kern_code then
- local s = getsubtype(current)
- if s == userkern_code or s == italickern_code then
+ elseif id == math_code then
+ -- par.auto_breaking = getsubtype(current) == endmath_code
+ auto_breaking = getsubtype(current) == endmath_code
local v = getnext(current)
- -- if par.auto_breaking and getid(v) == glue_code then
+ -- if par.auto_breaking and getid(v) == glue_code then
if auto_breaking and getid(v) == glue_code then
p_active, n_active = try_break(0, unhyphenated_code, par, first_p, current, checked_expansion)
end
local active_width = par.active_width
- active_width.size = active_width.size + getkern(current)
- else
- local kern = getkern(current)
- if kern ~= 0 then
- active_width.size = active_width.size + kern
- if checked_expansion and expand_kerns and getsubtype(current) == fontkern_code then
- local stretch, shrink = kern_stretch_shrink(current,kern)
- if expand_kerns == "stretch" then
- active_width.adjust_stretch = active_width.adjust_stretch + stretch
- elseif expand_kerns == "shrink" then
- active_width.adjust_shrink = active_width.adjust_shrink + shrink
- else
- active_width.adjust_stretch = active_width.adjust_stretch + stretch
- active_width.adjust_shrink = active_width.adjust_shrink + shrink
- end
- end
+ active_width.size = active_width.size + getkern(current) -- surround
+ -- new in luatex
+ + getwidth(current)
+ elseif id == rule_code then
+ active_width.size = active_width.size + getwidth(current)
+ elseif id == penalty_code then
+ p_active, n_active = try_break(getpenalty(current), unhyphenated_code, par, first_p, current, checked_expansion)
+ elseif id == dir_code then
+ par.line_break_dir = checked_line_dir(dirstack) or par.line_break_dir
+ elseif id == localpar_code then
+ par.internal_pen_inter = getfield(current,"pen_inter")
+ par.internal_pen_broken = getfield(current,"pen_broken")
+ par.internal_left_box = getfield(current,"box_left")
+ par.internal_left_box_width = getfield(current,"box_left_width")
+ par.internal_right_box = getfield(current,"box_right")
+ par.internal_right_box_width = getfield(current,"box_right_width")
+ elseif trace_unsupported then
+ if id == mark_code or id == ins_code or id == adjust_code then
+ -- skip
+ else
+ report_parbuilders("node of type %a found in paragraph",type(id))
end
end
- elseif id == math_code then
--- par.auto_breaking = getsubtype(current) == endmath_code
- auto_breaking = getsubtype(current) == endmath_code
- local v = getnext(current)
--- if par.auto_breaking and getid(v) == glue_code then
- if auto_breaking and getid(v) == glue_code then
- p_active, n_active = try_break(0, unhyphenated_code, par, first_p, current, checked_expansion)
- end
- local active_width = par.active_width
- active_width.size = active_width.size + getkern(current) -- surround
- -- new in luatex
- + getwidth(current)
- elseif id == rule_code then
- active_width.size = active_width.size + getwidth(current)
- elseif id == penalty_code then
- p_active, n_active = try_break(getpenalty(current), unhyphenated_code, par, first_p, current, checked_expansion)
- elseif id == dir_code then
- par.line_break_dir = checked_line_dir(dirstack) or par.line_break_dir
- elseif id == localpar_code then
- par.internal_pen_inter = getfield(current,"pen_inter")
- par.internal_pen_broken = getfield(current,"pen_broken")
- par.internal_left_box = getfield(current,"box_left")
- par.internal_left_box_width = getfield(current,"box_left_width")
- par.internal_right_box = getfield(current,"box_right")
- par.internal_right_box_width = getfield(current,"box_right_width")
- elseif trace_unsupported then
- if id == mark_code or id == ins_code or id == adjust_code then
- -- skip
- else
- report_parbuilders("node of type %a found in paragraph",type(id))
- end
+ current = getnext(current)
end
- current = getnext(current)
- end
- if not current then
- local p_active, n_active = try_break(eject_penalty, hyphenated_code, par, first_p, current, checked_expansion)
- if n_active ~= p_active then
- local r = n_active
- par.fewest_demerits = awful_badness
- repeat -- use local d
- if r.id ~= delta_code and r.total_demerits < par.fewest_demerits then
- par.fewest_demerits = r.total_demerits
- par.best_bet = r
- end
- r = r.next
- until r == p_active
- par.best_line = par.best_bet.line_number
- local asked_looseness = par.looseness
- if asked_looseness == 0 then
- return wrap_up(par)
- end
- local r = n_active
- local actual_looseness = 0
- -- minimize assignments to par but happens seldom
- repeat
- if r.id ~= delta_code then
- local line_diff = r.line_number - par.best_line
- par.line_diff = line_diff
- if (line_diff < actual_looseness and asked_looseness <= line_diff) or
- (line_diff > actual_looseness and asked_looseness >= line_diff) then
- par.best_bet = r
- actual_looseness = line_diff
+ if not current then
+ local p_active, n_active = try_break(eject_penalty, hyphenated_code, par, first_p, current, checked_expansion)
+ if n_active ~= p_active then
+ local r = n_active
+ par.fewest_demerits = awful_badness
+ repeat -- use local d
+ if r.id ~= delta_code and r.total_demerits < par.fewest_demerits then
par.fewest_demerits = r.total_demerits
- elseif line_diff == actual_looseness and r.total_demerits < par.fewest_demerits then
par.best_bet = r
- par.fewest_demerits = r.total_demerits
end
+ r = r.next
+ until r == p_active
+ par.best_line = par.best_bet.line_number
+ local asked_looseness = par.looseness
+ if asked_looseness == 0 then
+ return wrap_up(par)
+ end
+ local r = n_active
+ local actual_looseness = 0
+ -- minimize assignments to par but happens seldom
+ repeat
+ if r.id ~= delta_code then
+ local line_diff = r.line_number - par.best_line
+ par.line_diff = line_diff
+ if (line_diff < actual_looseness and asked_looseness <= line_diff) or
+ (line_diff > actual_looseness and asked_looseness >= line_diff) then
+ par.best_bet = r
+ actual_looseness = line_diff
+ par.fewest_demerits = r.total_demerits
+ elseif line_diff == actual_looseness and r.total_demerits < par.fewest_demerits then
+ par.best_bet = r
+ par.fewest_demerits = r.total_demerits
+ end
+ end
+ r = r.next
+ until r == p_active
+ par.best_line = par.best_bet.line_number
+ if actual_looseness == asked_looseness or par.final_pass then
+ return wrap_up(par)
end
- r = r.next
- until r == p_active
- par.best_line = par.best_bet.line_number
- if actual_looseness == asked_looseness or par.final_pass then
- return wrap_up(par)
end
end
- end
- reset_meta(par) -- clean up the memory by removing the break nodes
- if not second_pass then
- if tracing_paragraphs then
- diagnostics.current_pass(par,"secondpass")
- end
- par.threshold = par.tolerance
- par.second_pass = true
- par.final_pass = par.emergency_stretch <= 0
- else
- if tracing_paragraphs then
- diagnostics.current_pass(par,"emergencypass")
+ reset_meta(par) -- clean up the memory by removing the break nodes
+ if not second_pass then
+ if tracing_paragraphs then
+ diagnostics.current_pass(par,"secondpass")
+ end
+ par.threshold = par.tolerance
+ par.second_pass = true
+ par.final_pass = par.emergency_stretch <= 0
+ else
+ if tracing_paragraphs then
+ diagnostics.current_pass(par,"emergencypass")
+ end
+ par.background.stretch = par.background.stretch + par.emergency_stretch
+ par.final_pass = true
end
- par.background.stretch = par.background.stretch + par.emergency_stretch
- par.final_pass = true
end
+ return wrap_up(par)
end
- return wrap_up(par)
+
end
-- standard tex logging .. will be adapted ..
@@ -2537,7 +2581,7 @@ do
font_in_short_display = font
end
-- todo: instead of components the split tounicode string
- if getsubtype(a) == ligature_code then
+ if getsubtype(a) == ligatureglyph_code then
font_in_short_display = short_display(target,getcomponents(a),font_in_short_display)
else
write(target,utfchar(char))
@@ -2713,55 +2757,6 @@ do
local setnodecolor = nodes.tracers.colors.set
- local function glyph_width_height_depth(curdir,pdir,p)
- local wd, ht, dp = getwhd(p)
- if is_rotated[curdir] then
- if is_parallel[curdir][pdir] then
- local half = (ht + dp) / 2
- return wd, half, half
- else
- local half = wd / 2
- return ht + dp, half, half
- end
- elseif is_rotated[pdir] then
- if is_parallel[curdir][pdir] then
- local half = (ht + dp) / 2
- return wd, half, half
- else
- return ht + dp, wd, 0 -- weird
- end
- else
- if glyphdir_is_equal[curdir][pdir] then
- return wd, ht, dp
- elseif is_opposite[curdir][pdir] then
- return wd, dp, ht
- else -- can this happen?
- return ht + dp, wd, 0
- end
- end
- end
-
- local function pack_width_height_depth(curdir,pdir,p)
- local wd, ht, dp = getwhd(p)
- if is_rotated[curdir] then
- if is_parallel[curdir][pdir] then
- local half = (ht + dp) / 2
- return wd, half, half
- else -- can this happen?
- local half = wd / 2
- return ht + dp, half, half
- end
- else
- if pardir_is_equal[curdir][pdir] then
- return wd, ht, dp
- elseif is_opposite[curdir][pdir] then
- return wd, dp, ht
- else -- weird dimensions, can this happen?
- return ht + dp, wd, 0
- end
- end
- end
-
-- local function xpack(head,width,method,direction,analysis)
--
-- -- inspect(analysis)
@@ -2776,7 +2771,7 @@ do
-- local hlist = new_hlist()
--
-- setlist(hlist,head)
- -- setdir(hlist,direction or tex.textdir)
+ -- setdirection(hlist,direction or tex.textdirection)
-- setwhd(hlist,width,height,depth)
--
-- if delta == 0 then
@@ -2889,7 +2884,7 @@ do
local hlist = new_hlist()
- setdir(hlist,direction)
+ setdirection(hlist,direction)
if head == nil then
setwidth(hlist,width)
@@ -2958,7 +2953,7 @@ do
end
end
-- use inline
- local wd, ht, dp = glyph_width_height_depth(hpack_dir,"TLT",current) -- was TRT ?
+ local wd, ht, dp = getwhd(current)
natural = natural + wd
if ht > height then
height = ht
@@ -2984,7 +2979,7 @@ do
end
elseif id == disc_code then
local subtype = getsubtype(current)
- if subtype ~= second_disc_code then
+ if subtype ~= seconddisc_code then
-- todo : local stretch, shrink = char_stretch_shrink(s)
local replace = getfield(current,"replace")
if replace then
@@ -3008,7 +3003,7 @@ do
end
elseif id == hlist_code or id == vlist_code then
local sh = getshift(current)
- local wd, ht, dp = pack_width_height_depth(hpack_dir,getdir(current) or hpack_dir,current) -- added: or pack_dir
+ local wd, ht, dp = getwhd(current)
local hs, ds = ht - sh, dp + sh
natural = natural + wd
if hs > height then
@@ -3214,7 +3209,7 @@ do
local overfullrule = tex.overfullrule
if fuzz > hfuzz and overfullrule > 0 then
-- weird, is always called and no rules shows up
- setnext(slide_node_list(list),new_rule(overfullrule,nil,nil,getdir(hlist))) -- todo: find_tail
+ setnext(slide_node_list(list),new_rule(overfullrule,nil,nil,getdirection(hlist))) -- todo: find_tail
end
diagnostics.overfull_hbox(hlist,line,-delta)
end
diff --git a/tex/context/base/mkiv/node-nut.lua b/tex/context/base/mkiv/node-nut.lua
index 689a9d1e8..867d79a65 100644
--- a/tex/context/base/mkiv/node-nut.lua
+++ b/tex/context/base/mkiv/node-nut.lua
@@ -257,6 +257,8 @@ nuts.getdepth = direct.getdepth
nuts.setdepth = direct.setdepth
nuts.getshift = direct.getshift
nuts.setshift = direct.setshift
+nuts.gettransform = direct.gettransform or function() end
+nuts.settransform = direct.settransform or function() end
nuts.getnucleus = direct.getnucleus
nuts.setnucleus = direct.setnucleus
diff --git a/tex/context/base/mkiv/node-ppt.lua b/tex/context/base/mkiv/node-ppt.lua
index df2986a4e..b4a542681 100644
--- a/tex/context/base/mkiv/node-ppt.lua
+++ b/tex/context/base/mkiv/node-ppt.lua
@@ -42,7 +42,8 @@ local whatsitcodes = nodes.whatsitcodes
local whatsit_code = nodecodes.whatsit
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
-local userdefined_code = whatsitcodes.userdefined
+
+local userdefinedwhatsit_code = whatsitcodes.userdefined
local nodepool = nodes.pool
local new_usernumber = nodepool.usernumber
@@ -297,7 +298,7 @@ local anchored = {
n = getnext(n)
if getid(n) == whatsit_code then
local subtype = getsubtype(n)
- if (subtype == userdefined_code and getfield(n,"user_id") == property_id) then
+ if (subtype == userdefinedwhatsit_code and getfield(n,"user_id") == property_id) then
-- continue
else
return n
@@ -329,7 +330,7 @@ function properties.attach(head)
starttiming(properties)
for source, subtype in nextwhatsit, head do
- if subtype == userdefined_code then
+ if subtype == userdefinedwhatsit_code then
if last then
removenode(head,last,true)
last = nil
diff --git a/tex/context/base/mkiv/node-pro.lua b/tex/context/base/mkiv/node-pro.lua
index 5de3415f2..6804d810f 100644
--- a/tex/context/base/mkiv/node-pro.lua
+++ b/tex/context/base/mkiv/node-pro.lua
@@ -184,22 +184,22 @@ end
do
- local texnest = tex.nest
+ local texnest = tex.nest
- local getlist = nodes.getlist
- local setlist = nodes.setlist
- local getsubtype = nodes.getsubtype
+ local getlist = nodes.getlist
+ local setlist = nodes.setlist
+ local getsubtype = nodes.getsubtype
- local line_code = nodes.listcodes.line
+ local linelist_code = nodes.listcodes.line
- local actions = tasks.actions("contributers")
+ local actions = tasks.actions("contributers")
function processors.contribute_filter(groupcode)
if groupcode == "box" then -- "pre_box"
local whatever = texnest[texnest.ptr]
if whatever then
local line = whatever.tail
- if line and getsubtype(line) == line_code then
+ if line and getsubtype(line) == linelist_code then
local head = getlist(line)
if head then
local result = actions(head,groupcode,line)
diff --git a/tex/context/base/mkiv/node-ref.lua b/tex/context/base/mkiv/node-ref.lua
index da72337b8..3a6e66779 100644
--- a/tex/context/base/mkiv/node-ref.lua
+++ b/tex/context/base/mkiv/node-ref.lua
@@ -67,21 +67,25 @@ local getattr = nuts.getattr
local setattr = nuts.setattr
local getsubtype = nuts.getsubtype
local getwhd = nuts.getwhd
-local getdir = nuts.getdir
+local getdirection = nuts.getdirection
local setshift = nuts.setshift
local getboxglue = nuts.getboxglue
local hpack_list = nuts.hpack
local vpack_list = nuts.vpack
-local list_dimensions = nuts.dimensions
-local list_rangedimensions = nuts.rangedimensions
+local getdimensions = nuts.dimensions
+local getrangedimensions = nuts.rangedimensions
local traverse = nuts.traverse
local find_node_tail = nuts.tail
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
local listcodes = nodes.listcodes
+local dirvalues = nodes.dirvalues
+local lefttoright_code = dirvalues.lefttoright
+local righttoleft_code = dirvalues.righttoleft
+
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
local glue_code = nodecodes.glue
@@ -90,11 +94,11 @@ local rule_code = nodecodes.rule
local dir_code = nodecodes.dir
local localpar_code = nodecodes.localpar
-local leftskip_code = skipcodes.leftskip
-local rightskip_code = skipcodes.rightskip
-local parfillskip_code = skipcodes.parfillskip
+local leftskip_code = gluecodes.leftskip
+local rightskip_code = gluecodes.rightskip
+local parfillskip_code = gluecodes.parfillskip
-local line_code = listcodes.line
+----- linelist_code = listcodes.line
local new_rule = nodepool.rule
local new_kern = nodepool.kern
@@ -113,9 +117,9 @@ local implement = interfaces.implement
local function hlist_dimensions(start,stop,parent)
local last = stop and getnext(stop)
if parent then
- return list_rangedimensions(parent,start,last)
+ return getrangedimensions(parent,start,last)
else
- return list_dimensions(start,last)
+ return getdimensions(start,last)
end
end
@@ -250,11 +254,13 @@ local function dimensions(parent,start,stop) -- in principle we could move some
end
end
--- is pardir important at all?
-
local function inject_range(head,first,last,reference,make,stack,parent,pardir,txtdir)
local width, height, depth, line = dimensions(parent,first,last)
- if txtdir == "+TRT" or (txtdir == "===" and pardir == "TRT") then -- KH: textdir == "===" test added
+ if txtdir == righttoleft_code then
+ width = - width
+ elseif textdir == lefttoright_code then
+ -- go on
+ elseif pardir == righttoleft_code then
width = - width
end
local result, resolved = make(width,height,depth,reference)
@@ -264,7 +270,7 @@ local function inject_range(head,first,last,reference,make,stack,parent,pardir,t
local l = getlist(line)
if trace_areas then
report_area("%s: %i : %s %s %s => w=%p, h=%p, d=%p","line",
- reference,pardir or "---",txtdir or "---",
+ reference,pardir or "?",txtdir or "?",
tosequence(l,nil,true),width,height,depth)
end
setlist(line,result)
@@ -273,7 +279,7 @@ local function inject_range(head,first,last,reference,make,stack,parent,pardir,t
elseif head == first then
if trace_areas then
report_area("%s: %i : %s %s %s => w=%p, h=%p, d=%p","head",
- reference,pardir or "---",txtdir or "---",
+ reference,pardir or "?",txtdir or "?",
tosequence(first,last,true),width,height,depth)
end
setlink(result,first)
@@ -281,7 +287,7 @@ local function inject_range(head,first,last,reference,make,stack,parent,pardir,t
else
if trace_areas then
report_area("%s: %i : %s %s %s => w=%p, h=%p, d=%p","middle",
- reference,pardir or "---",txtdir or "---",
+ reference,pardir or "?",txtdir or "?",
tosequence(first,last,true),width,height,depth)
end
if first == last and getid(parent) == vlist_code and getid(first) == hlist_code then
@@ -306,7 +312,7 @@ local function inject_list(id,current,reference,make,stack,pardir,txtdir)
local correction = 0
local moveright = false
local first = getlist(current)
- if id == hlist_code then -- box_code line_code
+ if id == hlist_code then -- boxlist_code linelist_code
-- can be either an explicit hbox or a line and there is no way
-- to recognize this; anyway only if ht/dp (then inline)
local sr = stack[reference]
@@ -337,7 +343,7 @@ local function inject_list(id,current,reference,make,stack,pardir,txtdir)
correction = height + depth
height, depth = depth, height -- ugly hack, needed because pdftex backend does something funny
end
- if pardir == "TRT" then
+ if pardir == righttoleft_code then
width = - width
end
local result, resolved = make(width,height,depth,reference)
@@ -345,7 +351,7 @@ local function inject_list(id,current,reference,make,stack,pardir,txtdir)
if result and resolved then
if trace_areas then
report_area("%s: %04i %s %s %s: w=%p, h=%p, d=%p, c=%S","box",
- reference,pardir or "---",txtdir or "----","[]",width,height,depth,resolved)
+ reference,pardir or "?",txtdir or "?","[]",width,height,depth,resolved)
end
if not first then
setlist(current,result)
@@ -370,12 +376,6 @@ end
local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,txtdir) -- main
local first, last, firstdir, reference
- if not pardir then
- pardir = "==="
- end
- if not texdir then
- txtdir = "==="
- end
local current = head
while current do
local id = getid(current)
@@ -416,9 +416,10 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx
elseif id == glue_code and getsubtype(current) == leftskip_code then -- any glue at the left?
--
elseif id == dir_code then
- txtdir = getdir(current)
+ local direction, pop = getdirection(current)
+ txtdir = not pop and direction -- we might need a stack
elseif id == localpar_code then -- only test at begin
- pardir = getdir(current)
+ pardir = getdirection(current)
else
local r = getattr(current,attribute)
if not r then
@@ -450,12 +451,6 @@ end
--
-- local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,txtdir) -- main
-- local first, last, firstdir, reference
--- if not pardir then
--- pardir = "==="
--- end
--- if not texdir then
--- txtdir = "==="
--- end
-- local someatt = findattr(head,attribute)
-- if someatt then
-- local current = head
@@ -496,9 +491,10 @@ end
-- done[r] = done[r] - 1
-- end
-- elseif id == dir_code then
--- txtdir = getdir(current)
+-- local direction, pop = getdirection(current)
+-- txtdir = not pop and direction -- we might need a stack
-- elseif id == localpar_code then -- only test at begin
--- pardir = getdir(current)
+-- pardir = getdirection(current)
-- elseif id == glue_code and getsubtype(current) == leftskip_code then -- any glue at the left?
-- --
-- else
@@ -536,9 +532,10 @@ end
-- end
-- end
-- elseif id == dir_code then
--- txtdir = getdir(current)
+-- local direction, pop = getdirection(current)
+-- txtdir = not pop and direction -- we might need a stack
-- elseif id == localpar_code then -- only test at begin
--- pardir = getdir(current)
+-- pardir = getdirection(current)
-- end
-- current = getnext(current)
-- end
@@ -550,12 +547,6 @@ end
--
-- local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,txtdir) -- main
-- local first, last, firstdir, reference
--- if not pardir then
--- pardir = "==="
--- end
--- if not texdir then
--- txtdir = "==="
--- end
-- local current = head
-- while current do
-- local id = getid(current)
@@ -599,9 +590,10 @@ end
-- elseif id == glue_code and getsubtype(current) == leftskip_code then -- any glue at the left?
-- --
-- elseif id == dir_code then
--- txtdir = getdir(current)
+-- local direction, pop = getdirection(current)
+-- txtdir = not pop and direction -- we might need a stack
-- elseif id == localpar_code then -- only test at begin
--- pardir = getdir(current)
+-- pardir = getdirection(current)
-- end
-- goto next
-- ::rest::
diff --git a/tex/context/base/mkiv/node-res.lua b/tex/context/base/mkiv/node-res.lua
index 01cf1d1f0..da5dca9f3 100644
--- a/tex/context/base/mkiv/node-res.lua
+++ b/tex/context/base/mkiv/node-res.lua
@@ -22,20 +22,20 @@ nodes.pool = nodes.pool or { }
local nodepool = nodes.pool
local whatsitcodes = nodes.whatsitcodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
local kerncodes = nodes.kerncodes
local rulecodes = nodes.rulecodes
local nodecodes = nodes.nodecodes
-local gluecodes = nodes.gluecodes
+local leadercodes = nodes.leadercodes
local boundarycodes = nodes.boundarycodes
local usercodes = nodes.usercodes
-local glyphcode = nodecodes.glyph
-local rulecode = nodecodes.rule
-local kerncode = nodecodes.kern
-local gluecode = nodecodes.glue
-local whatsitcode = nodecodes.whatsit
+local glyph_code = nodecodes.glyph
+local rule_code = nodecodes.rule
+local kern_code = nodecodes.kern
+local glue_code = nodecodes.glue
+local whatsit_code = nodecodes.whatsit
local currentfont = font.current
@@ -159,21 +159,20 @@ nutpool.register = register_node -- could be register_nut
-- so far
local disc = register_nut(new_nut(nodecodes.disc))
-local kern = register_nut(new_nut(kerncode,kerncodes.userkern))
-local fontkern = register_nut(new_nut(kerncode,kerncodes.fontkern))
-local italickern = register_nut(new_nut(kerncode,kerncodes.italiccorrection))
+local kern = register_nut(new_nut(kern_code,kerncodes.userkern))
+local fontkern = register_nut(new_nut(kern_code,kerncodes.fontkern))
+local italickern = register_nut(new_nut(kern_code,kerncodes.italiccorrection))
local penalty = register_nut(new_nut(nodecodes.penalty))
-local glue = register_nut(new_nut(gluecode)) -- glue.spec = nil
+local glue = register_nut(new_nut(glue_code)) -- glue.spec = nil
local glue_spec = register_nut(new_nut(nodecodes.gluespec))
-local glyph = register_nut(new_nut(glyphcode,0))
-
+local glyph = register_nut(new_nut(glyph_code,0))
local textdir = register_nut(new_nut(nodecodes.dir))
-local latelua = register_nut(new_nut(whatsitcode,whatsitcodes.latelua))
-local savepos = register_nut(new_nut(whatsitcode,whatsitcodes.savepos))
+local latelua = register_nut(new_nut(whatsit_code,whatsitcodes.latelua))
+local savepos = register_nut(new_nut(whatsit_code,whatsitcodes.savepos))
-local user_node = new_nut(whatsitcode,whatsitcodes.userdefined)
+local user_node = new_nut(whatsit_code,whatsitcodes.userdefined)
local user_number = register_nut(copy_nut(user_node)) setfield(user_number, "type",usercodes.number)
local user_nodes = register_nut(copy_nut(user_node)) setfield(user_nodes, "type",usercodes.node)
@@ -185,10 +184,10 @@ local user_attributes = register_nut(copy_nut(user_node)) setfield(user_attrib
local left_margin_kern = register_nut(new_nut(nodecodes.marginkern,0))
local right_margin_kern = register_nut(new_nut(nodecodes.marginkern,1))
-local lineskip = register_nut(new_nut(gluecode,skipcodes.lineskip))
-local baselineskip = register_nut(new_nut(gluecode,skipcodes.baselineskip))
-local leftskip = register_nut(new_nut(gluecode,skipcodes.leftskip))
-local rightskip = register_nut(new_nut(gluecode,skipcodes.rightskip))
+local lineskip = register_nut(new_nut(glue_code,gluecodes.lineskip))
+local baselineskip = register_nut(new_nut(glue_code,gluecodes.baselineskip))
+local leftskip = register_nut(new_nut(glue_code,gluecodes.leftskip))
+local rightskip = register_nut(new_nut(glue_code,gluecodes.rightskip))
local temp = register_nut(new_nut(nodecodes.temp,0))
@@ -207,15 +206,18 @@ local choice = register_nut(new_nut(nodecodes.choice))
local boundary = register_nut(new_nut(nodecodes.boundary,boundarycodes.user))
local wordboundary = register_nut(new_nut(nodecodes.boundary,boundarycodes.word))
-local cleader = register_nut(copy_nut(glue)) setsubtype(cleader,gluecodes.cleaders) setglue(cleader,0,65536,0,2,0)
+local cleader = register_nut(copy_nut(glue)) setsubtype(cleader,leadercodes.cleaders) setglue(cleader,0,65536,0,2,0)
-- the dir field needs to be set otherwise crash:
-local rule = register_nut(new_nut(rulecode)) setdir(rule, "TLT")
-local emptyrule = register_nut(new_nut(rulecode,rulecodes.empty)) setdir(rule, "TLT")
-local userrule = register_nut(new_nut(rulecode,rulecodes.user)) setdir(rule, "TLT")
-local hlist = register_nut(new_nut(nodecodes.hlist)) setdir(hlist,"TLT")
-local vlist = register_nut(new_nut(nodecodes.vlist)) setdir(vlist,"TLT")
+local lefttoright_code = nodes.dirvalues.lefttoright
+
+local rule = register_nut(new_nut(rule_code)) setdirection(rule, lefttoright_code)
+local emptyrule = register_nut(new_nut(rule_code,rulecodes.empty)) setdirection(rule, lefttoright_code)
+local userrule = register_nut(new_nut(rule_code,rulecodes.user)) setdirection(rule, lefttoright_code)
+local outlinerule = register_nut(new_nut(rule_code,rulecodes.outline)) setdirection(rule, lefttoright_code)
+local hlist = register_nut(new_nut(nodecodes.hlist)) setdirection(hlist,lefttoright_code)
+local vlist = register_nut(new_nut(nodecodes.vlist)) setdirection(vlist,lefttoright_code)
function nutpool.glyph(fnt,chr)
local n = copy_nut(glyph)
@@ -347,7 +349,7 @@ function nutpool.disc(pre,post,replace)
return d
end
-function nutpool.textdir(dir)
+function nutpool.textdir(dir) -- obsolete !
local t = copy_nut(textdir)
if dir then
setdir(t,dir)
@@ -367,42 +369,40 @@ function nutpool.direction(dir,swap)
return t
end
-function nutpool.rule(width,height,depth,dir) -- w/h/d == nil will let them adapt
+function nutpool.rule(width,height,depth,direction) -- w/h/d == nil will let them adapt
local n = copy_nut(rule)
if width or height or depth then
setwhd(n,width,height,depth)
end
- if dir then
- setdir(n,dir)
+ if direction then
+ setdirection(n,direction)
end
return n
end
-function nutpool.emptyrule(width,height,depth,dir) -- w/h/d == nil will let them adapt
+function nutpool.emptyrule(width,height,depth,direction) -- w/h/d == nil will let them adapt
local n = copy_nut(emptyrule)
if width or height or depth then
setwhd(n,width,height,depth)
end
- if dir then
- setdir(n,dir)
+ if direction then
+ setdirection(n,direction)
end
return n
end
-function nutpool.userrule(width,height,depth,dir) -- w/h/d == nil will let them adapt
+function nutpool.userrule(width,height,depth,direction) -- w/h/d == nil will let them adapt
local n = copy_nut(userrule)
if width or height or depth then
setwhd(n,width,height,depth)
end
- if dir then
- setdir(n,dir)
+ if direction then
+ setdirection(n,direction)
end
return n
end
-local outlinerule = register_nut(new_nut(rulecode,rulecodes.outline)) setdir(rule, "TLT")
-
-function nutpool.outlinerule(width,height,depth,line,dir) -- w/h/d == nil will let them adapt
+function nutpool.outlinerule(width,height,depth,line,direction) -- w/h/d == nil will let them adapt
local n = copy_nut(outlinerule)
if width or height or depth then
setwhd(n,width,height,depth)
@@ -410,8 +410,8 @@ function nutpool.outlinerule(width,height,depth,line,dir) -- w/h/d == nil will l
if line then
setfield(n,"transform",line)
end
- if dir then
- setdir(n,dir)
+ if direction then
+ setdirection(n,direction)
end
return n
end
@@ -443,7 +443,7 @@ function nutpool.leftmarginkern(glyph,width)
local n = copy_nut(left_margin_kern)
if not glyph then
report_nodes("invalid pointer to left margin glyph node")
- elseif getid(glyph) ~= glyphcode then
+ elseif getid(glyph) ~= glyph_code then
report_nodes("invalid node type %a for %s margin glyph node",nodecodes[glyph],"left")
else
setfield(n,"glyph",glyph)
@@ -458,7 +458,7 @@ function nutpool.rightmarginkern(glyph,width)
local n = copy_nut(right_margin_kern)
if not glyph then
report_nodes("invalid pointer to right margin glyph node")
- elseif getid(glyph) ~= glyphcode then
+ elseif getid(glyph) ~= glyph_code then
report_nodes("invalid node type %a for %s margin glyph node",nodecodes[p],"right")
else
setfield(n,"glyph",glyph)
diff --git a/tex/context/base/mkiv/node-rul.lua b/tex/context/base/mkiv/node-rul.lua
index eee60efa0..54500a493 100644
--- a/tex/context/base/mkiv/node-rul.lua
+++ b/tex/context/base/mkiv/node-rul.lua
@@ -37,7 +37,7 @@ local setlink = nuts.setlink
local getnext = nuts.getnext
local getprev = nuts.getprev
local getid = nuts.getid
-local getdir = nuts.getdir
+local getdirection = nuts.getdirection
local getattr = nuts.getattr
local setattr = nuts.setattr
local getfont = nuts.getfont
@@ -56,7 +56,7 @@ local insert_node_after = nuts.insert_after
local insert_node_before = nuts.insert_before
local find_tail = nuts.tail
local setglue = nuts.setglue
-local list_dimensions = nuts.rangedimensions
+local getrangedimensions = nuts.rangedimensions
local hpack_nodes = nuts.hpack
local copy_list = nuts.copy_list
@@ -66,7 +66,6 @@ local nodecodes = nodes.nodecodes
local rulecodes = nodes.rulecodes
local gluecodes = nodes.gluecodes
local listcodes = nodes.listcodes
-local kerncodes = nodes.kerncodes
local glyph_code = nodecodes.glyph
local localpar_code = nodecodes.localpar
@@ -74,8 +73,8 @@ local dir_code = nodecodes.dir
local glue_code = nodecodes.glue
local hlist_code = nodecodes.hlist
-local indent_code = listcodes.indent
-local line_code = listcodes.line
+local indentlist_code = listcodes.indent
+local linelist_code = listcodes.line
local leftskip_code = gluecodes.leftskip
local rightskip_code = gluecodes.rightskip
@@ -265,7 +264,7 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a
if not f then
return head
end
- local w, ht, dp = list_dimensions(parent,f,getnext(l))
+ local w, ht, dp = getrangedimensions(parent,f,getnext(l))
local method = d.method
local empty = d.empty == v_yes
local offset = d.offset
@@ -410,7 +409,7 @@ local function flush_shifted(head,first,last,data,level,parent,strip) -- not tha
local next = getnext(last)
setprev(first)
setnext(last)
- local width, height, depth = list_dimensions(parent,first,next)
+ local width, height, depth = getrangedimensions(parent,first,next)
local list = hpack_nodes(first,width,"exactly") -- we can use a simple pack
if first == head then
head = list
@@ -471,7 +470,7 @@ local function linefiller(current,data,width,location)
ca = ca,
ta = ta,
option = location,
- direction = getdir(current),
+ direction = getdirection(current),
}
else
local rule = new_rule(width,height,depth)
@@ -507,7 +506,7 @@ function nodes.linefillers.filler(current,data,width,height,depth)
ca = ca,
ta = ta,
option = location,
- direction = getdir(current),
+ direction = getdirection(current),
}
else
local rule = new_rule(width,height,depth)
@@ -536,7 +535,7 @@ end
function nodes.linefillers.handler(head)
for current, subtype, list in nexthlist, head do
- if list and subtype == line_code then
+ if list and subtype == linelist_code then
-- why doesn't leftskip take the attributes
-- or list[linefiller] or maybe first match (maybe we need a fast helper for that)
local a = getattr(current,a_linefiller)
@@ -575,7 +574,7 @@ function nodes.linefillers.handler(head)
elseif id == localpar_code or id == dir_code then
-- go on
elseif id == hlist_code then
- if getsubtype(head) == indent_code then
+ if getsubtype(head) == indentlist_code then
iskip = head
end
break
diff --git a/tex/context/base/mkiv/node-rul.mkiv b/tex/context/base/mkiv/node-rul.mkiv
index c413edb1c..19f398eb9 100644
--- a/tex/context/base/mkiv/node-rul.mkiv
+++ b/tex/context/base/mkiv/node-rul.mkiv
@@ -71,7 +71,7 @@
%definesystemattribute[ruled]
%definesystemattribute[shifted]
-\registerctxluafile{node-rul}{}
+\registerctxluafile{node-rul}{optimize}
\installcorenamespace{bar}
\installcorenamespace{barindex}
diff --git a/tex/context/base/mkiv/node-scn.lua b/tex/context/base/mkiv/node-scn.lua
index 62c9fecec..a40a5271a 100644
--- a/tex/context/base/mkiv/node-scn.lua
+++ b/tex/context/base/mkiv/node-scn.lua
@@ -24,9 +24,8 @@ local setlist = nuts.setlist
local end_of_math = nuts.end_of_math
local nodecodes = nodes.nodecodes
-local rulecodes = nodes.rulecodes
+local leadercodes = nodes.leadercodes
local gluecodes = nodes.gluecodes
-local listcodes = nodes.listcodes
local kerncodes = nodes.kerncodes
local glyph_code = nodecodes.glyph
@@ -44,7 +43,8 @@ local vlist_code = nodecodes.vlist
local userskip_code = gluecodes.userskip
local spaceskip_code = gluecodes.spaceskip
local xspaceskip_code = gluecodes.xspaceskip
-local leader_code = gluecodes.leaders
+
+local leaders_code = leadercodes.leaders
local fontkern_code = kerncodes.fontkern
@@ -203,7 +203,7 @@ local function processwords(attribute,data,flush,head,parent,skip) -- we have hl
elseif id == glue_code then
-- catch \underbar{a} \underbar{a} (subtype test is needed)
local subtype = getsubtype(n)
- if getattr(n,attribute) and (subtype == userskip_code or subtype == spaceskip_code or subtype == xspaceskip_code or (leaders and subtype >= leader_code)) then
+ if getattr(n,attribute) and (subtype == userskip_code or subtype == spaceskip_code or subtype == xspaceskip_code or (leaders and subtype >= leaders_code)) then
l = n
else
head, done = flush(head,f,l,d,level,parent,strip), true
diff --git a/tex/context/base/mkiv/node-ser.lua b/tex/context/base/mkiv/node-ser.lua
index 4f201ca5e..6fc2b7ea4 100644
--- a/tex/context/base/mkiv/node-ser.lua
+++ b/tex/context/base/mkiv/node-ser.lua
@@ -24,7 +24,6 @@ local is_node = nodes.is_node
local nodecodes = nodes.nodecodes
local subtcodes = nodes.codes
-local noadcodes = nodes.noadcodes
local getfields = nodes.fields
local tonode = nodes.tonode
diff --git a/tex/context/base/mkiv/node-shp.lua b/tex/context/base/mkiv/node-shp.lua
index c7f1c9810..55fe0843a 100644
--- a/tex/context/base/mkiv/node-shp.lua
+++ b/tex/context/base/mkiv/node-shp.lua
@@ -13,46 +13,46 @@ local format = string.format
local concat, sortedpairs = table.concat, table.sortedpairs
local setmetatableindex = table.setmetatableindex
-local nodecodes = nodes.nodecodes
-local whatsitcodes = nodes.whatsitcodes
-local disccodes = nodes.disccodes
+local nodecodes = nodes.nodecodes
+local whatsitcodes = nodes.whatsitcodes
+local disccodes = nodes.disccodes
-local tasks = nodes.tasks
-local handlers = nodes.handlers
+local tasks = nodes.tasks
+local handlers = nodes.handlers
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local disc_code = nodecodes.disc
-local whatsit_code = nodecodes.whatsit
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local disc_code = nodecodes.disc
+local whatsit_code = nodecodes.whatsit
-local fulldisc_code = disccodes.discretionary
+local discretionarydisc_code = disccodes.discretionary
-local implement = interfaces.implement
+local implement = interfaces.implement
-local nuts = nodes.nuts
-local tonut = nuts.tonut
-local tonode = nuts.tonode
-local remove_node = nuts.remove
+local nuts = nodes.nuts
+local tonut = nuts.tonut
+local tonode = nuts.tonode
+local remove_node = nuts.remove
-local nextnode = nuts.traversers.node
+local nextnode = nuts.traversers.node
-local setfield = nuts.setfield
-local setlink = nuts.setlink
-local setprev = nuts.setprev
-local setnext = nuts.setnext
-local getid = nuts.getid
-local getdisc = nuts.getdisc
-local getboth = nuts.getboth
-local getnext = nuts.getnext
-local getlist = nuts.getlist
-local getsubtype = nuts.getsubtype
+local setfield = nuts.setfield
+local setlink = nuts.setlink
+local setprev = nuts.setprev
+local setnext = nuts.setnext
+local getid = nuts.getid
+local getdisc = nuts.getdisc
+local getboth = nuts.getboth
+local getnext = nuts.getnext
+local getlist = nuts.getlist
+local getsubtype = nuts.getsubtype
-local setlist = nuts.setlist
+local setlist = nuts.setlist
-local getbox = nuts.getbox
-local getboxnode = nodes.getbox
+local getbox = nuts.getbox
+local getboxnode = nodes.getbox
-local removables = {
+local removables = {
[whatsitcodes.open] = true,
[whatsitcodes.close] = true,
[whatsitcodes.write] = true,
@@ -74,7 +74,7 @@ local function cleanup_redundant(head) -- better name is: flatten_page
while start do
local id = getid(start)
if id == disc_code then
- if getsubtype(start) == fulldisc_code then
+ if getsubtype(start) == discretionarydisc_code then
local _, _, replace, _, _ tail = getdisc(start,true)
if replace then
local prev, next = getboth(start)
diff --git a/tex/context/base/mkiv/node-tra.lua b/tex/context/base/mkiv/node-tra.lua
index bb08e1030..7c2a93af0 100644
--- a/tex/context/base/mkiv/node-tra.lua
+++ b/tex/context/base/mkiv/node-tra.lua
@@ -50,7 +50,7 @@ local setattr = nuts.setattr
local getglue = nuts.getglue
local isglyph = nuts.isglyph
local getcomponents = nuts.getcomponents
-local getdir = nuts.getdir
+local getdirection = nuts.getdirection
local getwidth = nuts.getwidth
local flush_list = nuts.flush_list
@@ -66,8 +66,7 @@ local nutpool = nuts.pool
local new_rule = nutpool.rule
local nodecodes = nodes.nodecodes
-local whatcodes = nodes.whatcodes
-local skipcodes = nodes.skipcodes
+local whatsitcodes = nodes.whatsitcodes
local fillcodes = nodes.fillcodes
local subtypes = nodes.subtypes
@@ -84,7 +83,6 @@ local localpar_code = nodecodes.localpar
local whatsit_code = nodecodes.whatsit
local dimenfactors = number.dimenfactors
-local fillorders = nodes.fillcodes
local formatters = string.formatters
-- this will be reorganized:
@@ -130,7 +128,6 @@ function nodes.handlers.checkforleaks(sparse)
end
end
-
local function tosequence(start,stop,compact)
if start then
local f_sequence = formatters["U+%04X:%s"]
@@ -160,13 +157,11 @@ local function tosequence(start,stop,compact)
else
t[#t+1] = nodecodes[id]
end
- elseif id == dir_code or id == localpar_code then
- local d = getdir(start)
- if d then
- t[#t+1] = "[" .. d .. "]"
- else
- t[#t+1] = "[]"
- end
+ elseif id == dir_code then
+ local d, p = getdirection(start)
+ t[#t+1] = "[<" .. (p and "-" or "+") .. d .. ">]" -- todo l2r etc
+ elseif id == localpar_code then
+ t[#t+1] = "[<" .. getdirection(start) .. ">]" -- todo l2r etc
elseif compact then
t[#t+1] = "[]"
else
@@ -213,7 +208,7 @@ function nodes.idstostring(head,tail)
local f_one = formatters["[%s]"]
for n, id, subtype in nextnode, head do
if id == whatsit_code then
- id = whatcodes[subtype]
+ id = whatsitcodes[subtype]
else
id = nodecodes[id]
end
@@ -428,17 +423,17 @@ local function nodetodimen(n)
width = width / 65536
if stretch_order ~= 0 then
if shrink_order ~= 0 then
- return f_f_f(width,stretch,fillorders[stretch_order],shrink,fillorders[shrink_order])
+ return f_f_f(width,stretch,fillcodes[stretch_order],shrink,fillcodes[shrink_order])
elseif shrink ~= 0 then
- return f_f_m(width,stretch,fillorders[stretch_order],shrink)
+ return f_f_m(width,stretch,fillcodes[stretch_order],shrink)
else
- return f_f_z(width,stretch,fillorders[stretch_order])
+ return f_f_z(width,stretch,fillcodes[stretch_order])
end
elseif shrink_order ~= 0 then
if stretch ~= 0 then
- return f_p_f(width,stretch,shrink,fillorders[shrink_order])
+ return f_p_f(width,stretch,shrink,fillcodes[shrink_order])
else
- return f_z_f(width,shrink,fillorders[shrink_order])
+ return f_z_f(width,shrink,fillcodes[shrink_order])
end
elseif stretch ~= 0 then
if shrink ~= 0 then
diff --git a/tex/context/base/mkiv/node-tst.lua b/tex/context/base/mkiv/node-tst.lua
index 7ad35bd71..0dacff375 100644
--- a/tex/context/base/mkiv/node-tst.lua
+++ b/tex/context/base/mkiv/node-tst.lua
@@ -10,7 +10,7 @@ local nodes, node = nodes, node
local chardata = characters.data
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
local glue_code = nodecodes.glue
local penalty_code = nodecodes.penalty
@@ -19,10 +19,10 @@ local glyph_code = nodecodes.glyph
local whatsit_code = nodecodes.whatsit
local hlist_code = nodecodes.hlist
-local leftskip_code = skipcodes.leftskip
-local rightskip_code = skipcodes.rightskip
-local abovedisplayshortskip_code = skipcodes.abovedisplayshortskip
-local belowdisplayshortskip_code = skipcodes.belowdisplayshortskip
+local leftskip_code = gluecodes.leftskip
+local rightskip_code = gluecodes.rightskip
+local abovedisplayshortskip_code = gluecodes.abovedisplayshortskip
+local belowdisplayshortskip_code = gluecodes.belowdisplayshortskip
local nuts = nodes.nuts
diff --git a/tex/context/base/mkiv/pack-rul.lua b/tex/context/base/mkiv/pack-rul.lua
index c89335220..455d0bff8 100644
--- a/tex/context/base/mkiv/pack-rul.lua
+++ b/tex/context/base/mkiv/pack-rul.lua
@@ -20,46 +20,50 @@ if not modules then modules = { } end modules ['pack-rul'] = {
local type = type
-local context = context
-
-local hlist_code = nodes.nodecodes.hlist
-local vlist_code = nodes.nodecodes.vlist
-local box_code = nodes.listcodes.box
-local line_code = nodes.listcodes.line
-local equation_code = nodes.listcodes.equation
-
-local texsetdimen = tex.setdimen
-local texsetcount = tex.setcount
-
-local implement = interfaces.implement
-
-local nuts = nodes.nuts
-
-local getnext = nuts.getnext
-local getprev = nuts.getprev
-local getlist = nuts.getlist
-local setlist = nuts.setlist
-local getwhd = nuts.getwhd
-local getid = nuts.getid
-local getsubtype = nuts.getsubtype
-local getbox = nuts.getbox
-local getdir = nuts.getdir
-local getdirection = nuts.getdirection
-local setshift = nuts.setshift
-local setwidth = nuts.setwidth
-local getwidth = nuts.getwidth
-local setboxglue = nuts.setboxglue
-local getboxglue = nuts.getboxglue
-
-local hpack = nuts.hpack
-local list_dimensions = nuts.dimensions
-local flush_node = nuts.flush
-
-local nexthlist = nuts.traversers.hlist
-local nextvlist = nuts.traversers.vlist
-local nextlist = nuts.traversers.list
-
-local checkformath = false
+local context = context
+
+local nodecodes = nodes.nodecodes
+local listcodes = nodes.listcodes
+
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+
+local boxlist_code = listcodes.box
+local linelist_code = listcodes.line
+local equationlist_code = listcodes.equation
+
+local texsetdimen = tex.setdimen
+local texsetcount = tex.setcount
+
+local implement = interfaces.implement
+
+local nuts = nodes.nuts
+
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getlist = nuts.getlist
+local setlist = nuts.setlist
+local getwhd = nuts.getwhd
+local getid = nuts.getid
+local getsubtype = nuts.getsubtype
+local getbox = nuts.getbox
+local getdirection = nuts.getdirection
+local setshift = nuts.setshift
+local setwidth = nuts.setwidth
+local getwidth = nuts.getwidth
+local setboxglue = nuts.setboxglue
+local getboxglue = nuts.getboxglue
+
+local hpack = nuts.hpack
+local getdimensions = nuts.dimensions
+local flush_node = nuts.flush
+
+local traversers = nuts.traversers
+local nexthlist = traversers.hlist
+local nextvlist = traversers.vlist
+local nextlist = traversers.list
+
+local checkformath = false
directives.register("framed.checkmath",function(v) checkformath = v end) -- experiment
@@ -90,9 +94,8 @@ local function doreshapeframedbox(n)
noflines = noflines + 1
if list then
if id == hlist_code then
- if subtype == box_code or subtype == line_code then
- -- lastlinelength = list_dimensions(list,getdir(n))
- lastlinelength = list_dimensions(list,getdirection(n))
+ if subtype == boxlist_code or subtype == linelist_code then
+ lastlinelength = getdimensions(list)
else
lastlinelength = width
end
@@ -119,13 +122,13 @@ local function doreshapeframedbox(n)
if hdone then
for h, id, subtype, list in nextlist, list do
if list and id == hlist_code then
- if subtype == box_code or subtype == line_code then
- local p = hpack(list,maxwidth,'exactly',getdir(h)) -- multiple return value
+ if subtype == boxlist_code or subtype == linelist_code then
+ local p = hpack(list,maxwidth,'exactly',getdirection(h)) -- multiple return value
local set, order, sign = getboxglue(p)
setboxglue(h,set,order,sign)
setlist(p)
flush_node(p)
- elseif checkformath and subtype == equation_code then
+ elseif checkformath and subtype == equationlist_code then
-- display formulas use a shift
if nofnonzero == 1 then
setshift(h,0)
@@ -209,8 +212,8 @@ local function maxboxwidth(box)
for n, subtype in nexthlist, list do -- no dir etc needed
local l = getlist(n)
if l then
- if subtype == box_code or subtype == line_code then
- lastlinelength = list_dimensions(l,getdir(n))
+ if subtype == boxlist_code or subtype == linelist_code then
+ lastlinelength = getdimensions(l)
else
lastlinelength = getwidth(n)
end
diff --git a/tex/context/base/mkiv/pack-rul.mkiv b/tex/context/base/mkiv/pack-rul.mkiv
index 3cbb731fe..3d03942aa 100644
--- a/tex/context/base/mkiv/pack-rul.mkiv
+++ b/tex/context/base/mkiv/pack-rul.mkiv
@@ -18,7 +18,7 @@
%D packaging and expansion we also keep tracing reasonable. For instance, multiple
%D stacked backgrounds can slow down a run if not optimized this way.
-\registerctxluafile{pack-rul}{}
+\registerctxluafile{pack-rul}{optimize}
\unprotect
diff --git a/tex/context/base/mkiv/page-cst.lua b/tex/context/base/mkiv/page-cst.lua
index 155d6e8b0..1c2f5fc0b 100644
--- a/tex/context/base/mkiv/page-cst.lua
+++ b/tex/context/base/mkiv/page-cst.lua
@@ -19,87 +19,86 @@ local trace_cells = false trackers.register("columnsets.cells", function(v) t
local report = logs.reporter("column sets")
-local setmetatableindex = table.setmetatableindex
-
-local properties = nodes.properties
-
-local nodecodes = nodes.nodecodes
-local rulecodes = nodes.rulecodes
-
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local kern_code = nodecodes.kern
-local glue_code = nodecodes.glue
-local penalty_code = nodecodes.penalty
-local rule_code = nodecodes.rule
-
-local nuts = nodes.nuts
-local tonode = nuts.tonode
-local tonut = nuts.tonut
-
-local hpack = nuts.hpack
-local vpack = nuts.vpack
-local flushlist = nuts.flush_list
------ removenode = nuts.remove
-
-local setlink = nuts.setlink
-local setlist = nuts.setlist
-local setnext = nuts.setnext
-local setprev = nuts.setprev
-local setsubtype = nuts.setsubtype
-local setbox = nuts.setbox
-local getwhd = nuts.getwhd
-local setwhd = nuts.setwhd
-local getkern = nuts.getkern
-local getpenalty = nuts.getpenalty
-local getwidth = nuts.getwidth
-local getheight = nuts.getheight
-
-local getnext = nuts.getnext
-local getprev = nuts.getprev
-local getid = nuts.getid
-local getlist = nuts.getlist
-local getsubtype = nuts.getsubtype
-local takebox = nuts.takebox
-local takelist = nuts.takelist
-local splitbox = nuts.splitbox
-local getattribute = nuts.getattribute
-local copylist = nuts.copy_list
-
-local getbox = nuts.getbox
-local getcount = tex.getcount
-local getdimen = tex.getdimen
-
-local texsetbox = tex.setbox
-local texsetcount = tex.setcount
-local texsetdimen = tex.setdimen
-
-local theprop = nuts.theprop
-
-local nodepool = nuts.pool
-
-local new_vlist = nodepool.vlist
-local new_trace_rule = nodepool.rule
-local new_empty_rule = nodepool.emptyrule
-
-local context = context
-local implement = interfaces.implement
-
-local variables = interfaces.variables
-local v_here = variables.here
-local v_fixed = variables.fixed
-local v_top = variables.top
-local v_bottom = variables.bottom
-local v_repeat = variables["repeat"]
-local v_yes = variables.yes
-local v_page = variables.page
-local v_first = variables.first
-local v_last = variables.last
------ v_wide = variables.wide
-
-pagebuilders = pagebuilders or { } -- todo: pages.builders
-pagebuilders.columnsets = pagebuilders.columnsets or { }
-local columnsets = pagebuilders.columnsets
+local setmetatableindex = table.setmetatableindex
+
+local properties = nodes.properties
+
+local nodecodes = nodes.nodecodes
+
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local kern_code = nodecodes.kern
+local glue_code = nodecodes.glue
+local penalty_code = nodecodes.penalty
+local rule_code = nodecodes.rule
+
+local nuts = nodes.nuts
+local tonode = nuts.tonode
+local tonut = nuts.tonut
+
+local hpack = nuts.hpack
+local vpack = nuts.vpack
+local flushlist = nuts.flush_list
+----- removenode = nuts.remove
+
+local setlink = nuts.setlink
+local setlist = nuts.setlist
+local setnext = nuts.setnext
+local setprev = nuts.setprev
+local setsubtype = nuts.setsubtype
+local setbox = nuts.setbox
+local getwhd = nuts.getwhd
+local setwhd = nuts.setwhd
+local getkern = nuts.getkern
+local getpenalty = nuts.getpenalty
+local getwidth = nuts.getwidth
+local getheight = nuts.getheight
+
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getid = nuts.getid
+local getlist = nuts.getlist
+local getsubtype = nuts.getsubtype
+local takebox = nuts.takebox
+local takelist = nuts.takelist
+local splitbox = nuts.splitbox
+local getattribute = nuts.getattribute
+local copylist = nuts.copy_list
+
+local getbox = nuts.getbox
+local getcount = tex.getcount
+local getdimen = tex.getdimen
+
+local texsetbox = tex.setbox
+local texsetcount = tex.setcount
+local texsetdimen = tex.setdimen
+
+local theprop = nuts.theprop
+
+local nodepool = nuts.pool
+
+local new_vlist = nodepool.vlist
+local new_trace_rule = nodepool.rule
+local new_empty_rule = nodepool.emptyrule
+
+local context = context
+local implement = interfaces.implement
+
+local variables = interfaces.variables
+local v_here = variables.here
+local v_fixed = variables.fixed
+local v_top = variables.top
+local v_bottom = variables.bottom
+local v_repeat = variables["repeat"]
+local v_yes = variables.yes
+local v_page = variables.page
+local v_first = variables.first
+local v_last = variables.last
+----- v_wide = variables.wide
+
+pagebuilders = pagebuilders or { } -- todo: pages.builders
+pagebuilders.columnsets = pagebuilders.columnsets or { }
+local columnsets = pagebuilders.columnsets
local data = { [""] = { } }
diff --git a/tex/context/base/mkiv/page-lin.lua b/tex/context/base/mkiv/page-lin.lua
index 51bfb4a7e..b556ca32b 100644
--- a/tex/context/base/mkiv/page-lin.lua
+++ b/tex/context/base/mkiv/page-lin.lua
@@ -43,15 +43,14 @@ local v_no = variables.no
local properties = nodes.properties
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
-local whatcodes = nodes.whatcodes
local listcodes = nodes.listcodes
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
local whatsit_code = nodecodes.whatsit
local glyph_code = nodecodes.glyph
-local line_code = listcodes.line
+
+local linelist_code = listcodes.line
local a_displaymath = attributes.private('displaymath')
local a_linenumber = attributes.private('linenumber')
@@ -71,7 +70,7 @@ local getattr = nuts.getattr
local setattr = nuts.setattr
local getlist = nuts.getlist
local getbox = nuts.getbox
------ getdir = nuts.getdir
+----- getdirection = nuts.getdirection
----- getwidth = nuts.getwidth
local getheight = nuts.getheight
local getdepth = nuts.getdepth
@@ -285,7 +284,7 @@ end
local function listisnumbered(list)
if list then
for n, subtype in nexthlist, list do
- if subtype == line_code then
+ if subtype == linelist_code then
local a = getattr(n,a_linenumber)
if a then
-- a quick test for lines (only valid when \par before \stoplinenumbering)
@@ -307,7 +306,7 @@ local function findnumberedlist(list)
while n do
local id = getid(n)
if id == hlist_code then
- if getsubtype(n) == line_code then
+ if getsubtype(n) == linelist_code then
local a = getattr(n,a_linenumber)
if a then
return a > 0 and list
@@ -385,7 +384,7 @@ function boxed.stage_one(n,nested)
local function check()
for n, subtype in nexthlist, list do
- if subtype ~= line_code then
+ if subtype ~= linelist_code then
-- go on
elseif getheight(n) == 0 and getdepth(n) == 0 then
-- skip funny hlists -- todo: check line subtype
@@ -481,9 +480,9 @@ function boxed.stage_two(n,m)
local li = current_list[i]
local n, m, ti = li[1], li[2], t[i]
if ti then
- -- local d = getdir(n)
+ -- local d = getdirection(n)
-- local l = getlist(n)
- -- if d == "TRT" then
+ -- if d == 1 then
-- local w = getwidth(n)
-- ti = hpack_nodes(linked_nodes(new_kern(-w),ti,new_kern(w)))
-- end
diff --git a/tex/context/base/mkiv/scrp-cjk.lua b/tex/context/base/mkiv/scrp-cjk.lua
index faef77eec..ad63c1452 100644
--- a/tex/context/base/mkiv/scrp-cjk.lua
+++ b/tex/context/base/mkiv/scrp-cjk.lua
@@ -39,12 +39,14 @@ local new_kern = nodepool.kern
local new_penalty = nodepool.penalty
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
+
local glyph_code = nodecodes.glyph
local glue_code = nodecodes.glue
-local userskip_code = skipcodes.userskip
-local spaceskip_code = skipcodes.spaceskip
-local xspaceskip_code = skipcodes.xspaceskip
+
+local userskip_code = gluecodes.userskip
+local spaceskip_code = gluecodes.spaceskip
+local xspaceskip_code = gluecodes.xspaceskip
local a_scriptstatus = attributes.private('scriptstatus')
local a_scriptinjection = attributes.private('scriptinjection')
diff --git a/tex/context/base/mkiv/spac-ali.lua b/tex/context/base/mkiv/spac-ali.lua
index 3da0e57f4..b58040ac7 100644
--- a/tex/context/base/mkiv/spac-ali.lua
+++ b/tex/context/base/mkiv/spac-ali.lua
@@ -38,7 +38,8 @@ local listcodes = nodes.listcodes
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
-local line_code = listcodes.line
+
+local linelist_code = listcodes.line
local new_stretch = nodepool.stretch
@@ -68,7 +69,7 @@ local function handler(head,leftpage,realpageno) -- traverse_list
while current do
local id = getid(current)
if id == hlist_code then
- if getsubtype(current) == line_code then
+ if getsubtype(current) == linelist_code then
local a = takeattr(current,a_realign)
if not a or a == 0 then
-- skip
diff --git a/tex/context/base/mkiv/spac-ali.mkiv b/tex/context/base/mkiv/spac-ali.mkiv
index 71dbb6eb3..7e3b24197 100644
--- a/tex/context/base/mkiv/spac-ali.mkiv
+++ b/tex/context/base/mkiv/spac-ali.mkiv
@@ -27,7 +27,7 @@
%
% but that also means myoption gets frozen due to caching.
-\registerctxluafile{spac-ali}{}
+\registerctxluafile{spac-ali}{optimize}
\definesystemattribute[realign] [public] % might be combined with the next one
\definesystemattribute[alignstate][public] % will make a single attributes for several states
diff --git a/tex/context/base/mkiv/spac-chr.lua b/tex/context/base/mkiv/spac-chr.lua
index d666956e5..70f03c187 100644
--- a/tex/context/base/mkiv/spac-chr.lua
+++ b/tex/context/base/mkiv/spac-chr.lua
@@ -60,12 +60,10 @@ local new_rule = nodepool.rule
local new_disc = nodepool.disc
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
-local disccodes = nodes.disccodes
+local gluecodes = nodes.gluecodes
local glyph_code = nodecodes.glyph
-local space_skip_code = skipcodes.spaceskip
-local explicit_code = disccodes.explicit
+local spaceskip_code = gluecodes.spaceskip
local chardata = characters.data
local is_punctuation = characters.is_punctuation
@@ -134,10 +132,10 @@ local function nbsp(head,current)
local para = fontparameters[getfont(current)]
if getattr(current,a_alignstate) == 1 then -- flushright
head, current = inject_nobreak_space(0x00A0,head,current,para.space,0,0)
- setsubtype(current,space_skip_code)
+ setsubtype(current,spaceskip_code)
else
head, current = inject_nobreak_space(0x00A0,head,current,para.space,para.spacestretch,para.spaceshrink)
- setsubtype(current,space_skip_code)
+ setsubtype(current,spaceskip_code)
end
return head, current
end
diff --git a/tex/context/base/mkiv/spac-chr.mkiv b/tex/context/base/mkiv/spac-chr.mkiv
index ed2cb47f9..23f4ac8dd 100644
--- a/tex/context/base/mkiv/spac-chr.mkiv
+++ b/tex/context/base/mkiv/spac-chr.mkiv
@@ -15,7 +15,7 @@
\unprotect
-\registerctxluafile{spac-chr}{}
+\registerctxluafile{spac-chr}{optimize}
\definesystemattribute[characters][public]
diff --git a/tex/context/base/mkiv/spac-hor.mkiv b/tex/context/base/mkiv/spac-hor.mkiv
index bbdab80aa..32b7f06fb 100644
--- a/tex/context/base/mkiv/spac-hor.mkiv
+++ b/tex/context/base/mkiv/spac-hor.mkiv
@@ -609,9 +609,9 @@
\ifdefined\quad \else
- \unexpanded\def\enskip{\hskip.5\emwidth}
- \unexpanded\def\quad {\hskip \emwidth}
- \unexpanded\def\qquad {\hskip 2\emwidth}
+ \unexpanded\def\enskip{\hskip.5\emwidth\relax}
+ \unexpanded\def\quad {\hskip \emwidth\relax}
+ \unexpanded\def\qquad {\hskip 2\emwidth\relax}
\fi
diff --git a/tex/context/base/mkiv/spac-prf.lua b/tex/context/base/mkiv/spac-prf.lua
index f4d452cbb..d355cc533 100644
--- a/tex/context/base/mkiv/spac-prf.lua
+++ b/tex/context/base/mkiv/spac-prf.lua
@@ -17,6 +17,7 @@ local formatters = string.formatters
local nodecodes = nodes.nodecodes
local gluecodes = nodes.gluecodes
local listcodes = nodes.listcodes
+local leadercodes = nodes.leadercodes
local glyph_code = nodecodes.glyph
local disc_code = nodecodes.disc
@@ -30,10 +31,12 @@ local math_code = nodecodes.math
local rule_code = nodecodes.rule
local marginkern_code = nodecodes.marginkern
-local leaders_code = gluecodes.leaders
+local leaders_code = leadercodes.leaders
+
local lineskip_code = gluecodes.lineskip
local baselineskip_code = gluecodes.baselineskip
-local line_code = listcodes.line
+
+local linelist_code = listcodes.line
local texlists = tex.lists
local settexattribute = tex.setattribute
@@ -668,7 +671,7 @@ local function profilelist(line,mvl)
local id = getid(current)
if id == hlist_code then
local subtype = getsubtype(current)
- if subtype == line_code then
+ if subtype == linelist_code then
t_profile = hasprofile(current)
if t_profile then
top = current
@@ -710,7 +713,7 @@ local function profilelist(line,mvl)
if id == hlist_code then -- check subtype
local subtype = getsubtype(current)
- if subtype == line_code then
+ if subtype == linelist_code then
if top == current then
-- skip
bot = nil -- to be sure
@@ -819,7 +822,7 @@ function profiling.profilebox(specification)
local id = getid(current)
if id == hlist_code then
local subtype = getsubtype(current)
- if subtype == line_code then
+ if subtype == linelist_code then
if top then
bot = current
b_profile = setprofile(bot)
diff --git a/tex/context/base/mkiv/spac-ver.lua b/tex/context/base/mkiv/spac-ver.lua
index d056d6ed3..91d69a1e1 100644
--- a/tex/context/base/mkiv/spac-ver.lua
+++ b/tex/context/base/mkiv/spac-ver.lua
@@ -171,7 +171,7 @@ local new_kern = nodepool.kern
local new_rule = nodepool.rule
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
----- penaltycodes = nodes.penaltycodes
----- listcodes = nodes.listcodes
@@ -184,21 +184,19 @@ local vlist_code = nodecodes.vlist
local rule_code = nodecodes.rule
local localpar_code = nodecodes.localpar
-local linebreak_code = nodes.penaltycodes.linebreakpenalty
+local userskip_code = gluecodes.userskip
+local lineskip_code = gluecodes.lineskip
+local baselineskip_code = gluecodes.baselineskip
+local parskip_code = gluecodes.parskip
+local topskip_code = gluecodes.topskip
+local splittopskip_code = gluecodes.splittopskip
-local userskip_code = skipcodes.userskip
-local lineskip_code = skipcodes.lineskip
-local baselineskip_code = skipcodes.baselineskip
-local parskip_code = skipcodes.parskip
-local topskip_code = skipcodes.topskip
-local splittopskip_code = skipcodes.splittopskip
+local linelist_code = nodes.listcodes.line
-local line_code = nodes.listcodes.line
-
-local abovedisplayskip_code = skipcodes.abovedisplayskip
-local belowdisplayskip_code = skipcodes.belowdisplayskip
-local abovedisplayshortskip_code = skipcodes.abovedisplayshortskip
-local belowdisplayshortskip_code = skipcodes.belowdisplayshortskip
+local abovedisplayskip_code = gluecodes.abovedisplayskip
+local belowdisplayskip_code = gluecodes.belowdisplayskip
+local abovedisplayshortskip_code = gluecodes.abovedisplayshortskip
+local belowdisplayshortskip_code = gluecodes.belowdisplayshortskip
local properties = nodes.properties.data
@@ -886,7 +884,7 @@ local function nodes_to_string(head)
if id == penalty_code then
t[#t+1] = formatters["%s:%s"](ty,getpenalty(current))
elseif id == glue_code then
- t[#t+1] = formatters["%s:%s:%p"](ty,skipcodes[getsubtype(current)],getwidth(current))
+ t[#t+1] = formatters["%s:%s:%p"](ty,gluecodes[getsubtype(current)],getwidth(current))
elseif id == kern_code then
t[#t+1] = formatters["%s:%p"](ty,getkern(current))
else
@@ -1403,7 +1401,7 @@ do
end
head = insert_node_before(head,current,glue_data)
else
- -- report_vspacing("needs checking (%s): %p",skipcodes[getsubtype(glue_data)],w)
+ -- report_vspacing("needs checking (%s): %p",gluecodes[getsubtype(glue_data)],w)
flush_node(glue_data)
end
end
@@ -1821,7 +1819,7 @@ do
if snap and trace_vsnapping then
local w = getwidth(current)
if w ~= 0 then
- report_snapper("glue %p of type %a kept",w,skipcodes[subtype])
+ report_snapper("glue %p of type %a kept",w,gluecodes[subtype])
end
end
if trace then
@@ -2085,7 +2083,7 @@ do
while tail do
local id = getid(tail)
if id == hlist_code then
- if getsubtype(tail) == line_code then
+ if getsubtype(tail) == linelist_code then
noflines = noflines + 1
else
break
diff --git a/tex/context/base/mkiv/spac-ver.mkiv b/tex/context/base/mkiv/spac-ver.mkiv
index 0b53d24b1..ef33652f1 100644
--- a/tex/context/base/mkiv/spac-ver.mkiv
+++ b/tex/context/base/mkiv/spac-ver.mkiv
@@ -15,7 +15,7 @@
\unprotect
-\registerctxluafile{spac-ver}{}
+\registerctxluafile{spac-ver}{optimize}
% todo: use usernodes ?
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index b98120d35..9d01c3a8a 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 39ca462ff..ae17faf97 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/strc-mar.lua b/tex/context/base/mkiv/strc-mar.lua
index 51f896aa7..c904c699e 100644
--- a/tex/context/base/mkiv/strc-mar.lua
+++ b/tex/context/base/mkiv/strc-mar.lua
@@ -13,81 +13,82 @@ local insert, concat = table.insert, table.concat
local tostring, next, rawget, type = tostring, next, rawget, type
local lpegmatch = lpeg.match
-local context = context
-local commands = commands
+local context = context
+local commands = commands
-local implement = interfaces.implement
+local implement = interfaces.implement
-local allocate = utilities.storage.allocate
-local setmetatableindex = table.setmetatableindex
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
-local nuts = nodes.nuts
-local tonut = nuts.tonut
+local nuts = nodes.nuts
+local tonut = nuts.tonut
-local getid = nuts.getid
-local getlist = nuts.getlist
-local getattr = nuts.getattr
-local getbox = nuts.getbox
+local getid = nuts.getid
+local getlist = nuts.getlist
+local getattr = nuts.getattr
+local getbox = nuts.getbox
-local nextnode = nuts.traversers.node
+local nextnode = nuts.traversers.node
-local nodecodes = nodes.nodecodes
-local glyph_code = nodecodes.glyph
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
+local nodecodes = nodes.nodecodes
+local whatsitcodes = nodes.whatsitcodes
-local whatsit_code = nodecodes.whatsit
-local whatsitcodes = nodes.whatsitcodes
-local latelua_code = whatsitcodes.latelua
+local glyph_code = nodecodes.glyph
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local whatsit_code = nodecodes.whatsit
-local texsetattribute = tex.setattribute
+local lateluawhatsit_code = whatsitcodes.latelua
-local a_marks = attributes.private("structure","marks")
+local texsetattribute = tex.setattribute
-local trace_marks_set = false trackers.register("marks.set", function(v) trace_marks_set = v end)
-local trace_marks_get = false trackers.register("marks.get", function(v) trace_marks_get = v end)
-local trace_marks_all = false trackers.register("marks.detail", function(v) trace_marks_all = v end)
+local a_marks = attributes.private("structure","marks")
-local report_marks = logs.reporter("structure","marks")
+local trace_marks_set = false trackers.register("marks.set", function(v) trace_marks_set = v end)
+local trace_marks_get = false trackers.register("marks.get", function(v) trace_marks_get = v end)
+local trace_marks_all = false trackers.register("marks.detail", function(v) trace_marks_all = v end)
-local variables = interfaces.variables
+local report_marks = logs.reporter("structure","marks")
-local v_first = variables.first
-local v_last = variables.last
-local v_previous = variables.previous
-local v_next = variables.next
-local v_top = variables.top
-local v_bottom = variables.bottom
-local v_current = variables.current
-local v_default = variables.default
-local v_page = variables.page
-local v_all = variables.all
-local v_keep = variables.keep
+local variables = interfaces.variables
-local v_nocheck_suffix = ":" .. variables.nocheck
+local v_first = variables.first
+local v_last = variables.last
+local v_previous = variables.previous
+local v_next = variables.next
+local v_top = variables.top
+local v_bottom = variables.bottom
+local v_current = variables.current
+local v_default = variables.default
+local v_page = variables.page
+local v_all = variables.all
+local v_keep = variables.keep
-local v_first_nocheck = variables.first .. v_nocheck_suffix
-local v_last_nocheck = variables.last .. v_nocheck_suffix
-local v_previous_nocheck = variables.previous .. v_nocheck_suffix
-local v_next_nocheck = variables.next .. v_nocheck_suffix
-local v_top_nocheck = variables.top .. v_nocheck_suffix
-local v_bottom_nocheck = variables.bottom .. v_nocheck_suffix
+local v_nocheck_suffix = ":" .. variables.nocheck
-local structures = structures
-local marks = structures.marks
-local lists = structures.lists
+local v_first_nocheck = variables.first .. v_nocheck_suffix
+local v_last_nocheck = variables.last .. v_nocheck_suffix
+local v_previous_nocheck = variables.previous .. v_nocheck_suffix
+local v_next_nocheck = variables.next .. v_nocheck_suffix
+local v_top_nocheck = variables.top .. v_nocheck_suffix
+local v_bottom_nocheck = variables.bottom .. v_nocheck_suffix
-local settings_to_array = utilities.parsers.settings_to_array
+local structures = structures
+local marks = structures.marks
+local lists = structures.lists
-local boxes_too = false -- at some point we can also tag boxes or use a zero char
+local settings_to_array = utilities.parsers.settings_to_array
+
+local boxes_too = false -- at some point we can also tag boxes or use a zero char
directives.register("marks.boxestoo", function(v) boxes_too = v end)
-marks.data = marks.data or allocate()
+local data = marks.data or allocate()
+marks.data = data
storage.register("structures/marks/data", marks.data, "structures.marks.data")
-local data = marks.data
local stack, topofstack = { }, 0
local ranges = {
@@ -121,7 +122,7 @@ end
local function sweep(head,first,last)
for n, id, subtype in nextnode, head do
-- we need to handle empty heads so we test for latelua
- if id == glyph_code or (id == whatsit_code and subtype == latelua_code) then
+ if id == glyph_code or (id == whatsit_code and subtype == lateluawhatsit_code) then
local a = getattr(n,a_marks)
if not a then
-- next
diff --git a/tex/context/base/mkiv/strc-ref.mkvi b/tex/context/base/mkiv/strc-ref.mkvi
index be759548d..c7f204815 100644
--- a/tex/context/base/mkiv/strc-ref.mkvi
+++ b/tex/context/base/mkiv/strc-ref.mkvi
@@ -29,7 +29,7 @@
\registerctxluafile{strc-rsc}{}
\registerctxluafile{strc-ref}{}
-\registerctxluafile{node-ref}{}
+\registerctxluafile{node-ref}{optimize}
\unprotect
diff --git a/tex/context/base/mkiv/supp-box.lua b/tex/context/base/mkiv/supp-box.lua
index 133c93fe4..e57eaba54 100644
--- a/tex/context/base/mkiv/supp-box.lua
+++ b/tex/context/base/mkiv/supp-box.lua
@@ -20,67 +20,67 @@ local nodes = nodes
local implement = interfaces.implement
-local nodecodes = nodes.nodecodes
-
-local disc_code = nodecodes.disc
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local glue_code = nodecodes.glue
-local glyph_code = nodecodes.glyph
-
-local nuts = nodes.nuts
-local tonut = nuts.tonut
-local tonode = nuts.tonode
-
------ getfield = nuts.getfield
-local getnext = nuts.getnext
-local getprev = nuts.getprev
-local getboth = nuts.getboth
-local getdisc = nuts.getdisc
-local getid = nuts.getid
-local getlist = nuts.getlist
-local getattribute = nuts.getattribute
-local getbox = nuts.getbox
-local getdirection = nuts.getdirection
-local getwidth = nuts.getwidth
-local takebox = nuts.takebox
-
------ setfield = nuts.setfield
-local setlink = nuts.setlink
-local setboth = nuts.setboth
-local setnext = nuts.setnext
-local setbox = nuts.setbox
-local setlist = nuts.setlist
-local setdisc = nuts.setdisc
-local setwidth = nuts.setwidth
-local setheight = nuts.setheight
-local setdepth = nuts.setdepth
-local setshift = nuts.setshift
-
-local flush_node = nuts.flush_node
-local flush_list = nuts.flush_list
-local copy_node = nuts.copy
-local copy_list = nuts.copy_list
-local find_tail = nuts.tail
-local list_dimensions = nuts.dimensions
-local hpack = nuts.hpack
-
-local nextdisc = nuts.traversers.disc
-local nextdir = nuts.traversers.dir
-local nexthlist = nuts.traversers.hlist
-
-local listtoutf = nodes.listtoutf
-
-local nodepool = nuts.pool
-local new_penalty = nodepool.penalty
-local new_hlist = nodepool.hlist
-local new_glue = nodepool.glue
-
-local setlistcolor = nodes.tracers.colors.setlist
-
-local texget = tex.get
-local texgetbox = tex.getbox
-local texsetdimen = tex.setdimen
+local nodecodes = nodes.nodecodes
+
+local disc_code = nodecodes.disc
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local glue_code = nodecodes.glue
+local glyph_code = nodecodes.glyph
+
+local nuts = nodes.nuts
+local tonut = nuts.tonut
+local tonode = nuts.tonode
+
+----- getfield = nuts.getfield
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getboth = nuts.getboth
+local getdisc = nuts.getdisc
+local getid = nuts.getid
+local getlist = nuts.getlist
+local getattribute = nuts.getattribute
+local getbox = nuts.getbox
+local getdirection = nuts.getdirection
+local getwidth = nuts.getwidth
+local takebox = nuts.takebox
+
+----- setfield = nuts.setfield
+local setlink = nuts.setlink
+local setboth = nuts.setboth
+local setnext = nuts.setnext
+local setbox = nuts.setbox
+local setlist = nuts.setlist
+local setdisc = nuts.setdisc
+local setwidth = nuts.setwidth
+local setheight = nuts.setheight
+local setdepth = nuts.setdepth
+local setshift = nuts.setshift
+
+local flush_node = nuts.flush_node
+local flush_list = nuts.flush_list
+local copy_node = nuts.copy
+local copy_list = nuts.copy_list
+local find_tail = nuts.tail
+local getdimensions = nuts.dimensions
+local hpack = nuts.hpack
+
+local nextdisc = nuts.traversers.disc
+local nextdir = nuts.traversers.dir
+local nexthlist = nuts.traversers.hlist
+
+local listtoutf = nodes.listtoutf
+
+local nodepool = nuts.pool
+local new_penalty = nodepool.penalty
+local new_hlist = nodepool.hlist
+local new_glue = nodepool.glue
+
+local setlistcolor = nodes.tracers.colors.setlist
+
+local texget = tex.get
+local texgetbox = tex.getbox
+local texsetdimen = tex.setdimen
local function hyphenatedlist(head,usecolor)
local current = head and tonut(head)
@@ -368,7 +368,7 @@ local function getnaturaldimensions(n)
local w, h, d = 0, 0, 0
local l = getlist(getbox(n))
if l then
- w, h, d = list_dimensions(l)
+ w, h, d = getdimensions(l)
end
texsetdimen("lastnaturalboxwd",w)
texsetdimen("lastnaturalboxht",h)
@@ -398,7 +398,7 @@ interfaces.implement {
local w, h, d = 0, 0, 0
local l = getlist(getbox(n))
if l then
- w, h, d = list_dimensions(l)
+ w, h, d = getdimensions(l)
end
context("\\dimexpr%i\\scaledpoint\\relax",w)
end
@@ -424,9 +424,9 @@ local doifelse = commands.doifelse
do
- local dirvalues = nodes.dirvalues
- local righttoleft = dirvalues.righttoleft
- local lefttoright = dirvalues.lefttoright
+ local dirvalues = nodes.dirvalues
+ local lefttoright_code = dirvalues.lefttoright
+ local righttoleft_code = dirvalues.righttoleft
local function firstdirinbox(n)
local b = getbox(n)
@@ -441,7 +441,7 @@ do
end
end
end
- return lefttoright
+ return lefttoright_code
end
nodes.firstdirinbox = firstdirinbox
@@ -450,7 +450,7 @@ do
name = "doifelserighttoleftinbox",
arguments = "integer",
actions = function(n)
- doifelse(firstdirinbox(n) == righttoleft)
+ doifelse(firstdirinbox(n) == righttoleft_code)
end
}
@@ -613,7 +613,7 @@ do
actions = function()
local head = tex.lists.page_head
-- list dimensions returns 3 value but we take the first
- context(head and list_dimensions(getlist(find_tail(tonut(tex.lists.page_head)))) or 0)
+ context(head and getdimensions(getlist(find_tail(tonut(tex.lists.page_head)))) or 0)
end
}
diff --git a/tex/context/base/mkiv/supp-box.mkiv b/tex/context/base/mkiv/supp-box.mkiv
index 311b8a520..a74aeab2e 100644
--- a/tex/context/base/mkiv/supp-box.mkiv
+++ b/tex/context/base/mkiv/supp-box.mkiv
@@ -15,7 +15,7 @@
\unprotect
-\registerctxluafile{supp-box}{}
+\registerctxluafile{supp-box}{optimize}
% This file is partially cleaned up.
diff --git a/tex/context/base/mkiv/tabl-xtb.lua b/tex/context/base/mkiv/tabl-xtb.lua
index a8a32ec21..d87a5f49e 100644
--- a/tex/context/base/mkiv/tabl-xtb.lua
+++ b/tex/context/base/mkiv/tabl-xtb.lua
@@ -70,7 +70,7 @@ local getbox = nuts.getbox
local getwhd = nuts.getwhd
local setlink = nuts.setlink
-local setdir = nuts.setdir
+local setdirection = nuts.setdirection
local setshift = nuts.setshift
local copy_node_list = nuts.copy_list
@@ -84,6 +84,8 @@ local new_glue = nodepool.glue
local new_kern = nodepool.kern
local new_hlist = nodepool.hlist
+local lefttoright_code = nodes.dirvalues.lefttoright
+
local v_stretch = variables.stretch
local v_normal = variables.normal
local v_width = variables.width
@@ -886,7 +888,7 @@ function xtables.construct()
-- we have a direction issue here but hpack_node_list(list,0,"exactly","TLT") cannot be used
-- due to the fact that we need the width
local hbox = hpack_node_list(list)
- setdir(hbox,"TLT")
+ setdirection(hbox,lefttoright_code)
result[nofr] = {
hbox,
size,
diff --git a/tex/context/base/mkiv/trac-jus.lua b/tex/context/base/mkiv/trac-jus.lua
index 0acb685ed..aec1844ec 100644
--- a/tex/context/base/mkiv/trac-jus.lua
+++ b/tex/context/base/mkiv/trac-jus.lua
@@ -27,7 +27,7 @@ local findtail = nuts.tail
local nexthlist = nuts.traversers.hlist
-local list_dimensions = nuts.dimensions
+local getdimensions = nuts.dimensions
local copy_list = nuts.copy_list
local tracedrule = nodes.tracers.pool.nuts.rule
@@ -84,7 +84,7 @@ function checkers.handler(head)
if width > 0 then
local list = getlist(current)
if list then
- local naturalwidth, naturalheight, naturaldepth = list_dimensions(list)
+ local naturalwidth, naturalheight, naturaldepth = getdimensions(list)
local delta = naturalwidth - width
if naturalwidth == 0 or delta == 0 then
-- special box
diff --git a/tex/context/base/mkiv/trac-vis.lua b/tex/context/base/mkiv/trac-vis.lua
index 242363238..d690bfb4e 100644
--- a/tex/context/base/mkiv/trac-vis.lua
+++ b/tex/context/base/mkiv/trac-vis.lua
@@ -28,8 +28,6 @@ local compactfloat = number.compactfloat
-- todo: inline concat (more efficient)
-- todo: tags can also be numbers (just add to hash)
--- todo: dir and localpar nodes
-
local nodecodes = nodes.nodecodes
local nuts = nodes.nuts
@@ -63,7 +61,6 @@ local getdisc = nuts.getdisc
local getwhd = nuts.getwhd
local getkern = nuts.getkern
local getpenalty = nuts.getpenalty
------ getdirection = nuts.getdirection
local getwidth = nuts.getwidth
local getdepth = nuts.getdepth
local getshift = nuts.getshift
@@ -120,10 +117,6 @@ local stoptiming = statistics.stoptiming
local a_visual = attributes.private("visual")
local a_layer = attributes.private("viewerlayer")
------ dirvalues = nodes.dirvalues
------ LTL = dirvalues.LTL
------ RTT = dirvalues.RTT
-
local band = bit32.band
local bor = bit32.bor
@@ -721,40 +714,11 @@ local ruledbox do
local wd, ht, dp = getwhd(current)
if wd ~= 0 then
local shift = getshift(current)
- -- local dir = getdirection(current)
- -- if dir == LTL or dir == RRT then
- -- wd, ht, dp = ht + dp, wd, 0
- -- end
local next = getnext(current)
local prev = previous
- -- local prev = getprev(current) -- prev can be wrong in math mode < 0.78.3
setboth(current)
local linewidth = emwidth/fraction
local size = 2*linewidth
- -- local baseline, baseskip
- -- if dp ~= 0 and ht ~= 0 then
- -- if wd > 20*linewidth then
- -- local targetsize = wd - size
- -- baseline = b_cache[targetsize]
- -- if not baseline then
- -- -- due to an optimized leader color/transparency we need to set the glue node in order
- -- -- to trigger this mechanism
- -- local leader = setlink(new_glue(size),new_rule(3*size,linewidth,0),new_glue(size))
- -- leader = hpack_nodes(leader)
- -- baseline = new_glue(0,65536,0,2,0)
- -- setleader(baseline,leader)
- -- setsubtype(baseline,cleaders_code)
- -- setlisttransparency(baseline,c_text)
- -- baseline = hpack_nodes(baseline,targetsize)
- -- b_cache[targetsize] = baseline
- -- end
- -- baseline = copy_list(baseline)
- -- baseskip = new_kern(-wd+linewidth)
- -- else
- -- baseline = new_rule(wd-size,linewidth,0)
- -- baseskip = new_kern(-wd+size)
- -- end
- -- end
local this
if not simple then
this = b_cache[what]
@@ -767,19 +731,6 @@ local ruledbox do
end
end
-- we need to trigger the right mode (else sometimes no whatits)
- -- local info = setlink(
- -- this and copy_list(this) or nil,
- -- new_rule(linewidth,ht,dp),
- -- new_rule(wd-size,-dp+linewidth,dp),
- -- new_rule(linewidth,ht,dp),
- -- new_kern(-wd+linewidth),
- -- new_rule(wd-size,ht,-ht+linewidth),
- -- baseskip,
- -- baseskip and baseline or nil
- -- )
- --
- -- userrules:
- --
local info = setlink(
this and copy_list(this) or nil,
(dp == 0 and outlinerule and outlinerule(wd,ht,dp,linewidth)) or userrule {
@@ -870,51 +821,12 @@ local ruledglyph do
-- local wd = chardata[getfont(current)][getchar(current)].width
if wd ~= 0 then
local wd, ht, dp = getwhd(current)
- -- local dir = getdirection(current)
- -- if dir == LTL or dir == RTT then
- -- wd, ht, dp = ht + dp, wd, 0
- -- end
local next = getnext(current)
local prev = previous
setboth(current)
local linewidth = emwidth/(2*fraction)
local info
--
- -- original
- --
- -- local baseline
- -- if (dp >= 0 and ht >= 0) or (dp <= 0 and ht <= 0) then
- -- baseline = new_rule(wd-2*linewidth,linewidth,0)
- -- end
- -- local doublelinewidth = 2*linewidth
- -- -- could be a pdf rule (or a user rule now)
- -- info = setlink(
- -- new_rule(linewidth,ht,dp),
- -- new_rule(wd-doublelinewidth,-dp+linewidth,dp),
- -- new_rule(linewidth,ht,dp),
- -- new_kern(-wd+linewidth),
- -- new_rule(wd-doublelinewidth,ht,-ht+linewidth),
- -- new_kern(-wd+doublelinewidth),
- -- baseline
- -- )
- --
- -- experiment with subtype outline
- --
- -- if (dp >= 0 and ht >= 0) or (dp <= 0 and ht <= 0) then
- -- baseline = new_rule(wd,linewidth/2,0)
- -- end
- -- local r = new_rule(wd-linewidth,ht-linewidth/4,dp-linewidth/4)
- -- setsubtype(r,nodes.rulecodes.outline)
- -- setfield(r,"transform",linewidth)
- -- info = setlink(
- -- new_kern(linewidth/4),
- -- r,
- -- new_kern(-wd+linewidth/2),
- -- baseline
- -- )
- --
- -- userrules:
- --
info = setlink(
(dp == 0 and outlinerule and outlinerule(wd,ht,dp,linewidth)) or userrule {
width = wd,
@@ -963,13 +875,16 @@ end
local ruledglue do
- local gluecodes = nodes.gluecodes
- local cleaders_code = gluecodes.cleaders
- local userskip_code = gluecodes.userskip
- local space_code = gluecodes.spaceskip
- local xspace_code = gluecodes.xspaceskip
- local leftskip_code = gluecodes.leftskip
- local rightskip_code = gluecodes.rightskip
+ local gluecodes = nodes.gluecodes
+ local leadercodes = nodes.gluecodes
+
+ local userskip_code = gluecodes.userskip
+ local spaceskip_code = gluecodes.spaceskip
+ local xspaceskip_code = gluecodes.xspaceskip
+ local leftskip_code = gluecodes.leftskip
+ local rightskip_code = gluecodes.rightskip
+
+ local cleaders_code = leadercodes.cleaders
local g_cache_v = caches["vglue"]
local g_cache_h = caches["hglue"]
@@ -994,10 +909,10 @@ local ruledglue do
[gluecodes.thinmuskip] = "MS",
[gluecodes.medmuskip] = "MM",
[gluecodes.thickmuskip] = "ML",
- [gluecodes.leaders] = "NL",
- [gluecodes.cleaders] = "CL",
- [gluecodes.xleaders] = "XL",
- [gluecodes.gleaders] = "GL",
+ [leadercodes.leaders] = "NL",
+ [leadercodes.cleaders] = "CL",
+ [leadercodes.xleaders] = "XL",
+ [leadercodes.gleaders] = "GL",
-- true = "VS",
-- false = "HS",
}
@@ -1012,7 +927,7 @@ local ruledglue do
if info then
-- print("glue hit")
else
- if subtype == space_code or subtype == xspace_code then
+ if subtype == spaceskip_code or subtype == xspaceskip_code then
info = sometext(amount,l_glue,c_space)
elseif subtype == leftskip_code or subtype == rightskip_code then
info = sometext(amount,l_glue,c_skip_a)
@@ -1039,7 +954,7 @@ local ruledglue do
-- ruledspace = function(head,current,parent)
-- local subtype = getsubtype(current)
- -- if subtype == space_code or subtype == xspace_code then
+ -- if subtype == spaceskip_code or subtype == xspaceskip_code then
-- local width = effectiveglue(current,parent)
-- local amount = formatters["%s:%0.3f"](tags[subtype] or "HS",width*pt_factor)
-- local info = g_cache_h[amount]
@@ -1062,10 +977,10 @@ local ruledglue do
ruledspace = function(head,current,parent)
local subtype = getsubtype(current)
- if subtype == space_code or subtype == xspace_code then -- not yet all space
+ if subtype == spaceskip_code or subtype == xspaceskip_code then -- not yet all space
local width = effectiveglue(current,parent)
local info
- if subtype == space_code then
+ if subtype == spaceskip_code then
info = g_cache_s[width]
if not info then
info = someblob("SP",l_glue,c_space,nil,width)
@@ -1200,24 +1115,24 @@ end
do
- local disc_code = nodecodes.disc
- local kern_code = nodecodes.kern
- local glyph_code = nodecodes.glyph
- local glue_code = nodecodes.glue
- local penalty_code = nodecodes.penalty
- local whatsit_code = nodecodes.whatsit
- local user_code = nodecodes.user
- local math_code = nodecodes.math
- local hlist_code = nodecodes.hlist
- local vlist_code = nodecodes.vlist
-
- local kerncodes = nodes.kerncodes
- local font_kern_code = kerncodes.fontkern
- local italic_kern_code = kerncodes.italiccorrection
- ----- user_kern_code = kerncodes.userkern
-
- local listcodes = nodes.listcodes
- local line_code = listcodes.line
+ local disc_code = nodecodes.disc
+ local kern_code = nodecodes.kern
+ local glyph_code = nodecodes.glyph
+ local glue_code = nodecodes.glue
+ local penalty_code = nodecodes.penalty
+ local whatsit_code = nodecodes.whatsit
+ local user_code = nodecodes.user
+ local math_code = nodecodes.math
+ local hlist_code = nodecodes.hlist
+ local vlist_code = nodecodes.vlist
+
+ local kerncodes = nodes.kerncodes
+ local fontkern_code = kerncodes.fontkern
+ local italickern_code = kerncodes.italiccorrection
+ ----- userkern_code = kerncodes.userkern
+
+ local listcodes = nodes.listcodes
+ local linelist_code = listcodes.line
local cache
@@ -1379,14 +1294,14 @@ do
setdisc(current,pre,post,replace)
elseif id == kern_code then
local subtype = getsubtype(current)
- if subtype == font_kern_code then
+ if subtype == fontkern_code then
if trace_fontkern or prev_trace_fontkern then
head, current = fontkern(head,current)
end
if trace_expansion or prev_trace_expansion then
head, current = kernexpansion(head,current)
end
- elseif subtype == italic_kern_code then
+ elseif subtype == italickern_code then
if trace_italic or prev_trace_italic then
head, current = italickern(head,current)
elseif trace_kern then
@@ -1418,7 +1333,7 @@ do
if trace_depth then
ruleddepth(current)
end
- if trace_line and getsubtype(current) == line_code then
+ if trace_line and getsubtype(current) == linelist_code then
head, current = ruledbox(head,current,false,l_line,"L__",trace_simple,previous,trace_origin,parent)
elseif trace_hbox then
head, current = ruledbox(head,current,false,l_hbox,"H__",trace_simple,previous,trace_origin,parent)
diff --git a/tex/context/base/mkiv/typo-bld.lua b/tex/context/base/mkiv/typo-bld.lua
index 1c96947db..4c2f7f2a5 100644
--- a/tex/context/base/mkiv/typo-bld.lua
+++ b/tex/context/base/mkiv/typo-bld.lua
@@ -257,61 +257,8 @@ function builders.buildpage_filter(groupcode)
end
end
-------------------------
-
--- do
---
--- local nuts = nodes.nuts
--- local getglue = tex.getglue
--- local getwhd = nuts.getwhd
--- local new_b_skip = nuts.pool.baselineskip
--- local new_l_skip = nuts.pool.lineskip
--- local find_tail = nuts.tail
--- local setlink = nuts.setlink
--- local is_mirrored = nodes.is_mirrored
---
--- function nuts.setprevdepth(head,prevdepth) -- this will become a helper
--- local wd, ht, dp = getwhd(head)
--- local mirrored = false -- getid(box) == hlist_code and is_mirrored(getdir(box)) -- never mirrored
--- if prevdepth > -65536000 then
--- local b_width, b_stretch, b_shrink = getglue("baselineskip")
--- local l_width, l_stretch, l_shrink = getglue("lineskip")
--- local correction = b_width - prevdepth - (mirrored and dp or ht)
--- if correction < l_width then
--- head = setlink(new_l_skip(l_width,l_stretch,l_shrink),head)
--- else
--- head = setlink(new_b_skip(correction,b_stretch,b_shrink),head)
--- end
--- end
--- return head, mirrored and ht or dp
--- end
---
--- function nodes.setprevdepth(box,prevdepth)
--- local h, p = nodes.prepend_prevdepth(box,prevdepth)
--- if h then
--- return h, p
--- else
--- return head, prevdepth
--- end
--- end
---
--- end
---
--- local setprevdepth = nodes.setprevdepth
--- local appendactions = nodes.tasks.actions("listbuilders")
---
--- function builders.append_filter(box,location,prevdepth,mirrored)
--- starttiming(builders)
--- box, prevdepth = appendactions(box,location,prevdepth,mirrored)
--- box, prevdepth = setprevdepth(box,prevdepth)
--- stoptiming(builders)
--- return box, prevdepth
--- end
-
registercallback('vpack_filter', builders.vpack_filter, "vertical spacing etc")
registercallback('buildpage_filter', builders.buildpage_filter, "vertical spacing etc (mvl)")
-----------------("append_to_vlist_filter",builders.append_filter, "add content to the vlist")
-----------------('contribute_filter', builders.contribute_filter, "adding content to lists")
statistics.register("v-node processing time", function()
return statistics.elapsedseconds(builders)
diff --git a/tex/context/base/mkiv/typo-cap.lua b/tex/context/base/mkiv/typo-cap.lua
index 3937fb8ca..cb92933ef 100644
--- a/tex/context/base/mkiv/typo-cap.lua
+++ b/tex/context/base/mkiv/typo-cap.lua
@@ -41,7 +41,6 @@ local find_attribute = nuts.find_attribute
local nextglyph = nuts.traversers.glyph
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
local kerncodes = nodes.kerncodes
local glyph_code = nodecodes.glyph
diff --git a/tex/context/base/mkiv/typo-chr.lua b/tex/context/base/mkiv/typo-chr.lua
index fe70ec6de..c364df33c 100644
--- a/tex/context/base/mkiv/typo-chr.lua
+++ b/tex/context/base/mkiv/typo-chr.lua
@@ -8,29 +8,31 @@ if not modules then modules = { } end modules ['typo-chr'] = {
-- This module can be optimized.
--- local nodecodes = nodes.nodecodes
--- local whatsitcodes = nodes.whatsitcodes
--- local glyph_code = nodecodes.glyph
--- local whatsit_code = nodecodes.whatsit
--- local user_code = whatsitcodes.userdefined
+-- local nodecodes = nodes.nodecodes
+-- local whatsitcodes = nodes.whatsitcodes
--
--- local stringusernode = nodes.pool.userstring
+-- local glyph_code = nodecodes.glyph
+-- local whatsit_code = nodecodes.whatsit
--
--- local nuts = nodes.nuts
--- local pool = nuts.pool
+-- local userwhatsit_code = whatsitcodes.userdefined
--
--- local getid = nuts.getid
--- local getprev = nuts.getprev
--- local getchar = nuts.getchar
--- local getdata = nuts.getdata
--- local getfield = nuts.getfield
+-- local stringusernode = nodes.pool.userstring
--
--- local remove_node = nuts.remove
--- local nextwhatsit = nuts.traversers.whatsit
+-- local nuts = nodes.nuts
+-- local pool = nuts.pool
--
--- local signal = pool.userids.signal
+-- local getid = nuts.getid
+-- local getprev = nuts.getprev
+-- local getchar = nuts.getchar
+-- local getdata = nuts.getdata
+-- local getfield = nuts.getfield
--
--- local is_punctuation = characters.is_punctuation
+-- local remove_node = nuts.remove
+-- local nextwhatsit = nuts.traversers.whatsit
+--
+-- local signal = pool.userids.signal
+--
+-- local is_punctuation = characters.is_punctuation
--
-- local actions = {
-- removepunctuation = function(head,n)
@@ -51,7 +53,7 @@ if not modules then modules = { } end modules ['typo-chr'] = {
-- function typesetters.signals.handler(head)
-- local done = false
-- for n, subtype in nextwhatsit, head do
--- if subtype == user_code and getfield(n,"user_id") == signal and getfield(n,"type") == 115 then
+-- if subtype == userwhatsit_code and getfield(n,"user_id") == signal and getfield(n,"type") == 115 then
-- local action = actions[getdata(n)]
-- if action then
-- head = action(h,n)
@@ -81,42 +83,42 @@ if not modules then modules = { } end modules ['typo-chr'] = {
local insert, remove = table.insert, table.remove
-local context = context
-local ctx_doifelse = commands.doifelse
+local context = context
+local ctx_doifelse = commands.doifelse
-local nodecodes = nodes.nodecodes
-local subtypes = nodes.subtypes
+local nodecodes = nodes.nodecodes
+local boundarycodes = nodes.boundarycodes
+local subtypes = nodes.subtypes
-local glyph_code = nodecodes.glyph
-local localpar_code = nodecodes.localpar
-local boundary_code = nodecodes.boundary
+local glyph_code = nodecodes.glyph
+local localpar_code = nodecodes.localpar
+local boundary_code = nodecodes.boundary
-local word_code = nodes.boundarycodes.word
+local wordboundary_code = boundarycodes.word
-local texgetnest = tex.getnest -- to be used
+local texgetnest = tex.getnest -- to be used
+local texsetcount = tex.setcount
-local texsetcount = tex.setcount
+local flush_node = node.flush_node
+local flush_list = node.flush_list
-local flush_node = node.flush_node
-local flush_list = node.flush_list
+local settexattribute = tex.setattribute
+local punctuation = characters.is_punctuation
-local settexattribute = tex.setattribute
-local punctuation = characters.is_punctuation
+local variables = interfaces.variables
+local v_all = variables.all
+local v_reset = variables.reset
-local variables = interfaces.variables
-local v_all = variables.all
-local v_reset = variables.reset
+local stack = { }
-local a_marked = attributes.numbers['marked']
-local lastmarked = 0
-local marked = {
+local a_marked = attributes.numbers['marked']
+local lastmarked = 0
+local marked = {
[v_all] = 1,
[""] = 1,
[v_reset] = attributes.unsetvalue,
}
-local stack = { }
-
local function pickup()
local list = texgetnest()
if list then
@@ -340,7 +342,7 @@ interfaces.implement {
interfaces.implement {
name = "atwordboundary",
actions = function()
- lastnodeequals(boundary_code,word_code)
+ lastnodeequals(boundary_code,wordboundary_code)
end,
}
diff --git a/tex/context/base/mkiv/typo-dha.lua b/tex/context/base/mkiv/typo-dha.lua
index c12541175..8dffc79a4 100644
--- a/tex/context/base/mkiv/typo-dha.lua
+++ b/tex/context/base/mkiv/typo-dha.lua
@@ -55,7 +55,7 @@ local getsubtype = nuts.getsubtype
local getlist = nuts.getlist
local getattr = nuts.getattr
local getprop = nuts.getprop
-local getdir = nuts.getdir
+local getdirection = nuts.getdir
local isglyph = nuts.isglyph -- or ischar
local setprop = nuts.setprop
@@ -69,7 +69,7 @@ local end_of_math = nuts.end_of_math
local nodepool = nuts.pool
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
local glyph_code = nodecodes.glyph
local math_code = nodecodes.math
@@ -78,9 +78,13 @@ local glue_code = nodecodes.glue
local dir_code = nodecodes.dir
local localpar_code = nodecodes.localpar
-local parfillskip_code = skipcodes.parfillskip
+local dirvalues = nodes.dirvalues
+local lefttoright_code = dirvalues.lefttoright
+local righttoleft_code = dirvalues.righttoleft
-local new_textdir = nodepool.textdir
+local parfillskip_code = gluecodes.parfillskip
+
+local new_direction = nodepool.direction
local insert = table.insert
@@ -102,14 +106,14 @@ local strip = false
local s_isol = fonts.analyzers.states.isol
-local function stopdir(finish)
- local n = new_textdir(finish == "TRT" and "-TRT" or "-TLT")
+local function stopdir(finish) -- we could use finish directly
+ local n = new_direction(finish == righttoleft_code and righttoleft_code or lefttoright_code,true)
setprop(n,"direction",true)
return n
end
-local function startdir(finish)
- local n = new_textdir(finish == "TRT" and "+TRT" or "+TLT")
+local function startdir(finish) -- we could use finish directly
+ local n = new_direction(finish == righttoleft_code and righttoleft_code or lefttoright_code)
setprop(n,"direction",true)
return n
end
@@ -307,27 +311,31 @@ local function process(start)
elseif id == kern_code then
setprop(current,"direction",'k')
elseif id == dir_code then
- local dir = getdir(current)
- if dir == "+TRT" then
- autodir = -1
- elseif dir == "+TLT" then
- autodir = 1
- elseif dir == "-TRT" or dir == "-TLT" then
- if embedded and embedded~= 0 then
+ local direction, pop = getdirection(current)
+ if direction == righttoleft_code then
+ if not pop then
+ autodir = -1
+ elseif embedded and embedded~= 0 then
+ autodir = embedded
+ else
+ autodir = 0
+ end
+ elseif direction == lefttoright_code then
+ if not pop then
+ autodir = 1
+ elseif embedded and embedded~= 0 then
autodir = embedded
else
autodir = 0
end
- else
- -- message
end
textdir = autodir
setprop(current,"direction",true)
elseif id == localpar_code then
- local dir = getdir(current)
- if dir == 'TRT' then
+ local direction = getdirection(current)
+ if direction == righttoleft_code then
autodir = -1
- elseif dir == 'TLT' then
+ elseif direction == lefttoright_code then
autodir = 1
end
pardir = autodir
diff --git a/tex/context/base/mkiv/typo-dua.lua b/tex/context/base/mkiv/typo-dua.lua
index 9aaa536c9..f31cd9d54 100644
--- a/tex/context/base/mkiv/typo-dua.lua
+++ b/tex/context/base/mkiv/typo-dua.lua
@@ -75,11 +75,11 @@ local getsubtype = nuts.getsubtype
local getlist = nuts.getlist
local getchar = nuts.getchar
local getprop = nuts.getprop
-local getdir = nuts.getdir
+local getdirection = nuts.getdirection
local setprop = nuts.setprop
local setchar = nuts.setchar
-local setdir = nuts.setdir
+local setdirection = nuts.setdirection
----- setattrlist = nuts.setattrlist
local remove_node = nuts.remove
@@ -87,10 +87,10 @@ local insert_node_after = nuts.insert_after
local insert_node_before = nuts.insert_before
local nodepool = nuts.pool
-local new_textdir = nodepool.textdir
+local new_direction = nodepool.direction
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
local glyph_code = nodecodes.glyph
local glue_code = nodecodes.glue
@@ -99,7 +99,12 @@ local vlist_code = nodecodes.vlist
local math_code = nodecodes.math
local dir_code = nodecodes.dir
local localpar_code = nodecodes.localpar
-local parfillskip_code = skipcodes.parfillskip
+
+local parfillskip_code = gluecodes.parfillskip
+
+local dirvalues = nodes.dirvalues
+local lefttoright_code = dirvalues.lefttoright
+local righttoleft_code = dirvalues.righttoleft
----- object_replacement = 0xFFFC -- object replacement character
local maximum_stack = 60 -- probably spec but not needed
@@ -232,13 +237,19 @@ local function build_list(head) -- todo: store node pointer ... saves loop
list[size] = { char = 0x0020, direction = "ws", original = "ws", level = 0 }
current = getnext(current)
elseif id == dir_code then
- local dir = getdir(current)
- if dir == "+TLT" then
- list[size] = { char = 0x202A, direction = "lre", original = "lre", level = 0 }
- elseif dir == "+TRT" then
- list[size] = { char = 0x202B, direction = "rle", original = "rle", level = 0 }
- elseif dir == "-TLT" or dir == "-TRT" then
- list[size] = { char = 0x202C, direction = "pdf", original = "pdf", level = 0 }
+ local direction, pop = getdirection(current)
+ if direction == lefttoright_code then
+ if pop then
+ list[size] = { char = 0x202C, direction = "pdf", original = "pdf", level = 0 }
+ else
+ list[size] = { char = 0x202A, direction = "lre", original = "lre", level = 0 }
+ end
+ elseif direction == righttoleft_code then
+ if pop then
+ list[size] = { char = 0x202C, direction = "pdf", original = "pdf", level = 0 }
+ else
+ list[size] = { char = 0x202B, direction = "rle", original = "rle", level = 0 }
+ end
else
list[size] = { char = 0xFFFC, direction = "on", original = "on", level = 0, id = id } -- object replacement character
end
@@ -324,10 +335,11 @@ end
local function get_baselevel(head,list,size) -- todo: skip if first is object (or pass head and test for localpar)
local id = getid(head)
if id == localpar_code then
- if getdir(head) == "TRT" then
- return 1, "TRT", true
+ local direction = getdirection(head)
+ if direction == righttoleft_code or direction == "TRT" then -- for old times sake we we handle strings too
+ return 1, righttoleft_code, true
else
- return 0, "TLT", true
+ return 0, lefttoright_code, true
end
else
-- P2, P3
@@ -335,12 +347,12 @@ local function get_baselevel(head,list,size) -- todo: skip if first is object (o
local entry = list[i]
local direction = entry.direction
if direction == "r" or direction == "al" then
- return 1, "TRT", true
+ return 1, righttoleft_code, true
elseif direction == "l" then
- return 0, "TLT", true
+ return 0, lefttoright_code, true
end
end
- return 0, "TLT", false
+ return 0, lefttoright_code, false
end
end
@@ -695,11 +707,11 @@ local function insert_dir_points(list,size)
local begindir = nil
local enddir = nil
if level % 2 == 1 then
- begindir = "+TRT"
- enddir = "-TRT"
+ begindir = righttoleft_code
+ enddir = righttoleft_code
else
- begindir = "+TLT"
- enddir = "-TLT"
+ begindir = righttoleft_code
+ enddir = righttoleft_code
end
for i=1,size do
local entry = list[i]
@@ -748,11 +760,11 @@ local function apply_to_list(list,size,head,pardir)
setcolor(current,direction,false,mirror)
end
elseif id == hlist_code or id == vlist_code then
- setdir(current,pardir) -- is this really needed?
+ setdirection(current,pardir) -- is this really needed?
elseif id == glue_code then
if enddir and getsubtype(current) == parfillskip_code then
-- insert the last enddir before \parfillskip glue
- local d = new_textdir(enddir)
+ local d = new_direction(enddir,true)
setprop(d,"directions",true)
-- setattrlist(d,current)
head = insert_node_before(head,current,d)
@@ -761,7 +773,7 @@ local function apply_to_list(list,size,head,pardir)
elseif begindir then
if id == localpar_code then
-- localpar should always be the 1st node
- local d = new_textdir(begindir)
+ local d = new_direction(begindir)
setprop(d,"directions",true)
-- setattrlist(d,current)
head, current = insert_node_after(head,current,d)
@@ -769,7 +781,7 @@ local function apply_to_list(list,size,head,pardir)
end
end
if begindir then
- local d = new_textdir(begindir)
+ local d = new_direction(begindir)
setprop(d,"directions",true)
-- setattrlist(d,current)
head = insert_node_before(head,current,d)
@@ -782,7 +794,7 @@ local function apply_to_list(list,size,head,pardir)
end
end
if enddir then
- local d = new_textdir(enddir)
+ local d = new_direction(enddir,true)
setprop(d,"directions",true)
-- setattrlist(d,current)
head, current = insert_node_after(head,current,d)
diff --git a/tex/context/base/mkiv/typo-dub.lua b/tex/context/base/mkiv/typo-dub.lua
index 206cfd9ae..e08d96e88 100644
--- a/tex/context/base/mkiv/typo-dub.lua
+++ b/tex/context/base/mkiv/typo-dub.lua
@@ -63,11 +63,11 @@ local getlist = nuts.getlist
local getchar = nuts.getchar
local getattr = nuts.getattr
local getprop = nuts.getprop
-local getdir = nuts.getdir
+local getdir ection = nuts.getdirection
local setprop = nuts.setprop
local setchar = nuts.setchar
-local setdir = nuts.setdir
+local setdirection = nuts.setdirection
local setattrlist = nuts.setattrlist
local remove_node = nuts.remove
@@ -75,10 +75,10 @@ local insert_node_after = nuts.insert_after
local insert_node_before = nuts.insert_before
local nodepool = nuts.pool
-local new_textdir = nodepool.textdir
+local new_direction = nodepool.direction
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
local glyph_code = nodecodes.glyph
local glue_code = nodecodes.glue
@@ -87,7 +87,12 @@ local vlist_code = nodecodes.vlist
local math_code = nodecodes.math
local dir_code = nodecodes.dir
local localpar_code = nodecodes.localpar
-local parfillskip_code = skipcodes.parfillskip
+
+local parfillskip_code = gluecodes.parfillskip
+
+local dirvalues = nodes.dirvalues
+local lefttoright_code = dirvalues.lefttoright
+local righttoleft_code = dirvalues.righttoleft
local maximum_stack = 0xFF -- unicode: 60, will be jumped to 125, we don't care too much
@@ -280,13 +285,19 @@ local function build_list(head) -- todo: store node pointer ... saves loop
list[size] = { char = 0x0020, direction = "ws", original = "ws", level = 0 }
current = getnext(current)
elseif id == dir_code then
- local dir = getdir(current)
- if dir == "+TLT" then
- list[size] = { char = 0x202A, direction = "lre", original = "lre", level = 0 }
- elseif dir == "+TRT" then
- list[size] = { char = 0x202B, direction = "rle", original = "rle", level = 0 }
- elseif dir == "-TLT" or dir == "-TRT" then
- list[size] = { char = 0x202C, direction = "pdf", original = "pdf", level = 0 }
+ local direction, pop = getdirection(current)
+ if direction == lefttoright_code then
+ if pop then
+ list[size] = { char = 0x202C, direction = "pdf", original = "pdf", level = 0 }
+ else
+ list[size] = { char = 0x202A, direction = "lre", original = "lre", level = 0 }
+ end
+ elseif direction == righttoleft_code then
+ if pop then
+ list[size] = { char = 0x202C, direction = "pdf", original = "pdf", level = 0 }
+ else
+ list[size] = { char = 0x202B, direction = "rle", original = "rle", level = 0 }
+ end
else
list[size] = { char = 0xFFFC, direction = "on", original = "on", level = 0, id = id } -- object replacement character
end
@@ -395,10 +406,11 @@ end
local function get_baselevel(head,list,size) -- todo: skip if first is object (or pass head and test for localpar)
local id = getid(head)
if id == localpar_code then
- if getdir(head) == "TRT" then
- return 1, "TRT", true
+ local direction = getdirection(head)
+ if direction == righttoleft_code or direction == "TRT" then -- for old times sake we we handle strings too
+ return 1, righttoleft_code, true
else
- return 0, "TLT", true
+ return 0, lefttoright_code, true
end
else
-- P2, P3
@@ -406,12 +418,12 @@ local function get_baselevel(head,list,size) -- todo: skip if first is object (o
local entry = list[i]
local direction = entry.direction
if direction == "r" or direction == "al" then -- and an ?
- return 1, "TRT", true
+ return 1, righttoleft_code, true
elseif direction == "l" then
- return 0, "TLT", true
+ return 0, lefttoright_code, true
end
end
- return 0, "TLT", false
+ return 0, lefttoright_code, false
end
end
@@ -828,11 +840,11 @@ end
-- local begindir = nil
-- local enddir = nil
-- if level % 2 == 1 then
--- begindir = "+TRT"
--- enddir = "-TRT"
+-- begindir = righttoleft_code
+-- enddir = righttoleft_code
-- else
--- begindir = "+TLT"
--- enddir = "-TLT"
+-- begindir = lefttoright_code
+-- enddir = lefttoright_code
-- end
-- for i=1,size do
-- local entry = list[i]
@@ -875,12 +887,12 @@ local function insert_dir_points(list,size)
local enddir -- = nil
local prev -- = nil
if toggle then
- begindir = "+TLT"
- enddir = "-TLT"
+ begindir = righttoleft_code
+ enddir = righttoleft_code
toggle = false
else
- begindir = "+TRT"
- enddir = "-TRT"
+ begindir = righttoleft_code
+ enddir = righttoleft_code
toggle = true
end
for i=1,size do
@@ -920,7 +932,7 @@ local function insert_dir_points(list,size)
if trace_list and n > 1 then
report_directions("unbalanced list")
end
- last.enddir = s[n] == "+TRT" and "-TRT" or "-TLT"
+ last.enddir = s[n] == righttoleft_code or lefttoright_code
end
end
end
@@ -961,11 +973,11 @@ local function apply_to_list(list,size,head,pardir)
setcolor(current,direction,false,mirror)
end
elseif id == hlist_code or id == vlist_code then
- setdir(current,pardir) -- is this really needed?
+ setdirection(current,pardir) -- is this really needed?
elseif id == glue_code then
if enddir and getsubtype(current) == parfillskip_code then
-- insert the last enddir before \parfillskip glue
- local d = new_textdir(enddir)
+ local d = new_direction(enddir,true)
setprop(d,"directions",true)
-- setattrlist(d,current)
head = insert_node_before(head,current,d)
@@ -974,7 +986,7 @@ local function apply_to_list(list,size,head,pardir)
elseif begindir then
if id == localpar_code then
-- localpar should always be the 1st node
- local d = new_textdir(begindir)
+ local d = new_direction(begindir)
setprop(d,"directions",true)
-- setattrlist(d,current)
head, current = insert_node_after(head,current,d)
@@ -982,7 +994,7 @@ local function apply_to_list(list,size,head,pardir)
end
end
if begindir then
- local d = new_textdir(begindir)
+ local d = new_direction(begindir)
setprop(d,"directions",true)
-- setattrlist(d,current)
head = insert_node_before(head,current,d)
@@ -995,7 +1007,7 @@ local function apply_to_list(list,size,head,pardir)
end
end
if enddir then
- local d = new_textdir(enddir)
+ local d = new_direction(enddir,true)
setprop(d,"directions",true)
-- setattrlist(d,current)
head, current = insert_node_after(head,current,d)
diff --git a/tex/context/base/mkiv/typo-duc.lua b/tex/context/base/mkiv/typo-duc.lua
index 60191bf83..29d90cd4a 100644
--- a/tex/context/base/mkiv/typo-duc.lua
+++ b/tex/context/base/mkiv/typo-duc.lua
@@ -7,8 +7,6 @@ if not modules then modules = { } end modules ['typo-duc'] = {
comment = "Unicode bidi (sort of) variant c",
}
--- Will be replaced by typo-duc-new.lua!
-
-- This is a follow up on typo-uda which itself is a follow up on t-bidi by Khaled Hosny which
-- in turn is based on minibidi.c from Arabeyes. This is a further optimizations, as well as
-- an update on some recent unicode bidi developments. There is (and will) also be more control
@@ -58,6 +56,7 @@ local mirrordata = characters.mirrors
local textclassdata = characters.textclasses
local nuts = nodes.nuts
+local tonut = nuts.tonut
local getnext = nuts.getnext
local getid = nuts.getid
@@ -66,11 +65,11 @@ local getlist = nuts.getlist
local getchar = nuts.getchar
local getattr = nuts.getattr
local getprop = nuts.getprop
-local getdir = nuts.getdir
+local getdirection = nuts.getdirection
local setprop = nuts.setprop
local setchar = nuts.setchar
-local setdir = nuts.setdir
+local setdirection = nuts.setdirection
local setattrlist = nuts.setattrlist
local properties = nodes.properties.data
@@ -80,10 +79,10 @@ local insert_node_after = nuts.insert_after
local insert_node_before = nuts.insert_before
local nodepool = nuts.pool
-local new_textdir = nodepool.textdir
+local new_direction = nodepool.direction
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
local glyph_code = nodecodes.glyph
local glue_code = nodecodes.glue
@@ -92,7 +91,12 @@ local vlist_code = nodecodes.vlist
local math_code = nodecodes.math
local dir_code = nodecodes.dir
local localpar_code = nodecodes.localpar
-local parfillskip_code = skipcodes.parfillskip
+
+local parfillskip_code = gluecodes.parfillskip
+
+local dirvalues = nodes.dirvalues
+local lefttoright_code = dirvalues.lefttoright
+local righttoleft_code = dirvalues.righttoleft
local maximum_stack = 0xFF -- unicode: 60, will be jumped to 125, we don't care too much
@@ -290,13 +294,11 @@ local function build_list(head) -- todo: store node pointer ... saves loop
list[size] = setmetatable({ },mt_space)
current = getnext(current)
elseif id == dir_code then
- local dir = getdir(current)
- if dir == "+TLT" then
- list[size] = setmetatable({ },mt_lre)
- elseif dir == "+TRT" then
- list[size] = setmetatable({ },mt_rle)
- elseif dir == "-TLT" or dir == "-TRT" then
- list[size] = setmetatable({ },mt_pdf)
+ local dir, pop = getdirection(current)
+ if dir == lefttoright_code then
+ list[size] = setmetatable({ },swap and mt_pdf or mt_lre)
+ elseif dir == righttoleft_code then
+ list[size] = setmetatable({ },swap and mt_pdf or mt_rle)
else
list[size] = setmetatable({ id = id },mt_object)
end
@@ -405,25 +407,31 @@ end
-- the action
local function get_baselevel(head,list,size,direction)
- if not direction and getid(head) == localpar_code then
- direction = getdir(head)
+ if direction == lefttoright_code or direction == righttoleft_code then
+ return direction, true
+ elseif getid(head) == localpar_code then
+ direction = getdirection(head)
+ if direction == righttoleft_code or direction == lefttoright_code then
+ return direction, true
+ end
end
- if direction == "TRT" then
- return 1, "TRT", true
- elseif direction == "TLT" then
- return 0, "TLT", true
+ -- for old times sake we we handle strings too
+ if direction == "TLT" then
+ return righttoleft_code, true
+ elseif direction == "TRT" then
+ return lefttoright_code, true
end
-- P2, P3:
for i=1,size do
local entry = list[i]
local direction = entry.direction
if direction == "r" or direction == "al" then -- and an ?
- return 1, "TRT", true
+ return righttoleft_code, true
elseif direction == "l" then
- return 0, "TLT", true
+ return lefttoright_code, true
end
end
- return 0, "TLT", false
+ return lefttoright_code, false
end
local function resolve_explicit(list,size,baselevel)
@@ -724,33 +732,6 @@ local function resolve_neutral(list,size,start,limit,orderbefore,orderafter)
end
end
--- local function resolve_implicit(list,size,start,limit,orderbefore,orderafter)
--- -- I1
--- for i=start,limit do
--- local entry = list[i]
--- local level = entry.level
--- if level % 2 ~= 1 then -- not odd(level)
--- local direction = entry.direction
--- if direction == "r" then
--- entry.level = level + 1
--- elseif direction == "an" or direction == "en" then
--- entry.level = level + 2
--- end
--- end
--- end
--- -- I2
--- for i=start,limit do
--- local entry = list[i]
--- local level = entry.level
--- if level % 2 == 1 then -- odd(level)
--- local direction = entry.direction
--- if direction == "l" or direction == "en" or direction == "an" then
--- entry.level = level + 1
--- end
--- end
--- end
--- end
-
local function resolve_implicit(list,size,start,limit,orderbefore,orderafter,baselevel)
for i=start,limit do
local entry = list[i]
@@ -850,60 +831,6 @@ local function resolve_levels(list,size,baselevel,analyze_fences)
end
end
--- local function insert_dir_points(list,size)
--- -- L2, but no actual reversion is done, we simply annotate where
--- -- begindir/endddir node will be inserted.
--- local maxlevel = 0
--- local finaldir = false
--- local toggle = true
--- for i=1,size do
--- local level = list[i].level
--- if level > maxlevel then
--- maxlevel = level
--- end
--- end
--- for level=0,maxlevel do
--- local started -- = false
--- local begindir -- = nil
--- local enddir -- = nil
--- local prev -- = nil
--- if toggle then
--- begindir = "+TLT"
--- enddir = "-TLT"
--- toggle = false
--- else
--- begindir = "+TRT"
--- enddir = "-TRT"
--- toggle = true
--- end
--- for i=1,size do
--- local entry = list[i]
--- if entry.level >= level then
--- if not started then
--- entry.begindir = begindir
--- started = true
--- end
--- else
--- if started then
--- prev.enddir = enddir
--- started = false
--- end
--- end
--- prev = entry
--- end
--- -- make sure to close the run at end of line
--- if started then
--- finaldir = enddir
--- end
--- end
--- if finaldir then
--- list[size].enddir = finaldir
--- end
--- for i=1,size do
--- print("<",i,list[i].level,list[i].begindir,list[i].enddir)
--- end
--- end
-
local stack = { }
local function insert_dir_points(list,size)
@@ -923,12 +850,12 @@ local function insert_dir_points(list,size)
local enddir -- = nil
local prev -- = nil
if toggle then
- begindir = "+TLT"
- enddir = "-TLT"
+ begindir = lefttoright_code
+ enddir = lefttoright_code
toggle = false
else
- begindir = "+TRT"
- enddir = "-TRT"
+ begindir = righttoleft_code
+ enddir = righttoleft_code
toggle = true
end
for i=1,size do
@@ -967,7 +894,7 @@ local function insert_dir_points(list,size)
if trace_list and n > 1 then
report_directions("unbalanced list")
end
- last.enddir = stack[n] == "+TRT" and "-TRT" or "-TLT"
+ last.enddir = stack[n]
end
end
end
@@ -1008,11 +935,11 @@ local function apply_to_list(list,size,head,pardir)
setcolor(current,direction,false,mirror)
end
elseif id == hlist_code or id == vlist_code then
- setdir(current,pardir) -- is this really needed?
+ setdirection(current,pardir) -- is this really needed?
elseif id == glue_code then
if enddir and getsubtype(current) == parfillskip_code then
-- insert the last enddir before \parfillskip glue
- local d = new_textdir(enddir)
+ local d = new_direction(enddir,true)
local p = properties[d] if p then p.directions = true else properties[d] = { directions = true } end
-- setattrlist(d,current)
head = insert_node_before(head,current,d)
@@ -1021,7 +948,7 @@ local function apply_to_list(list,size,head,pardir)
elseif begindir then
if id == localpar_code then
-- localpar should always be the 1st node
- local d = new_textdir(begindir)
+ local d = new_direction(begindir)
local p = properties[d] if p then p.directions = true else properties[d] = { directions = true } end
-- setattrlist(d,current)
head, current = insert_node_after(head,current,d)
@@ -1029,7 +956,7 @@ local function apply_to_list(list,size,head,pardir)
end
end
if begindir then
- local d = new_textdir(begindir)
+ local d = new_direction(begindir)
local p = properties[d] if p then p.directions = true else properties[d] = { directions = true } end
-- setattrlist(d,current)
head = insert_node_before(head,current,d)
@@ -1042,7 +969,7 @@ local function apply_to_list(list,size,head,pardir)
end
end
if enddir then
- local d = new_textdir(enddir)
+ local d = new_direction(enddir,true)
local p = properties[d] if p then p.directions = true else properties[d] = { directions = true } end
-- setattrlist(d,current)
head, current = insert_node_after(head,current,d)
@@ -1075,9 +1002,9 @@ local function process(head,direction,only_one)
local analyze_fences = getfences(attr)
--
local list, size = build_list(head)
- local baselevel, pardir, dirfound = get_baselevel(head,list,size,direction) -- we always have an inline dir node in context
+ local baselevel, dirfound = get_baselevel(head,list,size,direction) -- we always have an inline dir node in context
if trace_details then
- report_directions("analyze: direction %a, baselevel %a",dirfound and pardir or "unknown",baselevel or 1)
+ report_directions("analyze: baselevel %a",baselevel == righttoleft_code and "r2l" or "l2r")
report_directions("before : %s",show_list(list,size,"original"))
end
resolve_explicit(list,size,baselevel)
@@ -1087,7 +1014,7 @@ local function process(head,direction,only_one)
report_directions("after : %s",show_list(list,size,"direction"))
report_directions("result : %s",show_done(list,size))
end
- return apply_to_list(list,size,head,pardir)
+ return apply_to_list(list,size,head,baselevel)
end
directions.installhandler(interfaces.variables.three,process)
diff --git a/tex/context/base/mkiv/typo-fln.lua b/tex/context/base/mkiv/typo-fln.lua
index b67086fbe..048980732 100644
--- a/tex/context/base/mkiv/typo-fln.lua
+++ b/tex/context/base/mkiv/typo-fln.lua
@@ -65,7 +65,7 @@ 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 list_dimensions = nuts.dimensions
+local getdimensions = nuts.dimensions
local hpack_node_list = nuts.hpack
local nodepool = nuts.pool
@@ -179,9 +179,7 @@ actions[v_line] = function(head,setting)
-- 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
- temp = hpack_node_list(temp)
- local width = getwidth(temp)
- flush_node_list(temp)
+ local width = getdimensions(temp)
return width
end
diff --git a/tex/context/base/mkiv/typo-krn.lua b/tex/context/base/mkiv/typo-krn.lua
index a099163db..87d89572f 100644
--- a/tex/context/base/mkiv/typo-krn.lua
+++ b/tex/context/base/mkiv/typo-krn.lua
@@ -59,7 +59,7 @@ local new_glue = nodepool.glue
local nodecodes = nodes.nodecodes
local kerncodes = nodes.kerncodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
local disccodes = nodes.disccodes
local listcodes = nodes.listcodes
@@ -71,17 +71,18 @@ local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
local math_code = nodecodes.math
-local box_list_code = listcodes.box
-local user_list_code = listcodes.unknown
+local boxlist_code = listcodes.box
+local unknownlist_code = listcodes.unknown
-local discretionary_code = disccodes.discretionary
-local automatic_code = disccodes.automatic
+local discretionarydisc_code = disccodes.discretionary
+local automaticdisc_code = disccodes.automatic
local fontkern_code = kerncodes.fontkern
local userkern_code = kerncodes.userkern
-local userskip_code = skipcodes.userskip
-local spaceskip_code = skipcodes.spaceskip
-local xspaceskip_code = skipcodes.xspaceskip
+
+local userskip_code = gluecodes.userskip
+local spaceskip_code = gluecodes.spaceskip
+local xspaceskip_code = gluecodes.xspaceskip
local fonthashes = fonts.hashes
local chardata = fonthashes.characters
@@ -435,14 +436,14 @@ function kerns.handler(head)
elseif id == disc_code then
local prev, next, pglyph, nglyph -- delayed till needed
local subtype = getsubtype(start)
- -- if subtype == automatic_code then
+ -- if subtype == automaticdisc_code then
-- -- this is kind of special, as we have already injected the
-- -- previous kern
-- local prev = getprev(start)
-- local pglyph = prev and getid(prev) == glyph_code
-- languages.expand(start,pglyph and prev)
-- -- we can have a different start now
- -- elseif subtype ~= discretionary_code then
+ -- elseif subtype ~= discretionarydisc_code then
-- prev = getprev(start)
-- pglyph = prev and getid(prev) == glyph_code
-- languages.expand(start,pglyph and prev)
@@ -529,7 +530,7 @@ function kerns.handler(head)
bound = false
elseif id == hlist_code or id == vlist_code then
local subtype = getsubtype(start)
- if subtype == user_list_code or subtype == box_list_code then
+ if subtype == unknownlist_code or subtype == boxlist_code then
-- special case
local b, f = closest_bound(start,getprev)
if b then
diff --git a/tex/context/base/mkiv/typo-lin.lua b/tex/context/base/mkiv/typo-lin.lua
index a1c0bb52b..3b0de080d 100644
--- a/tex/context/base/mkiv/typo-lin.lua
+++ b/tex/context/base/mkiv/typo-lin.lua
@@ -64,7 +64,7 @@ local listcodes = nodes.listcodes
local hlist_code = nodecodes.hlist
local glue_code = nodecodes.glue
local kern_code = nodecodes.kern
-local line_code = listcodes.line
+local linelist_code = listcodes.line
----- localpar_code = nodecodes.localpar
local leftskip_code = gluecodes.leftskip
local rightskip_code = gluecodes.rightskip
@@ -90,7 +90,7 @@ local getboth = nuts.getboth
local setlink = nuts.setlink
local setkern = nuts.setkern
local getkern = nuts.getkern
-local getdir = nuts.getdir
+local getdirection = nuts.getdirection
local getshift = nuts.getshift
local setshift = nuts.setshift
local getwidth = nuts.getwidth
@@ -109,6 +109,8 @@ local new_hlist = nodepool.hlist
local new_rule = nodepool.rule
local new_glue = nodepool.glue
+local righttoleft_code = nodes.dirvalues.righttoleft
+
local texgetcount = tex.getcount
local texgetglue = tex.getglue
local setmetatableindex = table.setmetatableindex
@@ -127,22 +129,12 @@ local noflines = 0
-- This is the third version, a mix between immediate (prestice lines) and delayed
-- as we don't want anchors that are not used.
--- if reverse then delta = - delta end
--- head = insert_before(head,head,nodepool.textdir("-TLT"))
--- ....
--- head = insert_before(head,head,nodepool.textdir("TLT"))
-
--- todo: figure out metatable mess ... when we copy we also need to copy
--- anchors ... use rawgets
-
--- problem: what if a box is copied ... we could check an attribute
-
local function finalize(prop,key) -- delayed calculations
local line = prop.line
local hsize = prop.hsize
local width = prop.width
local shift = getshift(line) -- dangerous as it can be vertical as well
- local reverse = getdir(line) == "TRT" or false
+ local reverse = getdirection(line) == righttoleft_code or false
local pack = new_hlist()
local head = getlist(line)
local delta = 0
@@ -255,7 +247,7 @@ function paragraphs.normalize(head,islocal)
local last = nil -- a nut
local done = mode == 2 -- false
for line, subtype in nexthlist, head do
- if subtype == line_code and not getprop(line,"line") then
+ if subtype == linelist_code and not getprop(line,"line") then
if done then
last = line
else
@@ -284,7 +276,7 @@ function paragraphs.normalize(head,islocal)
end
-- normalizer
for line, subtype in nexthlist, head do
- if subtype == line_code and not getprop(line,"line") then
+ if subtype == linelist_code and not getprop(line,"line") then
normalize(line)
end
end
diff --git a/tex/context/base/mkiv/typo-mar.lua b/tex/context/base/mkiv/typo-mar.lua
index b7288fd53..119ccf69e 100644
--- a/tex/context/base/mkiv/typo-mar.lua
+++ b/tex/context/base/mkiv/typo-mar.lua
@@ -95,7 +95,6 @@ local getprop = nuts.getprop
local nodecodes = nodes.nodecodes
local listcodes = nodes.listcodes
-local gluecodes = nodes.gluecodes
local whatsitcodes = nodes.whatsitcodes
local hlist_code = nodecodes.hlist
diff --git a/tex/context/base/mkiv/typo-par.mkiv b/tex/context/base/mkiv/typo-par.mkiv
index 3db0ffa45..066dc6a69 100644
--- a/tex/context/base/mkiv/typo-par.mkiv
+++ b/tex/context/base/mkiv/typo-par.mkiv
@@ -23,7 +23,7 @@
\unprotect
-\registerctxluafile{node-ltp}{}
+\registerctxluafile{node-ltp}{optimize}
\registerctxluafile{trac-par}{}
\protect \endinput
diff --git a/tex/context/base/mkiv/typo-rub.lua b/tex/context/base/mkiv/typo-rub.lua
index f1f3f0403..f096d3bb4 100644
--- a/tex/context/base/mkiv/typo-rub.lua
+++ b/tex/context/base/mkiv/typo-rub.lua
@@ -66,11 +66,8 @@ local vlist_code = nodecodes.vlist
local whatsit_code = nodecodes.whatsit
local localpar_code = nodecodes.localpar
-local whatsitcodes = nodes.whatsitcodes
------ late_luacode = whatsitcodes.latelua
-
local kerncodes = nodes.kerncodes
-local font_code = kerncodes.font
+local fontkern_code = kerncodes.font
local nodepool = nuts.pool
local new_kern = nodepool.kern
@@ -246,7 +243,7 @@ function rubies.check(head)
start = current
stop = current
end
- elseif id == kern_code and getsubtype(current,font_code) then
+ elseif id == kern_code and getsubtype(current,fontkern_code) then
-- go on
elseif found and id == disc_code then
-- go on (todo: look into disc)
diff --git a/tex/context/base/mkiv/typo-tal.lua b/tex/context/base/mkiv/typo-tal.lua
index 413c249fa..d9c2a51ac 100644
--- a/tex/context/base/mkiv/typo-tal.lua
+++ b/tex/context/base/mkiv/typo-tal.lua
@@ -50,7 +50,7 @@ local setchar = nuts.setchar
local insert_node_before = nuts.insert_before
local insert_node_after = nuts.insert_after
local nextglyph = nuts.traversers.glyph
-local list_dimensions = nuts.dimensions
+local getdimensions = nuts.dimensions
local first_glyph = nuts.first_glyph
local setglue = nuts.setglue
@@ -320,16 +320,16 @@ function characteralign.handler(head,where)
local predefined = dataset.predefined
local before, after
if predefined then
- before = b_start and list_dimensions(b_start,getnext(b_stop)) or 0
- after = a_start and list_dimensions(a_start,getnext(a_stop)) or 0
+ before = b_start and getdimensions(b_start,getnext(b_stop)) or 0
+ after = a_start and getdimensions(a_start,getnext(a_stop)) or 0
else
local entry = list[row]
if entry then
before = entry.before or 0
after = entry.after or 0
else
- before = b_start and list_dimensions(b_start,getnext(b_stop)) or 0
- after = a_start and list_dimensions(a_start,getnext(a_stop)) or 0
+ before = b_start and getdimensions(b_start,getnext(b_stop)) or 0
+ after = a_start and getdimensions(a_start,getnext(a_stop)) or 0
list[row] = {
before = before,
after = after,
diff --git a/tex/context/base/mkiv/typo-wrp.lua b/tex/context/base/mkiv/typo-wrp.lua
index 3be64f53e..9fb544152 100644
--- a/tex/context/base/mkiv/typo-wrp.lua
+++ b/tex/context/base/mkiv/typo-wrp.lua
@@ -17,13 +17,13 @@ local glue_code = nodecodes.glue
local penalty_code = nodecodes.penalty
local boundary_code = nodecodes.boundary
-local parfill_skip_code = gluecodes.parfillskip
+local parfillskip_code = gluecodes.parfillskip
-local user_penalty_code = penaltycodes.userpenalty
-local line_penalty_code = penaltycodes.linepenalty
-local linebreak_penalty_code = penaltycodes.linebreakpenalty
+local userpenalty_code = penaltycodes.userpenalty
+local linepenalty_code = penaltycodes.linepenalty
+local linebreakpenalty_code = penaltycodes.linebreakpenalty
-local word_boundary_code = boundarycodes.word
+local wordboundary_code = boundarycodes.word
local nuts = nodes.nuts
@@ -54,15 +54,15 @@ local report = logs.reporter("paragraphs","wrappers")
-- use attributes.
local function remove_dangling_crlf(head,tail)
- if head and tail and getid(tail) == glue_code and getsubtype(tail) == parfill_skip_code then
+ if head and tail and getid(tail) == glue_code and getsubtype(tail) == parfillskip_code then
tail = getprev(tail)
if tail and getid(tail) == penalty_code then
local subtype = getsubtype(tail)
- if subtype == line_penalty_code or subtype == linebreak_penalty_code then
+ if subtype == linepenalty_code or subtype == linebreakpenalty_code then
tail = getprev(tail)
- if tail and getid(tail) == boundary_code and getsubtype(tail) == word_boundary_code then
+ if tail and getid(tail) == boundary_code and getsubtype(tail) == wordboundary_code then
tail = getprev(tail)
- if tail ~= head and getid(tail) == penalty_code and getsubtype(tail) == user_penalty_code and getpenalty(tail) == -10000 then
+ if tail ~= head and getid(tail) == penalty_code and getsubtype(tail) == userpenalty_code and getpenalty(tail) == -10000 then
if trace_wrappers then
report("removing a probably unwanted end-of-par break in line %s (guess)",tex.inputlineno)
end
diff --git a/tex/context/base/mkiv/util-lua.lua b/tex/context/base/mkiv/util-lua.lua
index 1f531ef48..1199301f4 100644
--- a/tex/context/base/mkiv/util-lua.lua
+++ b/tex/context/base/mkiv/util-lua.lua
@@ -88,6 +88,7 @@ function luautilities.loadedluacode(fullname,forcestrip,name,macros)
code()
else
report_lua("loading of file %a failed:\n\t%s",fullname,message or "no message")
+ code, message = loadfile(fullname)
end
if forcestrip and luautilities.stripcode then
if type(forcestrip) == "function" then
diff --git a/tex/context/interface/mkii/keys-pe.xml b/tex/context/interface/mkii/keys-pe.xml
index eebe9e7a0..bd42a83dd 100644
--- a/tex/context/interface/mkii/keys-pe.xml
+++ b/tex/context/interface/mkii/keys-pe.xml
@@ -140,6 +140,7 @@
<cd:variable name='chemicals' value='chemicals'/>
<cd:variable name='chemistry' value='chemistry'/>
<cd:variable name='cite' value='cite'/>
+ <cd:variable name='closed' value='closed'/>
<cd:variable name='color' value='رنگ'/>
<cd:variable name='column' value='ستون'/>
<cd:variable name='columns' value='ستونها'/>
@@ -421,7 +422,7 @@
<cd:variable name='positive' value='مثبت'/>
<cd:variable name='postponing' value='تاخیر'/>
<cd:variable name='postscript' value='پست‌اسکریپت'/>
- <cd:variable name='precedingpage' value='followingpage'/>
+ <cd:variable name='precedingpage' value='precedingpage'/>
<cd:variable name='preference' value='ترجیح'/>
<cd:variable name='preview' value='پیش‌دید'/>
<cd:variable name='previous' value='قبلی'/>
diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf
index 06f7a694b..36541a927 100644
--- a/tex/context/interface/mkiv/i-context.pdf
+++ b/tex/context/interface/mkiv/i-context.pdf
Binary files differ
diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf
index 7e234137e..0127ead24 100644
--- a/tex/context/interface/mkiv/i-readme.pdf
+++ b/tex/context/interface/mkiv/i-readme.pdf
Binary files differ
diff --git a/tex/generic/context/luatex/luatex-core.lua b/tex/generic/context/luatex/luatex-core.lua
index 35518c0e8..6e1b31e96 100644
--- a/tex/generic/context/luatex/luatex-core.lua
+++ b/tex/generic/context/luatex/luatex-core.lua
@@ -376,6 +376,8 @@ do
if not loaded.socket then loaded.socket = loaded["socket.core"] end
if not loaded.mime then loaded.mime = loaded["mime.core"] end
+ if not loaded.lfs then loaded.lfs = lfs end
+
end
do
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 0c9bfcc38..b3afbafa1 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/sources/luatex-fonts.lua
--- merge date : 12/19/18 19:22:22
+-- merge date : 12/28/18 11:01:18
do -- begin closure to overcome local limits and interference
@@ -13531,7 +13531,7 @@ statistics.usedfeatures=usedfeatures
table.setmetatableindex(usedfeatures,function(t,k) if k then local v={} t[k]=v return v end end)
storage.register("fonts/otf/usedfeatures",usedfeatures,"fonts.handlers.otf.statistics.usedfeatures" )
local normalizedaxis=otf.readers.helpers.normalizedaxis or function(s) return s end
-function otffeatures.normalize(features)
+function otffeatures.normalize(features,wrap)
if features then
local h={}
for key,value in next,features do
@@ -13557,7 +13557,11 @@ function otffeatures.normalize(features)
elseif type(value)=="string" then
local b=is_boolean(value)
if type(b)=="nil" then
- uv=lower(value)
+ if wrap and find(value,",") then
+ uv="{"..lower(value).."}"
+ else
+ uv=lower(value)
+ end
else
uv=b
end
@@ -25696,8 +25700,8 @@ local disc_code=nodecodes.disc
local math_code=nodecodes.math
local dir_code=nodecodes.dir
local localpar_code=nodecodes.localpar
-local discretionary_code=disccodes.discretionary
-local ligature_code=glyphcodes.ligature
+local discretionarydisc_code=disccodes.discretionary
+local ligatureglyph_code=glyphcodes.ligature
local a_state=attributes.private('state')
local a_noligature=attributes.private("noligature")
local injections=nodes.injections
@@ -25864,7 +25868,7 @@ local set_components=setcomponents
local function count_components(start,marks)
if getid(start)~=glyph_code then
return 0
- elseif getsubtype(start)==ligature_code then
+ elseif getsubtype(start)==ligatureglyph_code then
local i=0
local components=getcomponents(start)
while components do
@@ -25892,7 +25896,7 @@ local function markstoligature(head,start,stop,char)
end
resetinjection(base)
setchar(base,char)
- setsubtype(base,ligature_code)
+ setsubtype(base,ligatureglyph_code)
set_components(base,start)
setlink(prev,base,next)
return head,base
@@ -25918,7 +25922,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou
end
resetinjection(base)
setchar(base,char)
- setsubtype(base,ligature_code)
+ setsubtype(base,ligatureglyph_code)
set_components(base,comp)
setlink(prev,base,next)
if not discfound then
@@ -25989,7 +25993,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou
set_components(base,copied)
replace=base
if forcediscretionaries then
- setdisc(discfound,pre,post,replace,discretionary_code)
+ setdisc(discfound,pre,post,replace,discretionarydisc_code)
else
setdisc(discfound,pre,post,replace)
end
@@ -28560,41 +28564,51 @@ local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,datase
end
end
end
-local function txtdirstate(start,stack,top,rlparmode)
- local nxt=getnext(start)
- local dir=getdir(start)
- if dir=="+TRT" then
- top=top+1
- stack[top]=dir
- return nxt,top,-1
- elseif dir=="+TLT" then
- top=top+1
- stack[top]=dir
- return nxt,top,1
- elseif dir=="-TRT" or dir=="-TLT" then
- if top==1 then
- return nxt,0,rlparmode
- else
- top=top-1
- if stack[top]=="+TRT" then
- return nxt,top,-1
+local txtdirstate,pardirstate do
+ local getdirection=nuts.getdirection
+ local lefttoright=0
+ local rightoleft=1
+ txtdirstate=function(start,stack,top,rlparmode)
+ local nxt=getnext(start)
+ local dir,pop=getdirection(start)
+ if pop then
+ if top==1 then
+ return nxt,0,rlparmode
else
- return nxt,top,1
+ top=top-1
+ if stack[top]==righttoleft then
+ return nxt,top,-1
+ else
+ return nxt,top,1
+ end
end
+ elseif dir==lefttoright then
+ top=top+1
+ stack[top]=0
+ return nxt,top,1
+ elseif dir==righttoleft then
+ top=top+1
+ stack[top]=1
+ return nxt,top,-1
+ else
+ return nxt,top,rlparmode
end
- else
- return nxt,top,rlparmode
end
-end
-local function pardirstate(start)
- local nxt=getnext(start)
- local dir=getdir(start)
- if dir=="TLT" then
- return nxt,1,1
- elseif dir=="TRT" then
- return nxt,-1,-1
- else
- return nxt,0,0
+ pardirstate=function(start)
+ local nxt=getnext(start)
+ local dir=getdirection(start)
+ if dir==lefttoright then
+ return nxt,1,1
+ end
+ if dir==righttoleft then
+ return nxt,-1,-1
+ elseif dir=="TRT" then
+ return nxt,1,1
+ elseif dir=="TLT" then
+ return nxt,-1,-1
+ else
+ return nxt,0,0
+ end
end
end
otf.helpers=otf.helpers or {}
@@ -28642,7 +28656,7 @@ do
if trace_steps then
checkstep(head)
end
- local initialrl=direction=="TRT" and -1 or 0
+ local initialrl=(direction==1 or direction=="TRT") and -1 or 0
local datasets=otfdataset(tfmdata,font,attr)
local dirstack={ nil }
sweephead={}
@@ -28866,7 +28880,7 @@ do
local done=false
local dirstack={ nil }
local start=head
- local initialrl=direction=="TRT" and -1 or 0
+ local initialrl=(direction==1 or direction=="TRT") and -1 or 0
local rlmode=initialrl
local rlparmode=initialrl
local topstack=0