From 915458f50da433e6c3a68ee21b76a98757ec8677 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Wed, 27 Jun 2012 14:37:00 +0200 Subject: beta 2012.06.27 14:37 --- tex/context/base/context-version.pdf | Bin 4147 -> 4149 bytes tex/context/base/context-version.png | Bin 106247 -> 106143 bytes tex/context/base/context.mkiv | 7 +- tex/context/base/core-var.mkiv | 8 +- tex/context/base/font-aux.mkvi | 101 +++++ tex/context/base/font-pre.mkiv | 2 + tex/context/base/font-set.mkvi | 2 +- tex/context/base/grph-epd.mkiv | 4 +- tex/context/base/lpdf-ren.lua | 9 +- tex/context/base/m-oldfun.mkiv | 714 ++++++++++++++++++++++++++++++++++ tex/context/base/m-oldnum.mkiv | 416 ++++++++++++++++++++ tex/context/base/mult-dim.mkvi | 1 + tex/context/base/node-fin.lua | 32 +- tex/context/base/spac-ali.mkiv | 4 + tex/context/base/spac-def.mkiv | 77 +--- tex/context/base/spac-grd.mkiv | 51 +-- tex/context/base/spac-hor.mkiv | 33 +- tex/context/base/spac-ver.mkiv | 46 ++- tex/context/base/status-files.pdf | Bin 24505 -> 24491 bytes tex/context/base/status-lua.pdf | Bin 182500 -> 182544 bytes tex/context/base/status-mkiv.lua | 34 +- tex/context/base/supp-fun.mkiv | 716 ----------------------------------- tex/context/base/supp-mat.mkiv | 88 +---- tex/context/base/supp-num.mkiv | 416 -------------------- tex/context/base/syst-aux.mkiv | 5 +- tex/context/base/trac-vis.lua | 234 +++++++++--- tex/context/base/trac-vis.mkiv | 31 +- 27 files changed, 1637 insertions(+), 1394 deletions(-) create mode 100644 tex/context/base/font-aux.mkvi create mode 100644 tex/context/base/m-oldfun.mkiv create mode 100644 tex/context/base/m-oldnum.mkiv delete mode 100644 tex/context/base/supp-fun.mkiv delete mode 100644 tex/context/base/supp-num.mkiv diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index 6158e4aee..f9ca424c5 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index 1b1cacf07..9d7298d86 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 279920315..847b6d460 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -23,7 +23,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.06.26 10:59} +\edef\contextversion{2012.06.27 14:37} %D For those who want to use this: @@ -150,12 +150,12 @@ \loadmarkfile{supp-box} %loadmarkfile{supp-vis} % replaced by trac-vis -\loadmarkfile{supp-fun} % close to obsolete +%loadmarkfile{supp-fun} % mostly replaced \loadmarkfile{supp-ran} \loadmarkfile{supp-mat} \loadmarkfile{spac-cha} -\loadmarkfile{supp-num} % replaced +%loadmarkfile{supp-num} % obsolete \loadmarkfile{typo-ini} @@ -349,6 +349,7 @@ \loadmarkfile{font-uni} \loadmkvifile{font-col} \loadmkvifile{font-gds} +\loadmkvifile{font-aux} \loadmarkfile{lxml-css} diff --git a/tex/context/base/core-var.mkiv b/tex/context/base/core-var.mkiv index 26559f246..854c07867 100644 --- a/tex/context/base/core-var.mkiv +++ b/tex/context/base/core-var.mkiv @@ -59,8 +59,12 @@ \newtoks \everyforgetall \newtoks \everycleanupfeatures -\def\cleanupfeatures{\the\everycleanupfeatures} -\def\forgetall {\the\everyforgetall} +\unexpanded\def\cleanupfeatures{\the\everycleanupfeatures} +\unexpanded\def\forgetall {\the\everyforgetall} + +\appendtoks + \everypar\emptytoks % pretty important +\to \everyforgetall %D Page building: diff --git a/tex/context/base/font-aux.mkvi b/tex/context/base/font-aux.mkvi new file mode 100644 index 000000000..50cc4a258 --- /dev/null +++ b/tex/context/base/font-aux.mkvi @@ -0,0 +1,101 @@ +%D \module +%D [ file=font-gds, +%D version=2012.06.26, +%D title=\CONTEXT\ Font Support, +%D subtitle=Helpers, +%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. + +\writestatus{loading}{ConTeXt Font Support / Helpers} + +%D Here we collect code moved from other files, like some of the +%D support modules. + +\unprotect + +%D \macros +%D {normalizefontheight,normalizefontwidth,normalizedfontsize} +%D +%D Next we introduce some font manipulation macros. When we +%D want to typeset some text spread in a well defined area, it +%D can be considered bad practice to manipulate character and +%D word spacing. In such situations the next few macros can be +%D of help: +%D +%D \starttyping +%D \normalizefontheight \name {sample text} {height} {font} +%D \normalizefontwidth \name {sample text} {width} {font} +%D \stoptyping +%D +%D Consider for instance: +%D +%D \startbuffer[a] +%D \NormalizeFontHeight \TempFont {X} {2\baselineskip} {Serif} +%D \stopbuffer +%D +%D \startbuffer[b] +%D \ruledhbox{\TempFont To Be Or Not To Be} +%D \stopbuffer +%D +%D \typebuffer[a,b] \getbuffer[a] +%D +%D This shows up as: +%D +%D \startlinecorrection +%D \ruledhbox{\getbuffer[b]} +%D \stoplinecorrection +%D +%D The horizontal counterpart is: +%D +%D \startbuffer[a] +%D \NormalizeFontWidth \TempFont {This Line Fits} {\hsize} {Serif} +%D \stopbuffer +%D +%D \startbuffer[b] +%D \ruledhbox{\TempFont This Line Fits} +%D \stopbuffer +%D +%D \typebuffer[a,b] \getbuffer[a] +%D +%D This gives: +%D +%D \startlinecorrection +%D \ruledhbox{\getbuffer[b]} +%D \stoplinecorrection +%D +%D The calculated font scale is avaliable in \type {\normalizedfontsize}. + +\unexpanded\def\font_helpers_normalize_size#what#cs#text#width#specification% + {\bgroup + \setbox\scratchbox\hbox{\definedfont[#specification at 10pt]#text}% + \normalexpanded{\egroup\edef\noexpand\normalizedfontsize + {\the\dimexpr\ifdim\wd\scratchbox>\zeropoint + \luaexpr{\number\dimexpr10pt\relax*\number\dimexpr#width\relax/\number#what\scratchbox}\scaledpoint + \else + \bodyfontsize + \fi\relax}}% + \definefont[\strippedcsname#cs][#specification at \normalizedfontsize]} + +\def\NormalizedFontSize{\bodyfontsize} + +\unexpanded\def\normalizefontwidth {\font_helpers_normalize_size\wd} +\unexpanded\def\normalizefontheight{\font_helpers_normalize_size\ht} +\unexpanded\def\normalizefontdepth {\font_helpers_normalize_size\dp} +\unexpanded\def\normalizefontline {\font_helpers_normalize_size\htdp} + +\unexpanded\def\widthspanningtext #text#width#specification{\hbox{\normalizefontwidth \temp{#text}{#width}{#specification}\temp#text}} +\unexpanded\def\heightspanningtext#text#width#specification{\hbox{\normalizefontheight\temp{#text}{#width}{#specification}\temp#text}} +\unexpanded\def\depthspanningtext #text#width#specification{\hbox{\normalizefontdepth \temp{#text}{#width}{#specification}\temp#text}} +\unexpanded\def\linespanningtext #text#width#specification{\hbox{\normalizefontline \temp{#text}{#width}{#specification}\temp#text}} + +\let\NormalizeFontHeight \normalizefontheight +\let\NormalizeFontWidth \normalizefontwidth +\let\WidthSpanningText \widthspanningtext +\def\TheNormalizedFontSize{\normalizefontsize} + +\protect \endinput diff --git a/tex/context/base/font-pre.mkiv b/tex/context/base/font-pre.mkiv index e5999df14..8288ef412 100644 --- a/tex/context/base/font-pre.mkiv +++ b/tex/context/base/font-pre.mkiv @@ -178,6 +178,7 @@ \definecolor[trace:m][m=.75,t=.5,a=1] \definecolor[trace:y][y=.75,t=.5,a=1] \definecolor[trace:s][s=.75,t=.5,a=1] +\definecolor[trace:o][r=1,g=.6,b=.1,t=.5,a=1] \definecolor[trace:dr][r=.75,t=.75,a=1] \definecolor[trace:dg][g=.75,t=.75,a=1] @@ -186,6 +187,7 @@ \definecolor[trace:dm][m=.75,t=.75,a=1] \definecolor[trace:dy][y=.75,t=.75,a=1] \definecolor[trace:ds][s=.75,t=.75,a=1] +\definecolor[trace:do][r=1,g=.6,b=.1,t=.75,a=1] %D Now we're up to some definitions. diff --git a/tex/context/base/font-set.mkvi b/tex/context/base/font-set.mkvi index 8e4044267..c5450a152 100644 --- a/tex/context/base/font-set.mkvi +++ b/tex/context/base/font-set.mkvi @@ -121,7 +121,7 @@ \unexpanded\def\font_preloads_fourth_stage {\begingroup %ifzeropt\fontcharwd\font\number`!\relax - \setbox\scratchbox\hbox{context}% + \setbox\scratchbox\hbox{checking fonts}% \ifzeropt\wd\scratchbox \writeline \writestatus\m!fonts{!! No bodyfont has been defined and no defaults have been}% diff --git a/tex/context/base/grph-epd.mkiv b/tex/context/base/grph-epd.mkiv index 26c07e731..f8e7461c2 100644 --- a/tex/context/base/grph-epd.mkiv +++ b/tex/context/base/grph-epd.mkiv @@ -22,7 +22,7 @@ \defineoverlay[system:graphics:epdf][\directsetup{system:graphics:epdf}] \startsetups system:graphics:epdf - \ctxlua{figures.mergegoodies("\externalfigureparameter\c!interaction")}% + \ctxlua{figures.mergegoodies("\externalfiguresparameter\c!interaction")}% \reference[\figurereference]{}% todo: dest area \stopsetups @@ -39,7 +39,7 @@ \appendtoks \iflocation - \doif\figurefiletype{pdf}{\doifnot{\externalfigureparameter\c!interaction}\v!none\grph_epdf_add_overlay}% + \doif\figurefiletype{pdf}{\doifnot{\externalfiguresparameter\c!interaction}\v!none\grph_epdf_add_overlay}% \fi \to \externalfigurepostprocessors diff --git a/tex/context/base/lpdf-ren.lua b/tex/context/base/lpdf-ren.lua index 29b78313f..6ffdf8110 100644 --- a/tex/context/base/lpdf-ren.lua +++ b/tex/context/base/lpdf-ren.lua @@ -108,6 +108,7 @@ end local pdfln, pdfld = { }, { } local textlayers, hidelayers, videlayers = pdfarray(), pdfarray(), pdfarray() local pagelayers, pagelayersreference, cache = nil, nil, { } +local alphabetic = { } local specifications = { } local initialized = { } @@ -152,6 +153,7 @@ local function useviewerlayer(name) -- move up so that we can use it as local cache[#cache+1] = { dn, dd } pdfld[tag] = dr textlayers[#textlayers+1] = nr + alphabetic[tag] = nr if specification.visible == v_start then videlayers[#videlayers+1] = nr else @@ -188,11 +190,16 @@ local function flushtextlayers() pdfflushobject(ci[1],ci[2]) end if textlayers and #textlayers > 0 then -- we can group them if needed, like: layout + local sortedlayers = { } + for k, v in table.sortedhash(alphabetic) do + sortedlayers[#sortedlayers+1] = v -- maybe do a proper numeric sort as well + end local d = pdfdictionary { OCGs = textlayers, D = pdfdictionary { Name = "Document", - Order = (viewerlayers.hasorder and textlayers) or nil, + -- Order = (viewerlayers.hasorder and textlayers) or nil, + Order = (viewerlayers.hasorder and sortedlayers) or nil, ON = videlayers, OFF = hidelayers, BaseState = pdf_on, diff --git a/tex/context/base/m-oldfun.mkiv b/tex/context/base/m-oldfun.mkiv new file mode 100644 index 000000000..1c5a1d29d --- /dev/null +++ b/tex/context/base/m-oldfun.mkiv @@ -0,0 +1,714 @@ +%D \module +%D [ file=m-oldfun, % was: supp-fun +%D version=1995.10.10, +%D title=\CONTEXT\ Support Macros, +%D subtitle=Fun Stuff, +%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. + +\unprotect + +%D Beware, these macros wil be replaced and at some point this +%D module will not be preloaded any more. + +%D This module implements some typographics tricks that can +%D be fun when designing document layouts. The examples use +%D macros that are typical to \CONTEXT, but non \CONTEXT\ +%D users can use the drop caps and first line treatment +%D macros without problems. This module will be extended +%D when the need for more of such tricks arises. + +\writestatus{loading}{ConTeXt Support Macros / Fun Stuff} + +%D \macros +%D {DroppedCaps, DroppedString, DroppedIndent, DroppedLines} +%D +%D \startbuffer +%D \DroppedCaps +%D {\color[green]} {SerifBold} +%D {\the\dimexpr2.2\baselineskip} {2pt} {\the\baselineskip} {2} +%D Let's start +%D \stopbuffer +%D +%D \getbuffer with dropped caps, those blown up first +%D characters of a paragraph. It's hard to implement a general +%D mechanism that suits all situations, but dropped caps are so +%D seldomly used that we can permit ourselves a rather user +%D unfriendly implementation. +%D +%D \typebuffer +%D +%D As we will see, there are 7 different settings involved. The +%D first argument takes a command that is used to do whatever +%D fancy things we want to do, but normally this one will be +%D empty. The second argument takes the font. Because we're +%D dealing with something very typographic, there is no real +%D reason to adopt complicated font switching schemes, a mere +%D name will do. Font encodings can bring no harm, because the +%D alphanumeric characters are nearly always located at their +%D natural position in the encoding vector. +%D +%D \startbuffer +%D \DroppedCaps +%D {\color[red]} {SerifBold} +%D {\the\baselineskip} {0pt} {0pt} {1} +%D This simple +%D \stopbuffer +%D +%D \getbuffer case shows us what happens when we apply minimal +%D values. Here we used: +%D +%D \typebuffer +%D +%D \startbuffer +%D \DroppedCaps +%D {\color[red]} {SerifBold} +%D {\the\dimexpr2\baselineskip} {0pt} {\the\baselineskip} {2} +%D Is this ugly +%D \stopbuffer +%D +%D \getbuffer example the third argument tells +%D this macro that we want a dropped capital scaled to the +%D baseline distance. The two zero point arguments are the +%D horizontal and vertical offsets and the last arguments +%D determines the hanging indentation. In this paragraph we +%D set the height to two times the baselinedistance and use +%D two hanging lines: +%D +%D \typebuffer +%D +%D Here, the first character is moved down one baseline. Here +%D we also see why the horizontal offset is important. The +%D first example (showing the~L) sets this to a few points and +%D also used a slightly larger height. +%D +%D Of course common users (typist) are not supposed to see this +%D kind of fuzzy definitions, but fortunately \TEX\ permits us +%D to hide them in macros. Using a macro also enables us to +%D garantee consistency throughout the document: +%D +%D \startbuffer +%D \def\MyDroppedCaps% +%D {\DroppedCaps +%D {\color[green]} {SerifBold} +%D {\the\dimexpr5\baselineskip} {3pt} {\the\dimexpr3\baselineskip} {4}} +%D +%D \MyDroppedCaps The implementation +%D \stopbuffer +%D +%D \typebuffer +%D +%D \getbuffer of the general macro is rather simple and only +%D depends on the arguments given and the dimensions of the +%D strut box. We explicitly load the font, which is no problem +%D because \TEX\ does not load a font twice. We could have +%D combined some arguments, like the height, vertical offset +%D and the number of lines, but the current implementation +%D proved to be the most flexible. One should be aware of the +%D fact that the offsets depend on the design of the glyphs +%D used. + +\let\DroppedIndent\!!zeropoint \def\DroppedLines{0} + +\def\DroppedString{ABCDEFGHIJKLMNOPQRSTUVWXYZ} + +\let\globaldropcaps\global % will be an option, but on by default + +\unexpanded\def\localdropcaps{\let\globaldropcaps\relax} + +\chardef\DroppedStatus = 0 % 0=done 1=starting 2=doing 3=error +\chardef\DropMode = 0 % 1 == marginhang + +\ifx\keeplinestogether\undefined + \let\keeplinestogether\gobbleoneargument +\fi + +\unexpanded\def\DroppedCaps#1#2#3#4#5#6#7% does not yet handle accented chars + {\defconvertedargument\asciia{#7}% + \defconvertedcommand \asciib{\DroppedString}% + \doifinstringelse\asciia\asciib + {\noindentation + \dontleavehmode + \checkindentation % redo this one + %\ifhmode\hskip-\parindent\fi % sensitive for context mechanism + \keeplinestogether{#6}% + \setbox0\hbox{\definedfont[#2 at #3]#1{#7}\hskip#4}% + \ifdim\dp0>\strutdp % one of those Q's , will be option + \setbox2\hbox{\raise\dp0\hbox{\lower\strutdp\copy0}}% + \ht2\ht0 + \dp0\strutdp + \setbox0\box2 + \fi + \setbox0\hbox + {\ifnum\DropMode=\plusone + \hskip-\wd0\wd0\zeropoint + \fi + \lower#5\box0}% + \ht0\strutht + \dp0\strutdp + \ifnum\DropMode=\plusone + \globaldropcaps\let\DroppedIndent\!!zeropoint + \globaldropcaps\edef\DroppedLines{\number\maxdimen}% + \globaldropcaps\chardef\DroppedStatus\plusthree + \else + \globaldropcaps\edef\DroppedIndent{\the\wd0}% + \globaldropcaps\edef\DroppedLines {\number#6}% + \globaldropcaps\chardef\DroppedStatus\plustwo + \globaldropcaps\hangindent\DroppedIndent + \globaldropcaps\hangafter-\DroppedLines +% \noindent + \noindentation + \checkindentation % redo this one + \hskip-\DroppedIndent + \fi + \vbox{\forgetall\box0}% + \nobreak + \let\next\ignorespaces} % Could be a one character word ! + {\globaldropcaps\let\DroppedIndent\!!zeropoint + \globaldropcaps\edef\DroppedLines{\number\maxdimen}% + \globaldropcaps\chardef\DroppedStatus\plusthree + \def\next{#7}}% + \let\globaldropcaps\global + \next} + +%D Before we go to the next topic, we summarize this command: +%D +%D \starttyping +%D \DroppedCaps +%D {command} {font} +%D {height} {hoffset} {voffset} {lines} +%D \stoptyping +%D +%D Sometimes you need to make sure that the global settings are +%D kept local, as in: +%D +% %D \startbuffer +% %D \defineparagraphs[SomePar][n=2,rule=on] +% %D \setupparagraphs [SomePar][1][width=.5\textwidth] +% %D \setupparagraphs [SomePar][2][width=.5\textwidth] +%D \startbuffer +%D \defineparagraphs[SomePar][n=2,rule=on] +%D \setupparagraphs [SomePar][1][width=.5\textwidth] +%D \setupparagraphs [SomePar][2][width=.5\textwidth] +%D +%D \startSomePar +%D \localdropcaps\NiceDroppedCaps{}{cmr12}{0pt}{2}Here we need +%D to explicitly keep the hanging indentation local, like it or +%D not. +%D \SomePar +%D \localdropcaps\NiceDroppedCaps{}{cmr12}{0pt}{2}Here we need +%D to explicitly keep the hanging indentation local, like it or +%D not. +%D \stopSomePar +%D \stopbuffer +%D +%D \typebuffer \getbuffer + +%D \macros +%D {AutoDroppedCaps, CheckDroppedCaps} +%D +%D {\em To be documented.} + +% example usage +% +% \def\bpar{\ifvmode\CheckDroppedCaps\fi} +% \def\epar{\ifhmode\par\fi\CheckDroppedCaps} + +\newcount\lastprevgraf +\newcount\droppedlines + +\unexpanded\def\CheckDroppedCaps + {\global\lastprevgraf\prevgraf} + +\unexpanded\def\AutoDroppedCaps % will be proper core stuff since it + {\globaldropcaps\chardef\DroppedStatus\plusone + \global\lastprevgraf\zerocount + \global\droppedlines\zerocount + \EveryPar{\doAutoDroppedCaps}} + +\let\AutoDroppedNext\relax + +\ifx\AutoDroppedCapsCommand\undefined + \unexpanded\def\AutoDroppedCapsCommand{\NiceDroppedCaps{}{SerifBold}{.125em}{3}} +\fi + +\unexpanded\def\doAutoDroppedCaps + {\ifcase\DroppedStatus % done + \let\next\relax + \or % starting + % \ifnum\lastprevgraf>0 % tricky, probably a wrong par + % \globaldropcaps\chardef\DroppedStatus=3 % and inhibits dropped + % \let\next\relax % caps after titles and more than once + % \else % so let's nill this rubishly code fragment + \let\next\AutoDroppedCapsCommand + % \fi % and hope for the best + \or % doing + \global\advance\droppedlines \lastprevgraf + \ifnum\droppedlines=\zerocount + \globaldropcaps\chardef\DroppedStatus\zerocount + \let\next\relax + \else\ifnum\droppedlines>\zerocount + \ifnum\droppedlines<\DroppedLines\relax + \globaldropcaps\hangindent\DroppedIndent + \globaldropcaps\hangafter-\DroppedLines + \globaldropcaps\advance\hangafter \droppedlines + \hskip-\parindent % brrr + \let\next\AutoDroppedNext + \else + \globaldropcaps\chardef\DroppedStatus\zerocount + \let\next\relax + \fi + \else + \globaldropcaps\chardef\DroppedStatus\zerocount + \let\next\relax + \fi\fi + \or % error + \globaldropcaps\chardef\DroppedStatus\zerocount + \let\next\relax + \fi + \next} + +%D \macros +%D {LineDroppedCaps, NiceDroppedCaps} +%D +%D To save definitions, we also provide: +%D +%D \starttyping +%D \LineDroppedCaps {command} {font} {hoffset} {lines} +%D \NiceDroppedCaps {command} {font} {hoffset} {lines} +%D \stoptyping +%D +%D The first command scales the font to the exact height, while +%D the second command scales the font to a nice 2.5 times the +%D line height, a value that gives a pleasant grayness. + +\unexpanded\def\DoLineDroppedCaps#1#2#3#4#5% compensation command font offset lines + {\scratchcounter#5% + \advance\scratchcounter \minusone + \scratchdimen\scratchcounter\baselineskip + \advance\scratchdimen #1% + \NormalizeFontHeight\DummyFont{W}\scratchdimen{#3}% + \DroppedCaps{#2}{#3}\TheNormalizedFontSize{#4} + {\scratchcounter\baselineskip}{#5}} + +\unexpanded\def\LineDroppedCaps% command font offset lines + {\DoLineDroppedCaps{\strutht}} + +\unexpanded\def\NiceDroppedCaps% command font offset lines + {\DoLineDroppedCaps{.5\baselineskip}} + +%D \macros +%D {TreatFirstLine} +%D +%D \startbuffer +%D \TreatFirstLine {\sc} {} {} {} +%D Instead of limiting its action to one token, the next macro +%D treats the whole first line. This paragraph was typeset by +%D saying: +%D \stopbuffer +%D +%D \getbuffer +%D +%D \typebuffer +%D +%D \startbuffer +%D \TreatFirstLine {\startcolor[red]\bf} {\stopcolor} {} {} +%D The combined color and font effect is also possible, +%D although one must be careful in using macros that accumulate +%D grouping, but the commands used here are pretty save in that +%D respect. +%D \stopbuffer +%D +%D \getbuffer +%D +%D \typebuffer +%D +%D Before we explain the third and fourth argument, we show the +%D implementation. Those who know a bit about the way \TEX\ +%D treats tokens, will probably see in one glance that this +%D alternative works all right for most text||only situations +%D in which there is enough text available for the first line, +%D but that more complicated things will blow. One has to live +%D with that. A workaround is rather trivial but obscures the +%D principles used. + +\unexpanded\def\TreatFirstLine#1#2#3#4% before, after, first, next + {\leavevmode + \bgroup + \forgetall + \bgroup + #1% + \setbox0\emptybox + \setbox2\emptybox + \def\grabfirstline##1 % + {\setbox2\hbox + {\ifvoid0 + {#3{\ignorespaces##1}}% + \else + \unhcopy0\ {#4{##1}}% + \fi}% + \ifdim\wd2=\zeropoint + \setbox0\emptybox + \setbox2\emptybox + \@EA\grabfirstline + \else\ifdim\wd2>\hsize + \hbox to \hsize{\strut\unhbox0}#2\egroup + \break##1\ + \egroup + \else + \setbox0\box2 + \@EAEAEA\grabfirstline + \fi\fi}% + \grabfirstline} + +%D \startbuffer +%D \gdef\FunnyCommand +%D {\getrandomfloat\FunnyR{0}{1}% +%D \getrandomfloat\FunnyG{0}{1}% +%D \getrandomfloat\FunnyB{0}{1}% +%D \definecolor[FunnyColor][r=\FunnyR,g=\FunnyG,b=\FunnyB]% +%D \color[FunnyColor]} +%D +%D %\TreatFirstLine {\bf} {} {\FunnyCommand} {\FunnyCommand} +%D The third and fourth argument can be used to gain special +%D effects on the individual words. Of course one needs ... +%D \stopbuffer +%D +%D \getbuffer +%D to know a bit more about the macro package used to get real +%D nice effects, but this example probably demonstrates the +%D principles well. +%D +%D \typebuffer +%D +%D Like in dropped caps case, one can hide such treatments in a +%D macro, like: +%D +%D \starttyping +%D \def\MyTreatFirstLine% +%D {\TreatFirstLine{\bf}{}{\FunnyCommand}{\FunnyCommand}} +%D \stoptyping + +%D \macros +%D {reshapebox} +%D +%D \startbuffer +%D \beginofshapebox +%D When using \CONTEXT, one can also apply this funny command +%D to whole lines by using the reshape mechanism. Describing +%D this interesting mechanism falls outside the scope of this +%D module, so we only show the trick. This is an example of +%D low level \CONTEXT\ functionality: it's all there, and it's +%D stable, but not entirely meant for novice users. +%D \endofshapebox +%D +%D \reshapebox{\FunnyCommand{\box\shapebox}} \flushshapebox +%D \stopbuffer +%D +%D \getbuffer +%D +%D \typebuffer +%D +%D This mechanism permits hyphenation and therefore gives +%D better results than the previously discussed macro +%D \type{\TreatFirstLine}. + +%D \macros +%D {TreatFirstCharacter} +%D +%D \startbuffer +%D \TreatFirstCharacter{\bf\color[green]} Just to be +%D \stopbuffer +%D +%D \getbuffer complete we also offer a very simple one +%D character alternative, that is not that hard to understand: + +\unexpanded\def\TreatFirstCharacter#1#2% command, character + {{#1{#2}}} + +%D A previous paragraph started with: +%D +%D \typebuffer + +%D \macros +%D {StackCharacters} +%D +%D The next hack deals with vertical stacking. + +\unexpanded\def\StackCharacters#1#2#3#4% sequence vsize vskip command + {\vbox #2 + {\forgetall + \baselineskip\zeropoint + \def\StackCharacter##1{#4{##1}\cr\noalign{#3}}% + \halign + {\hss##\hss&##\cr + \handletokens#1\with\StackCharacter\cr}}} + +%D \startbuffer +%D \StackCharacters{CONTEXT}{}{\vskip.2ex}{\FunnyCommand} +%D \stopbuffer +%D +%D Such a stack looks like: +%D +%D \startlinecorrection +%D \hbox to \hsize +%D {$\hss\bfd +%D \vcenter{\StackCharacters{TEX} {}{\vskip.2ex}{\FunnyCommand}}% +%D \hss +%D \vcenter{\StackCharacters{CON} {}{\vskip.2ex}{\FunnyCommand}} +%D \hss +%D \vcenter{\StackCharacters{TEXT} {}{\vskip.2ex}{\FunnyCommand}} +%D \hss +%D \vcenter{\StackCharacters{CONTEXT}{}{\vskip.2ex}{\FunnyCommand}} +%D \hss$} +%D \stoplinecorrection +%D +%D and is typeset by saying: +%D +%D \typebuffer +%D +%D An alternative would have been +%D +%D \starttyping +%D \StackCharacters {CONTEXT} {to 5cm} {\vfill} {\FunnyCommand} +%D \stoptyping + +%D \macros +%D {processtokens} +%D +%D At a lower level horizontal and vertical manipulations are +%D already supported by: +%D +%D \starttyping +%D \processtokens {begin} {between} {end} {space} {text} +%D \stoptyping +%D +%D \startbuffer[a] +%D \processtokens +%D {\hbox to .5\hsize\bgroup} {\hfill} +%D {\egroup} {\space} {LET'S HAVE} +%D \stopbuffer +%D +%D \startbuffer[b] +%D \processtokens +%D {\vbox\bgroup\raggedcenter\hsize1em} +%D {\vskip.25ex} {\egroup} {\strut} {FUN} +%D \stopbuffer +%D +%D This macro is able to typeset: +%D +%D \leavevmode\hbox to \hsize +%D {$\hfil\hfil +%D \vcenter{\bf\getbuffer[a]}% +%D \hfil +%D \vcenter{\bfd\getbuffer[b]}% +%D \hfil\hfil$} +%D +%D which was specified as: +%D +%D \typebuffer[a] +%D \typebuffer[b] + +%D \macros +%D {NormalizeFontHeight, NormalizeFontWidth, +%D TheNormalizedFontSize} +%D +%D Next we introduce some font manipulation macros. When we +%D want to typeset some text spread in a well defined area, it +%D can be considered bad practice to manipulate character and +%D word spacing. In such situations the next few macros can be +%D of help: +%D +%D \starttyping +%D \NormalizeFontHeight \name {sample text} {height} {font} +%D \NormalizeFontWidth \name {sample text} {width} {font} +%D \stoptyping +%D +%D These are implemented using an auxilliary macro: + +\unexpanded\def\NormalizeFontHeight{\NormalizeFontSize\ht} +\unexpanded\def\NormalizeFontWidth {\NormalizeFontSize\wd} + +\unexpanded\def\NormalizeFontSize#1#2#3#4#5% + {\bgroup + \dimen0=#4% #4 can be \ht0 or so + \setbox0\hbox{\definedfont[#5 at 5pt]#3}% 10pt + \ifdim\wd0>\zeropoint + \dimen2=#10 % #1 is \wd or \ht + \dimen4=\maxdimen % 10000pt + \divide\dimen4 \dimen2 + \divide\dimen0 1638 % 1000 + \dimen0=\number\dimen4\dimen0 + \divide \dimen0 \plustwo % ... + \xdef\TheNormalizedFontSize{\the\dimen0}% + \else + \dimen0\bodyfontsize + \fi + \normalexpanded{\egroup\def\noexpand#2{\definedfont[#5 at \the\dimen0]}}} + +%D Afterwards, we have access to the calculated size by: + +\let\TheNormalizedFontSize\!!zeropoint + +%D Extra: + +\unexpanded\def\WidthSpanningText#1#2#3% text width font + {\hbox{\NormalizeFontWidth\temp{#1}{#2}{#3}\temp\the\everydefinedfont#1}} + +%D Consider for instance: +%D +%D \startbuffer +%D \NormalizeFontHeight \tmp {X} {2\baselineskip} {cmr10} +%D +%D {\tmp To Be Or Not To Be} +%D \stopbuffer +%D +%D \typebuffer +%D +%D This shows up as (we also show the baselines): +%D +%D {\showbaselines\getbuffer} +%D +%D The horizontal counterpart is: +%D +%D \startbuffer +%D \NormalizeFontWidth \tmp {This Line Fits} {\hsize} {cmr10} +%D +%D \hbox{\tmp This Line Fits} +%D \stopbuffer +%D +%D \typebuffer +%D +%D The calculated font scale is avaliable in the macro +%D \type{\NormalizedFontSize}. +%D +%D \startlinecorrection +%D \ruledhbox{\getbuffer} +%D \stoplinecorrection +%D +%D One can of course combine these macros with the ones +%D described earlier, like in: +%D +%D \starttyping +%D \NormalizeFontHeight {text} \DroppedFont {2\baselineskip} {cmbx12} +%D +%D \def\NicelyDroppedCaps +%D {\DroppedCaps +%D {\color[green]} +%D {\DroppedFont} +%D {2pt} +%D {\baselineskip} +%D {2}} +%D \stoptyping +%D +%D It's up to the reader to test this one. + +\unexpanded\def\FirstNCharacters#1#2% \FirstNCharacters{3}{fr{\"o}beln} + {\bgroup + \scratchcounter\zerocount + \def\docommand##1% + {\ifnum\scratchcounter=#1\else + ##1\relax % catches ##1 = \"e and alike + \advance\scratchcounter\plusone + \fi} + \handletokens#2\with\docommand + \egroup} + +%D \macros +%D {FittingText} +%D +%D First used in Pascal (demo-bbv): +%D +%D \startbuffer +%D \ruledvbox{\FittingText{3cm}{1cm}{Serif}{24pt}{1pt}{1} +%D {\veryraggedright +%D \hangindent1em\hangafter1\relax +%D \begstrut \dorecurse{8}{Bram Marta }\unskip \endstrut}} +%D +%D \ruledvbox{\FittingText{3cm}{1cm}{Serif}{24pt}{1pt}{1} +%D {\raggedleft\begstrut Bram\\Marta \unskip\endstrut}} +%D \stopbuffer +%D +%D \typebuffer +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection + +% #1 width #2 height #3 font #4 size #5 step #6 interlinie #7 text + +\unexpanded\def\FittingText#1#2#3#4#5#6#7% + {\bgroup + \forgetall + \dontcomplain + \setuptolerance[\v!verytolerant]% == \tolerance4500 + \hsize#1% + \def\\{\softbreak}% + \!!heighta#4% + \!!heightb#2% + \doloop + {\ifdim\!!heighta>\onepoint + \expanded{\definefont[\s!dummy][#3 at \the\!!heighta][\c!interlinespace=#6]}% + \getvalue\s!dummy + \setbox\scratchbox\vbox{#7\endgraf}% + \ifdim\ht\scratchbox>\!!heightb + \advance\!!heighta-#5% + \else + \beginshapebox + \unvcopy\scratchbox + \endshapebox + \global\dimen1\hsize + \reshapebox + {\setbox\shapebox\hbox{\unhbox\shapebox}% + \ifdim\wd\shapebox>\dimen1 + \global\dimen1\wd\shapebox + \fi}% + \ifdim\dimen1>\hsize + \advance\!!heighta-#5% + \else + \exitloop + \fi + \fi + \else + \exitloop + \fi}% + %\writestatus{\strippedcsname\FittingText}{height: \the\!!heighta}% + \unvbox\scratchbox + \egroup} + +% \font width gap font spec text + +\unexpanded\def\NormalizeFontWidthSpread#1#2#3#4#5#6% + {\global\setfalse\NFSpread + \scratchdimen#3% + \scratchdimen-.5\scratchdimen + \advance\scratchdimen#2\relax + \NormalizeFontWidth + #1% + {\def\+{\global\settrue\NFSpread\gobbleuntil\relax}% + \def\\{\gobbleuntil\relax}% newline + \setupspacing + #6\relax}% + {\scratchdimen}% + {#4}% + \ifconditional\NFSpread + % de gap valt in de binding + \else + \definefont[\strippedcsname#1][#4 #5]% + \fi} + +\unexpanded\def\SpreadGapText#1#2% + {{\def\+{\kern#1}#2}} + +\unexpanded\def\GapText#1#2#3#4#5% width distance font spec title + {\bgroup + \NormalizeFontWidthSpread\DummyFont{#1}{#2}{#3}{#4}{#5}% + \DummyFont\setupspacing\SpreadGapText{#2}{#5}\endgraf + \egroup} + +\protect \endinput diff --git a/tex/context/base/m-oldnum.mkiv b/tex/context/base/m-oldnum.mkiv new file mode 100644 index 000000000..efc0af472 --- /dev/null +++ b/tex/context/base/m-oldnum.mkiv @@ -0,0 +1,416 @@ +%D \module +%D [ file=m-oldnum, % was: supp-num +%D version=1998.05.15, +%D title=\CONTEXT\ Support Macros, +%D subtitle=Numbers, +%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. + +% See end for transition to mkiv. + +\writestatus{loading}{ConTeXt Support Macros / Numbers} + +\unprotect + +%D \macros +%D {digits, setdigitmode, setdigitsign} +%D +%D Depending on the digit mode the command \type {\digits} +%D normalizes number patterns depending on the language set. +%D +%D \starttyping +%D This will never be a \digits{1.000.000} seller. +%D \stoptyping +%D +%D or +%D +%D \starttyping +%D I will never grow longer than \digits 1.86 \Meter. +%D \stoptyping +%D +%D The different modes are shown in: +%D +%D \startbuffer +%D \setdigitmode 1 \digits 12.345,90 \digits 12.345.000 \digits 1,23 +%D \setdigitmode 2 \digits 12.345,90 \digits 12.345.000 \digits 1,23 +%D \setdigitmode 3 \digits 12.345,90 \digits 12.345.000 \digits 1,23 +%D \setdigitmode 4 \digits 12.345,90 \digits 12.345.000 \digits 1,23 +%D \setdigitmode 5 \digits 12.345,90 \digits 12.345.000 \digits 1,23 +%D \setdigitmode 6 \digits 12.345,90 \digits 12.345.000 \digits 1,23 +%D \stopbuffer +%D +%D \typebuffer +% +% This is typset as: +% +% \startlines +% \getbuffer +% \stoplines +%D +%D The sign can be typeset as is or within the space of a +%D digit. +%D +%D \startbuffer +%D \setdigitsign 0 \digits +12.345,90 +%D \setdigitsign 1 \digits +12.345,90 +%D \setdigitsign 2 \digits +12.345,90 +%D \setdigitsign 3 \digits +12.345,90 +%D \stopbuffer +%D +%D \typebuffer +%D +% This is typset as: +% +% \startlines +% \getbuffer +% \stoplines + +\chardef\digitoutputmode=1 % 0..6 +\chardef\digitsignmode =0 % 0..3 + +\def\setdigitmode{\chardef\digitoutputmode} +\def\setdigitsign{\chardef\digitsignmode} + +%D The digit modes are: +%D +%D \startitemize[packed] +%D \item periods \& comma +%D \item commas \& period +%D \item thinmuskips \& comma +%D \item thinmuskips \& period +%D \item thickmuskips \& comma +%D \item thickmuskips \& period +%D \stopitemize + +\let\collecteddigits \empty \chardef\digitinputmode =1 +\let\saveddigits \empty \chardef\skipdigit =0 +\let\savedpowerdigits\empty \chardef\powerdigits =0 + +%D The first stage of the \type {\digit} macro takes care of +%D the grouped call, the other branch handles the fuzzy +%D delimited calls. + +\ifdefined\mbox \else \let\mbox\hbox \fi + +\unexpanded\def\digits + {\bgroup + \let~@% + \doifnextbgroupelse\dodigits{\doifnextcharelse\normalmathshift\domathdigits\grabdigit}} + +\def\dodigits#1% + {\grabdigit#1\relax} + +\def\domathdigits$#1$% + {\mbox{\grabdigit#1\relax}} % adding $ $ goes wrong in tabulate + +\def\grabdigit + {\futurelet\next\scandigit} + +%D Watch the test for \type {\nextobeyedline}, because the +%D endofline token can be \type {\def'd}, not \type {\let}'d, +%D we need to do an indirect test (see \type {verb-ini.tex}) +%D for details. (This probably needs an update.) + +\ifx\normalmathshift\undefined \let\normalmathshift=$ \fi + +\def\scandigit + {\ifx\next\blankspace + \let\next\handledigits + \else\ifx\next\nextobeyedline % the indirect one + \let\next\handledigits + \else\ifx\next\bgroup + \let\next\handledigits + \else\ifx\next\egroup + \let\next\handledigits + \else\ifx\next\normalmathshift + \let\next\handledigits + \else + \let\next\collectdigit + \fi\fi\fi\fi\fi + \next} + +%D We store the power||of||ten (to be signaled by \type {^}, +%D \type {e} or~\type {E}) in a seperate macro so that we can +%D typeset it in superscript. The space placeholders are +%D replaced by a \type {@}. + +\def\savedigit#1#2% + {\edef#1{#1\saveddigits#2}\let\saveddigits\empty} + +\long\def\collectdigit#1% + {\ifx#1~% + \savedigit\collecteddigits @% + \else\if#1_% tricky as can be several catcodes ... will become lua code anyway + \savedigit\collecteddigits @% + \else\if\noexpand#1\relax + \let\grabdigit\handledigits + \else\ifcase\powerdigits + \if#1E% + \chardef\powerdigits\plusone + \else\if#1e% + \chardef\powerdigits\plusone + \else\if#1^% + \chardef\powerdigits\plusone + \else + \savedigit\collecteddigits#1% + %\doifnumberelse{#1} + % {\savedigit\collecteddigits#1} + % {\def\saveddigits{#1}}% + \fi\fi\fi + \else + \savedigit\savedpowerdigits#1% + %\doifnumberelse{#1} + % {\savedigit\savedpowerdigits#1} + % {\def\saveddigits{#1}}% + \fi\fi\fi\fi + \grabdigit} + +\let\handlemathdigits\firstofoneargument +\let\handletextdigits\mathematics + +\def\handledigits + {%\ifcase\powerdigits + % \edef\collecteddigits{\collecteddigits\saveddigits}% + %\else + % \edef\savedpowerdigits{\savedpowerdigits\saveddigits}% + %\fi + \ifmmode + \handlemathdigits{\dohandledigits}% + \else + \dontleavehmode\hbox{\handletextdigits{\dohandledigits}}% + \fi + \egroup} + +%D Although we could do with one pass, a second pass for +%D handling the stored sequence is more readable. + +\ifnum\texengine=\luatexengine + + \def\dohandledigits + {\mathcode`\,="002C \mathcode`\.="002E % pretty hard coded + \expandafter\handletokens\collecteddigits\with\scandigits + \ifcase\powerdigits\else\digitpowerseparator^{\savedpowerdigits}\fi} + + \chardef\mathaxisfontid\zerocount + +\else + + \def\dohandledigits + {\mathcode`\,="013B \mathcode`\.="013A % pretty hard coded + \expandafter\handletokens\collecteddigits\with\scandigits + \ifcase\powerdigits\else\digitpowerseparator^{\savedpowerdigits}\fi} + + \chardef\mathaxisfontid\plustwo + +\fi + +\def\doscandigit#1% + {\ifcase\skipdigit\@EA\hbox\else\@EA\hphantom\fi\bgroup + \mathematics % brr, needed because of stored punctuation + {\ifnum\digitinputmode=#1\relax + \ifcase\digitoutputmode + \or .% + \or ,% + \or \mskip\thinmuskip + \or \mskip\thinmuskip + \or \mskip\thickmuskip + \or \mskip\thickmuskip + \fi + \else + \ifodd\digitoutputmode,\else.\fi + \fi}% + \egroup} + +%D The signs can be made smaller and sqeezed into the width +%D of a digit. Watch the \type {\mathaxisheight} trickery (this +%D font related register stored the math axis). + +% 0,= +% 0,== second = results in delta(00,=) +% 0,- is invalid, should be = +% 0,-- is invalid, should be == + +\def\digitzeroamount + {\digitsgn\zeroamount + \def\digitzeroamount + {\hphantom + {00\setbox\scratchbox\hbox{$\zeroamount$}% + \hskip-\wd\scratchbox}% + \let\digitzeroamount\empty}} + +\def\scandigits#1% + {\if#1.\digitsep1\else + \if#1,\digitsep2\else + \if#1@\digitnop \else + \if#1_\digitnop \else + \if#1/\digitsgn{\hphantom{+}}\chardef\skipdigit0\else + \if#1-\ifcase\skipdigit\digitsgn-\else + \box\digitsepbox\digitzeroamount \fi\chardef\skipdigit0\else + \if#1+\digitsgn+\chardef\skipdigit0\else + \if#1=\box\digitsepbox\digitzeroamount \chardef\skipdigit0\else + \if#1s\digitsgn{\hphantom{\positive}}\chardef\skipdigit0\else + \if#1p\digitsgn\positive\chardef\skipdigit0\else + \if#1m\digitsgn\negative\chardef\skipdigit0\else + \if#1n\digitsgn\negative\chardef\skipdigit0\else + \box\digitsepbox #1\chardef\skipdigit0\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} + +\newbox\digitsepbox \chardef\autodigitmode=1 + +\def\digitsep#1% + {\ifcase\autodigitmode + \doscandigit#1% + \else + \setbox\digitsepbox\hbox{\doscandigit#1}% + \fi + \chardef\skipdigit0\relax} + +% strange, does not work +% +% \def\digitnop +% {\hphantom{\box\digitsepbox}% +% \hphantom{0}\chardef\skipdigit1\relax} +% +% while this works + +\def\digitnop + {\hbox{\hphantom{\box\digitsepbox}}% + \hphantom{0}\chardef\skipdigit1\relax} + +% but this doesn't +% +% \def\digitnop +% {\hphantom{\box\digitsepbox0}% +% \chardef\skipdigit1\relax} + +\def\digitsgn#1% + {\ifcase\digitsignmode#1\else + \hbox + {\setbox\scratchbox\hbox{0}% + \scratchdimen\mathaxisheight\textfont\mathaxisfontid + \def\digitsgn##1##2% + {\advance\scratchdimen-\mathaxisheight##1\mathaxisfontid + \raise\scratchdimen + \hbox to \wd\scratchbox{\hss$##2#1$\hss}}% + \ifcase\digitsignmode\or + \digitsgn\textfont \textstyle \or + \digitsgn\scriptfont \scriptstyle \or + \digitsgn\scriptscriptfont\scriptscriptstyle\fi}% + \fi} + +\ifx\undefined\zeroamount \def\zeroamount{-} \fi +\ifx\undefined\positive \def\positive {+} \fi +\ifx\undefined\negative \def\negative {-} \fi + +%D The digit parser handles a bunch of special characters as +%D well as different formats. We strongly suggest you to use +%D the grouped call. +%D +%D \starttabulate[|l|l|l|] +%D \NC \type{.} \NC , . \NC comma or period \NC \NR +%D \NC \type{,} \NC , . \NC comma or period \NC \NR +%D \NC \type{@} \NC \NC invisible space \NC \NR +%D \NC \type{_} \NC \NC invisible space \NC \NR +%D \NC \type{/} \NC \NC invisible sign \NC \NR +%D \NC \type{-} \NC $-$ \NC minus sign \NC \NR +%D \NC \type{+} \NC $+$ \NC plus sign \NC \NR +%D \NC \type{s} \NC \NC invisible high sign \NC \NR +%D \NC \type{p} \NC $\positive$ \NC high plus sign \NC \NR +%D \NC \type{m} \NC $\negative$ \NC high minus sign \NC \NR +%D \NC \type{n} \NC $\negative$ \NC high minus (negative) sign \NC \NR +%D \NC \type{=} \NC $\zeroamount$ \NC zero padding \NC \NR +%D \stoptabulate +%D +%D These triggers are used in the following examples. +%D +%D \startbuffer +%D \digits 12 +%D \digits{~~~.~~~.~~~.68.712,34} +%D \digits ~~~.~~~.~~~.68.712,34 +%D \digits ___.___.111.68.712,34 +%D \digits 111.111.111.68.712,34 +%D \digits 12.345,90 +%D \digits 12.345.000 +%D \digits 12,34 +%D \digits{392.857.230.68.712,34} +%D {\digits1234} +%D \digits{1234} +%D \digits 1234\relax +%D $\digits 123.222,00$ +%D \digits 123.222,00 +%D \digits 123.222,== +%D \digits 123.222,00^10 +%D \digits 123.222,00e10 +%D \digits /123.222,00e-12 +%D \digits -123.222,00e-12 +%D \digits +123.222,00e-12 +%D \digits n123.222,00e-12 +%D \digits s123.222,00e-12 +%D \digits p123.222,00e-12 +%D \stopbuffer +%D +%D \typebuffer +% +% \startlines +% \getbuffer +% \stoplines + +%D \macros +%D {Digits} +%D +%D We also permit: + +\let\Digits\digits + +%D These macros are complicated by the fact that we also +%D have to support cases like: +%D +%D \starttyping +%D {\digits1234} +%D \digits{1234} +%D \digits 1234\whatever +%D $\digits 123.222,00$ +%D \digits 123.222,00. +%D \stoptyping +%D +%D The latter case shows us that trailing non digits are to +%D be passed untreated. +%D +%D Another interesting case is: +%D +%D \starttyping +%D \digits 123.222,00^10 +%D \stoptyping +%D +%D The separator is defined as: + +% \def\digitpowerseparator% +% {\cdot10} % {\times10} + +\def\digitpowerseparator + {\ifx\collecteddigits\empty\else\cdot\fi10} + +%D \macros +%D {digittemplate} +%D +%D Users can specify the way they enter those digits by saying +%D something like: +%D +%D \starttyping +%D \digittemplate 12.000.000,00 % \digittemplate ., +%D \stoptyping + +\def\digittemplate #1 % + {\chardef\digitinputmode\zerocount + \handletokens#1\with\scandigittemplate} + +\def\scandigittemplate#1% + {\if #1.\ifcase\digitinputmode\chardef\digitinputmode\plusone \fi% period + \else\if#1,\ifcase\digitinputmode\chardef\digitinputmode\plustwo \fi% comma + \fi\fi} + +\protect \endinput diff --git a/tex/context/base/mult-dim.mkvi b/tex/context/base/mult-dim.mkvi index 0889b411e..bad7af713 100644 --- a/tex/context/base/mult-dim.mkvi +++ b/tex/context/base/mult-dim.mkvi @@ -35,6 +35,7 @@ \installcorenamespace{dimensionnormal} \setvalue{\??dimensionnormal \v!none }#value#dimension#small#medium#big{#dimension\zeropoint} +\setvalue{\??dimensionnormal \empty }#value#dimension#small#medium#big{#dimension\zeropoint} \setvalue{\??dimensionnormal \v!small }#value#dimension#small#medium#big{#dimension=#small\relax} \setvalue{\??dimensionnormal \v!medium}#value#dimension#small#medium#big{#dimension=#medium\relax} \setvalue{\??dimensionnormal \v!big }#value#dimension#small#medium#big{#dimension=#big\relax} diff --git a/tex/context/base/node-fin.lua b/tex/context/base/node-fin.lua index dadbf80d3..84032c22d 100644 --- a/tex/context/base/node-fin.lua +++ b/tex/context/base/node-fin.lua @@ -699,26 +699,26 @@ local function stacker(namespace,attribute,head,default) -- no triggering, no in end elseif id == hlist_code or id == vlist_code then local content = current.list - if content then - if nslistwise then - local a = has_attribute(current,attribute) - if a and attrib ~= a and nslistwise[a] then -- viewerlayer - local p = attrib - attrib, done = a, true - head = insert_node_before(head,current,copy_node(nsdata[a])) - current.list = stacker(namespace,attribute,content,attrib) - head, current = insert_node_after(head,current,copy_node(nsnone)) - attrib = p - else - local ok = false - current.list, ok = stacker(namespace,attribute,content,attrib) - done = done or ok - end + if not content then + -- skip + elseif nslistwise then + local a = has_attribute(current,attribute) + if a and attrib ~= a and nslistwise[a] then -- viewerlayer + local p = attrib + attrib, done = a, true + head = insert_node_before(head,current,copy_node(nsdata[a])) + current.list = stacker(namespace,attribute,content,attrib) + head, current = insert_node_after(head,current,copy_node(nsnone)) + attrib = p else local ok = false - current.list, ok = stacker(namespace,attribute,content,default) + current.list, ok = stacker(namespace,attribute,content,attrib) done = done or ok end + else + local ok = false + current.list, ok = stacker(namespace,attribute,content,default) + done = done or ok end end previous = current diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv index 57806b6f2..0afbe313b 100644 --- a/tex/context/base/spac-ali.mkiv +++ b/tex/context/base/spac-ali.mkiv @@ -651,6 +651,10 @@ \let\forgetragged \spac_align_set_horizontal_none +\appendtoks + \spac_align_set_horizontal_none +\to \everyforgetall + % Box commands. \unexpanded\def\ibox#1#2#3% diff --git a/tex/context/base/spac-def.mkiv b/tex/context/base/spac-def.mkiv index 4cd7b1d1c..ea537aea7 100644 --- a/tex/context/base/spac-def.mkiv +++ b/tex/context/base/spac-def.mkiv @@ -13,47 +13,13 @@ \writestatus{loading}{ConTeXt Spacing Macros / Definitions} -% todo: move resetters to other modules +% Ideally these definitions should be moved to where they first appear and +% this will happen at some point. \unprotect -\unexpanded\def\forgeteverypar - {\everypar{\the\neverypar}} - -% worth trying: -% -% \unexpanded\def\forgeteverypar -% {\everypar\neverypar} - -\unexpanded\def\forgetparskip - {\s_spac_whitespace_parskip\zeropoint - \parskip\zeropoint - \let\v_spac_whitespace_current\v!none} - -\unexpanded\def\forgetbothskips - {\leftskip\zeropoint - \rightskip\zeropoint - \relax} - -\unexpanded\def\forgethorizontalstretch - {\emergencystretch\zeropoint} - -\unexpanded\def\forgetverticalstretch - {\spacing\plusone} - -\newif\ifforgotten % rather good signal for inner - -% This will become better: several resetters that do all in once as currently there is -% redundant code. - -\appendtoks \forgottentrue \to \everyforgetall -\appendtoks \forgetragged \to \everyforgetall -\appendtoks \forgetparskip \to \everyforgetall -\appendtoks \forgetparindent \to \everyforgetall -\appendtoks \forgetbothskips \to \everyforgetall -\appendtoks \forgethorizontalstretch \to \everyforgetall % needed in pagebody -\appendtoks \forgetverticalstretch \to \everyforgetall % needed in otr -\appendtoks \everypar\emptytoks \to \everyforgetall % indeed! +% maybe \everysynchronizeglobalspacing +% maybe \everysynchronizelocalspacing \appendtoks \forgetverticalstretch \to \everybodyfont \appendtoks \presetnormallineheight \to \everybodyfont @@ -67,26 +33,17 @@ \appendtoks \synchronizespacecodes \to \everybodyfont % not needed, frozen factors \appendtoks \setrelativeinterlinespace \to \everybodyfont +% why exception + \appendtoks \updateraggedskips \to \everyfontswitch % under test -\prependtoks \let\par\normalpar \to \everybeforepagebody % see \fillinline (was endgraf) -\appendtoks \synchronizespacecodes \to \everydefinedfont % not needed, frozen factors -\setupwhitespace - [\v!none] +% maybe more -\indenting - [\v!never] +\prependtoks \let\par\normalpar \to \everybeforepagebody % see \fillinline (was endgraf) -\setupindenting - [\v!none] +% needs checking: -\setupblank - [\v!big] % alternatively [\v!standard] - -\defineblank[\v!default] [\v!big] % todo: needs to adapt to \setupblank -\defineblank[\v!before] [\v!default] % but we need to avoid circular references -\defineblank[\v!inbetween][\v!default] % then -\defineblank[\v!after] [\v!before] +\appendtoks \synchronizespacecodes \to \everydefinedfont % not needed, frozen factors \setupinterlinespace [\c!minheight=\zeropoint, % only special purpose @@ -99,12 +56,8 @@ \c!line=2.8\exheight, \c!stretch=\zerocount] -\setupnarrower - [\c!before=\endgraf, - \c!after=\endgraf, - \c!left=1.5\emwidth, - \c!right=1.5\emwidth, - \c!middle=1.5\emwidth] +\setupblank + [\v!big] \setuptolerance [\v!horizontal,\v!verystrict] @@ -119,4 +72,10 @@ \setupspacing [\v!packed] +\indenting + [\v!never] + +\setupindenting + [\v!none] + \protect \endinput diff --git a/tex/context/base/spac-grd.mkiv b/tex/context/base/spac-grd.mkiv index 487521f6c..cf350fdb6 100644 --- a/tex/context/base/spac-grd.mkiv +++ b/tex/context/base/spac-grd.mkiv @@ -15,37 +15,38 @@ \writestatus{loading}{ConTeXt Spacing Macros / Grid Snapping} -% buff-ver.mkiv: halfline spacing -% strc-mat.mkiv: configure math grid (new code needed) -% page-one.mkiv: to be checked -% page-mul.mkiv: to be checked and redone -% page-sid.mkiv: to be checked -% page-set.mkiv: to be checked -% strc-not.mkiv: to be checked -% strc-ren.mkiv: to be checked -% strc-flt.mkiv: to be checked (captions, probably top/bottom) -% core-mis.mkiv: to be checked (placement, probbaly harmless) - \unprotect -%D Helpers: +%D A rather crappy macro that we need to avoid and as such it will probably +%D disappear: + +\installcorenamespace{lastnodepusher} \let\poplastnode\relax -\def\pushlastnode - {\ifdim\lastskip=\zeropoint - \ifnum\lastpenalty=\zerocount - \ifnum\lastkern=\zerocount - \let\poplastnode\relax - \else - \edef\poplastnode{\kern\the\lastkern\relax}\kern-\lastkern % untested - \fi +\unexpanded\def\pushlastnode + {\csname\??lastnodepusher + \ifcsname\??lastnodepusher\the\lastnodetype\endcsname + \the\lastnodetype \else - \edef\poplastnode{\penalty\the\lastpenalty\relax}\nobreak % untested + \s!unknown \fi - \else - \edef\poplastnode{\vskip\the\lastskip\relax}\vskip-\lastskip % \removelastskip - \fi} + \endcsname} + +\setvalue{\??lastnodepusher\number\kernnodecode}% + {\unexpanded\edef\poplastnode{\kern\the\lastkern\relax}% + \kern-\lastkern} + +\setvalue{\??lastnodepusher\number\gluenodecode}% + {\unexpanded\edef\poplastnode{\vskip\the\lastskip\relax}% + \vskip-\lastskip} + +\setvalue{\??lastnodepusher\number\penaltynodecode}% + {\unexpanded\edef\poplastnode{\penalty\the\lastpenalty\relax}% + \nobreak} + +\setvalue{\??lastnodepusher\s!unknown}% + {\let\poplastnode\relax} %D Moved from supp-box: @@ -133,6 +134,8 @@ % \startlinecorrection \framed{xxx} \stoplinecorrection % \input ward \par +% to be redone: + \unexpanded\def\dotopbaselinecorrection{\expandafter\blank\expandafter[\the\d_spac_lines_correction_before]} \unexpanded\def\dobotbaselinecorrection{\expandafter\blank\expandafter[\the\d_spac_lines_correction_after ]} diff --git a/tex/context/base/spac-hor.mkiv b/tex/context/base/spac-hor.mkiv index 47665e8b5..49187a6ad 100644 --- a/tex/context/base/spac-hor.mkiv +++ b/tex/context/base/spac-hor.mkiv @@ -34,7 +34,7 @@ \unexpanded\def\setupindenting {\doifnextoptionalelse\spac_indentation_setup_options\spac_indentation_setup_size} -\def\spac_indentation_setup_size +\unexpanded\def\spac_indentation_setup_size {\assigndimension\v_spac_indentation_current\d_spac_indentation_par{1\emwidth}{1.5\emwidth}{2\emwidth}} \let\synchronizeindenting\spac_indentation_setup_size @@ -286,6 +286,17 @@ \parindent\zeropoint \let\v_spac_indentation_current\v!none} +\appendtoks + \forgetparindent +\to \everyforgetall + +\unexpanded\def\forgethorizontalstretch + {\emergencystretch\zeropoint} + +\appendtoks + \forgethorizontalstretch +\to \everyforgetall % needed in pagebody + %D Helper: \unexpanded\def\softbreak @@ -479,8 +490,6 @@ \unexpanded\def\tfskip {\begingroup\tf\hskip\emwidth\endgroup} \unexpanded\def\dotfskip#1{\begingroup\tf\hskip #1\endgroup} % used elsewhere -% needs a proper \definenarrower or installnarrower -% % maybe we should hash the analysis \installcorenamespace{narrower} @@ -617,6 +626,24 @@ \unexpanded\def\doadaptleftskip #1{\dosetleftskipadaption {#1}\advance\leftskip \leftskipadaption } \unexpanded\def\doadaptrightskip#1{\dosetrightskipadaption{#1}\advance\rightskip\rightskipadaption} +\unexpanded\def\forgetbothskips + {\leftskip\zeropoint + \rightskip\zeropoint + \relax} + +\appendtoks + \forgetbothskips +\to \everyforgetall + +\unexpanded\def\forgetparskip + {\s_spac_whitespace_parskip\zeropoint + \parskip\zeropoint + \let\v_spac_whitespace_current\v!none} + +\appendtoks + \forgetparskip +\to \everyforgetall + %D Tolerance (can also be set with align): \installcorenamespace{tolerancemethods} diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv index 66d55a57a..e404dc9ef 100644 --- a/tex/context/base/spac-ver.mkiv +++ b/tex/context/base/spac-ver.mkiv @@ -414,6 +414,10 @@ \parskip\zeropoint \let\v_spac_whitespace_current\v!none} +\appendtoks + \forgetparskip +\to \everyforgetall + % \installwhitespacemethod \s!unknown {\s_spac_whitespace_parskip\commalistelement\relax} % % \def\spac_whitespace_setup_method#1% @@ -422,6 +426,9 @@ \unexpanded\def\nowhitespace{\vspacing[\v!nowhite]} \unexpanded\def\whitespace {\vspacing[\v!white]} +\setupwhitespace + [\v!none] + % Packed: % todo: when packed blocks blank, we need to enable forced @@ -748,6 +755,13 @@ \setnormalbaselines \setstrut} +\unexpanded\def\forgetverticalstretch % \forgetspacing + {\spacing\plusone} + +\appendtoks + \forgetverticalstretch +\to \everyforgetall % needed in otr + %D Sometimes one needs to freeze the interlinespacing %D %D \starttyping @@ -885,7 +899,7 @@ \def\spac_struts_set_vide {\setbox\strutbox\hbox - {\hbox to \zeropoint + {\spac_struts_vide_hbox to \zeropoint {% \hss % new, will be option \vrule \!!width \strutwidth @@ -893,6 +907,8 @@ \!!depth \strutdp \hss}}} +\let\spac_struts_vide_hbox\hbox % overloaded in trac-vis.mkiv + %D The dimen \type {\struttotal} holds the exact size of the %D strut; occasionally a one scaled point difference can show %D up with the lineheight. @@ -1728,17 +1744,6 @@ \let\synchronizevspacing\setupvspacing_nop -% used both - -\unexpanded\def\inhibitblank - {\vspacing[\v!disable]} % can be made faster - -\let\doinhibitblank\inhibitblank % keep this command, used in styles - -\let\setupblank \setupvspacing -\let\blank \vspacing -\let\synchronizeblank\synchronizevspacing - % category:4 is default % this interface might change (into an \install, buw we will then keep this one hidden) @@ -1788,12 +1793,27 @@ \dorecurse{10} % todo: other values < 4000 {\normalexpanded{\definevspacing[\v!samepage-\recurselevel][penalty:\the\numexpr4000+250*\recurselevel\relax]}} +\definevspacing[\v!default] [\v!big] % todo: needs to adapt to \setupblank +\definevspacing[\v!before] [\v!default] % but we need to avoid circular references +\definevspacing[\v!inbetween][\v!default] % then +\definevspacing[\v!after] [\v!before] + +\setupvspacing + [\v!big] % alternatively [\v!standard] + %D Maybe at some point we will differ between \type {\vspacing} and %D \type {\blank} (we needed the first one while playing with the %D new code). -\let\blank \vspacing +\unexpanded\def\inhibitblank + {\vspacing[\v!disable]} % can be made faster + +\let\doinhibitblank\inhibitblank % keep this command, used in styles + \let\defineblank \definevspacing +\let\setupblank \setupvspacing +\let\blank \vspacing +\let\synchronizeblank \synchronizevspacing \let\defineblankmethod\definevspacingamount %D The following command is for Wolfgang. It has to be used with diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 08010c8b9..d72c1e335 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 8b8f0f3dc..fd57767c1 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index aa5aa4d20..5240b43d4 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -74,7 +74,7 @@ return { { filename = "syst-aux", marktype = "mkiv", - status = "okay", + status = "unknown", comment = "will be better protected" }, { @@ -283,12 +283,12 @@ return { -- status = "unknown", -- comment = "will become a module (and part will stay in the core)", -- }, - { - filename = "supp-fun", - marktype = "mkiv", - status = "unknown", - comment = "will be integrated elsewhere", - }, + -- { + -- filename = "supp-fun", + -- marktype = "mkiv", + -- status = "unknown", + -- comment = "will be integrated elsewhere", + -- }, { filename = "supp-ran", marktype = "mkiv", @@ -300,12 +300,12 @@ return { status = "okay", comment = "will be moved to the math-* modules", }, - { - filename = "supp-num", - marktype = "mkiv", - status = "obsolete", - comment = "replaced by units", - }, + -- { + -- filename = "supp-num", + -- marktype = "mkiv", + -- status = "obsolete", + -- comment = "replaced by units", + -- }, { filename = "typo-ini", marktype = "mkiv", @@ -595,7 +595,7 @@ return { { filename = "spac-lin", marktype = "mkiv", - status = "unknown", + status = "okay", comment = "could be improved if needed" }, { @@ -618,6 +618,7 @@ return { filename = "spac-grd", marktype = "mkiv", status = "unknown", + comment = "needs thinking and redoing", }, { filename = "anch-pos", @@ -1074,6 +1075,11 @@ return { marktype = "mkvi", status = "okay", }, + { + filename = "font-aux", + marktype = "mkvi", + status = "okay", + }, { filename = "lxml-css", marktype = "mkiv", diff --git a/tex/context/base/supp-fun.mkiv b/tex/context/base/supp-fun.mkiv deleted file mode 100644 index 33bee0306..000000000 --- a/tex/context/base/supp-fun.mkiv +++ /dev/null @@ -1,716 +0,0 @@ -%D \module -%D [ file=supp-fun, -%D version=1995.10.10, -%D title=\CONTEXT\ Support Macros, -%D subtitle=Fun Stuff, -%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. - -\unprotect - -%D Beware, these macros wil be replaced and at some point this -%D module will not be preloaded any more. - -%D This module implements some typographics tricks that can -%D be fun when designing document layouts. The examples use -%D macros that are typical to \CONTEXT, but non \CONTEXT\ -%D users can use the drop caps and first line treatment -%D macros without problems. This module will be extended -%D when the need for more of such tricks arises. - -\writestatus{loading}{ConTeXt Support Macros / Fun Stuff} - -%D \macros -%D {DroppedCaps, DroppedString, DroppedIndent, DroppedLines} -%D -%D \startbuffer -%D \DroppedCaps -%D {\color[green]} {SerifBold} -%D {\the\dimexpr2.2\baselineskip} {2pt} {\the\baselineskip} {2} -%D Let's start -%D \stopbuffer -%D -%D \getbuffer with dropped caps, those blown up first -%D characters of a paragraph. It's hard to implement a general -%D mechanism that suits all situations, but dropped caps are so -%D seldomly used that we can permit ourselves a rather user -%D unfriendly implementation. -%D -%D \typebuffer -%D -%D As we will see, there are 7 different settings involved. The -%D first argument takes a command that is used to do whatever -%D fancy things we want to do, but normally this one will be -%D empty. The second argument takes the font. Because we're -%D dealing with something very typographic, there is no real -%D reason to adopt complicated font switching schemes, a mere -%D name will do. Font encodings can bring no harm, because the -%D alphanumeric characters are nearly always located at their -%D natural position in the encoding vector. -%D -%D \startbuffer -%D \DroppedCaps -%D {\color[red]} {SerifBold} -%D {\the\baselineskip} {0pt} {0pt} {1} -%D This simple -%D \stopbuffer -%D -%D \getbuffer case shows us what happens when we apply minimal -%D values. Here we used: -%D -%D \typebuffer -%D -%D \startbuffer -%D \DroppedCaps -%D {\color[red]} {SerifBold} -%D {\the\dimexpr2\baselineskip} {0pt} {\the\baselineskip} {2} -%D Is this ugly -%D \stopbuffer -%D -%D \getbuffer example the third argument tells -%D this macro that we want a dropped capital scaled to the -%D baseline distance. The two zero point arguments are the -%D horizontal and vertical offsets and the last arguments -%D determines the hanging indentation. In this paragraph we -%D set the height to two times the baselinedistance and use -%D two hanging lines: -%D -%D \typebuffer -%D -%D Here, the first character is moved down one baseline. Here -%D we also see why the horizontal offset is important. The -%D first example (showing the~L) sets this to a few points and -%D also used a slightly larger height. -%D -%D Of course common users (typist) are not supposed to see this -%D kind of fuzzy definitions, but fortunately \TEX\ permits us -%D to hide them in macros. Using a macro also enables us to -%D garantee consistency throughout the document: -%D -%D \startbuffer -%D \def\MyDroppedCaps% -%D {\DroppedCaps -%D {\color[green]} {SerifBold} -%D {\the\dimexpr5\baselineskip} {3pt} {\the\dimexpr3\baselineskip} {4}} -%D -%D \MyDroppedCaps The implementation -%D \stopbuffer -%D -%D \typebuffer -%D -%D \getbuffer of the general macro is rather simple and only -%D depends on the arguments given and the dimensions of the -%D strut box. We explicitly load the font, which is no problem -%D because \TEX\ does not load a font twice. We could have -%D combined some arguments, like the height, vertical offset -%D and the number of lines, but the current implementation -%D proved to be the most flexible. One should be aware of the -%D fact that the offsets depend on the design of the glyphs -%D used. - -\let\DroppedIndent\!!zeropoint \def\DroppedLines{0} - -\def\DroppedString{ABCDEFGHIJKLMNOPQRSTUVWXYZ} - -\let\globaldropcaps\global % will be an option, but on by default - -\def\localdropcaps{\let\globaldropcaps\relax} - -\chardef\DroppedStatus = 0 % 0=done 1=starting 2=doing 3=error -\chardef\DropMode = 0 % 1 == marginhang - -\ifx\keeplinestogether\undefined - \let\keeplinestogether\gobbleoneargument -\fi - -\def\DroppedCaps#1#2#3#4#5#6#7% does not yet handle accented chars - {\defconvertedargument\asciia{#7}% - \defconvertedcommand \asciib{\DroppedString}% - \doifinstringelse\asciia\asciib - {\noindentation - \dontleavehmode - \checkindentation % redo this one - %\ifhmode\hskip-\parindent\fi % sensitive for context mechanism - \keeplinestogether{#6}% - \setbox0\hbox{\definedfont[#2 at #3]#1{#7}\hskip#4}% - \ifdim\dp0>\strutdp % one of those Q's , will be option - \setbox2\hbox{\raise\dp0\hbox{\lower\strutdp\copy0}}% - \ht2\ht0 - \dp0\strutdp - \setbox0\box2 - \fi - \setbox0\hbox - {\ifnum\DropMode=\plusone - \hskip-\wd0\wd0\zeropoint - \fi - \lower#5\box0}% - \ht0\strutht - \dp0\strutdp - \ifnum\DropMode=\plusone - \globaldropcaps\let\DroppedIndent\!!zeropoint - \globaldropcaps\edef\DroppedLines{\number\maxdimen}% - \globaldropcaps\chardef\DroppedStatus\plusthree - \else - \globaldropcaps\edef\DroppedIndent{\the\wd0}% - \globaldropcaps\edef\DroppedLines {\number#6}% - \globaldropcaps\chardef\DroppedStatus\plustwo - \globaldropcaps\hangindent\DroppedIndent - \globaldropcaps\hangafter-\DroppedLines -% \noindent - \noindentation - \checkindentation % redo this one - \hskip-\DroppedIndent - \fi - \vbox{\forgetall\box0}% - \nobreak - \let\next\ignorespaces} % Could be a one character word ! - {\globaldropcaps\let\DroppedIndent\!!zeropoint - \globaldropcaps\edef\DroppedLines{\number\maxdimen}% - \globaldropcaps\chardef\DroppedStatus\plusthree - \def\next{#7}}% - \let\globaldropcaps\global - \next} - -%D Before we go to the next topic, we summarize this command: -%D -%D \starttyping -%D \DroppedCaps -%D {command} {font} -%D {height} {hoffset} {voffset} {lines} -%D \stoptyping -%D -%D Sometimes you need to make sure that the global settings are -%D kept local, as in: -%D -% %D \startbuffer -% %D \defineparagraphs[SomePar][n=2,rule=on] -% %D \setupparagraphs [SomePar][1][width=.5\textwidth] -% %D \setupparagraphs [SomePar][2][width=.5\textwidth] -%D \startbuffer -%D \defineparagraphs[SomePar][n=2,rule=on] -%D \setupparagraphs [SomePar][1][width=.5\textwidth] -%D \setupparagraphs [SomePar][2][width=.5\textwidth] -%D -%D \startSomePar -%D \localdropcaps\NiceDroppedCaps{}{cmr12}{0pt}{2}Here we need -%D to explicitly keep the hanging indentation local, like it or -%D not. -%D \SomePar -%D \localdropcaps\NiceDroppedCaps{}{cmr12}{0pt}{2}Here we need -%D to explicitly keep the hanging indentation local, like it or -%D not. -%D \stopSomePar -%D \stopbuffer -%D -%D \typebuffer \getbuffer - -%D \macros -%D {AutoDroppedCaps, CheckDroppedCaps} -%D -%D {\em To be documented.} - -% example usage -% -% \def\bpar{\ifvmode\CheckDroppedCaps\fi} -% \def\epar{\ifhmode\par\fi\CheckDroppedCaps} - -\newcount\lastprevgraf -\newcount\droppedlines - -\def\CheckDroppedCaps - {\global\lastprevgraf\prevgraf} - -\def\AutoDroppedCaps % will be proper core stuff since it - {\globaldropcaps\chardef\DroppedStatus\plusone - \global\lastprevgraf\zerocount - \global\droppedlines\zerocount - \EveryPar{\doAutoDroppedCaps}} - -\let\AutoDroppedNext\relax - -\ifx\AutoDroppedCapsCommand\undefined - \def\AutoDroppedCapsCommand{\NiceDroppedCaps{}{SerifBold}{.125em}{3}} -\fi - -\def\doAutoDroppedCaps - {\ifcase\DroppedStatus % done - \let\next\relax - \or % starting - % \ifnum\lastprevgraf>0 % tricky, probably a wrong par - % \globaldropcaps\chardef\DroppedStatus=3 % and inhibits dropped - % \let\next\relax % caps after titles and more than once - % \else % so let's nill this rubishly code fragment - \let\next\AutoDroppedCapsCommand - % \fi % and hope for the best - \or % doing - \global\advance\droppedlines \lastprevgraf - \ifnum\droppedlines=\zerocount - \globaldropcaps\chardef\DroppedStatus\zerocount - \let\next\relax - \else\ifnum\droppedlines>\zerocount - \ifnum\droppedlines<\DroppedLines\relax - \globaldropcaps\hangindent\DroppedIndent - \globaldropcaps\hangafter-\DroppedLines - \globaldropcaps\advance\hangafter \droppedlines - \hskip-\parindent % brrr - \let\next\AutoDroppedNext - \else - \globaldropcaps\chardef\DroppedStatus\zerocount - \let\next\relax - \fi - \else - \globaldropcaps\chardef\DroppedStatus\zerocount - \let\next\relax - \fi\fi - \or % error - \globaldropcaps\chardef\DroppedStatus\zerocount - \let\next\relax - \fi - \next} - -%D \macros -%D {LineDroppedCaps, NiceDroppedCaps} -%D -%D To save definitions, we also provide: -%D -%D \starttyping -%D \LineDroppedCaps {command} {font} {hoffset} {lines} -%D \NiceDroppedCaps {command} {font} {hoffset} {lines} -%D \stoptyping -%D -%D The first command scales the font to the exact height, while -%D the second command scales the font to a nice 2.5 times the -%D line height, a value that gives a pleasant grayness. - -\def\DoLineDroppedCaps#1#2#3#4#5% compensation command font offset lines - {\scratchcounter#5% - \advance\scratchcounter \minusone - \scratchdimen\scratchcounter\baselineskip - \advance\scratchdimen #1% - \NormalizeFontHeight\DummyFont{W}\scratchdimen{#3}% - \DroppedCaps{#2}{#3}\TheNormalizedFontSize{#4} - {\scratchcounter\baselineskip}{#5}} - -\def\LineDroppedCaps% command font offset lines - {\DoLineDroppedCaps{\strutht}} - -\def\NiceDroppedCaps% command font offset lines - {\DoLineDroppedCaps{.5\baselineskip}} - -%D \macros -%D {TreatFirstLine} -%D -%D \startbuffer -%D \TreatFirstLine {\sc} {} {} {} -%D Instead of limiting its action to one token, the next macro -%D treats the whole first line. This paragraph was typeset by -%D saying: -%D \stopbuffer -%D -%D \getbuffer -%D -%D \typebuffer -%D -%D \startbuffer -%D \TreatFirstLine {\startcolor[red]\bf} {\stopcolor} {} {} -%D The combined color and font effect is also possible, -%D although one must be careful in using macros that accumulate -%D grouping, but the commands used here are pretty save in that -%D respect. -%D \stopbuffer -%D -%D \getbuffer -%D -%D \typebuffer -%D -%D Before we explain the third and fourth argument, we show the -%D implementation. Those who know a bit about the way \TEX\ -%D treats tokens, will probably see in one glance that this -%D alternative works all right for most text||only situations -%D in which there is enough text available for the first line, -%D but that more complicated things will blow. One has to live -%D with that. A workaround is rather trivial but obscures the -%D principles used. - -\def\TreatFirstLine#1#2#3#4% before, after, first, next - {\leavevmode - \bgroup - \forgetall - \bgroup - #1% - \setbox0\emptybox - \setbox2\emptybox - \def\grabfirstline##1 % - {\setbox2\hbox - {\ifvoid0 - {#3{\ignorespaces##1}}% - \else - \unhcopy0\ {#4{##1}}% - \fi}% - \ifdim\wd2=\zeropoint - \setbox0\emptybox - \setbox2\emptybox - \@EA\grabfirstline - \else\ifdim\wd2>\hsize - \hbox to \hsize{\strut\unhbox0}#2\egroup - \break##1\ - \egroup - \else - \setbox0\box2 - \@EAEAEA\grabfirstline - \fi\fi}% - \grabfirstline} - -%D \startbuffer -%D \gdef\FunnyCommand -%D {\getrandomfloat\FunnyR{0}{1}% -%D \getrandomfloat\FunnyG{0}{1}% -%D \getrandomfloat\FunnyB{0}{1}% -%D \definecolor[FunnyColor][r=\FunnyR,g=\FunnyG,b=\FunnyB]% -%D \color[FunnyColor]} -%D -%D %\TreatFirstLine {\bf} {} {\FunnyCommand} {\FunnyCommand} -%D The third and fourth argument can be used to gain special -%D effects on the individual words. Of course one needs ... -%D \stopbuffer -%D -%D \getbuffer -%D to know a bit more about the macro package used to get real -%D nice effects, but this example probably demonstrates the -%D principles well. -%D -%D \typebuffer -%D -%D Like in dropped caps case, one can hide such treatments in a -%D macro, like: -%D -%D \starttyping -%D \def\MyTreatFirstLine% -%D {\TreatFirstLine{\bf}{}{\FunnyCommand}{\FunnyCommand}} -%D \stoptyping - -%D \macros -%D {reshapebox} -%D -%D \startbuffer -%D \beginofshapebox -%D When using \CONTEXT, one can also apply this funny command -%D to whole lines by using the reshape mechanism. Describing -%D this interesting mechanism falls outside the scope of this -%D module, so we only show the trick. This is an example of -%D low level \CONTEXT\ functionality: it's all there, and it's -%D stable, but not entirely meant for novice users. -%D \endofshapebox -%D -%D \reshapebox{\FunnyCommand{\box\shapebox}} \flushshapebox -%D \stopbuffer -%D -%D \getbuffer -%D -%D \typebuffer -%D -%D This mechanism permits hyphenation and therefore gives -%D better results than the previously discussed macro -%D \type{\TreatFirstLine}. - -%D \macros -%D {TreatFirstCharacter} -%D -%D \startbuffer -%D \TreatFirstCharacter{\bf\color[green]} Just to be -%D \stopbuffer -%D -%D \getbuffer complete we also offer a very simple one -%D character alternative, that is not that hard to understand: - -\def\TreatFirstCharacter#1#2% command, character - {{#1{#2}}} - -%D A previous paragraph started with: -%D -%D \typebuffer - -%D \macros -%D {StackCharacters} -%D -%D The next hack deals with vertical stacking. - -\def\StackCharacters#1#2#3#4% sequence vsize vskip command - {\vbox #2 - {\forgetall - \baselineskip\zeropoint - \def\StackCharacter##1{#4{##1}\cr\noalign{#3}}% - \halign - {\hss##\hss&##\cr - \handletokens#1\with\StackCharacter\cr}}} - -%D \startbuffer -%D \StackCharacters{CONTEXT}{}{\vskip.2ex}{\FunnyCommand} -%D \stopbuffer -%D -%D Such a stack looks like: -%D -%D \startlinecorrection -%D \hbox to \hsize -%D {$\hss\bfd -%D \vcenter{\StackCharacters{TEX} {}{\vskip.2ex}{\FunnyCommand}}% -%D \hss -%D \vcenter{\StackCharacters{CON} {}{\vskip.2ex}{\FunnyCommand}} -%D \hss -%D \vcenter{\StackCharacters{TEXT} {}{\vskip.2ex}{\FunnyCommand}} -%D \hss -%D \vcenter{\StackCharacters{CONTEXT}{}{\vskip.2ex}{\FunnyCommand}} -%D \hss$} -%D \stoplinecorrection -%D -%D and is typeset by saying: -%D -%D \typebuffer -%D -%D An alternative would have been -%D -%D \starttyping -%D \StackCharacters {CONTEXT} {to 5cm} {\vfill} {\FunnyCommand} -%D \stoptyping - -%D \macros -%D {processtokens} -%D -%D At a lower level horizontal and vertical manipulations are -%D already supported by: -%D -%D \starttyping -%D \processtokens {begin} {between} {end} {space} {text} -%D \stoptyping -%D -%D \startbuffer[a] -%D \processtokens -%D {\hbox to .5\hsize\bgroup} {\hfill} -%D {\egroup} {\space} {LET'S HAVE} -%D \stopbuffer -%D -%D \startbuffer[b] -%D \processtokens -%D {\vbox\bgroup\raggedcenter\hsize1em} -%D {\vskip.25ex} {\egroup} {\strut} {FUN} -%D \stopbuffer -%D -%D This macro is able to typeset: -%D -%D \leavevmode\hbox to \hsize -%D {$\hfil\hfil -%D \vcenter{\bf\getbuffer[a]}% -%D \hfil -%D \vcenter{\bfd\getbuffer[b]}% -%D \hfil\hfil$} -%D -%D which was specified as: -%D -%D \typebuffer[a] -%D \typebuffer[b] - -%D \macros -%D {NormalizeFontHeight, NormalizeFontWidth, -%D TheNormalizedFontSize} -%D -%D Next we introduce some font manipulation macros. When we -%D want to typeset some text spread in a well defined area, it -%D can be considered bad practice to manipulate character and -%D word spacing. In such situations the next few macros can be -%D of help: -%D -%D \starttyping -%D \NormalizeFontHeight \name {sample text} {height} {font} -%D \NormalizeFontWidth \name {sample text} {width} {font} -%D \stoptyping -%D -%D These are implemented using an auxilliary macro: - -\def\NormalizeFontHeight{\NormalizeFontSize\ht} -\def\NormalizeFontWidth {\NormalizeFontSize\wd} - -\def\NormalizeFontSize#1#2#3#4#5% - {\bgroup - \dimen0=#4% #4 can be \ht0 or so - \setbox0\hbox{\definedfont[#5 at 5pt]#3}% 10pt - \ifdim\wd0>\zeropoint - \dimen2=#10 % #1 is \wd or \ht - \dimen4=\maxdimen % 10000pt - \divide\dimen4 \dimen2 - \divide\dimen0 1638 % 1000 - \dimen0=\number\dimen4\dimen0 - \divide \dimen0 \plustwo % ... - \xdef\TheNormalizedFontSize{\the\dimen0}% - \else - \dimen0\bodyfontsize - \fi - \normalexpanded{\egroup\def\noexpand#2{\definedfont[#5 at \the\dimen0]}}} - -%D Afterwards, we have access to the calculated size by: - -\let\TheNormalizedFontSize\!!zeropoint - -%D Extra: - -\def\WidthSpanningText#1#2#3% text width font - {\hbox{\NormalizeFontWidth\temp{#1}{#2}{#3}\temp\the\everydefinedfont#1}} - -%D Consider for instance: -%D -%D \startbuffer -%D \NormalizeFontHeight \tmp {X} {2\baselineskip} {cmr10} -%D -%D {\tmp To Be Or Not To Be} -%D \stopbuffer -%D -%D \typebuffer -%D -%D This shows up as (we also show the baselines): -%D -%D {\showbaselines\getbuffer} -%D -%D The horizontal counterpart is: -%D -%D \startbuffer -%D \NormalizeFontWidth \tmp {This Line Fits} {\hsize} {cmr10} -%D -%D \hbox{\tmp This Line Fits} -%D \stopbuffer -%D -%D \typebuffer -%D -%D The calculated font scale is avaliable in the macro -%D \type{\NormalizedFontSize}. -%D -%D \startlinecorrection -%D \ruledhbox{\getbuffer} -%D \stoplinecorrection -%D -%D One can of course combine these macros with the ones -%D described earlier, like in: -%D -%D \starttyping -%D \NormalizeFontHeight {text} \DroppedFont {2\baselineskip} {cmbx12} -%D -%D \def\NicelyDroppedCaps -%D {\DroppedCaps -%D {\color[green]} -%D {\DroppedFont} -%D {2pt} -%D {\baselineskip} -%D {2}} -%D \stoptyping -%D -%D It's up to the reader to test this one. - -\unexpanded\def\FirstNCharacters#1#2% \FirstNCharacters{3}{fr{\"o}beln} - {\bgroup - \scratchcounter\zerocount - \def\docommand##1% - {\ifnum\scratchcounter=#1\else - ##1\relax % catches ##1 = \"e and alike - \advance\scratchcounter\plusone - \fi} - \handletokens#2\with\docommand - \egroup} - -%D \macros -%D {FittingText} -%D -%D First used in Pascal (demo-bbv): -%D -%D \startbuffer -%D \ruledvbox{\FittingText{3cm}{1cm}{Serif}{24pt}{1pt}{1} -%D {\veryraggedright -%D \hangindent1em\hangafter1\relax -%D \begstrut \dorecurse{8}{Bram Marta }\unskip \endstrut}} -%D -%D \ruledvbox{\FittingText{3cm}{1cm}{Serif}{24pt}{1pt}{1} -%D {\raggedleft\begstrut Bram\\Marta \unskip\endstrut}} -%D \stopbuffer -%D -%D \typebuffer -%D -%D \startlinecorrection -%D \getbuffer -%D \stoplinecorrection - -% #1 width #2 height #3 font #4 size #5 step #6 interlinie #7 text - -\long\def\FittingText#1#2#3#4#5#6#7% - {\bgroup - \forgetall - \dontcomplain - \setuptolerance[\v!verytolerant]% == \tolerance4500 - \hsize#1% - \def\\{\softbreak}% - \!!heighta#4% - \!!heightb#2% - \doloop - {\ifdim\!!heighta>\onepoint - \expanded{\definefont[\s!dummy][#3 at \the\!!heighta][\c!interlinespace=#6]}% - \getvalue\s!dummy - \setbox\scratchbox\vbox{#7\endgraf}% - \ifdim\ht\scratchbox>\!!heightb - \advance\!!heighta-#5% - \else - \beginshapebox - \unvcopy\scratchbox - \endshapebox - \global\dimen1\hsize - \reshapebox - {\setbox\shapebox\hbox{\unhbox\shapebox}% - \ifdim\wd\shapebox>\dimen1 - \global\dimen1\wd\shapebox - \fi}% - \ifdim\dimen1>\hsize - \advance\!!heighta-#5% - \else - \exitloop - \fi - \fi - \else - \exitloop - \fi}% - %\writestatus{\strippedcsname\FittingText}{height: \the\!!heighta}% - \unvbox\scratchbox - \egroup} - -%D New: - -% \font width gap font spec text - -\def\NormalizeFontWidthSpread#1#2#3#4#5#6% - {\global\setfalse\NFSpread - \scratchdimen#3% - \scratchdimen-.5\scratchdimen - \advance\scratchdimen#2\relax - \NormalizeFontWidth - #1% - {\def\+{\global\settrue\NFSpread\gobbleuntil\relax}% - \def\\{\gobbleuntil\relax}% newline - \setupspacing - #6\relax}% - {\scratchdimen}% - {#4}% - \ifconditional\NFSpread - % de gap valt in de binding - \else - \definefont[\strippedcsname#1][#4 #5]% - \fi} - -\def\SpreadGapText#1#2% - {{\def\+{\kern#1}#2}} - -\def\GapText#1#2#3#4#5% width distance font spec title - {\bgroup - \NormalizeFontWidthSpread\DummyFont{#1}{#2}{#3}{#4}{#5}% - \DummyFont\setupspacing\SpreadGapText{#2}{#5}\endgraf - \egroup} - -\protect \endinput diff --git a/tex/context/base/supp-mat.mkiv b/tex/context/base/supp-mat.mkiv index bc26611ae..21871e80d 100644 --- a/tex/context/base/supp-mat.mkiv +++ b/tex/context/base/supp-mat.mkiv @@ -52,31 +52,26 @@ \let\normalstopimath \Ustopmath \let\normalstartdmath \Ustartdisplaymath \let\normalstopdmath \Ustopmath + \def\normalmathaligntab{&} % \let\normalmathaligntab\aligntab does to work well in a let to & (a def works ok) -\let\normalsuper \Usuperscript % obsolete -\let\normalsuber \Usubscript % obsolete -\let\startimath \Ustartmath % obsolete, less safe -\let\stopimath \Ustopmath % obsolete, less safe -\let\startdmath \Ustartdisplaymath % obsolete, less safe -\let\stopdmath \Ustopmath % obsolete, less safe +\let\normalsuper \Usuperscript % obsolete +\let\normalsuber \Usubscript % obsolete + +\let\startimath \Ustartmath +\let\stopimath \Ustopmath +\let\startdmath \Ustartdisplaymath +\let\stopdmath \Ustopmath \unexpanded\def\mathematics#1{\relax \ifmmode#1\else\normalstartimath#1\normalstopimath\fi} \unexpanded\def\displaymath#1{\noindent \ifmmode#1\else\normalstartdmath#1\normalstopdmath\fi} \unexpanded\def\inlinemath #1{\dontleavehmode\ifmmode#1\else\normalstartimath#1\normalstopimath\fi} \unexpanded\def\textmath #1{\dontleavehmode\ifmmode#1\else\begingroup\everymath\emptytoks\normalstartimath#1\normalstopimath\endgroup\fi} % \mathsurround\zeropoint -\let\m\mathematics % unexpanded? +\let\m\mathematics \let\stopmathmode\relax -% \unexpanded\def\startmathmode % cannot be used nested -% {\relax\ifmmode -% \let\stopmathmode\relax -% \else -% \normalstartimath\let\stopmathmode\normalstopimath -% \fi} - \unexpanded\def\startmathmode % nested variant {\relax\ifmmode \begingroup @@ -128,7 +123,8 @@ \def\dimensionhalfspace {\,} \unexpanded\def\dimension#1% - {\def\dodimensionsignal{\kern\dimensionsignal}% + {\pushmacro\dodimensionsignal + \gdef\dodimensionsignal{\kern\dimensionsignal}% \ifdim\lastskip=\zeropoint\relax \ifdim\lastkern=\zeropoint\relax \ifmmode @@ -144,70 +140,16 @@ \else \unskip\mathematics{\dimensionhalfspace\dimensionhalfspace\dimensiontypeface#1}% \fi - \dodimensionsignal} + \dodimensionsignal + \popmacro\dodimensionsignal} \unexpanded\def\nodimension#1% {\unskip#1\global\let\dodimensionsignal\relax} -% %D \macros -% %D {super, suber} -% %D -% %D \TEX\ uses \type{^} and \type{_} for entering super- and -% %D subscript mode. We want however a bit more control than -% %D normally provided, and therefore provide \type {\super} -% %D and \type{\suber} (\type {\sub} is already taken). -% -% \global\let\normalsuper=\normalsuperscript % will become obsolete -% \global\let\normalsuber=\normalsubscript % will become obsolete -% -% \newcount\supersubmode -% -% \newevery\everysupersub \EverySuperSub -% -% \appendtoks \advance\supersubmode\plusone \to \everysupersub -% -% \def\super#1{\normalsuperscript{\the\everysupersub#1}} -% \def\suber#1{\normalsubscript {\the\everysupersub#1}} -% -% %D \macros -% %D {enablesupsub} -% %D -% %D We can let \type {^} and \type {_} act like \type {\super} -% %D and \type {\suber} by saying \type {\enablesupsub}. -% -% \bgroup -% \catcode\circumflexasciicode\activecatcode -% \catcode\underscoreasciicode\activecatcode -% \gdef\enablesupsub -% {\catcode\circumflexasciicode\activecatcode -% \catcode\underscoreasciicode\activecatcode -% \def^{\ifmmode\expandafter\super\else\expandafter\normalsuper\fi}% -% \def_{\ifmmode\expandafter\suber\else\expandafter\normalsuber\fi}} -% \egroup -% -% %D \macros -% %D {restoremathstyle} -% %D -% %D We can pick up the current math style by calling \type -% %D {\restoremathstyle}. -% -% \def\restoremathstyle -% {\ifmmode -% \ifcase\supsubmode -% \textstyle -% \or -% \scriptstyle -% \else -% \scriptscriptstyle -% \fi -% \fi} - %D \macros %D {cramped} %D -%D \TEX provides no primitive to force in cramped math mode. Here is -%D a macro that does so. It is based on a solution by Don Knuth (\useurl -%D {http://www.ctan.org/tex-archive/digests/tex-implementors/042}). +%D Cramped math: %D %D \startbuffer %D \ruledhbox{$\left\{{x^2\over y^2}\right\}$} @@ -305,7 +247,7 @@ % experiment, not yet to be used -% \def\displaybreak +% \unexpanded\def\displaybreak % {\ifhmode % \removeunwantedspaces % \ifcase\raggedstatus\hfill\fi diff --git a/tex/context/base/supp-num.mkiv b/tex/context/base/supp-num.mkiv deleted file mode 100644 index be0df026d..000000000 --- a/tex/context/base/supp-num.mkiv +++ /dev/null @@ -1,416 +0,0 @@ -%D \module -%D [ file=supp-num, -%D version=1998.05.15, -%D title=\CONTEXT\ Support Macros, -%D subtitle=Numbers, -%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. - -% See end for transition to mkiv. - -\writestatus{loading}{ConTeXt Support Macros / Numbers} - -\unprotect - -%D \macros -%D {digits, setdigitmode, setdigitsign} -%D -%D Depending on the digit mode the command \type {\digits} -%D normalizes number patterns depending on the language set. -%D -%D \starttyping -%D This will never be a \digits{1.000.000} seller. -%D \stoptyping -%D -%D or -%D -%D \starttyping -%D I will never grow longer than \digits 1.86 \Meter. -%D \stoptyping -%D -%D The different modes are shown in: -%D -%D \startbuffer -%D \setdigitmode 1 \digits 12.345,90 \digits 12.345.000 \digits 1,23 -%D \setdigitmode 2 \digits 12.345,90 \digits 12.345.000 \digits 1,23 -%D \setdigitmode 3 \digits 12.345,90 \digits 12.345.000 \digits 1,23 -%D \setdigitmode 4 \digits 12.345,90 \digits 12.345.000 \digits 1,23 -%D \setdigitmode 5 \digits 12.345,90 \digits 12.345.000 \digits 1,23 -%D \setdigitmode 6 \digits 12.345,90 \digits 12.345.000 \digits 1,23 -%D \stopbuffer -%D -%D \typebuffer -% -% This is typset as: -% -% \startlines -% \getbuffer -% \stoplines -%D -%D The sign can be typeset as is or within the space of a -%D digit. -%D -%D \startbuffer -%D \setdigitsign 0 \digits +12.345,90 -%D \setdigitsign 1 \digits +12.345,90 -%D \setdigitsign 2 \digits +12.345,90 -%D \setdigitsign 3 \digits +12.345,90 -%D \stopbuffer -%D -%D \typebuffer -%D -% This is typset as: -% -% \startlines -% \getbuffer -% \stoplines - -\chardef\digitoutputmode=1 % 0..6 -\chardef\digitsignmode =0 % 0..3 - -\def\setdigitmode{\chardef\digitoutputmode} -\def\setdigitsign{\chardef\digitsignmode} - -%D The digit modes are: -%D -%D \startitemize[packed] -%D \item periods \& comma -%D \item commas \& period -%D \item thinmuskips \& comma -%D \item thinmuskips \& period -%D \item thickmuskips \& comma -%D \item thickmuskips \& period -%D \stopitemize - -\let\collecteddigits \empty \chardef\digitinputmode =1 -\let\saveddigits \empty \chardef\skipdigit =0 -\let\savedpowerdigits\empty \chardef\powerdigits =0 - -%D The first stage of the \type {\digit} macro takes care of -%D the grouped call, the other branch handles the fuzzy -%D delimited calls. - -\ifdefined\mbox \else \let\mbox\hbox \fi - -\unexpanded\def\digits - {\bgroup - \let~@% - \doifnextbgroupelse\dodigits{\doifnextcharelse\normalmathshift\domathdigits\grabdigit}} - -\def\dodigits#1% - {\grabdigit#1\relax} - -\def\domathdigits$#1$% - {\mbox{\grabdigit#1\relax}} % adding $ $ goes wrong in tabulate - -\def\grabdigit - {\futurelet\next\scandigit} - -%D Watch the test for \type {\nextobeyedline}, because the -%D endofline token can be \type {\def'd}, not \type {\let}'d, -%D we need to do an indirect test (see \type {verb-ini.tex}) -%D for details. (This probably needs an update.) - -\ifx\normalmathshift\undefined \let\normalmathshift=$ \fi - -\def\scandigit - {\ifx\next\blankspace - \let\next\handledigits - \else\ifx\next\nextobeyedline % the indirect one - \let\next\handledigits - \else\ifx\next\bgroup - \let\next\handledigits - \else\ifx\next\egroup - \let\next\handledigits - \else\ifx\next\normalmathshift - \let\next\handledigits - \else - \let\next\collectdigit - \fi\fi\fi\fi\fi - \next} - -%D We store the power||of||ten (to be signaled by \type {^}, -%D \type {e} or~\type {E}) in a seperate macro so that we can -%D typeset it in superscript. The space placeholders are -%D replaced by a \type {@}. - -\def\savedigit#1#2% - {\edef#1{#1\saveddigits#2}\let\saveddigits\empty} - -\long\def\collectdigit#1% - {\ifx#1~% - \savedigit\collecteddigits @% - \else\if#1_% tricky as can be several catcodes ... will become lua code anyway - \savedigit\collecteddigits @% - \else\if\noexpand#1\relax - \let\grabdigit\handledigits - \else\ifcase\powerdigits - \if#1E% - \chardef\powerdigits\plusone - \else\if#1e% - \chardef\powerdigits\plusone - \else\if#1^% - \chardef\powerdigits\plusone - \else - \savedigit\collecteddigits#1% - %\doifnumberelse{#1} - % {\savedigit\collecteddigits#1} - % {\def\saveddigits{#1}}% - \fi\fi\fi - \else - \savedigit\savedpowerdigits#1% - %\doifnumberelse{#1} - % {\savedigit\savedpowerdigits#1} - % {\def\saveddigits{#1}}% - \fi\fi\fi\fi - \grabdigit} - -\let\handlemathdigits\firstofoneargument -\let\handletextdigits\mathematics - -\def\handledigits - {%\ifcase\powerdigits - % \edef\collecteddigits{\collecteddigits\saveddigits}% - %\else - % \edef\savedpowerdigits{\savedpowerdigits\saveddigits}% - %\fi - \ifmmode - \handlemathdigits{\dohandledigits}% - \else - \dontleavehmode\hbox{\handletextdigits{\dohandledigits}}% - \fi - \egroup} - -%D Although we could do with one pass, a second pass for -%D handling the stored sequence is more readable. - -\ifnum\texengine=\luatexengine - - \def\dohandledigits - {\mathcode`\,="002C \mathcode`\.="002E % pretty hard coded - \expandafter\handletokens\collecteddigits\with\scandigits - \ifcase\powerdigits\else\digitpowerseparator^{\savedpowerdigits}\fi} - - \chardef\mathaxisfontid\zerocount - -\else - - \def\dohandledigits - {\mathcode`\,="013B \mathcode`\.="013A % pretty hard coded - \expandafter\handletokens\collecteddigits\with\scandigits - \ifcase\powerdigits\else\digitpowerseparator^{\savedpowerdigits}\fi} - - \chardef\mathaxisfontid\plustwo - -\fi - -\def\doscandigit#1% - {\ifcase\skipdigit\@EA\hbox\else\@EA\hphantom\fi\bgroup - \mathematics % brr, needed because of stored punctuation - {\ifnum\digitinputmode=#1\relax - \ifcase\digitoutputmode - \or .% - \or ,% - \or \mskip\thinmuskip - \or \mskip\thinmuskip - \or \mskip\thickmuskip - \or \mskip\thickmuskip - \fi - \else - \ifodd\digitoutputmode,\else.\fi - \fi}% - \egroup} - -%D The signs can be made smaller and sqeezed into the width -%D of a digit. Watch the \type {\mathaxisheight} trickery (this -%D font related register stored the math axis). - -% 0,= -% 0,== second = results in delta(00,=) -% 0,- is invalid, should be = -% 0,-- is invalid, should be == - -\def\digitzeroamount - {\digitsgn\zeroamount - \def\digitzeroamount - {\hphantom - {00\setbox\scratchbox\hbox{$\zeroamount$}% - \hskip-\wd\scratchbox}% - \let\digitzeroamount\empty}} - -\def\scandigits#1% - {\if#1.\digitsep1\else - \if#1,\digitsep2\else - \if#1@\digitnop \else - \if#1_\digitnop \else - \if#1/\digitsgn{\hphantom{+}}\chardef\skipdigit0\else - \if#1-\ifcase\skipdigit\digitsgn-\else - \box\digitsepbox\digitzeroamount \fi\chardef\skipdigit0\else - \if#1+\digitsgn+\chardef\skipdigit0\else - \if#1=\box\digitsepbox\digitzeroamount \chardef\skipdigit0\else - \if#1s\digitsgn{\hphantom{\positive}}\chardef\skipdigit0\else - \if#1p\digitsgn\positive\chardef\skipdigit0\else - \if#1m\digitsgn\negative\chardef\skipdigit0\else - \if#1n\digitsgn\negative\chardef\skipdigit0\else - \box\digitsepbox #1\chardef\skipdigit0\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} - -\newbox\digitsepbox \chardef\autodigitmode=1 - -\def\digitsep#1% - {\ifcase\autodigitmode - \doscandigit#1% - \else - \setbox\digitsepbox\hbox{\doscandigit#1}% - \fi - \chardef\skipdigit0\relax} - -% strange, does not work -% -% \def\digitnop -% {\hphantom{\box\digitsepbox}% -% \hphantom{0}\chardef\skipdigit1\relax} -% -% while this works - -\def\digitnop - {\hbox{\hphantom{\box\digitsepbox}}% - \hphantom{0}\chardef\skipdigit1\relax} - -% but this doesn't -% -% \def\digitnop -% {\hphantom{\box\digitsepbox0}% -% \chardef\skipdigit1\relax} - -\def\digitsgn#1% - {\ifcase\digitsignmode#1\else - \hbox - {\setbox\scratchbox\hbox{0}% - \scratchdimen\mathaxisheight\textfont\mathaxisfontid - \def\digitsgn##1##2% - {\advance\scratchdimen-\mathaxisheight##1\mathaxisfontid - \raise\scratchdimen - \hbox to \wd\scratchbox{\hss$##2#1$\hss}}% - \ifcase\digitsignmode\or - \digitsgn\textfont \textstyle \or - \digitsgn\scriptfont \scriptstyle \or - \digitsgn\scriptscriptfont\scriptscriptstyle\fi}% - \fi} - -\ifx\undefined\zeroamount \def\zeroamount{-} \fi -\ifx\undefined\positive \def\positive {+} \fi -\ifx\undefined\negative \def\negative {-} \fi - -%D The digit parser handles a bunch of special characters as -%D well as different formats. We strongly suggest you to use -%D the grouped call. -%D -%D \starttabulate[|l|l|l|] -%D \NC \type{.} \NC , . \NC comma or period \NC \NR -%D \NC \type{,} \NC , . \NC comma or period \NC \NR -%D \NC \type{@} \NC \NC invisible space \NC \NR -%D \NC \type{_} \NC \NC invisible space \NC \NR -%D \NC \type{/} \NC \NC invisible sign \NC \NR -%D \NC \type{-} \NC $-$ \NC minus sign \NC \NR -%D \NC \type{+} \NC $+$ \NC plus sign \NC \NR -%D \NC \type{s} \NC \NC invisible high sign \NC \NR -%D \NC \type{p} \NC $\positive$ \NC high plus sign \NC \NR -%D \NC \type{m} \NC $\negative$ \NC high minus sign \NC \NR -%D \NC \type{n} \NC $\negative$ \NC high minus (negative) sign \NC \NR -%D \NC \type{=} \NC $\zeroamount$ \NC zero padding \NC \NR -%D \stoptabulate -%D -%D These triggers are used in the following examples. -%D -%D \startbuffer -%D \digits 12 -%D \digits{~~~.~~~.~~~.68.712,34} -%D \digits ~~~.~~~.~~~.68.712,34 -%D \digits ___.___.111.68.712,34 -%D \digits 111.111.111.68.712,34 -%D \digits 12.345,90 -%D \digits 12.345.000 -%D \digits 12,34 -%D \digits{392.857.230.68.712,34} -%D {\digits1234} -%D \digits{1234} -%D \digits 1234\relax -%D $\digits 123.222,00$ -%D \digits 123.222,00 -%D \digits 123.222,== -%D \digits 123.222,00^10 -%D \digits 123.222,00e10 -%D \digits /123.222,00e-12 -%D \digits -123.222,00e-12 -%D \digits +123.222,00e-12 -%D \digits n123.222,00e-12 -%D \digits s123.222,00e-12 -%D \digits p123.222,00e-12 -%D \stopbuffer -%D -%D \typebuffer -% -% \startlines -% \getbuffer -% \stoplines - -%D \macros -%D {Digits} -%D -%D We also permit: - -\let\Digits\digits - -%D These macros are complicated by the fact that we also -%D have to support cases like: -%D -%D \starttyping -%D {\digits1234} -%D \digits{1234} -%D \digits 1234\whatever -%D $\digits 123.222,00$ -%D \digits 123.222,00. -%D \stoptyping -%D -%D The latter case shows us that trailing non digits are to -%D be passed untreated. -%D -%D Another interesting case is: -%D -%D \starttyping -%D \digits 123.222,00^10 -%D \stoptyping -%D -%D The separator is defined as: - -% \def\digitpowerseparator% -% {\cdot10} % {\times10} - -\def\digitpowerseparator - {\ifx\collecteddigits\empty\else\cdot\fi10} - -%D \macros -%D {digittemplate} -%D -%D Users can specify the way they enter those digits by saying -%D something like: -%D -%D \starttyping -%D \digittemplate 12.000.000,00 % \digittemplate ., -%D \stoptyping - -\def\digittemplate #1 % - {\chardef\digitinputmode\zerocount - \handletokens#1\with\scandigittemplate} - -\def\scandigittemplate#1% - {\if #1.\ifcase\digitinputmode\chardef\digitinputmode\plusone \fi% period - \else\if#1,\ifcase\digitinputmode\chardef\digitinputmode\plustwo \fi% comma - \fi\fi} - -\protect \endinput diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 8a791e900..824754a77 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -3747,7 +3747,7 @@ \expandafter\appendtoks\expandafter\the\csname t\strippedcsname#1\endcsname\to #1% \csname t\strippedcsname#1\endcsname} -\def\newevery#1#2% +\unexpanded\def\newevery#1#2% {\ifx#1\everypar\else\newtoks#1\fi% we test for redefinition elsewhere \ifx#2\relax\else\ifdefined#2\else \expandafter\newtoks\csname t\strippedcsname#1\endcsname @@ -3763,6 +3763,9 @@ \newevery \neverypar \NeveryPar +\unexpanded\def\forgeteverypar + {\everypar{\the\neverypar}} + %D Which we're going to use indeed! When the second argument %D equals \type {\relax}, the first token list is created %D unless it is already defined. diff --git a/tex/context/base/trac-vis.lua b/tex/context/base/trac-vis.lua index aff044921..556dc1347 100644 --- a/tex/context/base/trac-vis.lua +++ b/tex/context/base/trac-vis.lua @@ -24,6 +24,9 @@ local format = string.format -- with full visualization enabled. In practice this will never happen -- unless one is demoing. +-- We could use pdf literals and re stream codes but it's not worth the +-- trouble because we would end up in color etc mess. + -- todo: global switch (so no attributes) -- todo: maybe also xoffset, yoffset of glyph -- todo: inline concat (more efficient) @@ -32,10 +35,12 @@ local nodecodes = nodes.nodecodes local disc_code = nodecodes.disc local kern_code = nodecodes.kern local glyph_code = nodecodes.glyph +local disc_code = nodecodes.disc local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local glue_code = nodecodes.glue local penalty_code = nodecodes.penalty +local whatsit_code = nodecodes.whatsit local kerncodes = nodes.kerncodes local font_kern_code = kerncodes.fontkern @@ -60,7 +65,9 @@ local free_node = node.free local free_node_list = node.flush_list local has_attribute = node.has_attribute local set_attribute = node.set_attribute +local unset_attribute = node.unset_attribute local insert_before = node.insert_before +local insert_after = node.insert_after local fast_hpack = nodes.fasthpack local tex_attribute = tex.attribute @@ -105,28 +112,39 @@ local bit = number.bit local setbit = number.setbit local clearbit = number.clearbit -local trace_hbox -- 1 -local trace_vbox -- 2 -local trace_kern -- 4 -local trace_glue -- 8 -local trace_penalty -- 16 -local trace_fontkern -- 32 +local trace_hbox +local trace_vbox +local trace_vtop +local trace_kern +local trace_glue +local trace_penalty +local trace_fontkern +local trace_strut +local trace_whatsit local report_visualize = logs.reporter("visualize") local modes = { - hbox = 1, - vbox = 2, - kern = 4, - glue = 8, - penalty = 16, - fontkern = 32, + hbox = 1, + vbox = 2, + vtop = 4, + kern = 8, + glue = 16, + penalty = 32, + fontkern = 64, + strut = 128, + whatsit = 256, + glyph = 512, } +local makeup_modes = { "hbox", "vbox", "vtop", "kern", "glue", "penalty" } +local all_modes = { "hbox", "vbox", "vtop", "kern", "glue", "penalty", "fontkern", "whatsit", "glyph" } + local usedfont, exheight, emwidth -local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox +local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox, l_vtop, l_strut, l_whatsit, l_glyph local enabled = false +local layers = { } function visualizers.setfont(id) usedfont = id or current_font() @@ -138,17 +156,15 @@ local function setvisual(n,a,what) -- this will become more efficient when we ha if not n or n == "reset" then return unsetvalue elseif n == "makeup" then - a = setvisual("hbox",a) - a = setvisual("vbox",a) - a = setvisual("kern",a) - a = setvisual("glue",a) - a = setvisual("penalty",a) + for i=1,#makeup_modes do + a = setvisual(makeup_modes[i],a) + end elseif n == "all" then if what == false then return unsetvalue else - for k, v in next, modes do - a = setvisual(k,a) + for i=1,#all_modes do + a = setvisual(all_modes[i],a) end end else @@ -176,7 +192,6 @@ local function setvisual(n,a,what) -- this will become more efficient when we ha -- we use a narrow monospaced font visualizers.setfont(fonts.definers.define { name = "lmmonoltcond10regular", size = tex.sp("4pt") }) end - local layers = { } for mode, value in next, modes do local tag = format("v_%s",mode) attributes.viewerlayers.define { @@ -188,12 +203,16 @@ local function setvisual(n,a,what) -- this will become more efficient when we ha } layers[mode] = attributes.viewerlayers.register(tag,true) end - l_penalty = layers.penalty + l_hbox = layers.hbox + l_vbox = layers.vbox + l_vtop = layers.vtop l_glue = layers.glue l_kern = layers.kern + l_penalty = layers.penalty l_fontkern = layers.fontkern - l_hbox = layers.hbox - l_vbox = layers.vbox + l_strut = layers.strut + l_whatsit = layers.whatsit + l_glyph = layers.glyph nodes.tasks.enableaction("shipouts","nodes.visualizers.handler") report_visualize("enabled") enabled = true @@ -205,7 +224,12 @@ function visualizers.setvisual(n) tex_attribute[a_visual] = setvisual(n,tex_attribute[a_visual]) end +function visualizers.setlayer(n) + tex_attribute[a_layer] = layers[n] or unsetvalue +end + commands.setvisual = visualizers.setvisual +commands.setlayer = visualizers.setlayer function commands.visual(n) context(setvisual(n,0)) @@ -230,6 +254,7 @@ local c_text = "trace:s" local c_space = "trace:y" local c_skip_a = "trace:c" local c_skip_b = "trace:m" +local c_glyph = "trace:o" local c_positive_d = "trace:db" local c_negative_d = "trace:dr" @@ -238,6 +263,7 @@ local c_text_d = "trace:ds" local c_space_d = "trace:dy" local c_skip_a_d = "trace:dc" local c_skip_b_d = "trace:dm" +local c_glyph_d = "trace:do" local function sometext(str,layer,color) local text = fast_hpack_string(str,usedfont) @@ -291,15 +317,29 @@ local function fontkern(head,current) info.depth = 0 f_cache[kern] = info end - head, current = insert_before(head,current,copy_list(info)) - return head, current.next + head = insert_before(head,current,copy_list(info)) + return head, current end --- cache baseline +local w_cache = { } + +local function whatsit(head,current) + local what = current.subtype + local info = w_cache[what] + if info then + -- print("hit whatsit") + else + local info = sometext(format("W:%s",what),usedfont) + set_attribute(info,a_layer,l_whatsit) + w_cache[what] = info + end + head, current = insert_after(head,current,copy_list(info)) + return head, current +end local b_cache -local function ruledbox(head, current, vertical) +local function ruledbox(head,current,vertical,layer) local wd = current.width if wd ~= 0 then local ht, dp = current.height, current.depth @@ -348,10 +388,13 @@ local function ruledbox(head, current, vertical) info.width = 0 info.height = 0 info.depth = 0 - set_attribute(info,a_layer,vertical and l_vbox or l_hbox) + set_attribute(info,a_layer,layer) local info = concat_nodes { - info, +-- info, +-- current, current, + new_kern(-wd), + info, } info = fast_hpack(info) if vertical then @@ -375,6 +418,59 @@ local function ruledbox(head, current, vertical) end end +local function ruledglyph(head,current) + local wd = current.width + if wd ~= 0 then + local ht, dp = current.height, current.depth + local next, prev = current.next, current.prev + current.next, current.prev = nil, nil + local linewidth = .05 * emwidth + local baseline + if dp ~= 0 and ht ~= 0 then + baseline = new_rule(wd-2*linewidth,linewidth,0) + end + local doublelinewidth = 2*linewidth + local info = concat_nodes { + 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, + } + setlistcolor(info,c_glyph) + setlisttransparency(info,c_glyph_d) + info = fast_hpack(info) + info.width = 0 + info.height = 0 + info.depth = 0 + set_attribute(info,a_layer,l_glyph) + local info = concat_nodes { + current, + new_kern(-wd), + info, + } + info = fast_hpack(info) + info.width = wd + if next then + info.next = next + next.prev = info + end + if prev then + info.prev = prev + prev.next = info + end + if head == current then + return info, info + else + return head, info + end + else + return head, current + end +end + local g_cache = { } local tags = { @@ -494,10 +590,14 @@ end local function visualize(head,vertical) local trace_hbox = false local trace_vbox = false + local trace_vtop = false local trace_kern = false local trace_glue = false local trace_penalty = false local trace_fontkern = false + local trace_strut = false + local trace_whatsit = false + local trace_glyph = false local current = head local prev_trace_fontkern = nil local attr = unsetvalue @@ -509,21 +609,50 @@ local function visualize(head,vertical) if not a then trace_hbox = false trace_vbox = false + trace_vtop = false trace_kern = false trace_glue = false trace_penalty = false trace_fontkern = false + trace_strut = false + trace_whatsit = false + trace_glyph = false else - trace_hbox = hasbit(a,1) - trace_vbox = hasbit(a,2) - trace_kern = hasbit(a,4) - trace_glue = hasbit(a,8) - trace_penalty = hasbit(a,16) - trace_fontkern = hasbit(a,32) + trace_hbox = hasbit(a, 1) + trace_vbox = hasbit(a, 2) + trace_vtop = hasbit(a, 4) + trace_kern = hasbit(a, 8) + trace_glue = hasbit(a, 16) + trace_penalty = hasbit(a, 32) + trace_fontkern = hasbit(a, 64) + trace_strut = hasbit(a,128) + trace_whatsit = hasbit(a,256) + trace_glyph = hasbit(a,512) end attr = a end - if id == kern_code then + if trace_strut then + set_attribute(current,a_layer,l_strut) + elseif id == glyph_code then + if trace_glyph then + head, current = ruledglyph(head,current) + end + elseif id == disc_code then + if trace_glyph then + local pre = current.pre + if pre then + current.pre = ruledglyph(pre,pre) + end + local post = current.post + if post then + current.post = ruledglyph(post,post) + end + local replace = current.replace + if replace then + current.replace = ruledglyph(replace,replace) + end + end + elseif id == kern_code then local subtype = current.subtype -- tricky ... we don't copy the trace attribute in node-inj (yet) if subtype == font_kern_code or has_attribute(current,a_fontkern) then @@ -538,7 +667,7 @@ local function visualize(head,vertical) elseif id == glue_code then local content = current.leader if content then - current.leaders = visualize(content,false) + current.leader = visualize(content,false) elseif trace_glue then head, current = ruledglue(head,current,vertical) end @@ -556,15 +685,21 @@ local function visualize(head,vertical) current.list = visualize(content,false) end if trace_hbox then - head, current = ruledbox(head,current,false) + head, current = ruledbox(head,current,false,l_hbox) end elseif id == vlist_code then local content = current.list if content then current.list = visualize(content,true) end - if trace_vbox then - head, current = ruledbox(head,current,true) + if trace_vtop then + head, current = ruledbox(head,current,true,l_vtop) + elseif trace_vbox then + head, current = ruledbox(head,current,true,l_vbox) + end + elseif id == whatsit_code then + if trace_whatsit then + head, current = whatsit(head,current) end end current = current.next @@ -586,30 +721,37 @@ local function freed(cache) end local function cleanup() - local hf, ng, np, nk + local hf, ng, np, nk, nw nf, f_cache = freed(f_cache) ng, g_cache = freed(g_cache) np, p_cache = freed(p_cache) nk, k_cache = freed(k_cache) + nw, w_cache = freed(w_cache) if b_cache then free_node_list(b_cache) b_cache = nil end - -- report_visualize("cache: %s fontkerns, %s skips, %s penalties, %s kerns",nf,ng,np,nk) + -- report_visualize("cache: %s fontkerns, %s skips, %s penalties, %s kerns, %s whatsits",nf,ng,np,nk,nw) end function visualizers.handler(head) if usedfont then starttiming(visualizers) + -- local l = tex_attribute[a_layer] + -- local v = tex_attribute[a_visual] + -- tex_attribute[a_layer] = unsetvalue + -- tex_attribute[a_visual] = unsetvalue head = visualize(head) --- cleanup() + -- tex_attribute[a_layer] = l + -- tex_attribute[a_visual] = v + -- -- cleanup() stoptiming(visualizers) end return head, false end -function nodes.visualizers.box(n) - tex.box[n].list = nodes.visualizers.handler(tex.box[n].list) +function visualizers.box(n) + tex.box[n].list = visualizers.handler(tex.box[n].list) end statistics.register("visualization time",function() diff --git a/tex/context/base/trac-vis.mkiv b/tex/context/base/trac-vis.mkiv index 256c648fc..ed24edf92 100644 --- a/tex/context/base/trac-vis.mkiv +++ b/tex/context/base/trac-vis.mkiv @@ -41,13 +41,27 @@ %D We only provide box visualizers as they can come in handy for testing %D macros. In due time we will move some of the m-visual code here too. +\let\syst_visualizers_hbox\hbox +\let\syst_visualizers_vbox\vbox +\let\syst_visualizers_vtop\vtop -\unexpanded\def\ruledhbox{\hbox attr \visualattribute \ctxcommand{visual("hbox")} } -\unexpanded\def\ruledvbox{\vbox attr \visualattribute \ctxcommand{visual("vbox")} } -\unexpanded\def\ruledvtop{\vtop attr \visualattribute \ctxcommand{visual("vbox")} } +\unexpanded\def\ruledhbox{\syst_visualizers_hbox attr \visualattribute \ctxcommand{visual("hbox")} } +\unexpanded\def\ruledvbox{\syst_visualizers_vbox attr \visualattribute \ctxcommand{visual("vbox")} } +\unexpanded\def\ruledvtop{\syst_visualizers_vtop attr \visualattribute \ctxcommand{visual("vtop")} } % special case \unexpanded\def\showmakeup - {\ctxcommand{setvisual("makeup")} } + {\ctxcommand{setvisual("makeup")}% + \let\normalvtop\ruledvtop + \let\vtop \ruledvtop} + +\unexpanded\def\showallmakeup + {\ctxcommand{setvisual("all")}% + \let\normalvtop\ruledvtop + \let\vtop \ruledvtop + \showstruts} + +\unexpanded\def\showglyphs + {\ctxcommand{setvisual("glyph")}} \unexpanded\def\setvisualizerfont {\dosingleempty\syst_visualizers_setfont} @@ -58,6 +72,15 @@ \ctxlua{nodes.visualizers.setfont()}% \endgroup} +%D Overload: + +% \def\spac_struts_vide_hbox +% {\hbox attr \visualattribute \ctxcommand{visual("strut")} } + +\def\spac_struts_vide_hbox + {\edef\spac_struts_vide_hbox{\hbox attr \visualattribute \ctxcommand{visual("strut")} }% + \spac_struts_vide_hbox} + %D We keep this one: \unexpanded\def\dontinterfere -- cgit v1.2.3