summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tex/context/base/context-version.pdfbin4147 -> 4149 bytes
-rw-r--r--tex/context/base/context-version.pngbin106247 -> 106143 bytes
-rw-r--r--tex/context/base/context.mkiv7
-rw-r--r--tex/context/base/core-var.mkiv8
-rw-r--r--tex/context/base/font-aux.mkvi101
-rw-r--r--tex/context/base/font-pre.mkiv2
-rw-r--r--tex/context/base/font-set.mkvi2
-rw-r--r--tex/context/base/grph-epd.mkiv4
-rw-r--r--tex/context/base/lpdf-ren.lua9
-rw-r--r--tex/context/base/m-oldfun.mkiv (renamed from tex/context/base/supp-fun.mkiv)44
-rw-r--r--tex/context/base/m-oldnum.mkiv (renamed from tex/context/base/supp-num.mkiv)2
-rw-r--r--tex/context/base/mult-dim.mkvi1
-rw-r--r--tex/context/base/node-fin.lua32
-rw-r--r--tex/context/base/spac-ali.mkiv4
-rw-r--r--tex/context/base/spac-def.mkiv77
-rw-r--r--tex/context/base/spac-grd.mkiv51
-rw-r--r--tex/context/base/spac-hor.mkiv33
-rw-r--r--tex/context/base/spac-ver.mkiv46
-rw-r--r--tex/context/base/status-files.pdfbin24505 -> 24491 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin182500 -> 182544 bytes
-rw-r--r--tex/context/base/status-mkiv.lua34
-rw-r--r--tex/context/base/supp-mat.mkiv88
-rw-r--r--tex/context/base/syst-aux.mkiv5
-rw-r--r--tex/context/base/trac-vis.lua234
-rw-r--r--tex/context/base/trac-vis.mkiv31
25 files changed, 529 insertions, 286 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 6158e4aee..f9ca424c5 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 1b1cacf07..9d7298d86 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files 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/supp-fun.mkiv b/tex/context/base/m-oldfun.mkiv
index 33bee0306..1c5a1d29d 100644
--- a/tex/context/base/supp-fun.mkiv
+++ b/tex/context/base/m-oldfun.mkiv
@@ -1,5 +1,5 @@
%D \module
-%D [ file=supp-fun,
+%D [ file=m-oldfun, % was: supp-fun
%D version=1995.10.10,
%D title=\CONTEXT\ Support Macros,
%D subtitle=Fun Stuff,
@@ -119,7 +119,7 @@
\let\globaldropcaps\global % will be an option, but on by default
-\def\localdropcaps{\let\globaldropcaps\relax}
+\unexpanded\def\localdropcaps{\let\globaldropcaps\relax}
\chardef\DroppedStatus = 0 % 0=done 1=starting 2=doing 3=error
\chardef\DropMode = 0 % 1 == marginhang
@@ -128,7 +128,7 @@
\let\keeplinestogether\gobbleoneargument
\fi
-\def\DroppedCaps#1#2#3#4#5#6#7% does not yet handle accented chars
+\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
@@ -222,10 +222,10 @@
\newcount\lastprevgraf
\newcount\droppedlines
-\def\CheckDroppedCaps
+\unexpanded\def\CheckDroppedCaps
{\global\lastprevgraf\prevgraf}
-\def\AutoDroppedCaps % will be proper core stuff since it
+\unexpanded\def\AutoDroppedCaps % will be proper core stuff since it
{\globaldropcaps\chardef\DroppedStatus\plusone
\global\lastprevgraf\zerocount
\global\droppedlines\zerocount
@@ -234,10 +234,10 @@
\let\AutoDroppedNext\relax
\ifx\AutoDroppedCapsCommand\undefined
- \def\AutoDroppedCapsCommand{\NiceDroppedCaps{}{SerifBold}{.125em}{3}}
+ \unexpanded\def\AutoDroppedCapsCommand{\NiceDroppedCaps{}{SerifBold}{.125em}{3}}
\fi
-\def\doAutoDroppedCaps
+\unexpanded\def\doAutoDroppedCaps
{\ifcase\DroppedStatus % done
\let\next\relax
\or % starting
@@ -287,7 +287,7 @@
%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
+\unexpanded\def\DoLineDroppedCaps#1#2#3#4#5% compensation command font offset lines
{\scratchcounter#5%
\advance\scratchcounter \minusone
\scratchdimen\scratchcounter\baselineskip
@@ -296,10 +296,10 @@
\DroppedCaps{#2}{#3}\TheNormalizedFontSize{#4}
{\scratchcounter\baselineskip}{#5}}
-\def\LineDroppedCaps% command font offset lines
+\unexpanded\def\LineDroppedCaps% command font offset lines
{\DoLineDroppedCaps{\strutht}}
-\def\NiceDroppedCaps% command font offset lines
+\unexpanded\def\NiceDroppedCaps% command font offset lines
{\DoLineDroppedCaps{.5\baselineskip}}
%D \macros
@@ -337,7 +337,7 @@
%D with that. A workaround is rather trivial but obscures the
%D principles used.
-\def\TreatFirstLine#1#2#3#4% before, after, first, next
+\unexpanded\def\TreatFirstLine#1#2#3#4% before, after, first, next
{\leavevmode
\bgroup
\forgetall
@@ -428,7 +428,7 @@
%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
+\unexpanded\def\TreatFirstCharacter#1#2% command, character
{{#1{#2}}}
%D A previous paragraph started with:
@@ -440,7 +440,7 @@
%D
%D The next hack deals with vertical stacking.
-\def\StackCharacters#1#2#3#4% sequence vsize vskip command
+\unexpanded\def\StackCharacters#1#2#3#4% sequence vsize vskip command
{\vbox #2
{\forgetall
\baselineskip\zeropoint
@@ -531,10 +531,10 @@
%D
%D These are implemented using an auxilliary macro:
-\def\NormalizeFontHeight{\NormalizeFontSize\ht}
-\def\NormalizeFontWidth {\NormalizeFontSize\wd}
+\unexpanded\def\NormalizeFontHeight{\NormalizeFontSize\ht}
+\unexpanded\def\NormalizeFontWidth {\NormalizeFontSize\wd}
-\def\NormalizeFontSize#1#2#3#4#5%
+\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
@@ -557,7 +557,7 @@
%D Extra:
-\def\WidthSpanningText#1#2#3% text width font
+\unexpanded\def\WidthSpanningText#1#2#3% text width font
{\hbox{\NormalizeFontWidth\temp{#1}{#2}{#3}\temp\the\everydefinedfont#1}}
%D Consider for instance:
@@ -642,7 +642,7 @@
% #1 width #2 height #3 font #4 size #5 step #6 interlinie #7 text
-\long\def\FittingText#1#2#3#4#5#6#7%
+\unexpanded\def\FittingText#1#2#3#4#5#6#7%
{\bgroup
\forgetall
\dontcomplain
@@ -681,11 +681,9 @@
\unvbox\scratchbox
\egroup}
-%D New:
-
% \font width gap font spec text
-\def\NormalizeFontWidthSpread#1#2#3#4#5#6%
+\unexpanded\def\NormalizeFontWidthSpread#1#2#3#4#5#6%
{\global\setfalse\NFSpread
\scratchdimen#3%
\scratchdimen-.5\scratchdimen
@@ -704,10 +702,10 @@
\definefont[\strippedcsname#1][#4 #5]%
\fi}
-\def\SpreadGapText#1#2%
+\unexpanded\def\SpreadGapText#1#2%
{{\def\+{\kern#1}#2}}
-\def\GapText#1#2#3#4#5% width distance font spec title
+\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
diff --git a/tex/context/base/supp-num.mkiv b/tex/context/base/m-oldnum.mkiv
index be0df026d..efc0af472 100644
--- a/tex/context/base/supp-num.mkiv
+++ b/tex/context/base/m-oldnum.mkiv
@@ -1,5 +1,5 @@
%D \module
-%D [ file=supp-num,
+%D [ file=m-oldnum, % was: supp-num
%D version=1998.05.15,
%D title=\CONTEXT\ Support Macros,
%D subtitle=Numbers,
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
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 8b8f0f3dc..fd57767c1 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files 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",
@@ -1075,6 +1076,11 @@ return {
status = "okay",
},
{
+ filename = "font-aux",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
filename = "lxml-css",
marktype = "mkiv",
status = "okay",
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/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