diff options
Diffstat (limited to 'tex')
24 files changed, 524 insertions, 243 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 377684c2c..96f8851e5 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{2022.07.24 12:17} +\newcontextversion{2022.07.27 17:51} %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 2310671e9..b34bfe923 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{2022.07.24 12:17} +\edef\contextversion{2022.07.27 17:51} %D For those who want to use this: diff --git a/tex/context/base/mkiv/char-def.lua b/tex/context/base/mkiv/char-def.lua index 967a11d07..3208eab6b 100644 --- a/tex/context/base/mkiv/char-def.lua +++ b/tex/context/base/mkiv/char-def.lua @@ -66996,6 +66996,7 @@ characters.data={ [0x2213]={ adobename="minusplus", category="sm", + contextname="textmp", description="MINUS-OR-PLUS SIGN", direction="et", linebreak="pr", diff --git a/tex/context/base/mkiv/cldf-ini.lua b/tex/context/base/mkiv/cldf-ini.lua index 0748635ef..0bdc60379 100644 --- a/tex/context/base/mkiv/cldf-ini.lua +++ b/tex/context/base/mkiv/cldf-ini.lua @@ -798,7 +798,7 @@ local function writer(parent,command,...) -- already optimized before call flush(currentcatcodes,"}") end elseif typ == "number" then - -- numbers never have funny catcodesz + -- numbers never have funny catcodes flush(currentcatcodes,"{",ti,"}") elseif typ == "table" then local tn = #ti @@ -852,7 +852,7 @@ local function writer(parent,command,...) -- already optimized before call else flush(currentcatcodes,"[",tj,"]") end - else -- is concat really faster than flushes here? probably needed anyway (print artifacts) + else flush(currentcatcodes,"[") for j=1,tn do local tj = ti[j] diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 70c83cf67..e853baed1 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{2022.07.24 12:17} +\newcontextversion{2022.07.27 17:51} %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 6a1e2c95e..82d356d35 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -49,7 +49,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2022.07.24 12:17} +\edef\contextversion{2022.07.27 17:51} %D Kind of special: diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index ace2b0e9b..40753f55c 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -111,6 +111,7 @@ return { "reboxcharitalickernmathcontrolcode", "applyboxeditalickernmathcontrolcode", "staircasekernmathcontrolcode", "applytextitalickernmathcontrolcode", "applyscriptitalickernmathcontrolcode", "checkspaceitalickernmathcontrolcode", "checktextitalickernmathcontrolcode", + "analyzescriptnucleuscharmathcontrolcode", "analyzescriptnucleuslistmathcontrolcode", "analyzescriptnucleusboxmathcontrolcode", -- "noligaturingglyphoptioncode", "nokerningglyphoptioncode", "noexpansionglyphoptioncode", "noprotrusionglyphoptioncode", "noleftkerningglyphoptioncode", "noleftligaturingglyphoptioncode", "norightkerningglyphoptioncode", "norightligaturingglyphoptioncode", diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index ac7f7511e..c01c04d54 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -76,12 +76,10 @@ return { "Udelimiterunder", "Uhextensible", "Uleft", - "UmathDelimiterPercent", - "UmathDelimiterShortfall", "Umathaccent", "Umathaccentbasedepth", "Umathaccentbaseheight", - "Umathaccentbottomoverschoot", + "Umathaccentbottomovershoot", "Umathaccentbottomshiftdown", "Umathaccentsuperscriptdrop", "Umathaccentsuperscriptpercent", @@ -105,6 +103,8 @@ return { "Umathconnectoroverlapmin", "Umathdegreevariant", "Umathdelimiterovervariant", + "Umathdelimiterpercent", + "Umathdelimitershortfall", "Umathdelimiterundervariant", "Umathdenominatorvariant", "Umathextrasubpreshift", @@ -154,6 +154,7 @@ return { "Umathpresubshiftdistance", "Umathpresupshiftdistance", "Umathprimeraise", + "Umathprimeraisecomposed", "Umathprimeshiftdrop", "Umathprimeshiftup", "Umathprimespaceafter", @@ -501,8 +502,6 @@ return { "mathrulesfam", "mathrulesmode", "mathscale", - "mathscriptboxmode", - "mathscriptcharmode", "mathscriptsmode", "mathslackmode", "mathspacingmode", @@ -567,6 +566,7 @@ return { "scaledinterwordshrink", "scaledinterwordspace", "scaledinterwordstretch", + "scaledmathstyle", "scaledslantperpoint", "scantextokens", "semiexpand", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 543b25c19..a4b660c90 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 78fefb060..b98b3fd51 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 9017ea449..38caf84ba 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{2022.07.24 12:17} +\newcontextversion{2022.07.27 17:51} %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 f68cb838d..3c7adcbec 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{2022.07.24 12:17} +\immutable\edef\contextversion{2022.07.27 17:51} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/core-env.mkxl b/tex/context/base/mkxl/core-env.mkxl index 6c347b0d5..77e634212 100644 --- a/tex/context/base/mkxl/core-env.mkxl +++ b/tex/context/base/mkxl/core-env.mkxl @@ -380,8 +380,8 @@ \permanent\def\fastsetupwithargument #1{\csname\??setup:#1\endcsname} % swapped per 2015-08-30 \permanent\def\fastsetupwithargumentswapped#1#2{\csname\??setup:#2\endcsname{#1}}% swapped per 2015-09-05 -% the next one is meant for \c!setups situations, hence the check for -% a shortcut +%D The next one is meant for \c!setups situations, hence the check for a +%D shortcut. \let\m_syst_setups_asked\empty @@ -408,11 +408,20 @@ \permanent\def\autosetups#1{\clf_autosetups{#1}} % todo: public implementor -\permanent\edef\setupwithargument#1% saves a few expansions and is faster - {\noexpand\csname\??setup:\noexpand\ifcsname\??setup:#1\endcsname#1\noexpand\else\??empty\noexpand\fi\endcsname} +%% \permanent\edef\setupwithargument#1% saves a few expansions and is faster +%% {\noexpand\csname\??setup:\noexpand\ifcsname\??setup:#1\endcsname#1\noexpand\else\??empty\noexpand\fi\endcsname} +%% +%% \permanent\edef\setupwithargumentswapped#1#2% saves a few expansions (can be \let) +%% {\noexpand\csname\??setup:\noexpand\ifcsname\??setup:#2\endcsname#2\noexpand\else\??empty\noexpand\fi\endcsname{#1}} -\permanent\edef\setupwithargumentswapped#1#2% saves a few expansions (can be \let) - {\noexpand\csname\??setup:\noexpand\ifcsname\??setup:#2\endcsname#2\noexpand\else\??empty\noexpand\fi\endcsname{#1}} +%D We can gain a bit more but as usual it's not noticeable at all in production runs. We use +%D this one a lot in the \XML\ code. + +% \permanent\def\setupwithargument #1{\futurecsname\gobbleoneargument\??setup:#1\endcsname} +% \permanent\def\setupwithargumentswapped #1#2{\futurecsname\gobbleoneargument\??setup:#2\endcsname{#1}} + +\permanent\edef\setupwithargument #1{\noexpand\futurecsname\noexpand\gobbleoneargument\??setup:#1\endcsname} +\permanent\edef\setupwithargumentswapped#1#2{\noexpand\futurecsname\noexpand\gobbleoneargument\??setup:#2\endcsname{#1}} \aliased\let\directsetup\syst_setups \aliased\let\texsetup \syst_setups % nicer than \directsetup and more en par with xmlsetup and luasetup diff --git a/tex/context/base/mkxl/font-ini.mklx b/tex/context/base/mkxl/font-ini.mklx index c30a610cc..473f37da2 100644 --- a/tex/context/base/mkxl/font-ini.mklx +++ b/tex/context/base/mkxl/font-ini.mklx @@ -612,7 +612,8 @@ \def\font_basics_check_text_bodyfont_step#whatever#body% size can be empty (checking needed as \bf is already defined) {\ifcsname#whatever\endcsname\else - \permanent\setugvalue{#whatever}{#body}% + %\permanent\setugvalue{#whatever}{#body}% + \permanent\protected\gdefcsname#whatever\endcsname{#body}% \fi} \def\font_basics_check_text_bodyfont#style#alternative#size% size can be empty (checking needed as \bf is already defined) diff --git a/tex/context/base/mkxl/font-mat.mklx b/tex/context/base/mkxl/font-mat.mklx index 7d72c5618..20925157b 100644 --- a/tex/context/base/mkxl/font-mat.mklx +++ b/tex/context/base/mkxl/font-mat.mklx @@ -562,4 +562,11 @@ \synchronizebigmath \fi} +%D This is an experiment! + +\permanent\protected\def\mx {\ifmmode\scaledmathstyle\dimexpression\plusthousand*(\xtextface /\textface)\relax\fi} +\permanent\protected\def\mxx{\ifmmode\scaledmathstyle\dimexpression\plusthousand*(\xxtextface/\textface)\relax\fi} + +\permanent\protected\def\setmscale#1{\ifmmode\scaledmathstyle\numericscale#1\relax\fi} + \protect \endinput diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl index f5c422612..1c5f062ec 100644 --- a/tex/context/base/mkxl/math-ini.mkxl +++ b/tex/context/base/mkxl/math-ini.mkxl @@ -104,6 +104,9 @@ % +\checkspaceitalickernmathcontrolcode % old code path +\applyscriptitalickernmathcontrolcode % +\italicshapekernmathcontrolcode % obsolete: instead of adding pre italic to the shift, inject a kern + +\analyzescriptnucleuscharmathcontrolcode + +\analyzescriptnucleuslistmathcontrolcode + +\analyzescriptnucleusboxmathcontrolcode \relax % \mathpenaltiesmode\plusone @@ -3338,13 +3341,10 @@ % \ruledhbox{$\mathtext{abc ffi}$} % \ruledhbox{$\mathword{abc ffi}$} -% I need to decide: -% -%mathscriptboxmode \zerocount % no kerning -%mathscriptboxmode \plusone % lists -\mathscriptboxmode \plustwo % lists and boxes -\mathscriptcharmode \plusone % lists and boxes %mathscriptboxmode \plusthree % lists and boxes with \boundary=1 (also for testing and demo) +%mathscriptboxmode \plusone % collapsed and then removed, now control option +%mathscriptcharmode \plusone % idem + %mathrulethicknessmode\plusone % adaptive \permanent\protected\def\mathtext {\mathortext{\math_text_choice_font\relax}\hbox} diff --git a/tex/context/base/mkxl/math-twk.mkxl b/tex/context/base/mkxl/math-twk.mkxl index 1d48cb50e..995f48bcb 100644 --- a/tex/context/base/mkxl/math-twk.mkxl +++ b/tex/context/base/mkxl/math-twk.mkxl @@ -42,19 +42,33 @@ % \setupbodyfont[bonum] \getbuffer % \setupbodyfont[pagella] \getbuffer -\Umathchardef \unaryminus \mathunarycode \zerocount \privatecharactercode{unary minus} -\Umathchardef \unaryplus \mathunarycode \zerocount \privatecharactercode{unary plus} -\Umathchardef \unaryplusminus \mathunarycode \zerocount \privatecharactercode{unary plus minus} -\Umathchardef \unaryminusplus \mathunarycode \zerocount \privatecharactercode{unary minus plus} +\immutable\Umathchardef \unaryminus \mathunarycode \zerocount \privatecharactercode{unary minus} +\immutable\Umathchardef \unaryplus \mathunarycode \zerocount \privatecharactercode{unary plus} +\immutable\Umathchardef \unaryplusminus \mathunarycode \zerocount \privatecharactercode{unary plus minus} +\immutable\Umathchardef \unaryminusplus \mathunarycode \zerocount \privatecharactercode{unary minus plus} \permanent\protected\def\um {\mathortext\unaryminus \textminus} \permanent\protected\def\up {\mathortext\unaryplus \textplus} \permanent\protected\def\upm{\mathortext\unaryplusminus\textpm} \permanent\protected\def\ump{\mathortext\unaryminusplus\textmp} -\permanent\protected\def\una#1{\mathatom class \mathunarycode {#1}} -\permanent\protected\def\bin#1{\mathatom class \mathbinarycode {#1}} -\permanent\protected\def\rel#1{\mathatom class \mathrelationcode{#1}} -\permanent\protected\def\ord#1{\mathatom class \mathordinarycode{#1}} +\permanent\protected\def\una#1{\mathatom \s!class \mathunarycode {#1}} +\permanent\protected\def\bin#1{\mathatom \s!class \mathbinarycode {#1}} +\permanent\protected\def\rel#1{\mathatom \s!class \mathrelationcode{#1}} +\permanent\protected\def\ord#1{\mathatom \s!class \mathordinarycode{#1}} + +% $x + \+1$\par +% $x + \-1$\par + +\immutable\Umathchardef\mathunaryplus \mathunarycode\zerocount"002B % these will go to char-def.lua +\immutable\Umathchardef\mathunaryminus \mathunarycode\zerocount"2212 % these will go to char-def.lua +\immutable\Umathchardef\mathunaryplusminus\mathunarycode\zerocount"00B1 % these will go to char-def.lua +\immutable\Umathchardef\mathunaryminusplus\mathunarycode\zerocount"2213 % these will go to char-def.lua + +\permanent\protected\def\+{\mathortext\mathunaryplus \textplus } +%permanent\protected\def\-{\mathortext\mathunaryminus \textminus } +\permanent\protected\def\-{\mathortext\mathunaryminus \explicitdiscretionary} +\permanent\protected\def\±{\mathortext\mathunaryplusminus\textpm} +\permanent\protected\def\∓{\mathortext\mathunaryminusplus\textmp} \protect diff --git a/tex/context/base/mkxl/mlib-pdf.lmt b/tex/context/base/mkxl/mlib-pdf.lmt index 3fe09eb93..3aeda8996 100644 --- a/tex/context/base/mkxl/mlib-pdf.lmt +++ b/tex/context/base/mkxl/mlib-pdf.lmt @@ -461,7 +461,6 @@ function metapost.flush(specification,result) local object = objects[o] if stack == object.stacking then local objecttype = object.type - -- print(i,o,stack,objecttype) if objecttype == "fill" or objecttype == "outline" then -- we use an indirect table as we want to overload -- entries but this is not possible in userdata @@ -708,7 +707,6 @@ function metapost.flush(specification,result) -- processspecial(object.prescript) -- end -- else - else -- error end end diff --git a/tex/context/base/mkxl/mult-aux.mkxl b/tex/context/base/mkxl/mult-aux.mkxl index 4bbebf2d1..9cdfebac2 100644 --- a/tex/context/base/mkxl/mult-aux.mkxl +++ b/tex/context/base/mkxl/mult-aux.mkxl @@ -1092,21 +1092,6 @@ \expandafter\noexpand\csname current#2\endcsname \expandafter\noexpand\csname setlocal#2current\endcsname}} -% The \LUA\ based variant is twice as fast as the above but as said, we don't use -% this one that often. It's more about less tracing than speed here. - -\permanent\protected\def\installmacrostack#1% - {\ifdefined#1\else\mutable\let#1\empty\fi - \protected\gdefcsname push_macro_\csstring#1\endcsname{\localpushmacro#1}% - \protected\gdefcsname pop_macro_\csstring#1\endcsname{\localpopmacro #1}} - -\permanent\protected\def\installglobalmacrostack#1% - {\ifdefined#1\else\mutable\glet#1\empty\fi - \protected\gdefcsname push_macro_\csstring#1\endcsname{\globalpushmacro#1}% - \protected\gdefcsname pop_macro_\csstring#1\endcsname{\globalpopmacro #1}} - -% \showmacrostack can be used to see if there are different entries - % \unprotect % % \installcorenamespace {test} \installcommandhandler \??test {test} \??test diff --git a/tex/context/base/mkxl/pack-obj.lmt b/tex/context/base/mkxl/pack-obj.lmt index 5f784b32a..1e22515b9 100644 --- a/tex/context/base/mkxl/pack-obj.lmt +++ b/tex/context/base/mkxl/pack-obj.lmt @@ -103,8 +103,8 @@ function objects.register(ns,id,b,referenced,offset,mode,delay) -- The delay feature is just an experiment: a value of 1 delays the -- flushing and 2 overloads the content. It might disappear again. local found = data[ns][id] + nodes.handlers.finalizebox(b) if found and delay == 2 then - nodes.handlers.finalizebox(b) data[ns][id] = { codeinjections.registerboxresource(b,nil,nil,found[1]), -- hardcoded [1] offset, diff --git a/tex/context/base/mkxl/syst-aux.mkxl b/tex/context/base/mkxl/syst-aux.mkxl index 018a95eb2..a507218c1 100644 --- a/tex/context/base/mkxl/syst-aux.mkxl +++ b/tex/context/base/mkxl/syst-aux.mkxl @@ -3188,8 +3188,6 @@ %D We now use the macro stack which is somewhat leaner and meaner and a little %D faster too. -% left overs: too much \protected here - \newcount\outerrecurse \newcount\innerrecurse @@ -3199,79 +3197,61 @@ \mutable\let\recurseaction\relax \mutable\let\recursestring\empty -% \let\syst_helpers_stepwise_next\relax - -% \protected\def\syst_helpers_stepwise_recurse#1#2#3% from to step -% {\ifnum#1>#2\relax -% \expandafter\syst_helpers_stepwise_recurse_nop -% \else -% \def\recurselevel{#1}% -% \doubleexpandafter\syst_helpers_stepwise_recurse_yes\expandafter -% \fi\expandafter{\the\numexpr\recurselevel+#3\relax}{#2}{#3}} - -\protected\def\syst_helpers_stepwise_recurse#1#2#3% from to step - {\ifnum#1>#2\relax - \expandafter\gobblefourarguments - \else - \def\recurselevel{#1}% -% \doubleexpandafter\syst_helpers_stepwise_recurse_yes\expandafter -% \fi\expandafter{\the\numexpr\recurselevel+#3\relax}{#2}{#3}} - \doubleexpandafter\syst_helpers_stepwise_recurse_yes - \fi\expandafter{\the\numexpr\recurselevel+#3\relax}{#2}{#3}} - -\protected\def\syst_helpers_stepwise_recurse_yes - {\syst_helpers_recurse_content - \syst_helpers_stepwise_recurse} - -\protected\def\syst_helpers_stepwise_reverse#1#2#3% from to step - {\ifnum#1<#2\relax -% \expandafter\syst_helpers_stepwise_recurse_nop - \expandafter\gobblefourarguments - \else - \def\recurselevel{#1}% - \innerrecurse#1\relax - \advance\innerrecurse#3\relax -% \doubleexpandafter\syst_helpers_stepwise_reverse_yes\expandafter -% \fi\expandafter{\the\innerrecurse}{#2}{#3}} - \doubleexpandafter\syst_helpers_stepwise_reverse_yes - \fi\expandafter{\the\numexpr\recurselevel+#3\relax}{#2}{#3}} - -\protected\def\syst_helpers_stepwise_reverse_yes - {\syst_helpers_recurse_content - \syst_helpers_stepwise_reverse} - -% \protected\def\syst_helpers_stepwise_exit -% {\syst_helpers_stepwise_recurse_nop\relax} - -\permanent\def\doexpandedrecurse#1#2% user macro (also was \doxprecurse) - {\ifnum#1>\zerocount - #2\expandafter\doexpandedrecurse\expandafter{\the\numexpr#1-\plusone\relax}{#2}% - \fi} +%% \protected\def\syst_helpers_stepwise_recurse#1#2#3% from to step +%% {\ifnum#1>#2\relax +%% \expandafter\gobblefourarguments +%% \else +%% \def\recurselevel{#1}% +%% \doubleexpandafter\syst_helpers_stepwise_recurse_yes +%% \fi\expandafter{\the\numexpr\recurselevel+#3\relax}{#2}{#3}} +%% +%% \protected\def\syst_helpers_stepwise_recurse_yes +%% {\syst_helpers_recurse_content +%% \syst_helpers_stepwise_recurse} +%% +%% \protected\def\syst_helpers_stepwise_reverse#1#2#3% from to step +%% {\ifnum#1<#2\relax +%% \expandafter\gobblefourarguments +%% \else +%% \def\recurselevel{#1}% +%% \innerrecurse#1\relax +%% \advance\innerrecurse#3\relax +%% \doubleexpandafter\syst_helpers_stepwise_reverse_yes +%% \fi\expandafter{\the\numexpr\recurselevel+#3\relax}{#2}{#3}} +%% +%% \protected\def\syst_helpers_stepwise_reverse_yes +%% {\syst_helpers_recurse_content +%% \syst_helpers_stepwise_reverse} +%% +%% \permanent\def\doexpandedrecurse#1#2% user macro (also was \doxprecurse) +%% {\ifnum#1>\zerocount +%% #2\expandafter\doexpandedrecurse\expandafter{\the\numexpr#1-\plusone\relax}{#2}% +%% \fi} %D The next one might replace the above and provides the current step in \type {#1} %D like \type {\dorecurse} do, but it comes with a tiny performance hit. -\installsystemnamespace{expandedrecurse} - -\mutable\let\m_expanded_recursed\gobbleoneargument - -\permanent\def\doexpandedrecursed#1#2% this might replace: \doexpandedrecurse - {\beginlocalcontrol - \localpushmacro\m_expanded_recursed - \def\m_expanded_recursed##1{#2}% - \endlocalcontrol - \syst_do_expanded_recursed{1}{#1}{#2}% no \plusone ! - \beginlocalcontrol - \localpopmacro\m_expanded_recursed - \endlocalcontrol} - -\def\syst_do_expanded_recursed#1#2#3% - {\ifnum#1>#2\norelax - \expandafter\gobblethreearguments - \else - \m_expanded_recursed{#1}\doubleexpandafter\syst_do_expanded_recursed - \fi - {\the\numexpr#1+\plusone\relax}{#2}{#3}} +%% \installsystemnamespace{expandedrecurse} +%% +%% \mutable\let\m_expanded_recursed\gobbleoneargument +%% +%% \permanent\def\doexpandedrecursed#1#2% this might replace: \doexpandedrecurse +%% {\beginlocalcontrol +%% \localpushmacro\m_expanded_recursed +%% \def\m_expanded_recursed##1{#2}% +%% \endlocalcontrol +%% \syst_do_expanded_recursed{1}{#1}{#2}% no \plusone ! +%% \beginlocalcontrol +%% \localpopmacro\m_expanded_recursed +%% \endlocalcontrol} +%% +%% \def\syst_do_expanded_recursed#1#2#3% +%% {\ifnum#1>#2\norelax +%% \expandafter\gobblethreearguments +%% \else +%% \m_expanded_recursed{#1}\doubleexpandafter\syst_do_expanded_recursed +%% \fi +%% {\the\numexpr#1+\plusone\relax}{#2}{#3}} %D As we can see here, the simple command \type{\dorecurse} is a special case of the %D more general: @@ -3290,31 +3270,31 @@ %D %D Because the simple case (n=1) is used often, we implement it more efficiently: -\permanent\protected\def\dorecurse#1% - {\ifcase#1\relax - \expandafter\gobbletwoarguments - \or - \expandafter\syst_helpers_recurse_y - \else - \expandafter\syst_helpers_recurse_x - \fi{#1}} - -\protected\def\syst_helpers_recurse_indeed#1#2% from to -% {\ifnum#1>#2 % - {\ifnum#1>#2\relax - \expandafter\syst_helpers_recurse_indeed_nop - \else - \def\recurselevel{#1}% - \innerrecurse#1\advance\innerrecurse\plusone - \doubleexpandafter\syst_helpers_recurse_indeed_yes - \fi\expandafter{\the\innerrecurse}{#2}} - -\protected\def\syst_helpers_recurse_indeed_yes - {\syst_helpers_recurse_content - \syst_helpers_recurse_indeed} - -\protected\def\syst_helpers_recurse_indeed_nop#0#0#0% - {} +%% \permanent\protected\def\dorecurse#1% +%% {\ifcase#1\relax +%% \expandafter\gobbletwoarguments +%% \or +%% \expandafter\syst_helpers_recurse_y +%% \else +%% \expandafter\syst_helpers_recurse_x +%% \fi{#1}} +%% +%% \protected\def\syst_helpers_recurse_indeed#1#2% from to +%% % {\ifnum#1>#2 % +%% {\ifnum#1>#2\relax +%% \expandafter\syst_helpers_recurse_indeed_nop +%% \else +%% \def\recurselevel{#1}% +%% \innerrecurse#1\advance\innerrecurse\plusone +%% \doubleexpandafter\syst_helpers_recurse_indeed_yes +%% \fi\expandafter{\the\innerrecurse}{#2}} +%% +%% \protected\def\syst_helpers_recurse_indeed_yes +%% {\syst_helpers_recurse_content +%% \syst_helpers_recurse_indeed} +%% +%% \protected\def\syst_helpers_recurse_indeed_nop#0#0#0% +%% {} %D \macros %D {dowith} @@ -3361,8 +3341,12 @@ {\def\recurselevel{#1}% \expandafter\syst_helpers_loop_yes\expandafter{\the\numexpr\recurselevel+\plusone\relax}} +%% \protected\def\syst_helpers_loop_yes +%% {\syst_helpers_recurse_content +%% \endofloop} + \protected\def\syst_helpers_loop_yes - {\syst_helpers_recurse_content + {\normalexpanded{\recurseaction{\recurselevel}{\the\outerrecurse}}% \endofloop} \protected\def\syst_helpers_loop_nop#0% @@ -3412,78 +3396,51 @@ %D \dorecurse{3}{\expanded{\definesymbol[test-\recurselevel][xx-\recurselevel]}} %D \stoptyping -\def\syst_helpers_recurse_content - {\normalexpanded{\recurseaction{\recurselevel}{\the\outerrecurse}}} - -\protected\def\syst_helpers_recurse_x#1#2% - {\global\advance\outerrecurse\plusone - \globalpushmacro\recurseaction - \globalpushmacro\recurselevel - \protected\gdef\recurseaction##1##2{#2}% - \expandafter\syst_helpers_recurse_indeed\expandafter1\expandafter{\number#1}% - \globalpopmacro\recurselevel - \globalpopmacro\recurseaction - \global\advance\outerrecurse\minusone} - -\protected\def\syst_helpers_recurse_y#1#2% - {\global\advance\outerrecurse\plusone - \globalpushmacro\recurseaction - \globalpushmacro\recurselevel - \let\recurselevel\!!plusone - \protected\gdef\recurseaction##1##2{#2}% - \syst_helpers_recurse_content - \globalpopmacro\recurselevel - \globalpopmacro\recurseaction - \global\advance\outerrecurse\minusone} - -% \protected\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 -% {\global\advance\outerrecurse \plusone -% \globalpushmacro\recurseaction -% \globalpushmacro\recurselevel -% \protected\gdef\recurseaction##1##2{#4}% -% \normalexpanded{\ifcmpnum#3\zerocount -% \ifnum#1<#2\relax\relax % so we catch \number\numexpr xx without \relax's -% \syst_helpers_stepwise_exit -% \else -% \syst_helpers_stepwise_reverse -% \fi -% \or -% \syst_helpers_stepwise_exit -% \or -% \ifnum#2<#1\relax\relax % so we catch \number\numexpr xx without \relax's -% \syst_helpers_stepwise_exit -% \else -% \syst_helpers_stepwise_recurse -% \fi -% \fi{\number#1}{\number#2}{\number#3}}% -% \globalpopmacro\recurselevel -% \globalpopmacro\recurseaction -% \global\advance\outerrecurse\minusone} - -\permanent\protected\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 ... todo: remove unused helpers - {\global\advance\outerrecurse \plusone - \globalpushmacro\recurseaction - \globalpushmacro\recurselevel - \protected\gdef\recurseaction##1##2{#4}% - \normalexpanded{\ifcmpnum#3\zerocount - \ifnum#1<#2\relax\relax % so we catch \number\numexpr xx without \relax's - \doubleexpandafter\gobbletwoarguments - \else - \tripleexpandafter\syst_helpers_stepwise_reverse - \fi - \or - \doubleexpandafter\gobbletwoarguments - \orelse\ifnum#2<#1\relax\relax % so we catch \number\numexpr xx without \relax's - \doubleexpandafter\gobbletwoarguments - \else - \doubleexpandafter\syst_helpers_stepwise_recurse - \fi\normalexpanded{{\number#1}{\number#2}{\number#3}}}% - \globalpopmacro\recurselevel - \globalpopmacro\recurseaction - \global\advance\outerrecurse\minusone} - -% \protected\def\syst_helpers_stepwise_recurse_nop#0#0#0#0% -% {} +%% \def\syst_helpers_recurse_content +%% {\normalexpanded{\recurseaction{\recurselevel}{\the\outerrecurse}}} +%% +%% \protected\def\syst_helpers_recurse_x#1#2% +%% {\global\advance\outerrecurse\plusone +%% \globalpushmacro\recurseaction +%% \globalpushmacro\recurselevel +%% \protected\gdef\recurseaction##1##2{#2}% +%% \expandafter\syst_helpers_recurse_indeed\expandafter1\expandafter{\number#1}% +%% \globalpopmacro\recurselevel +%% \globalpopmacro\recurseaction +%% \global\advance\outerrecurse\minusone} +%% +%% \protected\def\syst_helpers_recurse_y#1#2% +%% {\global\advance\outerrecurse\plusone +%% \globalpushmacro\recurseaction +%% \globalpushmacro\recurselevel +%% \let\recurselevel\!!plusone +%% \protected\gdef\recurseaction##1##2{#2}% +%% \syst_helpers_recurse_content +%% \globalpopmacro\recurselevel +%% \globalpopmacro\recurseaction +%% \global\advance\outerrecurse\minusone} +%% +%% \permanent\protected\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 ... todo: remove unused helpers +%% {\global\advance\outerrecurse \plusone +%% \globalpushmacro\recurseaction +%% \globalpushmacro\recurselevel +%% \protected\gdef\recurseaction##1##2{#4}% +%% \normalexpanded{\ifcmpnum#3\zerocount +%% \ifnum#1<#2\relax\relax % so we catch \number\numexpr xx without \relax's +%% \doubleexpandafter\gobbletwoarguments +%% \else +%% \tripleexpandafter\syst_helpers_stepwise_reverse +%% \fi +%% \or +%% \doubleexpandafter\gobbletwoarguments +%% \orelse\ifnum#2<#1\relax\relax % so we catch \number\numexpr xx without \relax's +%% \doubleexpandafter\gobbletwoarguments +%% \else +%% \doubleexpandafter\syst_helpers_stepwise_recurse +%% \fi\normalexpanded{{\number#1}{\number#2}{\number#3}}}% +%% \globalpopmacro\recurselevel +%% \globalpopmacro\recurseaction +%% \global\advance\outerrecurse\minusone} \newcount\fastloopindex \newcount\fastloopfinal @@ -3512,6 +3469,67 @@ \expandafter\syst_helpers_fast_loop_cs_step \fi} +%D Here are the more modern implementations: + +\permanent\protected\def\installmacrostack#1% + {\ifdefined#1\else\mutable\let#1\empty\fi + \protected\gdefcsname push_macro_\csstring#1\endcsname{\localpushmacro#1}% + \protected\gdefcsname pop_macro_\csstring#1\endcsname{\localpopmacro #1}} + +\permanent\protected\def\installglobalmacrostack#1% + {\ifdefined#1\else\mutable\glet#1\empty\fi + \protected\gdefcsname push_macro_\csstring#1\endcsname{\globalpushmacro#1}% + \protected\gdefcsname pop_macro_\csstring#1\endcsname{\globalpopmacro #1}} + +% \showmacrostack can be used to see if there are different entries + +\installglobalmacrostack \recurseaction +\installglobalmacrostack \recurselevel +\installglobalmacrostack \recursedepth + +\permanent\protected\def\dostepwiserecurse#1#2#3#4% + {\push_macro_recurseaction + \push_macro_recurselevel + \push_macro_recursedepth + \protected\gdef\recurseaction##1##2{#4}% + \localcontrolledloop=#1=#2=#3% + {\edef\recurselevel{\the\currentloopiterator}% + \edef\recursedepth{\the\currentloopnesting}% + \normalexpanded{\recurseaction{\recurselevel}{\recursedepth}}}% + \pop_macro_recursedepth + \pop_macro_recurselevel + \pop_macro_recurseaction} + +\permanent\protected\def\dorecurse#1#2% + {\push_macro_recurseaction + \push_macro_recurselevel + \push_macro_recursedepth + \protected\gdef\recurseaction##1##2{#2}% + \localcontrolledloop=\plusone=#1=\plusone + {\edef\recurselevel{\the\currentloopiterator}% + \edef\recursedepth{\the\currentloopnesting}% + \normalexpanded{\recurseaction{\recurselevel}{\recursedepth}}}% + \pop_macro_recursedepth + \pop_macro_recurselevel + \pop_macro_recurseaction} + +\permanent\def\doexpandedrecurse#1#2% user macro (also was \doxprecurse) + {\expandedloop\plusone#1\plusone{#2}} + +\mutable\let\m_expanded_recursed\gobbleoneargument + +\installmacrostack\m_expanded_recursed + +\permanent\def\doexpandedrecursed#1#2% this might replace: \doexpandedrecurse + {\beginlocalcontrol + \push_macro_m_expanded_recursed + \def\m_expanded_recursed##1{#2}% + \endlocalcontrol + \expandedloop\plusone#1\plusone{\expandafter\m_expanded_recursed\expandafter{\the\currentloopiterator}}% + \beginlocalcontrol + \pop_macro_m_expanded_recursed + \endlocalcontrol} + % Helper: \permanent\protected\def\resetrecurselevel{\let\recurselevel\!!zerocount} @@ -5888,14 +5906,30 @@ %D {\processcontent{stophans}\test{\message{\test}\wait}} %D \stoptyping -\permanent\protected\def\processcontent#1% - {\begingroup\expandafter\syst_helpers_process_content\csname#1\endcsname} +% \starttabulate[|||] +% \NC \type{#} \NC # \NC \NR +% \stoptabulate +% +% \def\test#1% +% {\starttabulate[|||] +% \NC \type{#1} \NC #1 \NC \NR +% \stoptabulate} +% +% \test{!} + +%% \permanent\protected\def\processcontent#1% +%% {\begingroup\expandafter\syst_helpers_process_content\csname#1\endcsname} \protected\def\syst_helpers_process_content#1#2#3% {\protected\def\syst_helpers_process_content##1#1% {\endgroup\def#2{##1}#3}% \syst_helpers_process_content} +\permanent\protected\def\processcontent#1% + {\begingroup + \catcode\hashasciicode\othercatcode + \expandafter\syst_helpers_process_content\csname#1\endcsname} + %D \macros %D {dogobblesingleempty, dogobbledoubleempty} %D diff --git a/tex/context/modules/mkxl/m-crappyspec.mkxl b/tex/context/modules/mkxl/m-crappyspec.mkxl new file mode 100644 index 000000000..483141141 --- /dev/null +++ b/tex/context/modules/mkxl/m-crappyspec.mkxl @@ -0,0 +1,229 @@ +%D \module +%D [ file=m-crappyspec, +%D version=2022.07.01, % about +%D title=\CONTEXT\ Extra Modules, +%D subtitle=Meeting weird demands, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This module is for Benjamin Buchmuller who has to meet rather weird demands with +%D respect to the number of characters per line. So, it's not about quality but more +%D sort of previous century typewriter specification. +%D +%D \setmainparbuilder[crappyspec] + +\startluacode + +local type = type + +local nuts = nodes.nuts + +local glyph_code = nodes.nodecodes.glyph +local hlist_code = nodes.nodecodes.hlist +local vlist_code = nodes.nodecodes.vlist +local disc_code = nodes.nodecodes.disc + +local line_code = nodes.listcodes.line + +local traverselist = nuts.traverselist +local traversecontent = nuts.traversecontent + +local flushlist = nuts.flushlist +local copylist = nuts.copylist +local getcharspec = nuts.getcharspec +local getreplace = nuts.getreplace +local getparstate = nuts.getparstate +local getlist = nuts.getlist +local getwidth = nuts.getwidth +local setwidth = nuts.setwidth + +local texset = tex.set +local texsetdimen = tex.setdimen +local texgetdimen = tex.getdimen +local texgetcount = tex.getcount +local texlinebreak = tex.linebreak + +local characters = fonts.hashes.characters + +local function countglyphs(h) + local c = 0 + if h then + for n, t, s in traversecontent(h) do + if t == glyph_code then + if true then + local g, f = getcharspec(n) + local d = characters[f][g] -- maybe cache + local u = d and d.unicode + if type(u) == "table" then + c = c + #u + else + c = c + 1 + end + else + c = c + 1 + end + elseif t == disc_code then + c = c + countglyphs(getreplace(n),c) + elseif t == hlist_code or s == vlist_code then + c = c + countglyphs(getlist(h),c) + else + -- leader + end + end + end + return c +end + +local function overflow(h, max) + for n, t, s in traverselist(h) do + if t == hlist_code and s == line_code then + local c = countglyphs(getlist(n)) + if c > max then + return c, getwidth(n) + end + end + end + return false +end + +function builders.paragraphs.constructors.methods.crappyspec(head) + -- todo: prevent useless calls + local p = getparstate(head) + if p then + local hsize = p.hsize + local max = texgetcount("crappyspeccount") + local step = texgetdimen("crappyspecstep") + if step <= 65536 then + step = 65536 + end + while true do + local n = copylist(head) + local l, d = texlinebreak(n, { hsize = hsize }) + local c, w = overflow(l,max) + if w and hsize > 10*step then -- safeguard + flushlist(l) + hsize = hsize - step + else + texsetdimen("crappyspecdimen",hsize) + flushlist(head) + head = l + local hsize = p.hsize + for n, t, s in traverselist(head) do + if t == hlist_code and s == line_code then + -- todo: add delta to rightskip or so + setwidth(n,hsize) + end + end + texset("prevdepth",d.prevdepth) + break + end + end + end + return head +end +\stopluacode + +\newcount\crappyspeccount +\newdimen\crappyspecstep \crappyspecstep \onepoint +\newdimen\crappyspecdimen + +\defineparbuilder [crappyspec] % implemented in the builder namespace +\defineparbuilder [default] % implemented in the builder namespace + +\continueifinputfile{m-crappyspec.mkxl} + +\setupbodyfont + [pagella] + +\setuptolerance + [verytolerant,stretch] + +\showmakeup + [line] + +\setmainparbuilder + [crappyspec] + +\dontcomplain + +\protected\def\CrappyTraced + {\par \strut \rlap \bgroup\infofont + (\enspace + max = \the\crappyspeccount \quad + step = \the\crappyspecstep \quad + hsize = \the\hsize \quad + used = \the\crappyspecdimen \enspace + ) + \egroup \par} + +\starttext + +\crappyspeccount60 \samplefile{tufte} \CrappyTraced \par +\crappyspeccount40 \samplefile{tufte} \CrappyTraced \par +% \crappyspecstep 2pt \samplefile{tufte} \CrappyTraced \par + +\samplefile{tufte} \CrappyTraced +\startitemize + \startitem + \samplefile{tufte} \CrappyTraced + \stopitem + \startitem + \samplefile{ward} \CrappyTraced + \stopitem +\stopitemize + +\startnarrower[6*left,right] + \samplefile{tufte} \CrappyTraced +\stopnarrower + +\starthanging [distance=4em,n=2] {test} + \samplefile{tufte} \CrappyTraced +\stophanging + +\page % \stoptext + +\setuppapersize[landscape,letter] + +\samplefile{knuth} \CrappyTraced +\startitemize[width=5em] + \startitem + \samplefile{knuth} \CrappyTraced + \stopitem + \startitem + {\smallcaps \darkblue \samplefile{knuth}} \CrappyTraced + \stopitem +\stopitemize +\crappyspeccount60 +\startitemize[width=5em] + \startitem + \samplefile{knuth} \CrappyTraced + \stopitem + \startitem + {\smallcaps \darkgreen \samplefile{knuth}} \CrappyTraced + \stopitem +\stopitemize + +\page + +\crappyspecstep 1pt \crappyspeccount 60 % 5.5 +\crappyspecstep 2pt \crappyspeccount 60 % 3.2 +\crappyspecstep 5pt \crappyspeccount 60 % 1.4 +\crappyspecstep 10pt \crappyspeccount 60 % 0.9 + +\crappyspecstep 1pt \crappyspeccount 80 % 0.8 +\crappyspecstep 2pt \crappyspeccount 80 % 0.8 +\crappyspecstep 5pt \crappyspeccount 80 % 0.8 +\crappyspecstep 10pt \crappyspeccount 80 % 0.6 + +% \crappyspecstep 1pt \crappyspeccount 120 % 0.25 +% \crappyspecstep 2pt \crappyspeccount 120 % 0.25 +% \crappyspecstep 5pt \crappyspeccount 120 % 0.25 + +% \testfeatureonce{100}{\samplefile{tufte}\par\CrappyTraced} % \page \elapsedtime + +\stoptext diff --git a/tex/context/modules/mkxl/x-mathml.mkxl b/tex/context/modules/mkxl/x-mathml.mkxl index 07faea353..1cb94ff44 100644 --- a/tex/context/modules/mkxl/x-mathml.mkxl +++ b/tex/context/modules/mkxl/x-mathml.mkxl @@ -569,26 +569,28 @@ \stopxmlsetups \startxmlsetups mml:cn:integer - \edef\mmlintegerbase{\xmlattdef{#1}{base}{}} - \ifx\mmlintegerbase\empty - \xmlflush{#1} - \else - \doifelse \MMLbasesymbol \v!no { - \MMLcCNbasedata{\xmlflush{#1}} - } { - \MMLcCNbasedata{\xmlflush{#1}}\normalsubscript{ - \hbox {\startimath - \mr - \scriptscriptstyle - \processaction - [\MMLbasesymbol] - [\v!characters=>\MMLcCNbasestring BODH, - \v!text=>\MMLcCNbasestring{BIN}{OCT}{DEC}{HEX}, - \s!unknown=>\mmlintegerbase] - \stopimath} + \mathatom class \mathdigitcode \bgroup + \edef\mmlintegerbase{\xmlattdef{#1}{base}{}} + \ifx\mmlintegerbase\empty + \xmlflush{#1} + \else + \mtext { + \nospacing + \MMLcCNbasedata{\xmlflush{#1}} } - } - \fi + \doifnot \MMLbasesymbol \v!no { + \normalsubscript { + \mtext { + \processaction + [\MMLbasesymbol] + [\v!characters=>\MMLcCNbasestring BODH, + \v!text=>\MMLcCNbasestring{BIN}{OCT}{DEC}{HEX}, + \s!unknown=>\mmlintegerbase] + } + } + } + \fi + \egroup \stopxmlsetups \def\MMLcCNbasedata#1% diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 8379da1b8..23ac64712 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 : 2022-07-24 12:17 +-- merge date : 2022-07-27 17:51 do -- begin closure to overcome local limits and interference |