diff options
author | Hans Hagen <pragma@wxs.nl> | 2021-04-18 19:27:46 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2021-04-18 19:27:46 +0200 |
commit | 4831ec8b98dbd0b637271f601c288960f9259bfc (patch) | |
tree | 9163b423a7b6f23b0249e923cab8e4a1f2ca18b0 /tex/context/base | |
parent | 113a26a2838ace27514f6348ed0d41bf87724472 (diff) | |
download | context-4831ec8b98dbd0b637271f601c288960f9259bfc.tar.gz |
2021-04-18 18:07:00
Diffstat (limited to 'tex/context/base')
29 files changed, 500 insertions, 291 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index b468ce3d0..740b08bdf 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{2021.04.14 22:55} +\newcontextversion{2021.04.18 18:04} %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 7ad92f388..49b387e44 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{2021.04.14 22:55} +\edef\contextversion{2021.04.18 18:04} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 7bb390194..3fdf4202b 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.04.14 22:55} +\newcontextversion{2021.04.18 18:04} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 6fa606a95..2ce45e779 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2021.04.14 22:55} +\edef\contextversion{2021.04.18 18:04} %D Kind of special: diff --git a/tex/context/base/mkiv/core-con.lua b/tex/context/base/mkiv/core-con.lua index 4bf1424bc..f1aa37a7c 100644 --- a/tex/context/base/mkiv/core-con.lua +++ b/tex/context/base/mkiv/core-con.lua @@ -1415,6 +1415,111 @@ data.es = data.spanish -- print(translate(101)) -- print(translate(199)) +-- verbose swedish by Peter Kvillegard + +do + + local words = { + [0] = "noll", + [1] = "ett", + [2] = "två", + [3] = "tre", + [4] = "fyra", + [5] = "fem", + [6] = "sex", + [7] = "sju", + [8] = "åtta", + [9] = "nio", + [10] = "tio", + [11] = "elva", + [12] = "tolv", + [13] = "tretton", + [14] = "fjorton", + [15] = "femton", + [16] = "sexton", + [17] = "sjutton", + [18] = "arton", + [19] = "nitton", + [20] = "tjugo", + [30] = "trettio", + [40] = "fyrtio", + [50] = "femtio", + [60] = "sextio", + [70] = "sjuttio", + [80] = "åttio", + [90] = "nittio", + [100] = "hundra", + [10^3] = "tusen", + [10^6] = "miljon", + [10^9] = "miljard", + [10^12] = "biljon", + [10^15] = "biljard", + } + + local function translate(n,connector) + local w = words[n] + if w then + return w + else + local t = { } + local l = 0 + -- group of three digits to words, e.g. 123 -> etthundratjugotre + local function triplets(n) + if floor(n/100) > 0 then + l = l + 1 ; t[l] = words[floor(n/100)] + l = l + 1 ; t[l] = words[100] + end + if n%100 > 20 then + l = l + 1 ; t[l] = words[n%100-n%10] + if n%10 > 0 then + l = l + 1 ; t[l] = words[n%10] + end + elseif n%100 > 0 then + l = l + 1 ; t[l] = words[n%100] + end + end + -- loops through 10^15,10^12,...10^3, extracting groups of three digits + -- to make words from, then adding names for order of magnitude + for i=15,3,-3 do + local triplet = floor(n/10^i)%10^3 + if triplet > 0 then + -- grammar: "en" instead of "ett" + if i > 3 and triplet == 1 then + l = l + 1 ; t[l] = "en" + else + triplets(triplet) + end + -- grammar: plural form of "millions" etc + l = l + 1 ; t[l] = words[10^i] + if i > 3 and triplet > 1 then + l = l + 1 ; t[l] = "er" + end + end + end + -- add last group of three numbers (no word for magnitude) + n = n%1000 + if n > 0 then + triplets(n) + end + t = concat(t," ") + -- grammar: spacing for numbers < 10^6 and repeated letters + if n < 10^6 then + t = gsub(t,"%stusen%s","tusen") + t = gsub(t,"etttusen","ettusen") + end + return t + end + end + + data.swedish = { + words = words, + translate = translate, + } + + data.sv = data.swedish + +end + -- verbose handler: function converters.verbose.translate(n,language,connector) diff --git a/tex/context/base/mkiv/luat-mac.lua b/tex/context/base/mkiv/luat-mac.lua index 01857511c..fca59c993 100644 --- a/tex/context/base/mkiv/luat-mac.lua +++ b/tex/context/base/mkiv/luat-mac.lua @@ -85,6 +85,8 @@ local set = CONTEXTLMTXMODE > 0 and return h .. "-" elseif s == "spacer" then return h .. "*" + elseif s == "keepspacer" then + return h .. "," elseif s == "pickup" then return h .. ":" else diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index 05e5f28e5..78f864307 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -164,6 +164,7 @@ return { "automaticpenaltyhyphenationmodecode", "explicitpenaltyhyphenationmodecode", "permitgluehyphenationmodecode", "permitallhyphenationmodecode", "permitmathreplacehyphenationmodecode", "forcecheckhyphenationmodecode", "lazyligatureshyphenationmodecode", "forcehandlerhyphenationmodecode", + "feedbackcompoundhyphenationmodecode", "ignoreboundshyphenationmodecode", -- "normalizelinecode", "parindentskipcode", "swaphangindentcode", "swapparsshapecode", "breakafterdircode", "removemarginkernscode", "clipwidthcode", "flattendiscretionariescode", diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index c2b11df3d..855b4bc1f 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -315,6 +315,7 @@ return { "glyphyscale", "gtoksapp", "gtokspre", + "hccode", "hjcode", "hpack", "hyphenationmin", @@ -593,6 +594,7 @@ return { "baselineskip", "batchmode", "begingroup", + "beginsimplegroup", "belowdisplayshortskip", "belowdisplayskip", "binoppenalty", @@ -640,6 +642,7 @@ return { "endgroup", "endinput", "endlinechar", + "endsimplegroup", "eqno", "errhelp", "errmessage", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 69556e09e..9d4db8781 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 615e7d326..5963b5c89 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkxl/buff-ver.mkxl b/tex/context/base/mkxl/buff-ver.mkxl index 68a07df60..c948181c5 100644 --- a/tex/context/base/mkxl/buff-ver.mkxl +++ b/tex/context/base/mkxl/buff-ver.mkxl @@ -835,13 +835,25 @@ \stoppacked \typingparameter\c!after\relax} -\permanent\protected\def\typeinlinebuffer +\permanent\tolerant\protected\def\typeinlinebuffer[#1]#,[#2]% {\dontleavehmode \begingroup - \enforced\let\buff_verbatim_type_buffer_indeed\buff_verbatim_type_buffer_indeed_inline \enforced\let\setupcurrenttyping\setupcurrenttype % a terrible hack but it saves code \let\currenttype\empty - \buff_verbatim_type_buffer} + \ifparameters + \buff_verbatim_type_buffer_indeed_inline\currenttyping\empty% [] + \or + \ifhastok={#1}% + \setupcurrenttyping[#1]% + \buff_verbatim_type_buffer_indeed_inline\currenttyping\empty% [settings] + \else + \processcommalist[#1]{\buff_verbatim_type_buffer_indeed_inline\currenttyping}% [name] + \fi + \or + \setupcurrenttyping[#2]% + \processcommalist[#1]{\buff_verbatim_type_buffer_indeed_inline\currenttyping}% [name] [settings] + \fi + \endgroup} \protected\def\buff_verbatim_type_buffer_indeed_inline#1#2% category name {\edef\currenttype{#1}% diff --git a/tex/context/base/mkxl/colo-ini.mkxl b/tex/context/base/mkxl/colo-ini.mkxl index c096fe90f..97ad183e5 100644 --- a/tex/context/base/mkxl/colo-ini.mkxl +++ b/tex/context/base/mkxl/colo-ini.mkxl @@ -125,7 +125,7 @@ % transparency \permanent\protected\def\transparent[#1]% - {\bgroup + {\beginsimplegroup \edef\scratchstringone{#1}% % the \relax catches a non existent csname \ifx\scratchstringone\v!reset @@ -150,7 +150,7 @@ % color \permanent\protected\def\coloronly[#1]% - {\bgroup + {\beginsimplegroup \edef\currentcolorname{#1}% \ifempty\currentcolorprefix \colo_helpers_activate_nop_only @@ -174,7 +174,7 @@ % color + transparency \permanent\protected\def\color[#1]% - {\bgroup + {\beginsimplegroup \edef\currentcolorname{#1}% \ifempty\currentcolorprefix \colo_helpers_activate_nop @@ -184,7 +184,7 @@ \let\nexttoken} \permanent\protected\def\graycolor[#1]% - {\bgroup + {\beginsimplegroup \colo_helpers_set_model\s!gray\colo_helpers_activate{#1}% \let\nexttoken} @@ -201,7 +201,7 @@ {\endgroup} \permanent\protected\def\colored[#1]% - {\bgroup + {\beginsimplegroup \colo_basics_defined_and_activated{#1}% \let\nexttoken} @@ -333,20 +333,38 @@ %D We provide stacking independent of grouping. -\newcount\c_colo_nesting +% the old one +% +% \newcount\c_colo_nesting +% +% \permanent\protected\def\pushcolor[#1]% +% {\global\advance\c_colo_nesting\plusone +% \edefcsname\??colorstack\number\c_colo_nesting\endcsname +% {\c_attr_colormodel \the\c_attr_colormodel +% \c_attr_color \the\c_attr_color +% \c_attr_transparency\the\c_attr_transparency +% \relax}% stack +% \colo_helpers_activate{#1}} +% +% \permanent\protected\def\popcolor +% {\csname\??colorstack\number\c_colo_nesting\endcsname +% \global\advance\c_colo_nesting\minusone} +% +% more efficient: + +\installmacrostack\m_color_state \permanent\protected\def\pushcolor[#1]% - {\global\advance\c_colo_nesting\plusone - \edefcsname\??colorstack\number\c_colo_nesting\endcsname + {\edef\m_color_state {\c_attr_colormodel \the\c_attr_colormodel \c_attr_color \the\c_attr_color - \c_attr_transparency\the\c_attr_transparency - \relax}% stack + \c_attr_transparency\the\c_attr_transparency}% + \push_macro_m_color_state \colo_helpers_activate{#1}} \permanent\protected\def\popcolor - {\csname\??colorstack\number\c_colo_nesting\endcsname - \global\advance\c_colo_nesting\minusone} + {\pop_macro_m_color_state + \m_color_state\relax} % a simple one: assumes grouping diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index f99a9ce23..2e0fc46a1 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.04.14 22:55} +\newcontextversion{2021.04.18 18:04} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index 103481265..c36c43a47 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.04.14 22:55} +\immutable\edef\contextversion{2021.04.18 18:04} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/core-con.mkxl b/tex/context/base/mkxl/core-con.mkxl index df505cfee..223afa1a1 100644 --- a/tex/context/base/mkxl/core-con.mkxl +++ b/tex/context/base/mkxl/core-con.mkxl @@ -418,7 +418,7 @@ \installcorenamespace{date} -\permanent\tolerant\protected\def\definedate[#1]#*[#2]% +\permanent\tolerant\protected\def\definedate[#1]#,[#2]% {\ifarguments\else\setvalue{\??date#1}{#2}\fi} \def\syst_converters_check_date_specification#1% @@ -452,7 +452,7 @@ \iftok{\directdummyparameter\c!m}\emptytoks\else\normalmonth\number\directdummyparameter\c!m\relax\fi \iftok{\directdummyparameter\c!y}\emptytoks\else\normalyear \number\directdummyparameter\c!y\relax\fi}} -\permanent\tolerant\protected\def\date[#1]#*[#2]% sets the date ! +\permanent\tolerant\protected\def\date[#1]#,[#2]% sets the date ! {\dontleavehmode \begingroup \setdate[#1]% sets the date ! diff --git a/tex/context/base/mkxl/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt index 80c2faffe..0ef37a054 100644 --- a/tex/context/base/mkxl/driv-shp.lmt +++ b/tex/context/base/mkxl/driv-shp.lmt @@ -444,6 +444,7 @@ local flush_character do end return 0, 0, 0 end + if vfcommands then vfcommands = data.commands end diff --git a/tex/context/base/mkxl/good-mth.lmt b/tex/context/base/mkxl/good-mth.lmt index 87b6787df..dc61e953d 100644 --- a/tex/context/base/mkxl/good-mth.lmt +++ b/tex/context/base/mkxl/good-mth.lmt @@ -143,6 +143,8 @@ local function finalize(tfmdata,feature,value) if commands then prependcommands(commands,yoffset,xoffset) else +-- character.commands = { { "offset", xoffset, yoffset, unicode } } +-- print(unicode,character.width) local slot = charcommand[unicode] if xoffset and yoffset then character.commands = { xoffset, yoffset, slot } diff --git a/tex/context/base/mkxl/grph-inc.mkxl b/tex/context/base/mkxl/grph-inc.mkxl index 5bd829e00..85f0af73e 100644 --- a/tex/context/base/mkxl/grph-inc.mkxl +++ b/tex/context/base/mkxl/grph-inc.mkxl @@ -215,7 +215,7 @@ % inclusion -\permanent\tolerant\protected\def\externalfigure[#1]#*[#2]#*[#3]% +\permanent\tolerant\protected\def\externalfigure[#1]#,[#2]#,[#3]% {\ifhastok={#2}% \grph_include_place[#1][][#2]% \else diff --git a/tex/context/base/mkxl/lang-ini.lmt b/tex/context/base/mkxl/lang-ini.lmt index a0bed0d0a..c80c57a73 100644 --- a/tex/context/base/mkxl/lang-ini.lmt +++ b/tex/context/base/mkxl/lang-ini.lmt @@ -650,7 +650,7 @@ do local compound_disc_code = tex.discoptioncodes.preword | tex.discoptioncodes.postword - local function setcompound(current,id,first,last,lh,rh) + local function setcompound(current,id,first,last,lh,rh,hyphen) local prev = getprev(current) -- local language = tolang(id) -- local prechar = prehyphenchar(language) @@ -659,6 +659,7 @@ do local postchar = posthyphenchar(id) local pre = prechar and copy_node(current) local post = postchar and copy_node(current) + local replace = hyphen and prechar and copy_node(current) local disc = new_disc() if pre then setchar(pre,prechar) @@ -666,9 +667,12 @@ do if post then setchar(post,postchar) end + if replace then + setchar(replace,prechar) + end setattrlist(disc,current) setoptions(disc,0x3) -- todo foo_code - setdisc(disc,pre,post) + setdisc(disc,pre,post,replace) setlink(prev,disc,current) if lh then setfield(first,"rhmin",rh) @@ -690,6 +694,16 @@ do return v end) + local sethyphens = setmetatableindex(function(t,l) + local v = setmetatableindex(function(t,r) + local v = function(current,id,first,last) return setcompound(current,id,first,last,l,r,true) end + t[r] = v + return v + end) + t[l] = v + return v + end) + local function replaceword(first,last,old,new,oldlen) local oldlen = utflength(old) local newlen = utflength(new) @@ -739,6 +753,8 @@ do local v = 0 if k == "compound" then v = setcompounds[lh][rh] + elseif k == "hyphen" then + v = sethyphens[lh][rh] else v = 0 for s in gmatch(k,"%w+") do @@ -992,6 +1008,11 @@ do v[n] = setcompounds[lh][rh] return true end + elseif oc == "hyphen" then + if n > 1 then + v[n] = sethyphens[lh][rh] + return true + end elseif oc == "nokern" then if n > 0 then local vv = v[n-1] @@ -1026,6 +1047,7 @@ do -- a=b : a:norightkern b:noleftkern -- a<b : b:noleftkern -- a>b : a:norightkern + -- a-b : hyphen -- a+b : compound local actions = { @@ -1034,6 +1056,7 @@ do ["<"] = "noleftkern", [">"] = "norightkern", ["+"] = "compound", + ["-"] = "hyphen", } local function analyzed(m,a,t,k) @@ -1098,13 +1121,13 @@ do -- maybe also a skip symbol - local replace1 = Cs ( ( S("|=<>+.0123456789")/"" + lpegpatterns.utf8character )^0 ) - local replace2 = Cs ( ( S("|=<>+.0123456789") + lpegpatterns.utf8character/".")^0 ) + local replace1 = Cs ( ( S("|=<>+-.0123456789")/"" + lpegpatterns.utf8character )^0 ) + local replace2 = Cs ( ( S("|=<>+-.0123456789") + lpegpatterns.utf8character/".")^0 ) local function stripped(str) -- todo : lpeg - str = gsub(str,"%-%-[^\n]+\n","") - str = gsub(str,"%%[^\n]+\n","") + str = gsub(str,"%-%-[^\n]*\n","") + str = gsub(str,"%%[^\n]*\n","") str = gsub(str,"%s+"," ") str = gsub(str,"^%s+","") str = gsub(str,"%s+$","") diff --git a/tex/context/base/mkxl/lang-ini.mkxl b/tex/context/base/mkxl/lang-ini.mkxl index c4a109f3b..4c9d11a1a 100644 --- a/tex/context/base/mkxl/lang-ini.mkxl +++ b/tex/context/base/mkxl/lang-ini.mkxl @@ -434,8 +434,15 @@ + \permitallhyphenationmodecode % okay, let's be even more tolerant + \permitmathreplacehyphenationmodecode % and again we're more permissive + \forcehandlerhyphenationmodecode % kick in the handler (could be an option) + + \feedbackcompoundhyphenationmodecode % feedback compound snippets + + \ignoreboundshyphenationmodecode % just in case we have hyphens at the edges \relax +\hccode"002D "002D +\hccode"2010 "2010 +\hccode"2013 "2013 +\hccode"2014 "2014 + % maybe a (un)setter for handlers \permanent\protected\def\dohyphens {\hyphenationmode\completehyphenationmodecode} diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index 800f56ca3..ce938a5c2 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -430,36 +430,9 @@ do local hshift = false local vshift = false - -- local naturalwidths = setmetatableindex(function(t,font) - -- local d = descriptions[font] - -- local c = characters[font] - -- local f = parameters[font].hfactor or parameters[font].factor - -- local v = setmetatableindex(function(t,char) - -- local w - -- local e = d and d[char] - -- if e then - -- w = e.width - -- if w then - -- w = w * f - -- end - -- end - -- if not w then - -- e = c and c[char] - -- if e then - -- w = e.width or 0 - -- end - -- end - -- if not w then - -- w = 0 - -- end - -- t[char] = w - -- return w - -- end) - -- t[font] = v - -- return v - -- end) - - -- when changing this, check math: compact-001.tex (rule width) + -- The width array uses the original dimensions! This is different from e.g. + -- luatex where we have more widths arrays and these reflect the cheated + -- widths (goes wrong elsewhere). local naturalwidths = setmetatableindex(function(t,font) local d = descriptions[font] @@ -467,17 +440,17 @@ do local f = parameters[font].hfactor or parameters[font].factor local v = setmetatableindex(function(t,char) local w - local e = c and c[char] + local e = d and d[char] if e then - w = e.width or 0 + w = e.width + if w then + w = w * f + end end if not w then - e = d and d[char] + e = c and c[char] if e then - w = e.width - if w then - w = w * f - end + w = e.width or 0 end end if not w then @@ -490,6 +463,42 @@ do return v end) + -- when changing this, check math: compact-001.tex (rule width) + +-- this goes wrong with adapted widths in (virtual) fonts so we really +-- need the above .. +-- +-- so, what was the failing test? if so, maybe adapt threshold (now 10pt) + +-- local xnaturalwidths = setmetatableindex(function(t,font) +-- local d = descriptions[font] +-- local c = characters[font] +-- local f = parameters[font].hfactor or parameters[font].factor +-- local v = setmetatableindex(function(t,char) +-- local w +-- local e = c and c[char] +-- if e then +-- w = e.width or 0 +-- end +-- if not w then +-- e = d and d[char] +-- if e then +-- w = e.width +-- if w then +-- w = w * f +-- end +-- end +-- end +-- if not w then +-- w = 0 +-- end +-- t[char] = w +-- return w +-- end) +-- t[font] = v +-- return v +-- end) + local function setup_fontparameters(font,factor,f,e,sx,sy) local slant = fontparameters.slantfactor or 0 local extend = fontparameters.extendfactor or 1 @@ -623,12 +632,12 @@ do local move = calc_pdfpos(pos_h,pos_v) - -- if trace_threshold then - -- report( - -- "font %i, char %C, factor %i, naturalwidth %p, move %l, tm %l, hpos %p, delta %p, threshold %p, cw %p", - -- font,char,factor,naturalwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw - -- ) - -- end + -- if trace_threshold then + -- report( + -- "font %i, char %C, factor %i, naturalwidth %p, move %l, tm %l, hpos %p, delta %p, threshold %p, cw %p", + -- font,char,factor,naturalwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw + -- ) + -- end if move or need_tm then if not need_tm then diff --git a/tex/context/base/mkxl/math-ali.mkxl b/tex/context/base/mkxl/math-ali.mkxl index decf8c655..44e436338 100644 --- a/tex/context/base/mkxl/math-ali.mkxl +++ b/tex/context/base/mkxl/math-ali.mkxl @@ -768,13 +768,32 @@ \def\math_cases_NC_two {\ifmmode\stopimath\fi} +\def\math_cases_TC_zero + {} + +\def\math_cases_TC_one + {\ifmmode\stopimath\fi + \aligntab} + \permanent\protected\def\math_cases_NC {\ifcase\c_math_cases_nc \expandafter\math_cases_NC_zero \or \expandafter\math_cases_NC_one \or - \expandafter\math_cases_NC_two + \expandafter\math_cases_NC_zero + \else + % error + \fi + \global\advance\c_math_cases_nc\plusone} + +\permanent\protected\def\math_cases_TC + {\ifcase\c_math_cases_nc + \expandafter\math_cases_TC_zero + \or + \expandafter\math_cases_TC_one + \or + \expandafter\math_cases_TC_two \else % error \fi @@ -807,6 +826,7 @@ \enforced\let\MC\math_cases_NC \enforced\let\NC\math_cases_NC \enforced\let\NR\math_cases_NR + \enforced\let\TC\math_cases_TC \enforced\let\TB\math_common_TB \normalbaselines \mathsurround\zeropoint diff --git a/tex/context/base/mkxl/mlib-svg.lmt b/tex/context/base/mkxl/mlib-svg.lmt index 961176e07..1b2114ec9 100644 --- a/tex/context/base/mkxl/mlib-svg.lmt +++ b/tex/context/base/mkxl/mlib-svg.lmt @@ -2006,7 +2006,7 @@ local fraction = offset and asnumber_p(offset) o = nil elseif o == "transparent" then o = f_opacity(0) - else + elseif o then o = asnumber_r(o) if o == ignoredopacity then o = nil diff --git a/tex/context/base/mkxl/node-ini.lmt b/tex/context/base/mkxl/node-ini.lmt index f29a2e448..e176b1214 100644 --- a/tex/context/base/mkxl/node-ini.lmt +++ b/tex/context/base/mkxl/node-ini.lmt @@ -56,6 +56,7 @@ local parcodes = mark(getsubtypes("par")) local fillvalues = mark(getvalues("fill")) local dirvalues = mark(getvalues("dir")) +local mathvalues = mark(getvalues("math")) local function simplified(t) local r = { } @@ -99,6 +100,7 @@ noadoptions = allocate(swapped(noadoptions,noadoptions)) dirvalues = allocate(swapped(dirvalues,dirvalues)) fillvalues = allocate(swapped(fillvalues,fillvalues)) +mathvalues = allocate(swapped(mathvalues,mathvalues)) nodes.gluecodes = gluecodes nodes.dircodes = dircodes @@ -120,6 +122,7 @@ nodes.noadoptions = noadoptions nodes.fillvalues = fillvalues nodes.fillcodes = fillvalues -- for now nodes.dirvalues = dirvalues +nodes.mathvalues = mathvalues nodes.nodecodes = nodecodes diff --git a/tex/context/base/mkxl/publ-ini.mkxl b/tex/context/base/mkxl/publ-ini.mkxl index 2f4d817f2..2c52b24e9 100644 --- a/tex/context/base/mkxl/publ-ini.mkxl +++ b/tex/context/base/mkxl/publ-ini.mkxl @@ -1502,7 +1502,7 @@ \permanent\protected\def\btxtextcitation {\publ_citation\v!text} \permanent\protected\def\btxalwayscitation{\publ_citation\v!always} -\tolerant\def\publ_citation#1[#2]#*[#3]% could be made more efficient but not now +\tolerant\def\publ_citation#1[#2]#,[#3]% could be made more efficient but not now {\dontleavehmode \begingroup \let\currentbtxcitemethod#1% diff --git a/tex/context/base/mkxl/strc-not.mklx b/tex/context/base/mkxl/strc-not.mklx index dd22bc6df..ac769ee38 100644 --- a/tex/context/base/mkxl/strc-not.mklx +++ b/tex/context/base/mkxl/strc-not.mklx @@ -1901,7 +1901,7 @@ \mutable\let\lastnotesymbol\empty % todo: per class -\permanent\tolerant\protected\def\notesymbol[#tag]#spacer[#reference]% +\permanent\tolerant\protected\def\notesymbol[#tag]#keepspacer[#reference]% {\ifnotesenabled \dontleavehmode \begingroup @@ -1916,7 +1916,7 @@ \endgroup \fi} -\permanent\tolerant\protected\def\note[#tag]#spacer[#reference]% +\permanent\tolerant\protected\def\note[#tag]#keepspacer[#reference]% {\iftok{#reference}\emptytoks \notesymbol[\v!footnote][#tag]% \else diff --git a/tex/context/base/mkxl/symb-ini.mkxl b/tex/context/base/mkxl/symb-ini.mkxl index c29b07360..ce489ee5a 100644 --- a/tex/context/base/mkxl/symb-ini.mkxl +++ b/tex/context/base/mkxl/symb-ini.mkxl @@ -212,7 +212,7 @@ \mutable\def\defaultsymbolfactor{10} \mutable\def\defaultsymbolheight{1.25ex} -\permanent\tolerant\protected\def\figuresymbol[#1]#*[#2]% +\permanent\tolerant\protected\def\figuresymbol[#1]#,[#2]% {\externalfigure[#1][\c!reset=\v!yes,\c!symbol=\v!yes,\c!height=\defaultsymbolheight,#2]} \permanent\tolerant\protected\def\definefiguresymbol[#1]#*[#2]#*[#3]% diff --git a/tex/context/base/mkxl/trac-ctx.mkxl b/tex/context/base/mkxl/trac-ctx.mkxl index 656a7a9aa..3410c5ea9 100644 --- a/tex/context/base/mkxl/trac-ctx.mkxl +++ b/tex/context/base/mkxl/trac-ctx.mkxl @@ -27,6 +27,20 @@ \clf_initializetexexperiments \to \everyjob +\pushoverloadmode + +\let\syst_beginsimplegroup_yes\beginsimplegroup +\let\syst_beginsimplegroup_nop\bgroup + +\let\beginsimplegroup\syst_beginsimplegroup_nop + +\installtexexperiment + {simplegroups} + {\enforced\let\beginsimplegroup\syst_beginsimplegroup_yes} + {\enforced\let\beginsimplegroup\syst_beginsimplegroup_nop} + +\popoverloadmode + \protect \endinput % this is one option: diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index 8b2380b70..0c3e0168c 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['trac-vis'] = { local node, nodes, attributes, tex = node, nodes, attributes, tex local type, tonumber, next, rawget = type, tonumber, next, rawget -local gmatch = string.gmatch +local gmatch, gsub = string.gmatch, string.gsub local formatters = string.formatters local round = math.round @@ -30,8 +30,6 @@ local round = math.round -- todo: tags can also be numbers (just add to hash) -- todo: make a lmtx variant (a few more efficient fetchers) -local nodecodes = nodes.nodecodes - local nuts = nodes.nuts local tonut = nuts.tonut @@ -133,33 +131,34 @@ local enableaction = nodes.tasks.enableaction local report_visualize = logs.reporter("visualize") local modes = { - hbox = 0x000001, - vbox = 0x000002, - vtop = 0x000004, - kern = 0x000008, - glue = 0x000010, - penalty = 0x000020, - fontkern = 0x000040, - strut = 0x000080, - whatsit = 0x000100, - glyph = 0x000200, - simple = 0x000400, - simplehbox = 0x000401, - simplevbox = 0x000402, - simplevtop = 0x000404, - user = 0x000800, - math = 0x001000, - italic = 0x002000, - origin = 0x004000, - discretionary = 0x008000, - expansion = 0x010000, - line = 0x020000, - space = 0x040000, - depth = 0x080000, - marginkern = 0x100000, - mathlistkern = 0x200000, - dir = 0x400000, - par = 0x800000, + hbox = 0x0000001, + vbox = 0x0000002, + vtop = 0x0000004, + kern = 0x0000008, + glue = 0x0000010, + penalty = 0x0000020, + fontkern = 0x0000040, + strut = 0x0000080, + whatsit = 0x0000100, + glyph = 0x0000200, + simple = 0x0000400, + simplehbox = 0x0000401, + simplevbox = 0x0000402, + simplevtop = 0x0000404, + user = 0x0000800, + math = 0x0001000, + italic = 0x0002000, + origin = 0x0004000, + discretionary = 0x0008000, + expansion = 0x0010000, + line = 0x0020000, + space = 0x0040000, + depth = 0x0080000, + marginkern = 0x0100000, + mathlistkern = 0x0200000, + dir = 0x0400000, + par = 0x0800000, + mathglue = 0x1000000, } local usedfont, exheight, emwidth @@ -175,7 +174,7 @@ local preset_makeup = preset_boxes local preset_all = preset_makeup + modes.fontkern + modes.marginkern + modes.mathlistkern + modes.whatsit + modes.glyph + modes.user + modes.math - + modes.dir + modes.whatsit + + modes.dir + modes.whatsit + modes.mathglue function visualizers.setfont(id) usedfont = id or current_font() @@ -380,42 +379,6 @@ trackers .register("visualizers.makeup", function(v) set("makeup",v) end) trackers .register("visualizers.boxes", function(v) set("boxes", v) end) directives.register("visualizers.fraction", function(v) fraction = (v and tonumber(v)) or (v == "more" and 5) or 10 end) -local c_positive = "trace:b" -local c_negative = "trace:r" -local c_zero = "trace:g" -local c_text = "trace:s" -local c_space = "trace:y" -local c_space_x = "trace:m" -local c_skip_a = "trace:c" -local c_skip_b = "trace:m" -local c_glyph = "trace:o" -local c_ligature = "trace:s" -local c_white = "trace:w" ------ c_math = "trace:s" ------ c_origin = "trace:o" ------ c_discretionary = "trace:d" ------ c_expansion = "trace:o" -local c_depth = "trace:o" -local c_indent = "trace:s" - -local c_positive_d = "trace:db" -local c_negative_d = "trace:dr" -local c_zero_d = "trace:dg" -local c_text_d = "trace:ds" -local c_space_d = "trace:dy" -local c_space_x_d = "trace:dm" -local c_skip_a_d = "trace:dc" -local c_skip_b_d = "trace:dm" -local c_glyph_d = "trace:do" -local c_ligature_d = "trace:ds" -local c_white_d = "trace:dw" -local c_math_d = "trace:dr" -local c_origin_d = "trace:do" -local c_discretionary_d = "trace:dd" ------ c_expansion_d = "trace:do" ------ c_depth_d = "trace:do" ------ c_indent_d = "trace:ds" - -- we can just paste verbatim together .. no typesetting needed local function sometext(str,layer,color,textcolor,lap,variant) @@ -430,7 +393,7 @@ local function sometext(str,layer,color,textcolor,lap,variant) setlistcolor(getlist(text),textcolor) end local info = setlink(rule,kern,text) - setlisttransparency(info,c_zero) + setlisttransparency(info,"trace:g") info = hpack_nodes(info) local width = getwidth(info) if variant then @@ -459,7 +422,7 @@ local function someblob(str,layer,color,textcolor,width) setlistcolor(getlist(text),textcolor) end local info = setlink(rule,kern,text) - setlisttransparency(info,c_zero) + setlisttransparency(info,"trace:g") info = hpack_nodes(info) local width = getwidth(info) info = new_hlist(info) @@ -488,11 +451,11 @@ local fontkern, italickern, marginkern, mathlistkern do local rule = new_rule(emwidth/fraction,6*exheight,2*exheight) local list = getlist(text) if kern > 0 then - setlistcolor(list,c_positive_d) + setlistcolor(list,"trace:db") elseif kern < 0 then - setlistcolor(list,c_negative_d) + setlistcolor(list,"trace:dr") else - setlistcolor(list,c_zero_d) + setlistcolor(list,"trace:dg") end setlisttransparency(list,color) setcolor(rule,color) @@ -507,19 +470,19 @@ local fontkern, italickern, marginkern, mathlistkern do end fontkern = function(head,current) - return somekern(head,current,f_cache,c_text_d,l_fontkern) + return somekern(head,current,f_cache,"trace:ds",l_fontkern) end italickern = function(head,current) - return somekern(head,current,i_cache,c_glyph_d,l_italic) + return somekern(head,current,i_cache,"trace:do",l_italic) end marginkern = function(head,current) - return somekern(head,current,m_cache,c_glyph_d,l_marginkern) + return somekern(head,current,m_cache,"trace:do",l_marginkern) end mathlistkern = function(head,current) - return somekern(head,current,l_cache,c_glyph_d,l_mathlistkern) + return somekern(head,current,l_cache,"trace:do",l_mathlistkern) end end @@ -538,13 +501,13 @@ local glyphexpansion do local rule = new_rule(emwidth/fraction,exheight,2*exheight) local list = getlist(text) if extra > 0 then - setlistcolor(list,c_positive_d) + setlistcolor(list,"trace:db") elseif extra < 0 then - setlistcolor(list,c_negative_d) + setlistcolor(list,"trace:dr") end - setlisttransparency(list,c_text_d) - setcolor(rule,c_text_d) - settransparency(rule,c_text_d) + setlisttransparency(list,"trace:ds") + setcolor(rule,"trace:ds") + settransparency(rule,"trace:ds") setshift(text,1.5 * exheight) info = new_hlist(setlink(rule,text)) setattr(info,a_layer,l_expansion) @@ -574,13 +537,13 @@ local kernexpansion do local rule = new_rule(emwidth/fraction,exheight,4*exheight) local list = getlist(text) if extra > 0 then - setlistcolor(list,c_positive_d) + setlistcolor(list,"trace:db") elseif extra < 0 then - setlistcolor(list,c_negative_d) + setlistcolor(list,"trace:dr") end - setlisttransparency(list,c_text_d) - setcolor(rule,c_text_d) - settransparency(rule,c_text_d) + setlisttransparency(list,"trace:ds") + setcolor(rule,"trace:ds") + settransparency(rule,"trace:ds") setshift(text,3.5 * exheight) info = new_hlist(setlink(rule,text)) setattr(info,a_layer,l_expansion) @@ -630,7 +593,7 @@ local whatsit do if info then -- print("hit whatsit") else - info = sometext(formatters["W:%s"](tags[what] or what),usedfont,nil,c_white) + info = sometext(formatters["W:%s"](tags[what] or what),usedfont,nil,"trace:w") setattr(info,a_layer,l_whatsit) w_cache[what] = info end @@ -666,7 +629,7 @@ local dir, par do if info then -- print("hit par") else - info = sometext(formatters["L:%s"](what),usedfont,nil,c_white) + info = sometext(formatters["L:%s"](what),usedfont,nil,"trace:w") setattr(info,a_layer,l_dir) d_cache[what] = info end @@ -686,7 +649,7 @@ local dir, par do if info then -- print("hit dir") else - info = sometext(formatters["D:%s"](what),usedfont,nil,c_white) + info = sometext(formatters["D:%s"](what),usedfont,nil,"trace:w") setattr(info,a_layer,l_dir) d_cache[what] = info end @@ -735,10 +698,10 @@ local math do if info then -- print("hit math") else - local text, width = sometext(formatters["M:%s"](tag and tags[tag] or what),usedfont,nil,c_math_d) + local text, width = sometext(formatters["M:%s"](tag and tags[tag] or what),usedfont,nil,"trace:dr") local rule = new_rule(skip,-655360/fraction,2*655360/fraction) - setcolor(rule,c_math_d) - settransparency(rule,c_math_d) + setcolor(rule,"trace:dr") + settransparency(rule,"trace:dr") setattr(rule,a_layer,l_math) if tag == "beginmath" then info = new_hlist(setlink(new_glue(-skip),rule,new_glue(-width),text)) @@ -760,8 +723,8 @@ local ruleddepth do local wd, ht, dp = getwhd(current) if dp ~= 0 then local rule = new_rule(wd,0,dp) - setcolor(rule,c_depth) - settransparency(rule,c_zero) + setcolor(rule,"trace:o") + settransparency(rule,"trace:g") setattr(rule,a_layer,l_depth) setlist(current,setlink(rule,new_kern(-wd),getlist(current))) end @@ -779,8 +742,8 @@ local ruledbox do setmetatableindex(o_cache,function(t,size) local rule = new_rule(2*size,size,size) local origin = hpack_nodes(rule) - setcolor(rule,c_origin_d) - settransparency(rule,c_origin_d) + setcolor(rule,"trace:do") + settransparency(rule,"trace:do") setattr(rule,a_layer,l_origin) t[size] = origin return origin @@ -801,7 +764,7 @@ local ruledbox do if not this then local text = hpack_string(what,usedfont) this = setlink(new_kern(-getwidth(text)),text) - setlisttransparency(this,c_text) + setlisttransparency(this,"trace:s") this = new_hlist(this) b_cache[what] = this end @@ -821,7 +784,7 @@ local ruledbox do } ) -- - setlisttransparency(info,c_text) + setlisttransparency(info,"trace:s") info = new_hlist(info) -- important -- setattr(info,a_layer,layer) @@ -911,11 +874,11 @@ local ruledglyph do local c, f = isglyph(current) local char = chardata[f][c] if char and type(char.unicode) == "table" then -- hackery test - setlistcolor(info,c_ligature) - setlisttransparency(info,c_ligature_d) + setlistcolor(info,"trace:s") + setlisttransparency(info,"trace:ds") else - setlistcolor(info,c_glyph) - setlisttransparency(info,c_glyph_d) + setlistcolor(info,"trace:o") + setlisttransparency(info,"trace:do") end info = new_hlist(info) setattr(info,a_layer,l_glyph) @@ -944,7 +907,7 @@ local ruledglyph do end -local ruledglue do +local ruledglue, ruledmathglue do local effectiveglue = nuts.effective_glue @@ -962,6 +925,7 @@ local ruledglue do local parfillleftskip_code = gluecodes.parfillleftskip or parfillskip_code local parfillrightskip_code = gluecodes.parfillrightskip or parfillskip_code local indentskip_code = gluecodes.indentskip + local intermathskip_code = gluecodes.intermathskip local correctionskip_code = gluecodes.correctionskip local g_cache_v = caches["vglue"] @@ -974,6 +938,7 @@ local ruledglue do local g_cache_rp = caches["parfillrightskip"] local g_cache_is = caches["indentskip"] local g_cache_cs = caches["correctionskip"] + local g_cache_gn = caches["gluename"] local tags = { -- [userskip_code] = "US", @@ -990,7 +955,7 @@ local ruledglue do [gluecodes.thinmuskip] = "MS", [gluecodes.medmuskip] = "MM", [gluecodes.thickmuskip] = "ML", - [gluecodes.intermathskip] = "IM", + [intermathskip_code] = "IM", [gluecodes.keepskip or 99] = "KS", [gluecodes.mathskip] = "MT", [gluecodes.leaders] = "NL", @@ -1023,45 +988,70 @@ local ruledglue do -- we sometimes pass previous as we can have issues in math (not watertight for all) + local f_amount = formatters["%s:%0.3f"] + local mathvalues = nodes.mathvalues + + local function gluename(name,layer,color) + local info = g_cache_gn[name] + if not info then + local text = hpack_string((gsub(mathvalues[name],"spacing","")),usedfont) + local rule = new_rule(emwidth/fraction,2*exheight,2.75*exheight) + local list = getlist(text) + setlisttransparency(list,color) + settransparency(rule,color) + setshift(text,2*exheight) + info = new_hlist(setlink(rule,text)) + setattr(info,a_layer,layer) + g_cache_gn[name] = info + end + return copy_list(info) + end + + ruledmathglue = function(head,current) + return insert_node_before(head,current,gluename(getfont(current),l_glue,"trace:m")) + end + ruledglue = function(head,current,vertical,parent) local subtype = getsubtype(current) local width = effectiveglue(current,parent) local stag = normalize and stags[subtype] - local amount = formatters["%s:%0.3f"](tags[subtype] or (vertical and "VS") or "HS",width*pt_factor) + local amount = f_amount(tags[subtype] or (vertical and "VS") or "HS",width*pt_factor) -- can be sped up local info = (vertical and g_cache_v or g_cache_h)[amount] + if subtype == intermathskip_code then + head = ruledmathglue(head, current) + end if info then -- print("glue hit") else if subtype == spaceskip_code or subtype == xspaceskip_code or subtype == zerospaceskip_code then - info = sometext(amount,l_glue,c_space) + info = sometext(amount,l_glue,"trace:y") elseif subtype == userskip_code then if width > 0 then - info = sometext(amount,l_glue,c_positive) + info = sometext(amount,l_glue,"trace:b") elseif width < 0 then - info = sometext(amount,l_glue,c_negative) + info = sometext(amount,l_glue,"trace:r") else - info = sometext(amount,l_glue,c_zero) + info = sometext(amount,l_glue,"trace:g") end elseif subtype == indentskip_code or subtype == correctionskip_code then - info = sometext(amount,l_glue,c_indent) + info = sometext(amount,l_glue,"trace:s") elseif subtype == leftskip_code then - info = sometext(amount,l_glue,normalize and c_space or c_skip_a,false,true,stag) + info = sometext(amount,l_glue,normalize and "trace:y" or "trace:c",false,true,stag) elseif subtype == rightskip_code then - info = sometext(amount,l_glue,normalize and c_space or c_skip_a,false,false,stag) + info = sometext(amount,l_glue,normalize and "trace:y" or "trace:c",false,false,stag) elseif subtype == lefthangskip_code then - info = sometext(amount,l_glue,normalize and c_space or c_skip_b,false,true,stag) + info = sometext(amount,l_glue,normalize and "trace:y" or "trace:m",false,true,stag) elseif subtype == righthangskip_code then - info = sometext(amount,l_glue,normalize and c_space or c_skip_b,false,false,stag) + info = sometext(amount,l_glue,normalize and "trace:y" or "trace:m",false,false,stag) elseif subtype == parfillleftskip_code then - info = sometext(amount,l_glue,c_indent,false,true,stag) + info = sometext(amount,l_glue,"trace:s",false,true,stag) elseif subtype == parfillrightskip_code then - info = sometext(amount,l_glue,c_indent,false,false,stag) + info = sometext(amount,l_glue,"trace:s",false,false,stag) else - info = sometext(amount,l_glue,c_skip_b) + info = sometext(amount,l_glue,"trace:m") end (vertical and g_cache_v or g_cache_h)[amount] = info end - ::PICKIP:: info = copy_list(info) if vertical then info = vpack_nodes(info) @@ -1070,53 +1060,29 @@ local ruledglue do return head, getnext(current) end - -- ruledspace = function(head,current,parent) - -- local subtype = getsubtype(current) - -- if subtype == spaceskip_code or subtype == xspaceskip_code or subtype == zerospaceskip_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] - -- if info then - -- -- print("space hit") - -- else - -- info = sometext(amount,l_glue,c_space) - -- g_cache_h[amount] = info - -- end - -- info = copy_list(info) - -- head, current = insert_node_before(head,current,info) - -- return head, getnext(current) - -- else - -- return head, current - -- end - -- end - local g_cache_s = caches["space"] local g_cache_x = caches["xspace"] ruledspace = function(head,current,parent) local subtype = getsubtype(current) - if subtype == spaceskip_code or subtype == xspaceskip_code or subtype == zerospaceskip_code then -- not yet all space - local width = effectiveglue(current,parent) - local info - if subtype == spaceskip_code then - info = g_cache_s[width] - if not info then - info = someblob("SP",l_glue,c_space,nil,width) - g_cache_s[width] = info - end - else - info = g_cache_x[width] - if not info then - info = someblob("XS",l_glue,c_space_x,nil,width) - g_cache_x[width] = info - end + local width = effectiveglue(current,parent) + local info + if subtype == spaceskip_code then + info = g_cache_s[width] + if not info then + info = someblob("SP",l_glue,"trace:y",nil,width) + g_cache_s[width] = info end - info = copy_list(info) - head, current = insert_node_before(head,current,info) - return head, getnext(current) else - return head, current + info = g_cache_x[width] + if not info then + info = someblob("XS",l_glue,"trace:m",nil,width) + g_cache_x[width] = info + end end + info = copy_list(info) + head, current = insert_node_before(head,current,info) + return head, getnext(current) end end @@ -1133,11 +1099,11 @@ local ruledkern do if not info then local amount = formatters["%s:%0.3f"](vertical and "VK" or (mk and "MK") or "HK",kern*pt_factor) if kern > 0 then - info = sometext(amount,l_kern,c_positive) + info = sometext(amount,l_kern,"trace:b") elseif kern < 0 then - info = sometext(amount,l_kern,c_negative) + info = sometext(amount,l_kern,"trace:r") else - info = sometext(amount,l_kern,c_zero) + info = sometext(amount,l_kern,"trace:g") end cache[kern] = info end @@ -1161,11 +1127,11 @@ local ruleditalic do if not info then local amount = formatters["%s:%0.3f"]("IC",kern*pt_factor) if kern > 0 then - info = sometext(amount,l_kern,c_positive) + info = sometext(amount,l_kern,"trace:b") elseif kern < 0 then - info = sometext(amount,l_kern,c_negative) + info = sometext(amount,l_kern,"trace:r") else - info = sometext(amount,l_kern,c_zero) + info = sometext(amount,l_kern,"trace:g") end i_cache[kern] = info end @@ -1186,11 +1152,11 @@ local ruledmarginkern do if not info then local amount = formatters["%s:%0.3f"]("MK",kern*pt_factor) if kern > 0 then - info = sometext(amount,l_marginkern,c_positive) + info = sometext(amount,l_marginkern,"trace:b") elseif kern < 0 then - info = sometext(amount,l_marginkern,c_negative) + info = sometext(amount,l_marginkern,"trace:r") else - info = sometext(amount,l_marginkern,c_zero) + info = sometext(amount,l_marginkern,"trace:g") end m_cache[kern] = info end @@ -1211,11 +1177,11 @@ local ruledmathlistkern do if not info then local amount = formatters["%s:%0.3f"]("LK",kern*pt_factor) if kern > 0 then - info = sometext(amount,l_mathlistkern,c_positive) + info = sometext(amount,l_mathlistkern,"trace:b") elseif kern < 0 then - info = sometext(amount,l_mathlistkern,c_negative) + info = sometext(amount,l_mathlistkern,"trace:r") else - info = sometext(amount,l_mathlistkern,c_zero) + info = sometext(amount,l_mathlistkern,"trace:g") end l_cache[kern] = info end @@ -1236,8 +1202,8 @@ local ruleddiscretionary do local rule = new_rule(4*emwidth/fraction,4*exheight,exheight) local kern = new_kern(-2*emwidth/fraction) setlink(kern,rule) - setcolor(rule,c_discretionary_d) - settransparency(rule,c_discretionary_d) + setcolor(rule,"trace:dd") + settransparency(rule,"trace:dd") setattr(rule,a_layer,l_discretionary) d = new_hlist(kern) d_cache[true] = d @@ -1267,11 +1233,11 @@ local ruledpenalty do else local amount = formatters["%s:%s"](vertical and "VP" or "HP",penalty) if penalty > 0 then - info = sometext(amount,l_penalty,c_positive) + info = sometext(amount,l_penalty,"trace:b") elseif penalty < 0 then - info = sometext(amount,l_penalty,c_negative) + info = sometext(amount,l_penalty,"trace:r") else - info = sometext(amount,l_penalty,c_zero) + info = sometext(amount,l_penalty,"trace:g") end (vertical and p_cache_v or p_cache_h)[penalty] = info end @@ -1289,6 +1255,7 @@ end do + local nodecodes = nodes.nodecodes local disc_code = nodecodes.disc local kern_code = nodecodes.kern local glyph_code = nodecodes.glyph @@ -1312,6 +1279,12 @@ do local mathlistkern_code = kerncodes.mathlistkern ----- userkern_code = kerncodes.userkern + local skipcodes = nodes.skipcodes + local spaceskip_code = skipcodes.spaceskip + local xspaceskip_code = skipcodes.xspaceskip + local zerospaceskip_code = skipcodes.zerospaceskip + local intermathskip_code = skipcodes.intermathskip + local listcodes = nodes.listcodes local linelist_code = listcodes.line @@ -1323,7 +1296,7 @@ do local setleader = nuts.setleader local setdisc = nuts.setdisc - local cache + -- local cache local function visualize(head,vertical,forced,parent) local trace_hbox = false @@ -1348,24 +1321,25 @@ do local trace_depth = false local trace_dir = false local trace_par = false + local trace_math_glue = false local current = head local previous = nil local attr = unsetvalue local prev_trace_fontkern = nil local prev_trace_italic = nil local prev_trace_marginkern = nil --- local prev_trace_mathlist = nil + -- local prev_trace_mathlist = nil local prev_trace_expansion = nil while current do local id = getid(current) local a = forced or getattr(current,a_visual) or unsetvalue - local subtype + local subtype, content if a ~= attr then prev_trace_fontkern = trace_fontkern prev_trace_italic = trace_italic prev_trace_marginkern = trace_marginkern --- prev_trace_mathlistkern = trace_mathlistkern + -- prev_trace_mathlistkern = trace_mathlistkern prev_trace_expansion = trace_expansion attr = a if a == unsetvalue then @@ -1393,6 +1367,7 @@ do trace_mathlistkern = false trace_dir = false trace_par = false + trace_math_glue = false if id == kern_code then goto kern else @@ -1400,30 +1375,31 @@ do end else -- dead slow: -- cache[a]() - trace_hbox = band(a,0x000001) ~= 0 - trace_vbox = band(a,0x000002) ~= 0 - trace_vtop = band(a,0x000004) ~= 0 - trace_kern = band(a,0x000008) ~= 0 - trace_glue = band(a,0x000010) ~= 0 - trace_penalty = band(a,0x000020) ~= 0 - trace_fontkern = band(a,0x000040) ~= 0 - trace_strut = band(a,0x000080) ~= 0 - trace_whatsit = band(a,0x000100) ~= 0 - trace_glyph = band(a,0x000200) ~= 0 - trace_simple = band(a,0x000400) ~= 0 - trace_user = band(a,0x000800) ~= 0 - trace_math = band(a,0x001000) ~= 0 - trace_italic = band(a,0x002000) ~= 0 - trace_origin = band(a,0x004000) ~= 0 - trace_discretionary = band(a,0x008000) ~= 0 - trace_expansion = band(a,0x010000) ~= 0 - trace_line = band(a,0x020000) ~= 0 - trace_space = band(a,0x040000) ~= 0 - trace_depth = band(a,0x080000) ~= 0 - trace_marginkern = band(a,0x100000) ~= 0 - trace_mathlistkern = band(a,0x200000) ~= 0 - trace_dir = band(a,0x400000) ~= 0 - trace_par = band(a,0x800000) ~= 0 + trace_hbox = band(a,0x0000001) ~= 0 + trace_vbox = band(a,0x0000002) ~= 0 + trace_vtop = band(a,0x0000004) ~= 0 + trace_kern = band(a,0x0000008) ~= 0 + trace_glue = band(a,0x0000010) ~= 0 + trace_penalty = band(a,0x0000020) ~= 0 + trace_fontkern = band(a,0x0000040) ~= 0 + trace_strut = band(a,0x0000080) ~= 0 + trace_whatsit = band(a,0x0000100) ~= 0 + trace_glyph = band(a,0x0000200) ~= 0 + trace_simple = band(a,0x0000400) ~= 0 + trace_user = band(a,0x0000800) ~= 0 + trace_math = band(a,0x0001000) ~= 0 + trace_italic = band(a,0x0002000) ~= 0 + trace_origin = band(a,0x0004000) ~= 0 + trace_discretionary = band(a,0x0008000) ~= 0 + trace_expansion = band(a,0x0010000) ~= 0 + trace_line = band(a,0x0020000) ~= 0 + trace_space = band(a,0x0040000) ~= 0 + trace_depth = band(a,0x0080000) ~= 0 + trace_marginkern = band(a,0x0100000) ~= 0 + trace_mathlistkern = band(a,0x0200000) ~= 0 + trace_dir = band(a,0x0400000) ~= 0 + trace_par = band(a,0x0800000) ~= 0 + trace_math_glue = band(a,0x1000000) ~= 0 end elseif a == unsetvalue then goto list @@ -1455,14 +1431,7 @@ do elseif id == kern_code then goto kern elseif id == glue_code then - local content = getleader(current) - if content then - setleader(current,visualize(content,false,nil,parent)) - elseif trace_glue then - head, current = ruledglue(head,current,vertical,parent) - elseif trace_space then - head, current = ruledspace(head,current,parent) - end + goto glue elseif id == penalty_code then if trace_penalty then head, current = ruledpenalty(head,current,vertical) @@ -1495,6 +1464,25 @@ do end end goto next + ::glue:: + content = getleader(current) + if content then + setleader(current,visualize(content,false,nil,parent)) + elseif trace_glue then + head, current = ruledglue(head,current,vertical,parent) + else + subtype = getsubtype(current) + if subtype == spaceskip_code or subtype == xspaceskip_code or subtype == zerospaceskip_code then -- not yet all space + if trace_space then + head, current = ruledspace(head,current,parent) + end + elseif subtype == intermathskip_code then + if trace_math or trace_math_glue then + head = ruledmathglue(head,current,parent) + end + end + end + goto next ::kern:: subtype = getsubtype(current) if subtype == fontkern_code then @@ -1617,6 +1605,7 @@ end do + local nodecodes = nodes.nodecodes local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local nextnode = nuts.traversers.node @@ -1739,10 +1728,10 @@ do local cache = caches[name] local layer = layers[name] if not textcolor then - textcolor = c_text_d + textcolor = "trace:ds" end if not rulecolor then - rulecolor = c_origin_d + rulecolor = "trace:do" end return function(str) if not str then |