summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/context/lua/mtxrun.lua19
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua19
-rwxr-xr-xscripts/context/stubs/unix/mtxrun19
-rw-r--r--tex/context/base/anch-tab.mkiv4
-rw-r--r--tex/context/base/buff-ini.mkiv37
-rw-r--r--tex/context/base/buff-ver.mkiv4
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4063 -> 4073 bytes
-rw-r--r--tex/context/base/context-version.pngbin103799 -> 105436 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv13
-rw-r--r--tex/context/base/core-env.mkiv4
-rw-r--r--tex/context/base/core-mis.mkiv395
-rw-r--r--tex/context/base/file-res.mkvi2
-rw-r--r--tex/context/base/font-fea.mkvi189
-rw-r--r--tex/context/base/font-fil.mkvi362
-rw-r--r--tex/context/base/font-ini.mkvi3233
-rw-r--r--tex/context/base/font-lib.mkvi94
-rw-r--r--tex/context/base/font-mat.mkvi408
-rw-r--r--tex/context/base/font-mis.lua2
-rw-r--r--tex/context/base/font-otf.lua6
-rw-r--r--tex/context/base/font-otn.lua14
-rw-r--r--tex/context/base/font-pre.mkiv12
-rw-r--r--tex/context/base/font-run.mkiv24
-rw-r--r--tex/context/base/font-set.mkvi142
-rw-r--r--tex/context/base/font-sty.mkvi360
-rw-r--r--tex/context/base/font-sym.mkvi231
-rw-r--r--tex/context/base/font-tra.mkiv74
-rw-r--r--tex/context/base/lxml-lpt.lua6
-rw-r--r--tex/context/base/lxml-tab.lua2
-rw-r--r--tex/context/base/lxml-xml.lua11
-rw-r--r--tex/context/base/mult-aux.mkiv143
-rw-r--r--tex/context/base/mult-low.lua2
-rw-r--r--tex/context/base/mult-sys.mkiv13
-rw-r--r--tex/context/base/node-bck.mkiv5
-rw-r--r--tex/context/base/pack-com.mkiv480
-rw-r--r--tex/context/base/pack-mis.mkvi56
-rw-r--r--tex/context/base/page-app.mkiv3
-rw-r--r--tex/context/base/page-lay.mkiv35
-rw-r--r--tex/context/base/scrn-ini.mkvi10
-rw-r--r--tex/context/base/spac-grd.mkiv2
-rw-r--r--tex/context/base/spac-pag.mkiv50
-rw-r--r--tex/context/base/status-files.pdfbin24242 -> 24297 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin170726 -> 170779 bytes
-rw-r--r--tex/context/base/status-mkiv.lua67
-rw-r--r--tex/context/base/status-mkiv.tex71
-rw-r--r--tex/context/base/syst-aux.mkiv111
-rw-r--r--tex/context/base/tabl-com.mkiv32
-rw-r--r--tex/context/base/tabl-tbl.lua21
-rw-r--r--tex/context/base/tabl-tbl.mkiv2481
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua22
52 files changed, 4959 insertions, 4337 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index f3c09d598..d289891c2 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -7566,7 +7566,7 @@ function xml.is_valid(root)
return root and not root.error
end
-xml.errorhandler = report
+xml.errorhandler = report_xml
--[[ldx--
<p>We cannot load an <l n='lpeg'/> from a filehandle so we need to load
@@ -9128,9 +9128,9 @@ end
expressions.child = function(e,pattern)
return applylpath(e,pattern) -- todo: cache
end
-expressions.count = function(e,pattern)
+expressions.count = function(e,pattern) -- what if pattern == empty or nil
local collected = applylpath(e,pattern) -- todo: cache
- return (collected and #collected) or 0
+ return pattern and (collected and #collected) or 0
end
-- external
@@ -9139,7 +9139,7 @@ expressions.oneof = function(s,...) -- slow
local t = {...} for i=1,#t do if s == t[i] then return true end end return false
end
expressions.error = function(str)
- xml.errorhandler("unknown function in lpath expression",tostring(str or "?"))
+ xml.errorhandler(format("unknown function in lpath expression: %s",tostring(str or "?")))
return false
end
expressions.undefined = function(s)
@@ -10167,6 +10167,7 @@ if not modules then modules = { } end modules ['lxml-xml'] = {
}
local concat = table.concat
+local find = string.find
local xml = xml
@@ -10416,7 +10417,7 @@ local function tags(collected,nonamespace)
return t
end
-local function empty(collected)
+local function empty(collected,spacesonly)
if not collected then
return true
end
@@ -10435,7 +10436,9 @@ local function empty(collected)
local typ = type(edk)
if typ == "table" then
return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
+ elseif edk ~= "" then
+ return false
+ elseif spacesonly and not find(edk,"%S") then
return false
end
elseif n > 1 then
@@ -10519,8 +10522,8 @@ function xml.match(id,pattern) -- number
return match(xmlfilter(id,pattern))
end
-function xml.empty(id,pattern)
- return empty(xmlfilter(id,pattern))
+function xml.empty(id,pattern,spacesonly)
+ return empty(xmlfilter(id,pattern),spacesonly)
end
xml.all = xml.filter
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index f3c09d598..d289891c2 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -7566,7 +7566,7 @@ function xml.is_valid(root)
return root and not root.error
end
-xml.errorhandler = report
+xml.errorhandler = report_xml
--[[ldx--
<p>We cannot load an <l n='lpeg'/> from a filehandle so we need to load
@@ -9128,9 +9128,9 @@ end
expressions.child = function(e,pattern)
return applylpath(e,pattern) -- todo: cache
end
-expressions.count = function(e,pattern)
+expressions.count = function(e,pattern) -- what if pattern == empty or nil
local collected = applylpath(e,pattern) -- todo: cache
- return (collected and #collected) or 0
+ return pattern and (collected and #collected) or 0
end
-- external
@@ -9139,7 +9139,7 @@ expressions.oneof = function(s,...) -- slow
local t = {...} for i=1,#t do if s == t[i] then return true end end return false
end
expressions.error = function(str)
- xml.errorhandler("unknown function in lpath expression",tostring(str or "?"))
+ xml.errorhandler(format("unknown function in lpath expression: %s",tostring(str or "?")))
return false
end
expressions.undefined = function(s)
@@ -10167,6 +10167,7 @@ if not modules then modules = { } end modules ['lxml-xml'] = {
}
local concat = table.concat
+local find = string.find
local xml = xml
@@ -10416,7 +10417,7 @@ local function tags(collected,nonamespace)
return t
end
-local function empty(collected)
+local function empty(collected,spacesonly)
if not collected then
return true
end
@@ -10435,7 +10436,9 @@ local function empty(collected)
local typ = type(edk)
if typ == "table" then
return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
+ elseif edk ~= "" then
+ return false
+ elseif spacesonly and not find(edk,"%S") then
return false
end
elseif n > 1 then
@@ -10519,8 +10522,8 @@ function xml.match(id,pattern) -- number
return match(xmlfilter(id,pattern))
end
-function xml.empty(id,pattern)
- return empty(xmlfilter(id,pattern))
+function xml.empty(id,pattern,spacesonly)
+ return empty(xmlfilter(id,pattern),spacesonly)
end
xml.all = xml.filter
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index f3c09d598..d289891c2 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -7566,7 +7566,7 @@ function xml.is_valid(root)
return root and not root.error
end
-xml.errorhandler = report
+xml.errorhandler = report_xml
--[[ldx--
<p>We cannot load an <l n='lpeg'/> from a filehandle so we need to load
@@ -9128,9 +9128,9 @@ end
expressions.child = function(e,pattern)
return applylpath(e,pattern) -- todo: cache
end
-expressions.count = function(e,pattern)
+expressions.count = function(e,pattern) -- what if pattern == empty or nil
local collected = applylpath(e,pattern) -- todo: cache
- return (collected and #collected) or 0
+ return pattern and (collected and #collected) or 0
end
-- external
@@ -9139,7 +9139,7 @@ expressions.oneof = function(s,...) -- slow
local t = {...} for i=1,#t do if s == t[i] then return true end end return false
end
expressions.error = function(str)
- xml.errorhandler("unknown function in lpath expression",tostring(str or "?"))
+ xml.errorhandler(format("unknown function in lpath expression: %s",tostring(str or "?")))
return false
end
expressions.undefined = function(s)
@@ -10167,6 +10167,7 @@ if not modules then modules = { } end modules ['lxml-xml'] = {
}
local concat = table.concat
+local find = string.find
local xml = xml
@@ -10416,7 +10417,7 @@ local function tags(collected,nonamespace)
return t
end
-local function empty(collected)
+local function empty(collected,spacesonly)
if not collected then
return true
end
@@ -10435,7 +10436,9 @@ local function empty(collected)
local typ = type(edk)
if typ == "table" then
return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
+ elseif edk ~= "" then
+ return false
+ elseif spacesonly and not find(edk,"%S") then
return false
end
elseif n > 1 then
@@ -10519,8 +10522,8 @@ function xml.match(id,pattern) -- number
return match(xmlfilter(id,pattern))
end
-function xml.empty(id,pattern)
- return empty(xmlfilter(id,pattern))
+function xml.empty(id,pattern,spacesonly)
+ return empty(xmlfilter(id,pattern),spacesonly)
end
xml.all = xml.filter
diff --git a/tex/context/base/anch-tab.mkiv b/tex/context/base/anch-tab.mkiv
index 62b46dc46..75ba07796 100644
--- a/tex/context/base/anch-tab.mkiv
+++ b/tex/context/base/anch-tab.mkiv
@@ -151,7 +151,7 @@
{\bpos}
\def\dotabulateepos#1%
- {\ifvoid\tablebox\tabulatecolumn
+ {\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column
\epos{#1}%
\glet\doflushtabulateepos\relax
\else
@@ -159,7 +159,7 @@
\fi}
\def\flushtabulatesplitbox
- {\box\tabulatebox
+ {\box\b_tabl_tabulate
\iftrialtypesetting\else\ifconditional\tablehaspositions\doflushtabulateepos\fi\fi}
\appendtoks
diff --git a/tex/context/base/buff-ini.mkiv b/tex/context/base/buff-ini.mkiv
index 0512910ce..658f54f33 100644
--- a/tex/context/base/buff-ini.mkiv
+++ b/tex/context/base/buff-ini.mkiv
@@ -20,8 +20,6 @@
% number is messy and not needed as we store the number anyway
% we can get rid of \c!number
-\newcount\nofdefinedbuffers
-
\let\currentbuffer\empty
\def\doifelsebuffer#1%
@@ -34,7 +32,7 @@
{\ctxcommand{erasebuffer("#1")}}
\setuvalue{\e!start\v!buffer}%
- {\begingroup % (1)
+ {\begingroup % (3)
\obeylines
\dosingleempty\buff_start}
@@ -45,12 +43,13 @@
{\normalexpanded{\buff_pickup{#2}{#3}{#4}{}{\buff_stop{#4}}}}
\unexpanded\def\grabbufferdata % was: \dostartbuffer
- {\begingroup % (1)
+ {\begingroup % (4)
\obeylines
\doquadrupleempty\buff_grab_direct_indeed}
\unexpanded\def\grabbufferdatadirect % name start stop
- {\buff_start_indeed\empty}
+ {\begingroup % (6)
+ \buff_start_indeed\empty}
\def\buff_grab_direct_indeed % [category] [name] [start] [stop]
{\iffourthargument
@@ -63,7 +62,8 @@
\def\buff_grab_direct_indeed_b[#1][#2][#3][#4]{\buff_start_indeed\empty{#1}{#2}{#3}}
\unexpanded\def\buff_pickup#1#2#3#4#5% name, startsequence, stopsequence, before, after
- {#4%
+ {\begingroup % (1)
+ #4%
\begingroup % (2)
\edef\catcodetableofbuffer{\number\catcodetable}%
\ctxcommand{erasebuffer("#1")}%
@@ -80,7 +80,7 @@
\buff_gobble}
\unexpanded\def\buff_stop#1%
- {% already done \egroup
+ {\endgroup % (3 & 4 & 5 & 6)
\getvalue{#1}}
\unexpanded\def\setbuffer
@@ -103,15 +103,22 @@
[\c!before=,
\c!after=]
+\newcount\c_buff_n_of_defined
+
+\let\currentdefinedbuffer\s!dummy
+
\appendtoks
- \global\advance\nofdefinedbuffers\plusone
- \setexpandedbufferparameter\c!number{\number\nofdefinedbuffers}%
- \setuevalue{\e!start\currentbuffer}{\buff_start_indeed
- {\currentbuffer}{def-\number\nofdefinedbuffers}{\e!start\currentbuffer}{\e!stop\currentbuffer}}%
- \setuevalue{\e!get\currentbuffer}{\buff_get_stored
- {\currentbuffer}{def-\number\nofdefinedbuffers}}%
+ \global\advance\c_buff_n_of_defined\plusone
+ \setexpandedbufferparameter\c!number{\number\c_buff_n_of_defined}%
+ \edef\currentdefinedbuffer{def-\number\c_buff_n_of_defined}%
+ \setuevalue{\e!start\currentbuffer}{\buff_start_defined{\currentbuffer}{\currentdefinedbuffer}{\e!start\currentbuffer}{\e!stop\currentbuffer}}%
+ \setuevalue{\e!get\currentbuffer }{\buff_get_stored{\currentbuffer}{\currentdefinedbuffer}}%
\to \everydefinebuffer
+\unexpanded\def\buff_start_defined
+ {\begingroup % (5)
+ \buff_start_indeed}
+
\def\thebuffernumber #1{\namedbufferparameter{#1}\c!number}
\def\thedefinedbuffer#1{def-\namedbufferparameter{#1}\c!number}
@@ -188,4 +195,8 @@
\let\dostartbuffer\grabbufferdata % for old times sake
+% new (expandable):
+
+\def\getbufferdata[#1]{\buff_get_stored_indeed{#1}}
+
\protect \endinput
diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv
index 52626166c..a9dab57f3 100644
--- a/tex/context/base/buff-ver.mkiv
+++ b/tex/context/base/buff-ver.mkiv
@@ -682,10 +682,10 @@
{\dotripleempty\dodotypedefinedbuffer}
\appendtoks
- \setuevalue{\e!type\currentbuffer}{\noexpand\dotypedefinedbuffer[\v!buffer][def-\number\nofdefinedbuffers]}%
+ \setuevalue{\e!type\currentbuffer}{\dotypedefinedbuffer[\v!buffer][\currentdefinedbuffer]}%
\to \everydefinebuffer
-\def\dotypebuffer[#1][#2]%
+\unexpanded\def\dotypebuffer[#1][#2]%
{\bgroup
\ifsecondargument
\setuptyping[\v!buffer][#2]%
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 43da43bd6..aefba48d3 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2012.01.12 11:03}
+\newcontextversion{2012.01.16 18:33}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index dd3bf86dd..cc0142fc7 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2012.01.12 11:03}
+\newcontextversion{2012.01.16 18:33}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 6c7fccec0..dff3babb1 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 44fc1db1b..67ef67ed4 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.mkii b/tex/context/base/context.mkii
index 944066f75..ad8f7242b 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2012.01.12 11:03}
+\edef\contextversion{2012.01.16 18:33}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 5f6719619..595d057d6 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.01.12 11:03}
+\edef\contextversion{2012.01.16 18:33}
%D For those who want to use this:
@@ -323,7 +323,16 @@
\loadmkvifile{scrn-hlp}
\loadmarkfile{char-enc} % will move up
-\loadmkvifile{font-ini} % will move up
+
+\loadmkvifile{font-lib}
+\loadmkvifile{font-fil}
+\loadmkvifile{font-fea}
+\loadmkvifile{font-mat} % might move below ini
+\loadmkvifile{font-ini}
+\loadmkvifile{font-sym}
+\loadmkvifile{font-sty}
+\loadmkvifile{font-set}
+
\loadmkvifile{font-emp}
\loadmarkfile{font-pre}
\loadmarkfile{font-unk}
diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv
index 8afe469bb..a6e9415a6 100644
--- a/tex/context/base/core-env.mkiv
+++ b/tex/context/base/core-env.mkiv
@@ -169,9 +169,9 @@
{\let\syst_modes_check_all_step\syst_modes_check_all_indeed
\rawprocesscommacommand[#3]\syst_modes_check_all_step
\ifx\syst_modes_check_all_step\gobbleoneargument
- \expandafter#2
+ \expandafter#2%
\else
- \expandafter#1
+ \expandafter#1%
\fi}
\unexpanded\def\doifmodeelse {\syst_modes_check\firstoftwoarguments\secondoftwoarguments}
diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv
index 299a01fa2..63e91143d 100644
--- a/tex/context/base/core-mis.mkiv
+++ b/tex/context/base/core-mis.mkiv
@@ -560,401 +560,6 @@
\unexpanded\def\xxbox
{\bgroup\aftergroup\egroup\hbox\bgroup\txx\let\next=}
-%D \macros
-%D {definepairedbox, setuppairedbox, placepairedbox}
-%D
-%D Paired boxes, formally called legends, but from now on a
-%D legend is just an instance, are primarily meant for
-%D typesetting some text alongside an illustration. Although
-%D there is quite some variation possible, the functionality is
-%D kept simple, if only because in most cases such pairs are
-%D typeset sober.
-%D
-%D The location specification accepts a pair, where the first
-%D keyword specifies the arrangement, and the second one the
-%D alignment. The first key of the location pair is one of
-%D \type {left}, \type {right}, \type {top} or \type {bottom},
-%D while the second key can also be \type {middle}.
-%D
-%D The first box is just collected in an horizontal box, but
-%D the second one is a vertical box that gets passed the
-%D bodyfont and alignment settings.
-
-%D Today we would implement this using layers .... but for the
-%D moment we keep it this way.
-
-% \startbuffer[test]
-% \test left \test left,top \test left,bottom \test left,middle
-% \test right \test right,top \test right,bottom \test right,middle
-% \test top \test top,left \test top,right \test top,middle
-% \test bottom \test bottom,left \test bottom,right \test bottom,middle
-% \stopbuffer
-%
-% \def\showtest#1%
-% {\pagina
-% \typebuffer[demo]
-% \def\test##1
-% {\startlinecorrection[blank]
-% \getbuffer[demo]%
-% \ruledhbox\placelegend
-% [bodyfont=6pt,location={##1}]
-% {\framed[width=.25\textwidth]{\tttf##1}}
-% {#1}
-% \stoplinecorrection}
-% \getbuffer[test]}
-%
-% \startbuffer[demo]
-% \setuplegend
-% [width=\hsize,maxwidth=\makeupwidth,
-% height=\vsize,maxheight=\makeupheight]
-% \stopbuffer
-%
-% \showtest{These examples demonstrate the default settings.}
-%
-% \startbuffer[demo]
-% \setuplegend
-% [width=\textwidth,
-% maxwidth=\textwidth]
-% \stopbuffer
-%
-% \showtest{\input tufte }
-%
-% \startbuffer[demo]
-% \setuplegend
-% [width=.65\textwidth]
-% \stopbuffer
-%
-% \showtest{\input knuth }
-%
-% \startbuffer[demo]
-% \setuplegend
-% [height=2cm]
-% \stopbuffer
-%
-% \showtest{These examples demonstrate some other settings.}
-%
-% \startbuffer[demo]
-% \setuplegend
-% [width=.65\textwidth,
-% height=2cm]
-% \stopbuffer
-%
-% \showtest{These examples demonstrate some other settings.}
-%
-% \startbuffer[demo]
-% \setuplegend
-% [n=2,align=right,width=.5\textwidth]
-% \stopbuffer
-%
-% \showtest{\input zapf }
-
-%D \macros
-%D {setuplegend, placelegend}
-%D
-%D It makes sense to typeset a legend to a figure in \TEX\
-%D and not in a drawing package. The macro \type {\placelegend}
-%D combines a figure (or something else) and its legend. This
-%D command is just a paired box.
-%D
-%D The legend is placed according to \type {location}, being
-%D \type {bottom} or \type {right}. The macro macro is used as
-%D follows.
-%D
-%D \starttyping
-%D \placefigure
-%D {whow}
-%D {\placelegend
-%D {\externalfigure[cow]}
-%D {\starttabulation
-%D \NC 1 \NC head \NC \NR
-%D \NC 2 \NC legs \NC \NR
-%D \NC 3 \NC tail \NC \NR
-%D \stoptabulation}}
-%D
-%D \placefigure
-%D {whow}
-%D {\placelegend
-%D {\externalfigure[cow]}
-%D {\starttabulation[|l|l|l|l|]
-%D \NC 1 \NC head \NC 3 \NC tail \NC \NR
-%D \NC 2 \NC legs \NC \NC \NC \NR
-%D \stoptabulation}}
-%D
-%D \placefigure
-%D {whow}
-%D {\placelegend[n=2]
-%D {\externalfigure[cow]}
-%D {\starttabulation
-%D \NC 1 \NC head \NC \NR
-%D \NC 2 \NC legs \NC \NR
-%D \NC 3 \NC tail \NC \NR
-%D \stoptabulation}}
-%D
-%D \placefigure
-%D {whow}
-%D {\placelegend[n=2]
-%D {\externalfigure[cow]}
-%D {head \par legs \par tail}}
-%D
-%D \placefigure
-%D {whow}
-%D {\placelegend[n=2]
-%D {\externalfigure[cow]}
-%D {\startitemize[packed]
-%D \item head \item legs \item tail \item belly \item horns
-%D \stopitemize}}
-%D
-%D \placefigure
-%D {whow}
-%D {\placelegend[n=2,width=.8\hsize]
-%D {\externalfigure[cow]}
-%D {\startitemize[packed]
-%D \item head \item legs \item tail \item belly \item horns
-%D \stopitemize}}
-%D \stoptyping
-
-\newsystemmode{pairedbox}
-
-\appendtoks
- \global\resetsystemmode{pairedbox}%
-\to \everyinsidefloat
-
-\newbox\firstpairedbox
-\newbox\secondpairedbox
-
-\unexpanded\def\definepairedbox
- {\dodoubleempty\dodefinepairedbox}
-
-\def\dodefinepairedbox[#1][#2]%
- {\getparameters
- [\??ld#1]
- [\c!n=1,
- \c!distance=\bodyfontsize,
- \c!before=,
- \c!after=,
- \c!color=,
- \c!style=,
- \c!inbetween={\blank[\v!medium]},
- \c!width=\hsize,
- \c!height=\vsize,
- \c!maxwidth=\textwidth, % \makeupwidth,
- \c!maxheight=\textheight, % \makeupheight,
- \c!bodyfont=,
- \c!align=,
- \c!location=\v!bottom,
- #2]%
- \setvalue{\e!setup#1\e!endsetup}{\setuppairedbox[#1]}%
- \setvalue{\e!place#1}{\placepairedbox[#1]}}
-
-\unexpanded\def\setuppairedbox
- {\dodoubleempty\dosetuppairedbox}
-
-\def\dosetuppairedbox[#1]%
- {\getparameters[\??ld#1]}
-
-\unexpanded\def\placepairedbox
- {\bgroup\dodoubleempty\doplacepairedbox}
-
-\def\doplacepairedbox[#1][#2]% watch the hsize/vsize tricks
- {\setuppairedbox[#1][#2]% % and don't change them
- \copyparameters % brrr
- [\??ld][\??ld#1]
- [\c!n,\c!distance,\c!inbetween,\c!before,\c!after,
- \c!width,\c!height,\c!maxwidth,\c!maxheight,
- \c!color,\c!style,\c!bodyfont,\c!align,\c!location]%
- \@@ldbefore\bgroup
- \global\setsystemmode{pairedbox}%
- \beforefirstpairedbox
- \dowithnextbox
- {\betweenbothpairedboxes
- \dowithnextbox
- {\afterbothpairedboxes
- \egroup\@@ldafter
- \egroup}
- \vbox\bgroup
- \insidesecondpairedbox
- \let\next=}
- \hbox}
-
-\setnewconstant\pairedlocationa\plusone
-\setnewconstant\pairedlocationb\plusfour
-
-\def\beforefirstpairedbox
- {\pairedlocationa\plusone % left
- \pairedlocationb\plusfour % middle
- \getfromcommacommand[\@@ldlocation][1]%
- \processaction
- [\commalistelement]
- [ \v!left=>\pairedlocationa\zerocount,
- \v!right=>\pairedlocationa\plusone,
- \v!top=>\pairedlocationa\plustwo,
- \v!bottom=>\pairedlocationa\plusthree]%
- \getfromcommacommand[\@@ldlocation][2]%
- \processaction
- [\commalistelement]
- [ \v!left=>\pairedlocationb\zerocount,
- \v!right=>\pairedlocationb\plusone,
- \v!high=>\pairedlocationb\plustwo,
- \v!top=>\pairedlocationb\plustwo,
- \v!low=>\pairedlocationb\plusthree,
- \v!bottom=>\pairedlocationb\plusthree,
- \v!middle=>\pairedlocationb\plusfour]}
-
-\def\betweenbothpairedboxes
- {\switchtobodyfont[\@@ldbodyfont]% split under same regime
- \setbox\firstpairedbox\flushnextbox
- \ifnum\pairedlocationa<\plustwo
- \hsize\wd\firstpairedbox % trick
- \hsize\@@ldwidth
- \scratchdimen\wd\firstpairedbox
- \advance\scratchdimen \@@lddistance
- \bgroup\advance\scratchdimen \hsize
- \ifdim\scratchdimen>\@@ldmaxwidth\relax
- \egroup
- \hsize\@@ldmaxwidth
- \advance\hsize -\scratchdimen
- \else
- \egroup
- \fi
- \else
- \hsize\wd\firstpairedbox
- \hsize\@@ldwidth % can be \hsize
- \ifdim\hsize>\@@ldmaxwidth\relax \hsize\@@ldmaxwidth \fi % can be \hsize
- \fi
- \ifnum\@@ldn>\plusone
- \setrigidcolumnhsize\hsize\@@lddistance\@@ldn
- \fi}
-
-\def\afterbothpairedboxes
- {\setbox\secondpairedbox\vbox
- {\ifnum\@@ldn>1
- \rigidcolumnbalance\nextbox
- \else
- \flushnextbox
- \fi}%
- \ifnum\pairedlocationa<\plustwo\hbox\else\vbox\fi\bgroup % hide vsize
- \forgetall
- \ifnum\pairedlocationa<\plustwo
- \scratchdimen\maxoftwoboxdimens\ht\firstpairedbox\secondpairedbox
- \vsize\scratchdimen
- \ifdim\scratchdimen<\@@ldheight\relax % can be \vsize
- \scratchdimen\@@ldheight
- \fi
- \ifdim\scratchdimen>\@@ldmaxheight\relax
- \scratchdimen\@@ldmaxheight
- \fi
- \valignpairedbox\firstpairedbox \scratchdimen
- \valignpairedbox\secondpairedbox\scratchdimen
- \else
- \scratchdimen\maxoftwoboxdimens\wd\firstpairedbox\secondpairedbox
- \halignpairedbox\firstpairedbox \scratchdimen
- \halignpairedbox\secondpairedbox\scratchdimen
- \scratchdimen\ht\secondpairedbox
- \vsize\scratchdimen
- \ifdim\ht\secondpairedbox<\@@ldheight\relax % can be \vsize
- \scratchdimen\@@ldheight\relax % \relax needed
- \fi
- \ifdim\scratchdimen>\@@ldmaxheight\relax % todo: totale hoogte
- \scratchdimen\@@ldmaxheight\relax % \relax needed
- \fi
- \ifdim\scratchdimen>\ht\secondpairedbox
- \setbox\secondpairedbox\vbox to \scratchdimen
- {\ifnum\pairedlocationa=\plusthree \vss\fi %
- \box\secondpairedbox
- \ifnum\pairedlocationa=\plustwo \vss\fi}% \kern\zeropoint
- \fi
- \fi
- \ifcase\pairedlocationa
- \box\secondpairedbox\hskip\@@lddistance\box\firstpairedbox \or
- \box\firstpairedbox \hskip\@@lddistance\box\secondpairedbox\or
- \box\secondpairedbox\endgraf \nointerlineskip \@@ldinbetween \box\firstpairedbox \or
- \box\firstpairedbox \endgraf \nointerlineskip \@@ldinbetween \box\secondpairedbox\else
- \fi
- \egroup}
-
-\def\insidesecondpairedbox
- {\forgetall
- \setupalign[\@@ldalign]%
- \tolerantTABLEbreaktrue % hm.
- \blank[\v!disable]%
- \everypar{\begstrut}}
-
-\def\maxoftwoboxdimens#1#2#3%
- {#1\ifdim#1#2>#1#3 #2\else#3\fi}
-
-\def\valignpairedbox#1#2%
- {\setbox#1\vbox to #2
- {\ifcase\pairedlocationb\or\or\or\vss\or\vss\fi
- \box#1\relax
- \ifcase\pairedlocationb\or\or\vss\or\or\vss\fi}}
-
-\def\halignpairedbox#1#2%
- {\setbox#1\hbox to #2
- {\ifcase\pairedlocationb\or\hss\or\or\or\hss\fi
- \box#1\relax
- \ifcase\pairedlocationb\hss\or\or\or\or\hss\fi}}
-
-\definepairedbox[\v!legend]
-
-\unexpanded\def\placerelativetoeachother#1#2%
- {\bgroup
- \dowithnextbox
- {\bgroup
- \setbox0\box\nextbox
- \dowithnextbox
- {\setbox2\box\nextbox
- #1{#2#########2\cr\box0\cr\box2\cr}
- \egroup
- \egroup}
- \hbox}
- \hbox}
-
-\unexpanded\def\placeontopofeachother{\placerelativetoeachother\halign\hss}
-\unexpanded\def\placesidebyside {\placerelativetoeachother\valign\vss}
-
-% to be used in some other places! todo!
-%
-% divides \hsize in fractions, will be made a bit more
-% clever and advanced when needed
-%
-% \horizontaldivision[n/m,elements,distance]
-%
-% \horizontaldivision[2/5,3,1em]
-% \horizontaldivision[2/5,3,1em]
-% \horizontaldivision[1/5,3,1em]
-%
-% \setuphorizontaldivision[afstand=,aantal=] (passend,passend)
-
-\unexpanded\def\setuphorizontaldivision
- {\dodoubleargument\getparameters[\??fr]}
-
-\def\horizontaldivision
- {\dosingleargument\dohorizontaldivision}
-
-\def\dohorizontaldivision[#1]%
- {\dodohorizontaldivision[#1,,,,,,]}
-
-\def\dodohorizontaldivision[#1/#2,#3,#4,#5]%
- {\doifelsenothing{#3}
- {\doifelse\@@frn\v!fit
- {\!!counta#2\relax}
- {\!!counta\@@frn\relax}}
- {\!!counta#3\relax}%
- \doifelsenothing{#4}
- {\doifelse\@@frdistance\v!fit
- {\!!widtha\zeropoint}
- {\!!widtha\@@frdistance}}
- {\!!widtha#4}%
- \advance\!!counta \minusone
- \multiply\!!widtha \!!counta
- \advance\hsize -\!!widtha
- \divide\hsize #2\relax
- \hsize#1\hsize}
-
-\setuphorizontaldivision
- [\c!distance=\emwidth,
- \c!n=\v!fit]
-
%D This one is for Daniel Pittman, who wanted tight fractions. We show
%D three versions. First the simple one using \type {\low} and \type {high}:
%D
diff --git a/tex/context/base/file-res.mkvi b/tex/context/base/file-res.mkvi
index 2247a2559..5162e63be 100644
--- a/tex/context/base/file-res.mkvi
+++ b/tex/context/base/file-res.mkvi
@@ -78,7 +78,7 @@
\fi}
\def\syst_files_read_file_indeed#true#false%
- {#true
+ {#true%
\relax
\normalinput{\readfilename}%
\relax}
diff --git a/tex/context/base/font-fea.mkvi b/tex/context/base/font-fea.mkvi
new file mode 100644
index 000000000..969e95575
--- /dev/null
+++ b/tex/context/base/font-fea.mkvi
@@ -0,0 +1,189 @@
+%D \module
+%D [ file=font-sty,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=features,
+%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 Macros / Features}
+
+\unprotect
+
+%D Feature management.
+%D
+%D \starttyping
+%D \definefontfeature[smallcaps][smcp=yes,script=latn]
+%D \definefontfeature[smallcaps][SmallCapitals=yes,script=latn]
+%D \definefontfeature[smallcaps][Small Capitals=yes,script=latn]
+%D \definefontfeature[smallcaps][small capitals=yes,script=latn]
+%D \definefontfeature[smallcaps][smallcapitals=yes,script=latn]
+%D
+%D \definedfont[cambria*smallcaps] test
+%D
+%D \starttext
+%D \definefontfeature[basekerned][default][mode=base]
+%D \definefontfeature[nodekerned][default][mode=node]
+%D \definefontfeature[nonekerned][default][mode=base,kern=no]
+%D \setupcolors[state=start]
+%D \startoverlay
+%D {\vbox{\red \definedfont[Serif*nonekerned at 12pt]\input tufte }}
+%D {\vbox{\blue \definedfont[Serif*basekerned at 12pt]\input tufte }}
+%D {\vbox{\green\definedfont[Serif*nodekerned at 12pt]\input tufte }}
+%D \stopoverlay
+%D \stoptext
+%D
+%D \enabletrackers[otf.kerns]
+%D
+%D \definefontfeature[withkern][default][mode=node]
+%D \definefontfeature[nokern] [default][mode=node,kern=no]
+%D \definefontfeature[single] [default][mode=node,cpsp=yes]
+%D \definefontfeature[simple] [default][mode=node,cpsp=yes,kern=no]
+%D
+%D {\definedfont[Serif*default] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
+%D {\definedfont[Serif*nokern] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
+%D {\definedfont[Serif*single] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
+%D {\definedfont[Serif*simple] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
+%D \stoptyping
+
+% \definefontfeature[slanted] [default][slant=.25]
+% \definefontfeature[stretched][default][stretch=2]
+%
+% \start \definedfont[SerifBold*slanted at 20pt] \ruledhbox{Test!} \stop
+% \start \definedfont[SerifBold*stretched at 20pt] \ruledhbox{Test!} \stop
+%
+% \definefontfeature[default] [liga=yes,texligatures=yes,texquotes=yes]
+% \definefontfeature[default-caps][liga=yes,texligatures=yes,texquotes=yes,smcp=yes,script=latn]
+%
+% \starttypescript [serif] [palatino-nova-regular] [name]
+% \definefontsynonym[Serif] [palatinonova-regular][features=default]
+% \definefontsynonym[SerifCaps][palatinonova-regular][features=default-caps] % also sets Serif
+% \stoptypescript
+%
+% \starttypescript [serif] [palatino-nova-regular] [name]
+% \definefontsynonym[Serif] [palatinonova-regular*default]
+% \definefontsynonym[SerifCaps] [palatinonova-regular*default-caps]
+% \stoptypescript
+%
+% \definetypeface[mainface][rm][serif][palatino-nova-regular][default] \setupbodyfont[mainface]
+%
+% \starttext
+% ``Test'' -- --- ff fi fl \sc ``Test'' -- --- ff fi fl
+% \stoptext
+%
+% \definefontfeature
+% [default-base]
+% [script=latn,language=dflt,liga=yes,kern=yes,tlig=yes,trep=yes]
+% \definefontfeature
+% [default-node]
+% [script=latn,language=dflt,liga=yes,kern=yes,tlig=yes,trep=yes,mode=node]
+% \definefontfeature
+% [default-none]
+% [script=latn,language=dflt,liga=yes,kern=no, tlig=yes,trep=yes]
+%
+% \startoverlay
+% {\vtop{\color[red] {\font\test=name:lmroman12regular*default-node \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[green]{\font\test=name:lmroman12regular*default-base \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[blue] {\font\test=name:lmroman12regular*default-none \test \input ward \input zapf \input linden }}}
+% \stopoverlay
+%
+% \blank
+%
+% \startoverlay
+% {\vtop{\color[red] {\font\test=name:texgyrepagella*default-node \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[green]{\font\test=name:texgyrepagella*default-base \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[blue] {\font\test=name:texgyrepagella*default-none \test \input ward \input zapf \input linden }}}
+% \stopoverlay
+%
+% \blank
+%
+% \startoverlay
+% {\vtop{\color[red] {\font\test=name:palatinonovaregular*default-node \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[green]{\font\test=name:palatinonovaregular*default-base \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[blue] {\font\test=name:palatinonovaregular*default-none \test \input ward \input zapf \input linden }}}
+% \stopoverlay
+%
+% \startoverlay
+% {\vtop{\color[red] {\font\test=name:OfficinaSerifBookITC*default-node \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[green]{\font\test=name:OfficinaSerifBookITC*default-base \test \input ward \input zapf \input linden }}}
+% {\vtop{\color[blue] {\font\test=name:OfficinaSerifBookITC*default-none \test \input ward \input zapf \input linden }}}
+% \stopoverlay
+%
+% \definefontfeature[superdefault][default][compose=yes]
+%
+% {\font\oeps=name:lmroman10regular*default at 30pt \oeps test \char7683}
+% {\font\oeps=name:lmroman10regular*superdefault at 30pt \oeps test \char7683}
+
+\unexpanded\def\definefontfeature
+ {\dotripleargument\font_basics_define_font_feature}
+
+\def\font_basics_define_font_feature[#featureset][#parent][#settings]%
+ {\ctxcommand{definefontfeature("#featureset","#parent","#settings")}}
+
+\unexpanded\def\fontfeatureslist
+ {\dodoubleargument\font_basics_features_list}
+
+\def\font_basics_features_list[#name][#separator]% todo: arg voor type
+ {\cldcommand{featurelist("#name","otf","\luaescapestring{#separator}","yes","no",true,{"number"})}}
+
+\attribute\zerocount\zerocount % first in list, so fast match
+
+\let\currentfeature\empty
+
+% ! ! ! very experimental, some test code for idris advanced features ! ! !
+%
+% \startbuffer
+% \definefontfeature[smallcaps][smallcaps][script=latn]
+% \definefontfeature[oldstyle] [oldstyle] [script=latn]
+%
+% \definedfont[name:cambria at 15pt]
+%
+% Hello there {\setff{smallcaps}capped 123 \setff{oldstyle}123!} \blank
+% Hello there {\addff{smallcaps}capped 123 \addff{oldstyle}123!} \blank
+% Hello there {\addff{smallcaps}capped \subff{smallcaps}normal} \blank
+% \stopbuffer
+%
+% \typebuffer \getbuffer
+
+\unexpanded\def\featureattribute#feature{\ctxcommand{featureattribute("#feature")}}
+\unexpanded\def\setfontfeature #feature{\ctxcommand{setfontfeature("#feature")}\edef\currentfeature{#feature}}
+%unexpanded\def\resetfontfeature {\ctxcommand{resetfontfeature()}\let\currentfeature\empty} % initial value
+\unexpanded\def\resetfontfeature {\attribute\zerocount\zerocount \let\currentfeature\empty} % initial value
+
+\unexpanded\def\addfontfeaturetoset #feature{\ctxcommand{addfs("#feature")}} % merge
+\unexpanded\def\subtractfontfeaturefromset #feature{\ctxcommand{subfs("#feature")}} % merge
+\unexpanded\def\addfontfeaturetofont #feature{\ctxcommand{addff("#feature")}} % overload
+\unexpanded\def\subtractfontfeaturefromfont#feature{\ctxcommand{subff("#feature")}} % overload
+
+\let\setff\setfontfeature
+\let\addfs\addfontfeaturetoset
+\let\subfs\subtractfontfeaturefromset
+\let\addff\addfontfeaturetofont
+\let\subff\subtractfontfeaturefromfont
+
+%D \macros
+%D {os}
+%D
+%D In good old \TEX, the old style numerals were often taken
+%D from the math fonts. No longer.
+
+\definefontfeature
+ [just-os]
+ [mode=node,onum=yes]
+
+%unexpanded\def\sc{\setfontfeature{smallcaps}}
+\unexpanded\def\os{\setfontfeature{just-os}}
+
+% \doifelsecurrentfonthasfeature{smcp}{YES}{NO}
+% \doifelsecurrentfonthasfeature{crap}{YES}{NO}
+% \doifelsecurrentfonthasfeature{kern}{YES}{NO}
+
+\def\doifelsecurrentfonthasfeature#feature%
+ {\ctxcommand{doifelsecurrentfonthasfeature("#feature")}}
+
+\protect \endinput
diff --git a/tex/context/base/font-fil.mkvi b/tex/context/base/font-fil.mkvi
new file mode 100644
index 000000000..8a9fb53cf
--- /dev/null
+++ b/tex/context/base/font-fil.mkvi
@@ -0,0 +1,362 @@
+%D \module
+%D [ file=font-fil,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Classes and Files,
+%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 Macros / Classes and Files}
+
+\unprotect
+
+%D Personally I think that using \TEX\ macro packages is
+%D complicated by the way fonts are handled. Apart from the
+%D many encodings, we also deal with different naming schemes.
+%D Confronted with this problem, I decided to change the
+%D definitions into:
+%D
+%D \starttyping
+%D \definebodyfont [12pt] [rm] [tf=Times-Roman at 12pt]
+%D \stoptyping
+%D
+%D combined with for instance:
+%D
+%D \starttyping
+%D \definefontsynonym [Times-Roman] [tir]
+%D \stoptyping
+
+% \definetypeface[palatino][rm][serif][palatino,allbold][default]
+%
+% \startfontclass[palatino]
+% \definefontsynonym [Serif] [SerifBold]
+% \definefontsynonym [SerifItalic] [SerifBoldItalic]
+% \definefontsynonym [SerifSlanted] [SerifBoldSlanted]
+% \definefontsynonym [SerifCaps] [SerifBold]
+% \stopfontclass
+%
+% \setupbodyfont[palatino]
+
+\let\fontclass\empty
+
+\unexpanded\def\startfontclass
+ {\dosingleempty\font_basics_start_font_class}
+
+\def\font_basics_start_font_class[#class]%
+ {\pushmacro\fontclass
+ \doifelse{#class}\v!each
+ {\let\fontclass\empty}
+ {\doifsomething{#class}{\def\fontclass{#class}}}}
+
+\unexpanded\def\stopfontclass
+ {\popmacro\fontclass}
+
+\def\classfont#class#name{#class#name} % \definefont[whatever][\classfont{xx}{yy} at 10pt]
+
+%D \macros
+%D {definefontsynonym, doifelsefontsynonym,
+%D expandfontsynonym, truefontname, truefontdata}
+%D
+%D While looking for fonts, fontsynonyms are used for accessing
+%D the files!
+%D
+%D \starttyping
+%D \definefontsynonym[Serif][Lucida-Bright]
+%D \definefontsynonym[Lucida-Bright][lbr][encoding=texnansi]
+%D \stoptyping
+
+\installcorenamespace {fontfile} % file synonyms
+
+\let\m_font_name\empty
+\let\m_font_file\empty
+
+\def \defaultfontfile{\truefontname{Normal}} % was cmtt10, but that one is gone
+\edef\nullfontname {\fontname\nullfont}
+
+\unexpanded\def\definefontsynonym[#name]#crap[#file]%
+ {\edef\m_font_name{#name}%
+ \edef\m_font_file{#file}%
+ \ifx\fontclass\empty
+ \expandafter\font_basics_define_font_synonym_nop
+ \else
+ \expandafter\font_basics_define_font_synonym_yes
+ \fi}
+
+\def\font_basics_define_font_synonym_nop
+ {\expandafter\let\csname\??fontfile\m_font_name\endcsname\m_font_file
+ \doifnextoptionalelse\font_basics_define_font_synonym_nop_opt\font_basics_define_font_synonym_nop_nil}
+
+\def\font_basics_define_font_synonym_yes
+ {\expandafter\let\csname\??fontfile\fontclass\m_font_name\endcsname\m_font_file
+ \doifnextoptionalelse\font_basics_define_font_synonym_yes_opt\font_basics_define_font_synonym_yes_nil}
+
+\def\font_basics_define_font_synonym_nop_opt[#specification]%
+ {\let\p_features \undefined
+ \let\p_fallbacks\undefined
+ \let\p_goodies \undefined
+ \expandafter\font_basics_get_font_parameter_nop#specification,]=,}
+
+\def\font_basics_define_font_synonym_yes_opt[#specification]%
+ {\let\p_features \undefined
+ \let\p_fallbacks\undefined
+ \let\p_goodies \undefined
+ \expandafter\font_basics_get_font_parameter_yes#specification,]=,}
+
+\def\font_basics_get_font_parameter_nop#key=#value,%
+ {\if]#key%
+ \font_basics_get_font_parameter_nop_finish
+ \else
+ \expandafter\normaldef\csname p_#key\endcsname{#value}%
+ \expandafter\font_basics_get_font_parameter_nop
+ \fi}
+
+\def\font_basics_get_font_parameter_yes#key=#value,%
+ {\if]#key%
+ \font_basics_get_font_parameter_yes_finish
+ \else
+ \expandafter\normaldef\csname p_#key\endcsname{#value}%
+ \expandafter\font_basics_get_font_parameter_yes
+ \fi}
+
+% helpers, some day these will be toks and counts
+
+% \def\fntsetdefname {\global\let\somefontname\defaultfontfile}
+% \def\fntsetsomename{\gdef\somefontname} % takes argument
+% \def\fntsetnopsize {\let\somefontsize\empty}
+% \def\fntsetsomesize{\def\somefontsize} % takes argument
+
+% happens later, else mkvi parsing gets into troubles
+
+% end of helpers
+
+% we could collect them in one macro (but no expansion)
+
+\def\font_basics_define_font_synonym_nop_nil
+ {\expandafter\let\csname\??fontfile\m_font_name\s!features \endcsname\undefined
+ \expandafter\let\csname\??fontfile\m_font_name\s!fallbacks\endcsname\undefined
+ \expandafter\let\csname\??fontfile\m_font_name\s!goodies \endcsname\undefined}
+
+\def\font_basics_define_font_synonym_yes_nil
+ {\global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!features \endcsname\undefined
+ \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!fallbacks\endcsname\undefined
+ \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\undefined}
+
+\def\font_basics_get_font_parameter_nop_finish
+ {\expandafter\let\csname\??fontfile\m_font_name\s!features \endcsname\p_features
+ \expandafter\let\csname\??fontfile\m_font_name\s!fallbacks\endcsname\p_fallbacks
+ \expandafter\let\csname\??fontfile\m_font_name\s!goodies \endcsname\p_goodies}
+
+\def\font_basics_get_font_parameter_yes_finish
+ {\global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!features \endcsname\p_features
+ \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!fallbacks\endcsname\p_fallbacks
+ \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\p_goodies}
+
+%\definefontsynonym [KopFont] [\fontclassname{officina}{SerifBold}]
+%
+%\defineclassfontsynonym [KopFont] [officina] [SerifBold]
+
+\unexpanded\def\defineclassfontsynonym
+ {\dotripleargument\font_basics_define_class_font_synonym}
+
+%\definefontsynonym[#tag][\fontclassname{#class}{#fileortag}]}
+
+\def\font_basics_define_class_font_synonym[#tag][#class][#fileortag]% needs testing
+ {\expandafter\normaldef\csname\??fontfile\fontclass#tag\endcsname{\fontclassname{#class}{#fileortag}}%
+ \font_basics_define_font_synonym_yes_nil}
+
+\let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater
+
+\unexpanded\def\setupfontsynonym
+ {\dodoubleempty\dosetupfontsynonym}
+
+\def\dosetupfontsynonym[#name][#settings]% not yet supported, will do when needed
+ {}
+
+% todo: replace * by ... less messy with features
+
+\def\truefontname#name%
+ {\expandafter\font_helpers_true_fontname#name*\empty*\relax}
+
+\def\font_helpers_true_fontname#name*#first#rest*#crap\relax
+ {\ifcsname\??fontfile\fontclass#name\endcsname
+ \ifx#first\empty
+ \expandafter\truefontname\csname\??fontfile\fontclass#name\endcsname
+ \else
+ \expandafter\font_helpers_true_fontname_check\csname\??fontfile\fontclass#name\endcsname*#first#rest%
+ \fi
+ \else\ifcsname\??fontfile\defaultfontclass#name\endcsname
+ \ifx#first\empty
+ \expandafter\truefontname\csname\??fontfile\defaultfontclass#name\endcsname
+ \else
+ \expandafter\font_helpers_true_fontname_check\csname\??fontfile\defaultfontclass#name\endcsname*#first#rest%
+ \fi
+ \else\ifcsname\??fontfile#name\endcsname
+ \ifx#first\empty
+ \expandafter\truefontname\csname\??fontfile#name\endcsname
+ \else
+ \expandafter\font_helpers_true_fontname_check\csname\??fontfile#name\endcsname*#first#rest%
+ \fi
+ \else
+ #name\ifx#first\empty\else*#first#rest\fi
+ \fi\fi\fi}
+
+\def\font_helpers_true_fontname_check#name%
+ {\expandafter\font_helpers_true_fontname_check_indeed#name*\relax}
+
+\def\font_helpers_true_fontname_check_indeed#name*#crap\relax
+ {\ifcsname\??fontfile\fontclass#name\endcsname
+ \expandafter\font_helpers_true_fontname_check\csname\??fontfile\fontclass#name\endcsname
+ \else\ifcsname\??fontfile\defaultfontclass#name\endcsname
+ \expandafter\font_helpers_true_fontname_check\csname\??fontfile\defaultfontclass#name\endcsname
+ \else\ifcsname\??fontfile#name\endcsname
+ \expandafter\font_helpers_true_fontname_check\csname\??fontfile#name\endcsname
+ \else
+ #name%
+ \fi\fi\fi}
+
+\def\expandfontsynonym#command#name% one level expansion
+ {\ifcsname\??fontfile\fontclass#name\endcsname
+ \expandafter\normaldef\expandafter#command\expandafter{\csname\??fontfile\fontclass#name\endcsname}%
+ \else\ifcsname\??fontfile\defaultfontclass#2\endcsname
+ \expandafter\normaldef\expandafter#command\expandafter{\csname\??fontfile\defaultfontclass#name\endcsname}%
+ \fi\fi}
+
+\def\doifelsefontsynonym#name%
+ {\ifcsname\??fontfile\fontclass#name\endcsname
+ \singleexpandafter\firstoftwoarguments
+ \else\ifcsname\??fontfile\defaultfontclass#name\endcsname
+ \doubleexpandafter\firstoftwoarguments
+ \else
+ \doubleexpandafter\secondoftwoarguments
+ \fi\fi}
+
+%D \macros
+%D {tracedfontname}
+%D
+%D A goody:
+
+\def\tracedfontname#name%
+ {#name\ifcsname\??fontfile\fontclass#name\endcsname
+ \expandafter\tracedfontname\csname\??fontfile\fontclass#name\endcsname
+ \else\ifcsname\??fontfile#name\endcsname
+ \expandafter\tracedfontname\csname\??fontfile#name\endcsname
+ \fi\fi}
+
+%D \macros
+%D {fontclass, defaultfontclass}
+%D
+%D The fontclass model was introduced a while after we implement
+%D the basic font model and at that time we still defaulted to
+%D no model at all. Nowadays we default to the \type {modern}
+%D fontclass.
+
+\let\fontclass \empty
+\let\defaultfontclass\empty
+
+\def\fontclassname#class#name%
+ {\ifcsname\??fontfile#class#name\endcsname
+ \fontclassname{#class}{\csname\??fontfile#class#name\endcsname}%
+ \else\ifcsname\??fontfile#name\endcsname
+ \fontclassname{#class}{\csname\??fontfile#name\endcsname}%
+ \else
+ #2%
+ \fi\fi}
+
+%D Files or names can have properties and these need to be consulted
+%D at some point. They can inherit them.
+
+% Why these expanded and rscale not ... maybe not worth the trouble (delayed
+% expansion actually would be better i.e. macros in feature specs). Test
+% without pre-expansion.
+
+\def\font_helpers_update_font_class_parameters
+ {\edef\m_font_class_direction{\ifcsname\??fontclass\fontclass\fontstyle\s!direction\endcsname\csname\??fontclass\fontclass\fontstyle\s!direction\endcsname\fi}%
+ \edef\m_font_class_features {\ifcsname\??fontclass\fontclass\fontstyle\s!features \endcsname\csname\??fontclass\fontclass\fontstyle\s!features \endcsname\fi}%
+ \edef\m_font_class_fallbacks{\ifcsname\??fontclass\fontclass\fontstyle\s!fallbacks\endcsname\csname\??fontclass\fontclass\fontstyle\s!fallbacks\endcsname\fi}%
+ \edef\m_font_class_goodies {\ifcsname\??fontclass\fontclass\fontstyle\s!goodies \endcsname\csname\??fontclass\fontclass\fontstyle\s!goodies \endcsname\fi}}
+
+% resolve
+
+\def\font_helpers_set_features_yes#name%
+ {\ifcsname\??fontfile\fontclass#name\s!features \endcsname\expandafter\let\expandafter\m_font_features
+ \csname\??fontfile\fontclass#name\s!features \endcsname\else
+ \ifcsname\??fontfile #name\s!features \endcsname\expandafter\let\expandafter\m_font_features
+ \csname\??fontfile #name\s!features \endcsname\else
+ \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_features_yes
+ \csname\??fontfile\fontclass #name\endcsname\else
+ \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_features_yes
+ \csname\??fontfile #name\endcsname\else
+ \let\m_font_features\empty\fi\fi\fi\fi}
+
+\def\font_helpers_set_fallbacks_yes#name%
+ {\ifcsname\??fontfile\fontclass#name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks
+ \csname\??fontfile\fontclass#name\s!fallbacks\endcsname\else
+ \ifcsname\??fontfile #name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks
+ \csname\??fontfile #name\s!fallbacks\endcsname\else
+ \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_fallbacks_yes
+ \csname\??fontfile\fontclass #name\endcsname\else
+ \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_fallbacks_yes
+ \csname\??fontfile #name\endcsname\else
+ \let\m_font_fallbacks\empty\fi\fi\fi\fi}
+
+\def\font_helpers_set_goodies_yes#name%
+ {\ifcsname\??fontfile\fontclass#name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies
+ \csname\??fontfile\fontclass#name\s!goodies \endcsname\else
+ \ifcsname\??fontfile #name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies
+ \csname\??fontfile #name\s!goodies \endcsname\else
+ \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_goodies_yes
+ \csname\??fontfile\fontclass #name\endcsname\else
+ \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_goodies_yes
+ \csname\??fontfile #name\endcsname\else
+ \let\m_font_goodies\empty\fi\fi\fi\fi}
+
+\def\font_helpers_set_features_nop#name%
+ {\ifcsname\??fontfile#name\s!features \endcsname\expandafter\let\expandafter\m_font_features
+ \csname\??fontfile#name\s!features \endcsname\else
+ \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_features_nop
+ \csname\??fontfile #name\endcsname\else
+ \let\m_font_features\empty\fi\fi}
+
+\def\font_helpers_set_fallbacks_nop#name%
+ {\ifcsname\??fontfile#name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks
+ \csname\??fontfile#name\s!fallbacks\endcsname\else
+ \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_fallbacks_nop
+ \csname\??fontfile #name\endcsname\else
+ \let\m_font_fallbacks\empty\fi\fi}
+
+\def\font_helpers_set_goodies_nop#name%
+ {\ifcsname\??fontfile#name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies
+ \csname\??fontfile#name\s!goodies \endcsname\else
+ \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_goodies_nop
+ \csname\??fontfile #name\endcsname\else
+ \let\m_font_goodies\empty\fi\fi}
+
+\def\font_helpers_update_font_parameters_yes
+ {\font_helpers_set_features_yes \somefontname
+ \font_helpers_set_fallbacks_yes\somefontname
+ \font_helpers_set_goodies_yes \somefontname}
+
+\def\font_helpers_update_font_parameters_nop
+ {\font_helpers_set_features_nop \somefontname
+ \font_helpers_set_fallbacks_nop\somefontname
+ \font_helpers_set_goodies_nop \somefontname}
+
+\def\font_helpers_update_font_parameters
+ {\ifx\fontclass\empty\font_helpers_update_font_parameters_nop\else\font_helpers_update_font_parameters_yes\fi}
+
+\installcorenamespace{fontclass}
+
+\unexpanded\def\savefontclassparameters#style#rscale#features#fallbacks#goodies#direction%
+ {\setxvalue{\??fontclass\fontclass#style\s!rscale }{#rscale}%
+ \setxvalue{\??fontclass\fontclass#style\s!features }{#features}%
+ \setxvalue{\??fontclass\fontclass#style\s!fallbacks}{#fallbacks}%
+ \setxvalue{\??fontclass\fontclass#style\s!goodies }{#goodies}%
+ \setxvalue{\??fontclass\fontclass#style\s!direction}{#direction}}
+
+
+\protect \endinput
diff --git a/tex/context/base/font-ini.mkvi b/tex/context/base/font-ini.mkvi
index ee50e664a..aea095823 100644
--- a/tex/context/base/font-ini.mkvi
+++ b/tex/context/base/font-ini.mkvi
@@ -12,14 +12,16 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+% todo: < 3 pt => 3pt
+% todo: check where more class usage
+% todo: split font-nam (style/alternative/size)
+% todo: split font-dim (scales etc)
+
%D Watch out: as we define inside macros in sometimes special ways,
%D an occasional \type {\normaldef} is used in order to please the
%D \MKVI\ parser.
-%D The \type {type-ini} and \type {font-ini} modules come as a pair
-%D and have mutual dependencies.
-
-%D Beware, we use s special set of parameters here:
+%D Beware, we use a special set of parameters here:
%D
%D \starttabulate[|l|l|]
%D \NC system variable (fixed) \NC \type {\s!text} \NC \NR
@@ -38,158 +40,55 @@
%D when switching sizes, and the two constants are used in key|/|value
%D situations.
-% a few more names need to be _'d but best first make all mkvi so
-% that we can come up with more meaningful names
-
-% at some point fontclass will always have a value so that quite some
-% code can go away
-
-% todo: reconsider design sizes ... kick 'm out which removes the size
-% code and simplifies things considerably. After all, there will be no
-% lm math in sizes.
-
-% \definefontfeature[smallcaps][smcp=yes,script=latn]
-% \definefontfeature[smallcaps][SmallCapitals=yes,script=latn]
-% \definefontfeature[smallcaps][Small Capitals=yes,script=latn]
-% \definefontfeature[smallcaps][small capitals=yes,script=latn]
-% \definefontfeature[smallcaps][smallcapitals=yes,script=latn]
-%
-% \definedfont[cambria*smallcaps] test
-
-% \starttext
-% \definefontfeature[basekerned][default][mode=base]
-% \definefontfeature[nodekerned][default][mode=node]
-% \definefontfeature[nonekerned][default][mode=base,kern=no]
-% \setupcolors[state=start]
-% \startoverlay
-% {\vbox{\red \definedfont[Serif*nonekerned at 12pt]\input tufte }}
-% {\vbox{\blue \definedfont[Serif*basekerned at 12pt]\input tufte }}
-% {\vbox{\green\definedfont[Serif*nodekerned at 12pt]\input tufte }}
-% \stopoverlay
-% \stoptext
-
-% \enabletrackers[otf.kerns]
-%
-% \definefontfeature[withkern][default][mode=node]
-% \definefontfeature[nokern] [default][mode=node,kern=no]
-% \definefontfeature[single] [default][mode=node,cpsp=yes]
-% \definefontfeature[simple] [default][mode=node,cpsp=yes,kern=no]
-%
-% {\definedfont[Serif*default] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
-% {\definedfont[Serif*nokern] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
-% {\definedfont[Serif*single] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
-% {\definedfont[Serif*simple] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par}
-
-% figure out why \fontbody is not expanded
+%D We should consider design sizes ... maybe kick 'm out which removes
+%D the size code and simplifies things considerably. After all, there
+%D will be no latin modern math in sizes.
\writestatus{loading}{ConTeXt Font Macros / Initialization}
-\registerctxluafile{font-ini}{1.001}
-\registerctxluafile{font-log}{1.001}
-\registerctxluafile{font-con}{1.001}
-\registerctxluafile{font-enc}{1.001}
-%registerctxluafile{font-agl}{1.001} % loaded when needed, saves 100K in format
-\registerctxluafile{font-cid}{1.001} % cid maps
-\registerctxluafile{font-map}{1.001}
-\registerctxluafile{font-syn}{1.001}
-
-\registerctxluafile{font-tfm}{1.001}
-
-\registerctxluafile{font-afm}{1.001}
-
-\registerctxluafile{font-oti}{1.001} % otf initialization
-\registerctxluafile{font-ott}{1.001} % otf tables (first)
-\registerctxluafile{font-otf}{1.001} % otf main
-\registerctxluafile{font-otb}{1.001} % otf main base
-\registerctxluafile{node-inj}{1.001} % we might split it off
-\registerctxluafile{font-otn}{1.001} % otf main node
-\registerctxluafile{font-otd}{1.001} % otf dynamics (does an overload)
-\registerctxluafile{font-ota}{1.001} % otf analyzers (needs dynamics)
-\registerctxluafile{font-otp}{1.001} % otf pack
-\registerctxluafile{font-otc}{1.001} % otf context
-\registerctxluafile{font-oth}{1.001} % otf helpers
-
-\registerctxluafile{font-pat}{1.001} % patchers
-
-\registerctxluafile{node-fnt}{1.001} % here
-
-\registerctxluafile{font-lua}{1.001}
-
-\registerctxluafile{font-vf} {1.001}
-\registerctxluafile{font-enh}{1.001}
-
-\registerctxluafile{font-gds}{1.001} % currently only otf
-
-\registerctxluafile{font-def}{1.001}
-\registerctxluafile{font-ctx}{1.001} % after def as it overloads
-
-\registerctxluafile{font-ext}{1.001}
-\registerctxluafile{font-fbk}{1.001}
-\registerctxluafile{font-chk}{1.001}
-
-\registerctxluafile{font-aux}{1.001}
+%D Documentation is somewhat messy as it contains bits and pieces of
+%D previous versions.
\unprotect
-% \def\fontrange#criteria%
-% {\font_basics_fontrange{#criteria =\bodyfontsize}}
-%
-% \def\font_basics_fontrange#criteria%
-% {\font_basics_fontrange_grab#criteria \relax}% \v_font_string_a
-%
-% \def\font_basics_fontrange_grab#specification #criterium %
-% {\ifdim\bodyfontsize#criterium%
-% #specification\expandafter\gobbleuntilrelax
-% \else
-% \expandafter\font_basics_fontrange_grab
-% \fi}
-%
-% \definefont
-% [crap]
-% [\fontrange
-% {Regular <10pt
-% RegularBold <12pt
-% RegularSlanted <15pt
-% Regular} sa 1]
-%
-% may be better:
-%
-% \definefontrange
-% [crap]
-% [Regular <10pt
-% RegularBold <12pt
-% RegularSlanted <15pt]
-% [Regular sa 1]
+%D There are several ways to specify a font. Three of them are
+%D pure \TeX\ ones, the fourth one is new:
+%D
+%D \starttyping
+%D \font\name=cmr12
+%D \font\name=cmr12 at 10pt
+%D \font\name=cmr12 scaled 2
+%D \font\name=cmr12 sa 1.440
+%D \stoptyping
+%D
+%D The non||\TEX\ alternative \type{sa} stands for {\em scaled
+%D at}. This means as much as: scale the bodyfontsize with this
+%D factor. The scaled option is not that useful as one needs to
+%D know the design size.
+%D
+%D Because \type {sa} (scaled at) and \type {mo} (mapped on)
+%D are not low level \TEX\ supported alternatives, we have to
+%D test for it ourselves. In doing so, we need an auxiliary
+%D \DIMENSION. We cannot use \type{\scratchdimen} because font
+%D loading can happen at any moment due to postponed loading.
+%D We could instead have used dirty grouping tricks, but this
+%D one works too.
+
+% \enableexperiments[fonts.autorscale]
%
+% \starttypescript[mscore]
+% \definetypeface [mscore] [rm] [serif] [mscoretimes] [default]
+% \definetypeface [mscore] [ss] [sans] [mscorearial] [default] [rscale=auto] % 0.860]
+% \definetypeface [mscore] [tt] [mono] [mscorecourier] [default] [rscale=auto] % 1.065]
+% \definetypeface [mscore] [mm] [math] [times] [default] [rscale=auto] % 1.020]
+% \stoptypescript
%
-% \dostepwiserecurse{2}{15}{1}
-% {{\switchtobodyfont[\recurselevel pt]\crap test}\endgraf}
-
-% adapted, else wrong interlinespace
-
-\unexpanded\def\setfontparameters
- {\setfalse\c_font_synchronize
- \the\everybodyfont
- \settrue\c_font_synchronize}
-
-% handy
-
-\unexpanded\def\savefont
- {\edef\savedfont{\the\font}% gives \csname
- \pushmacro\savedfont}
-
-\unexpanded\def\restorefont
- {\popmacro\savedfont
- \savedfont}
-
-\unexpanded\def\pushcurrentfont
- {\edef\popcurrentfont
- {\def\noexpand\fontbody {\fontbody}%
- \def\noexpand\fontstyle {\fontstyle}%
- \def\noexpand\fontalternative{\fontalternative}%
- \def\noexpand\fontsize {\fontsize}%
- \font_helpers_check_big_math_synchronization
- \font_helpers_synchronize_font}}
+% \starttext
+% \setupbodyfont[mscore,12pt]
+% \startTEXpage
+% test \ss test \tt test
+% \stopTEXpage
+% \stoptext
% \definetypeface[one][rm][serif][computer-roman][default]
% \definetypeface[two][rm][serif][computer-roman][default][rscale=.9]
@@ -198,51 +97,6 @@
% {\one \bf test \pushcurrentfont \two \popcurrentfont test}
%D \macros
-%D {definedfont,startfont,doiffontcharelse}
-%D
-%D A couple of relatively new macros:
-
-% \newtoks \everydefinedfont % not ot be confused with \everydefinefont
-
-\let\thedefinedfont\relax
-
-\unexpanded\def\definedfont
- {\doifnextoptionalelse\font_basics_defined_font_yes\font_basics_defined_font_nop}
-
-\def\font_basics_defined_font_yes[#specification]%
- {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
- %\definefont[thedefinedfont][#specification]%
- \font_basics_define_font_without_parameters{thedefinedfont}{#specification}%
- \thedefinedfont
- \the\everydefinedfont}
-
-\def\font_basics_defined_font_nop
- {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
- \thedefinedfont
- \the\everydefinedfont}
-
-\unexpanded\def\startfont
- {\begingroup\definedfont}
-
-\unexpanded\def\stopfont
- {\endgroup}
-
-\unexpanded\def\doiffontcharelse#specification#unicode% this could be a direct lua call
- {\begingroup
- %\definedfont[#specification]%
- \font_basics_define_font_without_parameters{thedefinedfont}{#specification}%
- \iffontchar\font#unicode\relax
- \endgroup\expandafter\firstoftwoarguments
- \else
- \endgroup\expandafter\secondoftwoarguments
- \fi}
-
-%D For more detailed (and historic information) we refer to the file
-%D \type {font-ini.mkii}. Here we have a much simplified lower level
-%D implementation due to a different approach to math. Also the chapter
-%D on fonts in the reference manual explains a lot.
-
-%D \macros
%D {rm,ss,tt,hw,cg}
%D
%D Fonts are defined in separate files. When we define a font,
@@ -462,393 +316,209 @@
%D \NC \NR
%D \HL
%D \stoptabulate
-%D
-%D Remark: math support has changed a bit.
-
-\installcorenamespace {fontfile} % file synonyms
-\installcorenamespace {fontsize} % bodyfont size prefix (12pt etc)
-\installcorenamespace {fontstyle} % full style prefix (roman etc)
-\installcorenamespace {fontshortstyle} % short style prefix (rm etc)
-\installcorenamespace {fontclassyes} % fontclass
-\installcorenamespace {fontclassnop} % nofontclass
-
-%D \macros
-%D {fontclass, defaultfontclass}
-%D
-%D The fontclass model was introduced a while after we implement
-%D the basic font model and at that time we still defaulted to
-%D no model at all. Nowadays we default to the \type {modern}
-%D fontclass.
-
-\let\fontclass \empty
-\let\defaultfontclass\empty
-
-\def\fontclassname#class#name%
- {\ifcsname\??fontfile#class#name\endcsname
- \fontclassname{#class}{\csname\??fontfile#class#name\endcsname}%
- \else\ifcsname\??fontfile#name\endcsname
- \fontclassname{#class}{\csname\??fontfile#name\endcsname}%
- \else
- #2%
- \fi\fi}
-
-%D \macros
-%D {textonly}
-%D
-%D Traditionally math has a big impact on font definitions, mainly
-%D because we need to define alphabet variants using families and
-%D fonts. This means that one can easily get 10 fonts loaded per
-%D math size. In \MKIV\ we use a different approach: one family
-%D which has either a virtual font made of traditional fonts, or
-%D an \OPENTYPE\ font that has it all.
-%D
-%D We currently use only one math family but in the future we
-%D might consider using a second one for bold math. For the
-%D moment we keep the \MKII\ method of using a token register
-%D for definitions but we already dropped the text and symbols
-%D ones since they now live in the same family.
-
-\newtoks \t_font_math_strategies
-\newconditional\c_font_synchronize_math_fonts \settrue\c_font_synchronize_math_fonts
-
-\unexpanded\def\font_helpers_synchronize_math % math stuff in mmode
- {\ifconditional\c_font_synchronize_math_fonts\the\t_font_math_strategies\fi}
-\unexpanded\def\textonly{\setfalse\c_font_synchronize_math_fonts} % document this
+\fontslantperpoint \nullfont 0\scaledpoint
+\fontinterwordspace \nullfont 256377\scaledpoint
+\fontinterwordstretch\nullfont 128188\scaledpoint
+\fontinterwordshrink \nullfont 85459\scaledpoint
+\fontexheight \nullfont 338952\scaledpoint
+\fontemwidth \nullfont 786432\scaledpoint
+\fontextraspace \nullfont 85459\scaledpoint
-%D The main math font definer. We have removed some optimized
-%D code simply because we now always have a fontclass. We could
-%D check for fontclass being default or empty and save a few
-%D tests but it does not help us when no math is defined.
+%D Tracing
-%D Because we want to keep mr=.. and mb=... settings (read: not
-%D break downward compatibility by enforcing mrlr etc) we need a
-%D bit more code that optimal.
+\newtoks\t_font_tracers_definitions
-% todo: \c_font_fam_mr
+\unexpanded\def\tracefontdefinitions
+ {\the\t_font_tracers_definitions}
-\let\c_font_fam_mr \zerocount % math regular
-\let\c_font_fam_mr_lr\plusone % math regular l2r
-\let\c_font_fam_mr_rl\plustwo % math regular r2l
+%D Some housekeeping macros:
-\let\c_font_fam_mb \plusthree % math bold
-\let\c_font_fam_mb_lr\plusfour % math bold l2r
-\let\c_font_fam_mb_rl\plusfive % math bold r2l
+\unexpanded\def\setfontparameters
+ {\setfalse\c_font_synchronize
+ \the\everybodyfont
+ \settrue\c_font_synchronize}
-\definesystemattribute[mathfamily][public]
+\unexpanded\def\savefont
+ {\edef\savedfont{\the\font}% gives \csname
+ \pushmacro\savedfont}
-\newconditional\c_font_bidirectional_math_strategy % can be default, not that much overhead: \settrue\c_font_bidirectional_math_strategy
-\newconditional\c_font_complete_bold_math_strategy \settrue\c_font_complete_bold_math_strategy
+\unexpanded\def\restorefont
+ {\popmacro\savedfont
+ \savedfont}
-\def\mathtextsuffix {-text}
-\def\mathscriptsuffix {-script}
-\def\mathscriptscriptsuffix{-scriptscript}
+\unexpanded\def\pushcurrentfont
+ {\edef\popcurrentfont
+ {\def\noexpand\fontbody {\fontbody}%
+ \def\noexpand\fontstyle {\fontstyle}%
+ \def\noexpand\fontalternative{\fontalternative}%
+ \def\noexpand\fontsize {\fontsize}%
+ \font_helpers_check_big_math_synchronization
+ \font_helpers_synchronize_font}}
-\let\currentmathsize\empty
+%D \macros{definedfont}
-\def\mathsizesuffix{\ifcase0\currentmathsize\or\mathtextsuffix\or\mathscriptsuffix\or\mathscriptscriptsuffix\fi}
+\let\thedefinedfont\relax % not to be confused with \everydefinefont
-% Beware: truefontname also does a fallback on defaultfontclass so there
-% can be some interference here, which is why we use a different method
-% for bold.
+\unexpanded\def\definedfont
+ {\doifnextoptionalelse\font_basics_defined_font_yes\font_basics_defined_font_nop}
-\def\font_helpers_set_math_family_a
- {\ifcsname\fontclass \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size
- \csname\fontclass \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \else
- \ifcsname\fontclass \fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size
- \csname\fontclass \fontbody\s!mm\fontfamily \currentmathsize\endcsname \else
- \font_helpers_set_math_family_b
- \fi\fi}
+\def\font_basics_defined_font_yes[#specification]%
+ {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
+ \font_basics_define_font_without_parameters{thedefinedfont}{#specification}%
+ \thedefinedfont
+ \the\everydefinedfont}
-\def\font_helpers_set_math_family_b
- {\ifcsname\defaultfontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size
- \csname\defaultfontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \else
- \ifcsname\defaultfontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size
- \csname\defaultfontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname \else
- \font_helpers_set_math_family_c
- \fi\fi}
+\def\font_basics_defined_font_nop
+ {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
+ \thedefinedfont
+ \the\everydefinedfont}
-\def\font_helpers_set_math_family_c
- {\ifcsname \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size
- \csname \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \else
- \ifcsname \fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size
- \csname \fontbody\s!mm\fontfamily \currentmathsize\endcsname \else
- \nullfont \settrue\font_auto_font_size
- \fi\fi}
+%D \macros{startfont}
-\def\font_helpers_set_math_family_indeed#mrtag#family% \currentmathsize etc are also used later on
- {\let\savedfontbody\fontbody
- \let\fontfamily#family%
- \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\font_helpers_set_math_family_a\scriptscriptfont#mrtag\font
- \let\currentmathsize\!!plustwo \let\fontbody\scriptface \font_helpers_set_math_family_a\scriptfont #mrtag\font
- \let\currentmathsize\!!plusone \let\fontbody\textface \font_helpers_set_math_family_a\textfont #mrtag\font
- \let\currentmathsize\empty
- \let\fontbody\savedfontbody
- \setfalse\font_auto_font_size}
-
-\def\font_helpers_set_math_family_bold_a#font#mbfam#mrfam%
- {\ifcsname\fontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size
- \csname\fontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname #font#mbfam\font \else
- \ifcsname\fontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size
- \csname\fontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname #font#mbfam\font \else
- #font#mbfam#font#mrfam%
- \fi\fi}
+\unexpanded\def\startfont
+ {\begingroup\definedfont}
-\def\font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam% \c_font_fam_mb \s!mb \c_font_fam_mr
- {\let\savedfontclass\defaultfontclass
- \let\defaultfontclass\fontclass % else truefontname falls back on the wrong one
- \let\savedfontbody\fontbody
- \let\fontfamily#familytag%
- \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\font_helpers_set_math_family_bold_a\scriptscriptfont#mbfam#mrfam%
- \let\currentmathsize\!!plustwo \let\fontbody\scriptface \font_helpers_set_math_family_bold_a\scriptfont #mbfam#mrfam%
- \let\currentmathsize\!!plusone \let\fontbody\textface \font_helpers_set_math_family_bold_a\textfont #mbfam#mrfam%
- \let\currentmathsize\empty
- \let\fontbody\savedfontbody
- \let\defaultfontclass\savedfontclass
- \setfalse\font_auto_font_size}
-
-% optimized: math fonts are never changed (10K \bfa $x$: 3.2 => 2.5 (baseline 1.0))
-%
-% sort of tricky: we cannot reset in \everybeforedefinetypeface as we don't know
-% all sizes so we postpone the optimization to the first starttext
-%
-% pitfall: we should reset 'm when a fontclass name is reused
+\unexpanded\def\stopfont
+ {\endgroup}
-\newconditional\optimizemathfontdefinitions \settrue\optimizemathfontdefinitions
+%D \macros{doiffontcharelse}
-\def\font_helpers_set_math_family#mrfam#familytag%
- {\ifconditional\optimizemathfontdefinitions
- \ifcsname\??fontsclass\fontclass\textface\s!mm#familytag1\fontsize1\endcsname
- \font_helpers_preset_math_family_indeed#mrfam#familytag%
- \else
- \font_helpers_set_math_family_indeed#mrfam#familytag%
- \fi
+\unexpanded\def\doiffontcharelse#specification#unicode% this could be a direct lua call
+ {\begingroup
+ \font_basics_define_font_without_parameters{thedefinedfont}{#specification}%
+ \iffontchar\font#unicode\relax
+ \endgroup\expandafter\firstoftwoarguments
\else
- \font_helpers_set_math_family_indeed#mrfam#familytag%
+ \endgroup\expandafter\secondoftwoarguments
\fi}
-\def\font_helpers_set_math_family_bold#mbfam#familytag#mrfam%
- {\ifconditional\optimizemathfontdefinitions
- \ifcsname\??fontsclass\fontclass\textface\s!mm#familytag1\fontsize1\endcsname
- \font_helpers_preset_math_family_indeed#mbfam#familytag%
- \else
- \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam%
- \fi
- \else
- \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam%
- \fi}
+%D \macros
+%D {everybodyfont,Everybodyfont,everyglobalbodyfont}
+%D
+%D Every change in bodyfont size has conseqences for the baseline
+%D distance and skips between paragraphs. These are initialized
+%D in other modules. Here we only provide the hooks that
+%D garantees their handling.
-\def\font_helpers_preset_math_family_indeed#fam#familytag%
- {\scriptscriptfont#fam\csname\??fontsclass\fontclass\scriptscriptface\s!mm#familytag3\fontsize3\endcsname
- \scriptfont #fam\csname\??fontsclass\fontclass\scriptface \s!mm#familytag2\fontsize2\endcsname
- \textfont #fam\csname\??fontsclass\fontclass\textface \s!mm#familytag1\fontsize1\endcsname}
-
-\let\font_helpers_reset_fontclass_math_families\gobbleoneargument
-
-% It would be nice if characters could be defined in a neutral way (say fam 255) and
-% be mapped to a real family during noad list construction. However, this changes
-% tex in critical places so for the moment we simulate this using manipulation.
-
-% \appendtoks
-% \font_helpers_check_bodyfont_environment[\scriptscriptface]% pretty slow when many switches
-% \font_helpers_check_bodyfont_environment[\scriptface]%
-% \font_helpers_check_bodyfont_environment[\textface]%
-% \to \t_font_math_strategies
-
-% For tracing purposes we use three families but in l2r mode 1 and 2 are copies of 0
-% while in rl mode 0 is a copy of 1. There is no real overhead involved in this. This
-% also permits different font definitions for normal and mixed.
-
-\let\m_font_class_direction\empty
-\let\m_font_class_features \empty
-\let\m_font_class_fallbacks\empty
-\let\m_font_class_goodies \empty
-
-\let\m_font_direction\empty
-\let\m_font_features \empty
-\let\m_font_fallbacks\empty
-\let\m_font_goodies \empty
-
-\appendtoks % can be analyzed once
- % why here ..
- \edef\m_font_class_direction{\ifcsname\??fontclass\fontclass\s!mm\s!direction\endcsname\csname\??fontclass\fontclass\s!mm\s!direction\endcsname\fi}%
- % ...
- \ifx\m_font_class_direction\v!both
- \settrue\c_font_bidirectional_math_strategy
- \else
- \setfalse\c_font_bidirectional_math_strategy
- \fi
-\to \t_font_math_strategies
-
-\def\font_helpers_bidirectional_mathstrategy_yes
- {\font_helpers_set_math_family\c_font_fam_mr_lr\s!mrlr
- \font_helpers_set_math_family\c_font_fam_mr_rl\s!mrrl
- \textfont \c_font_fam_mr\textfont \c_font_fam_mr_lr
- \scriptfont \c_font_fam_mr\scriptfont \c_font_fam_mr_lr
- \scriptscriptfont\c_font_fam_mr\scriptscriptfont\c_font_fam_mr_lr}
-
-\def\font_helpers_bidirectional_mathstrategy_nop
- {\font_helpers_set_math_family\c_font_fam_mr\s!mr
- \textfont \c_font_fam_mr_rl\textfont \c_font_fam_mr
- \scriptfont \c_font_fam_mr_rl\scriptfont \c_font_fam_mr
- \scriptscriptfont\c_font_fam_mr_rl\scriptscriptfont\c_font_fam_mr
- \textfont \c_font_fam_mr_lr\textfont \c_font_fam_mr
- \scriptfont \c_font_fam_mr_lr\scriptfont \c_font_fam_mr
- \scriptscriptfont\c_font_fam_mr_lr\scriptscriptfont\c_font_fam_mr}
+%D At the system level one can initialize thing like:
+%D
+%D \starttyping
+%D \appendtoks \setupspacing \to \everybodyfont
+%D \stoptyping
+%D
+%D While users can add their own non standard commands like:
+%D
+%D \starttyping
+%D \EveryBodyFont{\message{changing to bodyfont \the\bodyfontsize}}
+%D \stoptyping
+%D
+%D Personnaly I never felt the need for such extensions, but
+%D at least its possible.
-\appendtoks
- \ifconditional\c_font_bidirectional_math_strategy
- \font_helpers_bidirectional_mathstrategy_yes
- \else
- \font_helpers_bidirectional_mathstrategy_nop
- \fi
-\to \t_font_math_strategies
-
-\def\font_helpers_complete_bold_math_strategy_yes_bidi
- {\font_helpers_set_math_family_bold\c_font_fam_mb_lr\s!mblr\c_font_fam_mr_lr
- \font_helpers_set_math_family_bold\c_font_fam_mb_rl\s!mbrl\c_font_fam_mr_rl
- \textfont \c_font_fam_mb\textfont \c_font_fam_mb_lr
- \scriptfont \c_font_fam_mb\scriptfont \c_font_fam_mb_lr
- \scriptscriptfont\c_font_fam_mb\scriptscriptfont\c_font_fam_mb_lr}
-
-\def\font_helpers_complete_bold_math_strategy_yes
- {\font_helpers_set_math_family_bold\c_font_fam_mb\s!mb\c_font_fam_mr
- \textfont \c_font_fam_mb_rl\textfont \c_font_fam_mb
- \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mb
- \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mb
- \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mb
- \scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mb
- \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mb}
-
-\def\font_helpers_complete_bold_math_strategy_nop
- {\textfont \c_font_fam_mb \textfont \c_font_fam_mr
- \scriptfont \c_font_fam_mb \scriptfont \c_font_fam_mr
- \scriptscriptfont\c_font_fam_mb \scriptscriptfont\c_font_fam_mr
- \textfont \c_font_fam_mb_rl\textfont \c_font_fam_mr_rl
- \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mr_rl
- \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mr_rl
- \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mr_lr
- \scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mr_lr
- \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mr_lr}
-
-\def\font_helpers_apply_complete_bold_math_strategy
- {\ifconditional\c_font_complete_bold_math_strategy
- \ifconditional\c_font_bidirectional_math_strategy
- \font_helpers_complete_bold_math_strategy_yes_bidi
- \else
- \font_helpers_complete_bold_math_strategy_yes
- \fi
- \else
- \font_helpers_complete_bold_math_strategynop
- \fi}
+%D \macros
+%D {globalbodyfontsize,localbodyfontsize,bodyfontsize}
-\appendtoks
- \font_helpers_apply_complete_bold_math_strategy
-\to \t_font_math_strategies
+%D Here we have to distinguish between the global (overal) bodyfont
+%D size and the local (sometimes in the textflow) size. We store
+%D these dimensions in two \DIMENSION\ registers. These registers are
+%D not to be misused in calculations.
-\ifdefined\defaultmathfamily \else
- \setnewconstant\defaultmathfamily\zerocount
-\fi
+\ifdefined\globalbodyfontsize\else \newdimen\globalbodyfontsize \fi \globalbodyfontsize=12pt
+\ifdefined\localbodyfontsize \else \newdimen\localbodyfontsize \fi \localbodyfontsize =\globalbodyfontsize
+\ifdefined\bodyfontsize \else \newdimen\bodyfontsize \fi \bodyfontsize =\globalbodyfontsize
-\appendtoks
- \fam\defaultmathfamily % all characters and symbols are in this family
-\to \everymathematics
+%D When we assign for instance 12pt to a \DIMENSION\ register the \type
+%D {\the}'d value comes out as 12.0pt, which is often not the way users
+%D specify the bodyfont size. Therefore we use normalized values. They
+%D are caches to save overhead in \LUA\ calls.
-\unexpanded\def\font_helpers_synchronize_math_family_mr
- {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_math_strategy
- \ifconditional\c_math_right_to_left
- \plustwo
- \else
- \plusone
- \fi
- \else
- \zerocount
- \fi}
+\setnewconstant\fontdigits\plustwo
-\unexpanded\def\font_helpers_synchronize_math_family_mb
- {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_math_strategy
- \ifconditional\c_math_right_to_left
- \ifconditional\c_font_pseudo_bold_math_state\pluseight\else\plusfive\fi
- \else
- \ifconditional\c_font_pseudo_bold_math_state\plusseven\else\plusfour\fi
- \fi
- \else
- \ifconditional\c_font_pseudo_bold_math_state\plussix\else\plusthree\fi
+\installcorenamespace{fontnormalizedbody}
+
+\def\normalizebodyfontsize#macro#body%
+ {\expandafter\let\expandafter#macro\csname\??fontnormalizedbody\number\fontdigits:\number\dimexpr#body\endcsname
+ \ifx#macro\relax
+ \normalizebodyfontsize_indeed#macro{#body}%
\fi}
-\installcorenamespace{fontmathsynchronizer}
-\installcorenamespace{fontmathstoredstrategy}
-
-\letvalue{\??fontmathsynchronizer\s!tf }\font_helpers_synchronize_math_family_mr
-\letvalue{\??fontmathsynchronizer\s!sl }\font_helpers_synchronize_math_family_mr
-\letvalue{\??fontmathsynchronizer\s!it }\font_helpers_synchronize_math_family_mr
-\letvalue{\??fontmathsynchronizer\s!bf }\font_helpers_synchronize_math_family_mb
-\letvalue{\??fontmathsynchronizer\s!bs }\font_helpers_synchronize_math_family_mb
-\letvalue{\??fontmathsynchronizer\s!bi }\font_helpers_synchronize_math_family_mb
-\letvalue{\??fontmathsynchronizer\empty}\font_helpers_synchronize_math_family_mr
-
-\def\font_helpers_synchronize_math_family
- {\csname\??fontmathsynchronizer\ifcsname\??fontmathsynchronizer\fontalternative\endcsname\fontalternative\fi\endcsname}
-
-\ifdefined \fontid % we need to keep this test for a while
- \appendtoks
- \ifnum\fontid\textfont\zerocount=\fontid\textfont\plusthree
- \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_partial_bold_strategy
- \else
- \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_full_bold_strategy
- \fi
- \to \t_font_math_strategies
-\else
- \appendtoks
- \edef\currentmathfontmr{\fontname\textfont\zerocount}%
- \edef\currentmathfontmb{\fontname\textfont\plusthree}%
- \ifx\currentmathfontmr\currentmathfontmb
- \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_partial_bold_strategy
- \else
- \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_full_bold_strategy
- \fi
- \to \t_font_math_strategies
-\fi
+\def\normalizebodyfontsize_indeed#macro#body%
+ {\edef#macro{\ctxcommand{nbfs(\number\dimexpr#body,\number\fontdigits)}}%
+ \global\expandafter\let\csname\??fontnormalizedbody\number\fontdigits:\number\dimexpr#body\endcsname#macro}
-\def\font_helpers_synchronize_math_bold_strategy{\csname\??fontmathstoredstrategy\fontclass\endcsname}
+\def\thenormalizedbodyfontsize#body%
+ {\ctxcommand{nbfs(\number\dimexpr#body\relax,\number\fontdigits)}}
-\newconditional\c_font_pseudo_bold_math_state
+\edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}
+\edef\normalizedlocalbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
+\edef\normalizedbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
-\def\font_helpers_set_math_partial_bold_strategy{\settrue \c_font_pseudo_bold_math_state}
-\def\font_helpers_set_math_full_bold_strategy {\setfalse\c_font_pseudo_bold_math_state}
+%D \macros
+%D {mapfontsize}
+%D
+%D For special purposes, like in math, you may want to use
+%D slightly different sizes than the ones given. This happens
+%D for instance with the Math Times fonts. Mapped font sizes
+%D can be specified by using the \type {mo} key instead of
+%D \type {sa} in font definitions.
+%D
+%D \startbuffer
+%D \mapfontsize[10pt][11pt]
+%D \mapfontsize[11pt][12pt]
+%D \mapfontsize[12pt][13pt]
+%D
+%D \definefont[test][Serif]\test TEST \par
+%D \definefont[test][Serif sa 5]\test TEST \par
+%D \definefont[test][Serif mo 5]\test TEST \par
+%D \definefont[test][Serif sa d]\test TEST \par
+%D \definefont[test][Serif at 60pt]\test TEST \par
+%D \definefont[test][Serif scaled 6000]\test TEST \par
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \startpacked
+%D \getbuffer
+%D \stoppacked
-\appendtoks
- \font_helpers_synchronize_math_bold_strategy
-\to \everymathematics
+\installcorenamespace{mappedfontsize}
-% Bold is somewhat special as we might want both full-bold-math mixed
-% regular-math, as well as automatic adaption to outer bold (in titles
-% and inline text bold) so we will need explicit switches as well as
-% an automatic one. (We will use lucida as an example.)
+\unexpanded\def\mapfontsize
+ {\dodoubleargument\font_basics_map_fontsize}
-\unexpanded\def\mr
- {\ifmmode
- \font_helpers_synchronize_math_family_mr
- \else
- \font_helpers_set_current_font_alternative\s!mr
- \fi}
+\def\font_basics_map_fontsize[#from][#to]%
+ {\setvalue{\??mappedfontsize\the\dimexpr#from\relax}{#to}}
-\unexpanded\def\mb
- {\ifmmode
- \font_helpers_synchronize_math_family_mb
- \else
- \font_helpers_set_current_font_alternative\s!mb
+\def\font_basics_set_mapped_fontsize#from%
+ {\ifcsname\??mappedfontsize\the\dimexpr#from\relax\endcsname
+ \csname\??mappedfontsize\the\dimexpr#from\relax\endcsname\else#from%
\fi}
-\appendtoks
- \font_helpers_synchronize_math_family % auto bold
-\to \everymathematics
+%D \macros
+%D {fontstyle,fontalternative,fontsize}
+%D
+%D Within a bodyfont, fonts can come in different sizes. For instance
+%D \type {\tf} is accompanied by \type {\tfa}, \type {\tfb} etc. The
+%D first two characters denote the alternative, while the third
+%D character in these sequences represents the size. The actual size
+%D is saved in a macro. The styles, being roman (\type {\rm}), sans
+%D serif (\type {\ss}) etc. are also available in macros in \type {rm},
+%D \type {ss} etc. form.
+
+\let\defaultfontalternative\s!tf
+\let\defaultfontstyle \empty
+\let\defaultfontsize \empty
-%D All used styles, like rm, ss and tt, are saved in a comma
-%D separated list. Appart from practical limitations one can
-%D define as many styles as needed.
+\let\fontalternative \defaultfontalternative
+\let\fontstyle \defaultfontstyle
+\let\fontsize \defaultfontsize
-\def\font_helpers_process_relative_size_list#command%
+\installcorenamespace{fontbodyknown}
+\installcorenamespace{fontclassyes} % fontclass
+\installcorenamespace{fontclassnop} % nofontclass
+
+\def\font_helpers_process_relative_size_list#command% could be a toks
{#command\s!text
#command\s!script
#command\s!scriptscript
@@ -857,45 +527,6 @@
#command\v!big
#command\v!small}
-%D There are several ways to specify a font. Three of them are
-%D pure \TeX\ ones, the fourth one is new:
-%D
-%D \starttyping
-%D \font\name=cmr12
-%D \font\name=cmr12 at 10pt
-%D \font\name=cmr12 scaled 2
-%D \font\name=cmr12 sa 1.440
-%D \stoptyping
-%D
-%D The non||\TEX\ alternative \type{sa} stands for {\em scaled
-%D at}. This means as much as: scale the bodyfontsize with this
-%D factor. The scaled option is not that useful as one needs to
-%D know the design size.
-%D
-%D Because \type {sa} (scaled at) and \type {mo} (mapped on)
-%D are not low level \TEX\ supported alternatives, we have to
-%D test for it ourselves. In doing so, we need an auxiliary
-%D \DIMENSION. We cannot use \type{\scratchdimen} because font
-%D loading can happen at any moment due to postponed loading.
-%D We could instead have used dirty grouping tricks, but this
-%D one works too.
-
-% \enableexperiments[fonts.autorscale]
-%
-% \starttypescript[mscore]
-% \definetypeface [mscore] [rm] [serif] [mscoretimes] [default]
-% \definetypeface [mscore] [ss] [sans] [mscorearial] [default] [rscale=auto] % 0.860]
-% \definetypeface [mscore] [tt] [mono] [mscorecourier] [default] [rscale=auto] % 1.065]
-% \definetypeface [mscore] [mm] [math] [times] [default] [rscale=auto] % 1.020]
-% \stoptypescript
-%
-% \starttext
-% \setupbodyfont[mscore,12pt]
-% \startTEXpage
-% test \ss test \tt test
-% \stopTEXpage
-% \stoptext
-
\let\v_font_size_relative \plusone
\def\v_font_size_absolute {\fontbody}
@@ -922,6 +553,123 @@
\let\relativefontid\minusone
\fi}
+\def\font_helpers_register_fontbody#body%
+ {\expandafter\let\csname\??fontbodyknown#body\endcsname\empty}
+
+%D \macros
+%D {definefontstyle,definefontsize,definefontalternative}
+%D
+%D When setting of switching the overall style we can use the
+%D short identifier like rm and ss, but when defined we can
+%D also use more verbose names like roman or sansserif. Such
+%D names are defined by:
+%D
+%D \starttyping
+%D \definefontstyle [serif,rm] [rm]
+%D \definefontstyle [sansserif,ss] [ss]
+%D \stoptyping
+
+\installcorenamespace{fontstyle} % full style prefix (roman etc)
+\installcorenamespace{fontshortstyle} % short style prefix (rm etc)
+
+\installcorenamespace{fontstyleknown}
+\installcorenamespace{fontalternativeknown}
+\installcorenamespace{fontsizeknown}
+
+\newtoks\t_font_style_commands
+\newtoks\t_font_size_commands
+\newtoks\t_font_alternative_commands
+
+\let\m_font_style_command \gobbleoneargument
+\let\m_font_size_command \gobbleoneargument
+\let\m_font_alternative_command\gobbleoneargument
+
+\def\font_helpers_process_style_list #command{\def\m_font_style_command {#command}\the\t_font_style_commands}
+\def\font_helpers_process_size_list #command{\def\m_font_size_command {#command}\the\t_font_size_commands}
+\def\font_helpers_process_alternative_list#command{\def\m_font_alternative_command{#command}\the\t_font_alternative_commands}
+
+\def\font_helpers_register_style #style{\expandafter\let\csname\??fontstyleknown #style\endcsname\empty}
+\def\font_helpers_register_size #size{\expandafter\let\csname\??fontsizeknown #size\endcsname\empty}
+\def\font_helpers_register_alternative#alternative{\expandafter\let\csname\??fontalternativeknown#alternative\endcsname\empty}
+
+\unexpanded\def\definefontstyle
+ {\dodoubleargument\font_basics_define_fontstyle}
+
+\def\font_basics_define_fontstyle[#commands][#style]% style: rm ss tt ...
+ {\ifcsname\??fontstyleknown#style\endcsname \else % can be delayed till used (cg, hw)
+ \font_helpers_register_style{#style}%
+ \t_font_style_commands\expandafter{\the\t_font_style_commands
+ \m_font_style_command{#style}}%
+ \fi
+ \processcommalist[#commands]{\font_basics_define_fontstyle_indeed{#style}}}
+
+\def\font_basics_define_fontstyle_indeed#style#command%
+ {\setvalue{\??fontshortstyle#command}{#style}%
+ \setvalue{\??fontstyle #command}{\csname#style\endcsname}}
+
+\unexpanded\def\definefontsize[#size]%
+ {\ifcsname\??fontsizeknown#size\endcsname \else
+ \font_helpers_register_size{#size}%
+ \t_font_size_commands\expandafter{\the\t_font_size_commands
+ \m_font_size_command{#size}}%
+ \fi
+ \font_helpers_check_fontname_combinations}
+
+\unexpanded\def\definefontalternative[#alternative]%
+ {\ifcsname\??fontalternativeknown#alternative\endcsname \else
+ \font_helpers_register_alternative{#alternative}%
+ \t_font_alternative_commands\expandafter{\the\t_font_alternative_commands
+ \m_font_alternative_command{#alternative}}%
+ \fi
+ \font_helpers_check_fontname_combinations}
+
+\unexpanded\def\font_helpers_check_fontname_combinations % we need to split math and text here ... todo (math only has mr and mb)
+ {\font_helpers_process_style_list\font_helpers_check_fontname_combinations_s}
+
+\def\font_helpers_check_fontname_combinations_s#style%
+ {\font_helpers_process_alternative_list{\font_helpers_check_fontname_combinations_indeed_s_a{#style}}}
+
+\def\font_helpers_check_fontname_combinations_indeed_s_a#style#alternative%
+ {\font_helpers_process_size_list{\font_basics_check_fontname_combination{#style}{#alternative}}}
+
+%D We define all the font switching commands globally. After all they are part
+%D of the formal font interface once defined. The size can be empty (so
+%D checking is needed as \type {\bf} is already defined)
+
+\let\m_font_mm\empty
+
+\def\font_basics_check_fontname_combination#style% alternative size
+ {\edef\m_font_mm{#style}%
+ \ifx\m_font_mm\s!mm % prevents \max and alike (re)defs
+ \expandafter\font_basics_check_math_bodyfont
+ \else
+ \expandafter\font_basics_check_text_bodyfont
+ \fi{#style}} % no \m_font_mm, not expanded later on
+
+\def\font_basics_check_math_bodyfont#style#alternative#size%
+ {%setugvalue{#alternative}{\font_helpers_set_current_font_alternative{#alternative}}% \mr \mb
+ \setugvalue{#style}{\font_helpers_set_current_font_style{#style}}}% \mm
+
+\def\font_basics_check_text_bodyfont#style#alternative#size% size can be empty (checking needed as \bf is already defined)
+ {\setugvalue{#style#size}{\font_helpers_set_current_font_style_size{#style}{#size}}% \rma
+ \setugvalue{#alternative#size}{\font_helpers_set_current_font_alternative_size{#alternative}{#size}}% \sla
+ \setugvalue{#style#alternative#size}{\font_helpers_set_current_font_style_alternative_size{#style}{#alternative}{#size}}% \rmsla
+ \ifcsname\s!normal#style\endcsname % text/math check
+ \expandafter\let\csname#style\expandafter\endcsname\csname\s!normal#style\endcsname
+ \else
+ \setugvalue{#style}{\font_helpers_set_current_font_style{#style}}% \rm
+ \fi
+ \ifcsname\s!normal#alternative\endcsname % text/math check
+ \expandafter\let\csname#alternative\expandafter\endcsname\csname\s!normal#alternative\endcsname
+ \else
+ \setugvalue{#alternative}{\font_helpers_set_current_font_alternative{#alternative}}% \sl
+ \fi
+ \setugvalue{#style\s!x}{\font_helpers_set_current_font_x_style_alternative{#style}}% \rmx
+ \setugvalue{#style\s!xx}{\font_helpers_set_current_font_xx_style_alternative{#style}}% \rmxx
+ \setugvalue{#alternative\s!x}{\font_helpers_set_current_font_x_alternative{#alternative}}% \slx
+ \setugvalue{#alternative\s!xx}{\font_helpers_set_current_font_xx_alternative{#alternative}}% \slxx
+ \setugvalue{#style#alternative}{\font_helpers_set_current_font_style_alternative{#style}{#alternative}}}% \rmsl
+
%D Scaling macros:
%D
%D This system is somewhat complicated by two (possible conflicting)
@@ -937,7 +685,7 @@
%D future there maybe a switch that also honors the environment
%D in named scales.
%D \stopitemize
-
+%D
%D Keep in mind that the smaller sizes are just for text super and
%D subscripts while larger sizes can be used in titles where for
%D instance math follows the size.
@@ -953,10 +701,6 @@
% 3:x{\definedfont[Serif sa 3]x}\par
% 4:x{\definedfont[Serif sa 4]x}\par
% 5:x{\definedfont[Serif sa 5]x}\par
-%
-% {\definedfont[cmbx10 at 10pt]x\definedfont[cmbx8 at 10pt]x}
-
-\installcorenamespace{fonts}
\def\safontscale{\number\dimexpr\v_font_size_absolute\relax}
\def\mofontscale{\number\dimexpr\font_basics_set_mapped_fontsize\v_font_size_absolute\relax}
@@ -969,26 +713,13 @@
\newcount\lastfontid % also used at the lua end / tex end
\newtoks \everydefinefont
-\def\currentfontbodysize
- {\ifcsname\??fonts\s!default\somefontsize\endcsname
- \csname\??fonts\s!default\somefontsize\endcsname
- \else
- \somefontsize
- \fi}
-
\let\relativefontid\empty
-% 0 = none
-% 1 = fontonly
-% 2 = classonly
-% 3 = fontfirst
-% 4 = classfirst
-
-\let\c_font_feature_inheritance_fontnone \zerocount
-\let\c_font_feature_inheritance_fontonly \plusone
-\let\c_font_feature_inheritance_classonly \plustwo
-\let\c_font_feature_inheritance_fontfirst \plusthree
-\let\c_font_feature_inheritance_classfirst\plusfour
+\let\c_font_feature_inheritance_fontnone \zerocount % none
+\let\c_font_feature_inheritance_fontonly \plusone % fontonly
+\let\c_font_feature_inheritance_classonly \plustwo % classonly
+\let\c_font_feature_inheritance_fontfirst \plusthree % fontfirst
+\let\c_font_feature_inheritance_classfirst\plusfour % classfirst
\let\c_font_feature_inheritance_default \c_font_feature_inheritance_fontfirst
@@ -1058,415 +789,34 @@
\the\everydefinefont
\c_font_feature_inheritance_mode\c_font_feature_inheritance_default}
-% Why these expanded and rscale not ... maybe not worth the trouble (delayed
-% expansion actually would be better i.e. macros in feature specs). Test
-% without pre-expansion.
-
-\def\font_helpers_update_font_class_parameters
- {\edef\m_font_class_direction{\ifcsname\??fontclass\fontclass\fontstyle\s!direction\endcsname\csname\??fontclass\fontclass\fontstyle\s!direction\endcsname\fi}%
- \edef\m_font_class_features {\ifcsname\??fontclass\fontclass\fontstyle\s!features \endcsname\csname\??fontclass\fontclass\fontstyle\s!features \endcsname\fi}%
- \edef\m_font_class_fallbacks{\ifcsname\??fontclass\fontclass\fontstyle\s!fallbacks\endcsname\csname\??fontclass\fontclass\fontstyle\s!fallbacks\endcsname\fi}%
- \edef\m_font_class_goodies {\ifcsname\??fontclass\fontclass\fontstyle\s!goodies \endcsname\csname\??fontclass\fontclass\fontstyle\s!goodies \endcsname\fi}}
-
-% resolve
-
-\def\font_helpers_set_features_yes#name%
- {\ifcsname\??fontfile\fontclass#name\s!features \endcsname\expandafter\let\expandafter\m_font_features
- \csname\??fontfile\fontclass#name\s!features \endcsname\else
- \ifcsname\??fontfile #name\s!features \endcsname\expandafter\let\expandafter\m_font_features
- \csname\??fontfile #name\s!features \endcsname\else
- \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_features_yes
- \csname\??fontfile\fontclass #name\endcsname\else
- \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_features_yes
- \csname\??fontfile #name\endcsname\else
- \let\m_font_features\empty\fi\fi\fi\fi}
-
-\def\font_helpers_set_fallbacks_yes#name%
- {\ifcsname\??fontfile\fontclass#name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks
- \csname\??fontfile\fontclass#name\s!fallbacks\endcsname\else
- \ifcsname\??fontfile #name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks
- \csname\??fontfile #name\s!fallbacks\endcsname\else
- \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_fallbacks_yes
- \csname\??fontfile\fontclass #name\endcsname\else
- \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_fallbacks_yes
- \csname\??fontfile #name\endcsname\else
- \let\m_font_fallbacks\empty\fi\fi\fi\fi}
-
-\def\font_helpers_set_goodies_yes#name%
- {\ifcsname\??fontfile\fontclass#name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies
- \csname\??fontfile\fontclass#name\s!goodies \endcsname\else
- \ifcsname\??fontfile #name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies
- \csname\??fontfile #name\s!goodies \endcsname\else
- \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_goodies_yes
- \csname\??fontfile\fontclass #name\endcsname\else
- \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_goodies_yes
- \csname\??fontfile #name\endcsname\else
- \let\m_font_goodies\empty\fi\fi\fi\fi}
-
-\def\font_helpers_set_features_nop#name%
- {\ifcsname\??fontfile#name\s!features \endcsname\expandafter\let\expandafter\m_font_features
- \csname\??fontfile#name\s!features \endcsname\else
- \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_features_nop
- \csname\??fontfile #name\endcsname\else
- \let\m_font_features\empty\fi\fi}
-
-\def\font_helpers_set_fallbacks_nop#name%
- {\ifcsname\??fontfile#name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks
- \csname\??fontfile#name\s!fallbacks\endcsname\else
- \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_fallbacks_nop
- \csname\??fontfile #name\endcsname\else
- \let\m_font_fallbacks\empty\fi\fi}
-
-\def\font_helpers_set_goodies_nop#name%
- {\ifcsname\??fontfile#name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies
- \csname\??fontfile#name\s!goodies \endcsname\else
- \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_goodies_nop
- \csname\??fontfile #name\endcsname\else
- \let\m_font_goodies\empty\fi\fi}
-
-\def\font_helpers_update_font_parameters_yes
- {\font_helpers_set_features_yes \somefontname
- \font_helpers_set_fallbacks_yes\somefontname
- \font_helpers_set_goodies_yes \somefontname}
-
-\def\font_helpers_update_font_parameters_nop
- {\font_helpers_set_features_nop \somefontname
- \font_helpers_set_fallbacks_nop\somefontname
- \font_helpers_set_goodies_nop \somefontname}
-
-\def\font_helpers_update_font_parameters
- {\ifx\fontclass\empty\font_helpers_update_font_parameters_nop\else\font_helpers_update_font_parameters_yes\fi}
+%D The following macros are used at the \LUA\ end. Watch the \type {\normal}
+%D hackery: this makes the mkvi parser happy.
+
+\normaldef\fntsetdefname {\global\let\somefontname\defaultfontfile}
+\normaldef\fntsetsomename{\normalgdef\somefontname} % takes argument
+\normaldef\fntsetnopsize {\let\somefontsize\empty}
+\normaldef\fntsetsomesize{\normaldef\somefontsize} % takes argument
\newif\ifskipfontcharacteristics \skipfontcharacteristicstrue
-%D When fontclasses are used, we define the font global,
-%D since namespaces are used. Otherwise we parse the specs
-%D each time.
+%D When fontclasses are used, we define the font global, since namespaces are
+%D used. Otherwise we parse the specs each time.
\let\fontfile\s!unknown
-% \definefontfeature[slanted] [default][slant=.25]
-% \definefontfeature[stretched][default][stretch=2]
-%
-% \start \definedfont[SerifBold*slanted at 20pt] \ruledhbox{Test!} \stop
-% \start \definedfont[SerifBold*stretched at 20pt] \ruledhbox{Test!} \stop
-
-% \definefontfeature[default] [liga=yes,texligatures=yes,texquotes=yes]
-% \definefontfeature[default-caps][liga=yes,texligatures=yes,texquotes=yes,smcp=yes,script=latn]
-%
-% \starttypescript [serif] [palatino-nova-regular] [name]
-% \definefontsynonym[Serif] [palatinonova-regular][features=default]
-% \definefontsynonym[SerifCaps][palatinonova-regular][features=default-caps] % also sets Serif
-% \stoptypescript
-%
-% \starttypescript [serif] [palatino-nova-regular] [name]
-% \definefontsynonym[Serif] [palatinonova-regular*default]
-% \definefontsynonym[SerifCaps] [palatinonova-regular*default-caps]
-% \stoptypescript
-
-% \definetypeface[mainface][rm][serif][palatino-nova-regular][default] \setupbodyfont[mainface]
-%
-% \starttext
-% ``Test'' -- --- ff fi fl \sc ``Test'' -- --- ff fi fl
-% \stoptext
-
-% \starttext
-% \definefont
-% [blabla]
-% [name:Latin Modern Something]
-% \definefont
-% [blabla]
-% [file:texnansi-lmr10]
-% \blabla test
-% \definefont
-% [blabla]
-% [texnansi-lmtt10]
-% \blabla test
-% \stoptext
-
-% \starttext
-%
-% \setupcolors[state=start]
-%
-% \definefontfeature
-% [default-base]
-% [script=latn,language=dflt,liga=yes,kern=yes,tlig=yes,trep=yes]
-% \definefontfeature
-% [default-node]
-% [script=latn,language=dflt,liga=yes,kern=yes,tlig=yes,trep=yes,mode=node]
-% \definefontfeature
-% [default-none]
-% [script=latn,language=dflt,liga=yes,kern=no, tlig=yes,trep=yes]
-%
-% \startoverlay
-% {\vtop{\color[red] {\font\test=name:lmroman12regular*default-node \test \input ward \input zapf \input linden }}}
-% {\vtop{\color[green]{\font\test=name:lmroman12regular*default-base \test \input ward \input zapf \input linden }}}
-% {\vtop{\color[blue] {\font\test=name:lmroman12regular*default-none \test \input ward \input zapf \input linden }}}
-% \stopoverlay
-%
-% \blank
-%
-% \startoverlay
-% {\vtop{\color[red] {\font\test=name:texgyrepagella*default-node \test \input ward \input zapf \input linden }}}
-% {\vtop{\color[green]{\font\test=name:texgyrepagella*default-base \test \input ward \input zapf \input linden }}}
-% {\vtop{\color[blue] {\font\test=name:texgyrepagella*default-none \test \input ward \input zapf \input linden }}}
-% \stopoverlay
-%
-% \blank
-%
-% \startoverlay
-% {\vtop{\color[red] {\font\test=name:palatinonovaregular*default-node \test \input ward \input zapf \input linden }}}
-% {\vtop{\color[green]{\font\test=name:palatinonovaregular*default-base \test \input ward \input zapf \input linden }}}
-% {\vtop{\color[blue] {\font\test=name:palatinonovaregular*default-none \test \input ward \input zapf \input linden }}}
-% \stopoverlay
-%
-% \startoverlay
-% {\vtop{\color[red] {\font\test=name:OfficinaSerifBookITC*default-node \test \input ward \input zapf \input linden }}}
-% {\vtop{\color[green]{\font\test=name:OfficinaSerifBookITC*default-base \test \input ward \input zapf \input linden }}}
-% {\vtop{\color[blue] {\font\test=name:OfficinaSerifBookITC*default-none \test \input ward \input zapf \input linden }}}
-% \stopoverlay
-%
-% \definefontfeature[superdefault][default][compose=yes]
-%
-% {\font\oeps=name:lmroman10regular*default at 30pt \oeps test \char7683}
-% {\font\oeps=name:lmroman10regular*superdefault at 30pt \oeps test \char7683}
-%
-% \stoptext
-
-\def \defaultfontfile{\truefontname{Normal}} % was cmtt10, but that one is gone
-\edef\nullfontname {\fontname\nullfont}
-
%D \macros
%D {everyfont,everyfontswitch}
-%D
-%D For special purposes, we provide a hook.
-% \newevery \everyfont \relax
-% \newevery \everyfontswitch \relax
+\ifdefined\everyfont \else \newtoks\everyfont \fi
+\ifdefined\everyfontswitch \else \newtoks\everyfontswitch \fi
-%D We also accept \type{sa a}||\type{sa d} as specification.
-
-%D \macros
-%D {definefontsynonym, doifelsefontsynonym,
-%D expandfontsynonym, truefontname, truefontdata}
-%D
-%D While looking for fonts, fontsynonyms are used for accessing
-%D the files!
-%D
-%D \starttyping
-%D \definefontsynonym[Serif][Lucida-Bright]
-%D \definefontsynonym[Lucida-Bright][lbr][encoding=texnansi]
-%D \stoptyping
-
-\def\classfont#class#name{#class#name} % \definefont[whatever][\classfont{xx}{yy} at 10pt]
-
-% We need to move the feature into the filename else it may be
-% overloaded by another reference. For instance the definition of
-% a regular and caps variant can use the same font.
-
-% We could use an indirect method ... store in 'array' and refer to
-% slot.
-%
-% or nicer .. use parent chain
-
-\let\m_font_name\empty
-\let\m_font_file\empty
-
-\unexpanded\def\definefontsynonym[#name]#crap[#file]%
- {\edef\m_font_name{#name}%
- \edef\m_font_file{#file}%
- \ifx\fontclass\empty
- \expandafter\font_basics_define_font_synonym_nop
- \else
- \expandafter\font_basics_define_font_synonym_yes
- \fi}
-
-\def\font_basics_define_font_synonym_nop
- {\expandafter\let\csname\??fontfile\m_font_name\endcsname\m_font_file
- \doifnextoptionalelse\font_basics_define_font_synonym_nop_opt\font_basics_define_font_synonym_nop_nil}
-
-\def\font_basics_define_font_synonym_yes
- {\expandafter\let\csname\??fontfile\fontclass\m_font_name\endcsname\m_font_file
- \doifnextoptionalelse\font_basics_define_font_synonym_yes_opt\font_basics_define_font_synonym_yes_nil}
-
-\def\font_basics_define_font_synonym_nop_opt[#specification]%
- {\let\p_features \undefined
- \let\p_fallbacks\undefined
- \let\p_goodies \undefined
- \expandafter\font_basics_get_font_parameter_nop#specification,]=,}
-
-\def\font_basics_define_font_synonym_yes_opt[#specification]%
- {\let\p_features \undefined
- \let\p_fallbacks\undefined
- \let\p_goodies \undefined
- \expandafter\font_basics_get_font_parameter_yes#specification,]=,}
-
-\def\font_basics_get_font_parameter_nop#key=#value,%
- {\if]#key%
- \font_basics_get_font_parameter_nop_finish
- \else
- \expandafter\normaldef\csname p_#key\endcsname{#value}%
- \expandafter\font_basics_get_font_parameter_nop
- \fi}
-
-\def\font_basics_get_font_parameter_yes#key=#value,%
- {\if]#key%
- \font_basics_get_font_parameter_yes_finish
- \else
- \expandafter\normaldef\csname p_#key\endcsname{#value}%
- \expandafter\font_basics_get_font_parameter_yes
- \fi}
-
-% helpers, some day these will be toks and counts
-
-% \def\fntsetdefname {\global\let\somefontname\defaultfontfile}
-% \def\fntsetsomename{\gdef\somefontname} % takes argument
-% \def\fntsetnopsize {\let\somefontsize\empty}
-% \def\fntsetsomesize{\def\somefontsize} % takes argument
-
-% happens later, else mkvi parsing gets into troubles
-
-% end of helpers
-
-% we could collect them in one macro (but no expansion)
-
-\def\font_basics_define_font_synonym_nop_nil
- {\expandafter\let\csname\??fontfile\m_font_name\s!features \endcsname\undefined
- \expandafter\let\csname\??fontfile\m_font_name\s!fallbacks\endcsname\undefined
- \expandafter\let\csname\??fontfile\m_font_name\s!goodies \endcsname\undefined}
-
-\def\font_basics_define_font_synonym_yes_nil
- {\global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!features \endcsname\undefined
- \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!fallbacks\endcsname\undefined
- \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\undefined}
-
-\def\font_basics_get_font_parameter_nop_finish
- {\expandafter\let\csname\??fontfile\m_font_name\s!features \endcsname\p_features
- \expandafter\let\csname\??fontfile\m_font_name\s!fallbacks\endcsname\p_fallbacks
- \expandafter\let\csname\??fontfile\m_font_name\s!goodies \endcsname\p_goodies}
-
-\def\font_basics_get_font_parameter_yes_finish
- {\global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!features \endcsname\p_features
- \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!fallbacks\endcsname\p_fallbacks
- \global\expandafter\let\csname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\p_goodies}
-
-%\definefontsynonym [KopFont] [\fontclassname{officina}{SerifBold}]
-%
-%\defineclassfontsynonym [KopFont] [officina] [SerifBold]
-
-\unexpanded\def\defineclassfontsynonym
- {\dotripleargument\font_basics_define_class_font_synonym}
-
-%\definefontsynonym[#tag][\fontclassname{#class}{#fileortag}]}
-
-\def\font_basics_define_class_font_synonym[#tag][#class][#fileortag]% needs testing
- {\expandafter\normaldef\csname\??fontfile\fontclass#tag\endcsname{\fontclassname{#class}{#fileortag}}%
- \font_basics_define_font_synonym_yes_nil}
-
-\let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater
-
-\unexpanded\def\setupfontsynonym
- {\dodoubleempty\dosetupfontsynonym}
-
-\def\dosetupfontsynonym[#name][#settings]% not yet supported, will do when needed
- {}
-
-% todo: replace * by ... less messy with features
-
-\def\truefontname#name%
- {\expandafter\font_helpers_true_fontname#name*\empty*\relax}
-
-\def\font_helpers_true_fontname#name*#first#rest*#crap\relax
- {\ifcsname\??fontfile\fontclass#name\endcsname
- \ifx#first\empty
- \expandafter\truefontname\csname\??fontfile\fontclass#name\endcsname
- \else
- \expandafter\font_helpers_true_fontname_check\csname\??fontfile\fontclass#name\endcsname*#first#rest%
- \fi
- \else\ifcsname\??fontfile\defaultfontclass#name\endcsname
- \ifx#first\empty
- \expandafter\truefontname\csname\??fontfile\defaultfontclass#name\endcsname
- \else
- \expandafter\font_helpers_true_fontname_check\csname\??fontfile\defaultfontclass#name\endcsname*#first#rest%
- \fi
- \else\ifcsname\??fontfile#name\endcsname
- \ifx#first\empty
- \expandafter\truefontname\csname\??fontfile#name\endcsname
- \else
- \expandafter\font_helpers_true_fontname_check\csname\??fontfile#name\endcsname*#first#rest%
- \fi
- \else
- #name\ifx#first\empty\else*#first#rest\fi
- \fi\fi\fi}
-
-\def\font_helpers_true_fontname_check#name%
- {\expandafter\font_helpers_true_fontname_check_indeed#name*\relax}
-
-\def\font_helpers_true_fontname_check_indeed#name*#crap\relax
- {\ifcsname\??fontfile\fontclass#name\endcsname
- \expandafter\font_helpers_true_fontname_check\csname\??fontfile\fontclass#name\endcsname
- \else\ifcsname\??fontfile\defaultfontclass#name\endcsname
- \expandafter\font_helpers_true_fontname_check\csname\??fontfile\defaultfontclass#name\endcsname
- \else\ifcsname\??fontfile#name\endcsname
- \expandafter\font_helpers_true_fontname_check\csname\??fontfile#name\endcsname
- \else
- #name%
- \fi\fi\fi}
-
-\def\expandfontsynonym#command#name% one level expansion
- {\ifcsname\??fontfile\fontclass#name\endcsname
- \expandafter\normaldef\expandafter#command\expandafter{\csname\??fontfile\fontclass#name\endcsname}%
- \else\ifcsname\??fontfile\defaultfontclass#2\endcsname
- \expandafter\normaldef\expandafter#command\expandafter{\csname\??fontfile\defaultfontclass#name\endcsname}%
- \fi\fi}
-
-\def\doifelsefontsynonym#name%
- {\ifcsname\??fontfile\fontclass#name\endcsname
- \singleexpandafter\firstoftwoarguments
- \else\ifcsname\??fontfile\defaultfontclass#name\endcsname
- \doubleexpandafter\firstoftwoarguments
- \else
- \doubleexpandafter\secondoftwoarguments
- \fi\fi}
-
-% \definetypeface[palatino][rm][serif][palatino,allbold][default]
-%
-% \startfontclass[palatino]
-% \definefontsynonym [Serif] [SerifBold]
-% \definefontsynonym [SerifItalic] [SerifBoldItalic]
-% \definefontsynonym [SerifSlanted] [SerifBoldSlanted]
-% \definefontsynonym [SerifCaps] [SerifBold]
-% \stopfontclass
-%
-% \setupbodyfont[palatino]
-
-\unexpanded\def\startfontclass
- {\dosingleempty\font_basics_start_font_class}
-
-\def\font_basics_start_font_class[#class]%
- {\pushmacro\fontclass
- \doifelse{#class}\v!each
- {\let\fontclass\empty}
- {\doifsomething{#class}{\def\fontclass{#class}}}}
-
-\unexpanded\def\stopfontclass
- {\popmacro\fontclass}
-
-%D \macros
-%D {tracedfontname}
-%D
-%D A goody:
-
-\def\tracedfontname#name%
- {#name\ifcsname\??fontfile\fontclass#name\endcsname
- \expandafter\tracedfontname\csname\??fontfile\fontclass#name\endcsname
- \else\ifcsname\??fontfile#name\endcsname
- \expandafter\tracedfontname\csname\??fontfile#name\endcsname
- \fi\fi}
+\def\setfontcharacteristics{\the\everyfont}
%D \macros
%D {definefont}
%D
+%D We also accept \type{sa a}||\type{sa d} as specification.
+%D
%D Before we implement the main definition macro, we first show
%D one for local use:
%D
@@ -1479,23 +829,6 @@
%D
%D The implementation looks as follows:
-% \unexpanded\def\definefont
-% {\dotripleempty\font_basics_define_font}
-%
-% \def\font_basics_define_font[#name][#specification][#settings]% [name][spec][1.6 | line=10pt | setup_id]
-% {\ifthirdargument
-% \setuvalue{#name}{\font_basics_define_font_with_parameters{#name}{#specification}{#settings}}%
-% \else
-% \setuvalue{#name}{\font_basics_define_font_without_parameters{#name}{#specification}}%
-% \fi}
-%
-% \def\font_basics_define_font_with_parameters#name#specification#settings%
-% {\font_basics_define_font_without_parameters{#name}{#specification}%
-% \doifsetupselse{#settings}
-% {\setups[#settings]} % don't forget to document this !
-% {\setuplocalinterlinespace[#settings]%
-% \setupspacing}} % needed ?
-
\unexpanded\def\definefont % [name][spec][1.6 | line=10pt | setup_id]
{\dotripleempty\font_basics_define_font}
@@ -1523,7 +856,8 @@
{\font_basics_define_font_without_parameters{#name}{#specification}%
\setups[#settings]}
-% Beware, currently no settings are supported ... might happen some day
+%D Beware, in the frozen variants no settings are supported yet, but that might happen
+%D some day.
\unexpanded\def\definefrozenfont
{\dotripleempty\font_basics_define_frozen_font}
@@ -1534,29 +868,26 @@
\csname#name\endcsname
\expandafter\endgroup\expandafter\let\csname#name\endcsname\lastrawfontcall}
-%D The \type {*} makes the switch local, so that we can redefine a
+%D The instance namespace protection makes the switch local so that we can redefine a
%D logical name and/or change the size in between.
% todo: now mathsize twice in name (so it can go here)
% todo: check when mathsize is needed
-\installcorenamespace{fontsbasic}
-\installcorenamespace{fontsclass}
+\ifdefined\??fontinstancebasic \else \installcorenamespace{fontinstancebasic} \fi
+\ifdefined\??fontinstanceclass \else \installcorenamespace{fontinstanceclass} \fi
\newconditional\font_auto_font_size \settrue\font_auto_font_size
\let\lastfontidentifier\empty
-\def\v_font_identifier_basic{\??fontsbasic \lastfontidentifier\fontsize\currentmathsize}
-\def\v_font_identifier_class{\??fontsclass\fontclass\lastfontidentifier\fontsize\currentmathsize}
-
-\def\v_font_identifier_basic{\??fontsbasic \lastfontidentifier\fontsize\currentmathsize}
-\def\v_font_identifier_class{\??fontsclass\fontclass\lastfontidentifier\fontsize\currentmathsize}
+\def\v_font_identifier_basic{\??fontinstancebasic \lastfontidentifier\fontsize\currentmathsize}
+\def\v_font_identifier_class{\??fontinstanceclass\fontclass\lastfontidentifier\fontsize\currentmathsize}
\let\v_font_identifier_basic_saved\v_font_identifier_basic
\let\v_font_identifier_class_saved\v_font_identifier_class
-% \def\v_font_identifier_class{\??fontsclass\fontclass\lastfontidentifier\fontstyle\fontsize} % no \currentmathsize
+% \def\v_font_identifier_class{\??fontinstanceclass\fontclass\lastfontidentifier\fontstyle\fontsize} % no \currentmathsize
\def\font_basics_define_font_without_parameters#identifier#2%
{\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
@@ -1600,72 +931,6 @@
\let\v_font_identifier_class\v_font_identifier_class_saved}
%D \macros
-%D {mapfontsize}
-%D
-%D For special purposes, like in math, you may want to use
-%D slightly different sizes than the ones given. This happens
-%D for instance with the Math Times fonts. Mapped font sizes
-%D can be specified by using the \type {mo} key instead of
-%D \type {sa} in font definitions.
-%D
-%D \startbuffer
-%D \mapfontsize[10pt][11pt]
-%D \mapfontsize[11pt][12pt]
-%D \mapfontsize[12pt][13pt]
-%D
-%D \definefont[test][Serif]\test TEST \par
-%D \definefont[test][Serif sa 5]\test TEST \par
-%D \definefont[test][Serif mo 5]\test TEST \par
-%D \definefont[test][Serif sa d]\test TEST \par
-%D \definefont[test][Serif at 60pt]\test TEST \par
-%D \definefont[test][Serif scaled 6000]\test TEST \par
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \startpacked
-%D \getbuffer
-%D \stoppacked
-
-\installcorenamespace{mappedfontsize}
-
-\unexpanded\def\mapfontsize
- {\dodoubleargument\font_basics_map_fontsize}
-
-\def\font_basics_map_fontsize[#from][#to]%
- {\setvalue{\??mappedfontsize\the\dimexpr#from\relax}{#to}}
-
-\def\font_basics_set_mapped_fontsize#from%
- {\ifcsname\??mappedfontsize\the\dimexpr#from\relax\endcsname
- \csname\??mappedfontsize\the\dimexpr#from\relax\endcsname\else#from%
- \fi}
-
-%D To be documented.
-
-\let\fontsizelist \empty
-\let\fontalternativelist\empty
-\let\fontstylelist \empty
-
-% if we really need it we can make a toks
-
-\def\font_helpers_check_fontname_combinations_indeed#size%
- {\def\font_helpers_check_fontname_combinations_indeed_a#alternative%
- {\def\font_helpers_check_fontname_combinations_indeed_b#style{\font_basics_check_bodyfont{#style}{#alternative}{#size}}%
- \processcommacommand[\fontstylelist]\font_helpers_check_fontname_combinations_indeed_b}%
- \processcommacommand[\fontalternativelist]\font_helpers_check_fontname_combinations_indeed_a}
-
-\unexpanded\def\font_helpers_check_fontname_combinations % we need to split math and text here ... todo (math only has mr and mb)
- {\processcommacommand[\fontsizelist]\font_helpers_check_fontname_combinations_indeed}
-
-\unexpanded\def\definefontsize[#size]% sneller met toks
- {\addtocommalist{#size}\fontsizelist
- \font_helpers_check_fontname_combinations}
-
-\unexpanded\def\definefontalternative[#alternative]%
- {\addtocommalist{#alternative}\fontalternativelist
- \font_helpers_check_fontname_combinations}
-
-%D \macros
%D {currentfontscale,currentfontbodyscale}
%D
%D Sometimes we need to have access to the font scale
@@ -1673,19 +938,28 @@
%D returns the current scaling factor. Take a look at
%D \type {cont-log.tex} for an example of its use.
-\def\currentfontscale
- {\csname\??fonts\s!default
- \ifcsname\??fonts\s!default\xfontsize\endcsname \xfontsize \else
- \ifcsname\??fonts\s!default\s!text \endcsname \s!text \fi\fi
+\installcorenamespace{fontenvironments}
+
+\def\currentfontbodysize
+ {\ifcsname\??fontenvironments\s!default\somefontsize\endcsname
+ \csname\??fontenvironments\s!default\somefontsize\endcsname
+ \else
+ \somefontsize
+ \fi}
+
+\def\currentfontscale % always default ?
+ {\csname\??fontenvironments\s!default
+ \ifcsname\??fontenvironments\s!default\xfontsize\endcsname \xfontsize \else
+ \ifcsname\??fontenvironments\s!default\s!text \endcsname \s!text \fi\fi
\endcsname}
\def\currentfontbodyscale
- {\csname\??fonts\s!default
- \ifcsname\??fonts\s!default\fontsize\endcsname \fontsize \else
- \ifcsname\??fonts\s!default\s!text \endcsname \s!text \fi\fi
+ {\csname\??fontenvironments\s!default
+ \ifcsname\??fontenvironments\s!default\fontsize\endcsname \fontsize \else
+ \ifcsname\??fontenvironments\s!default\s!text \endcsname \s!text \fi\fi
\endcsname}
-\setvalue{\??fonts\s!default}{1}
+\setvalue{\??fontenvironments\s!default}{1}
%D Both alternatives use \type {\xfontsize}, a macro that
%D expands to the current size in terms of \type {a} \unknown
@@ -1777,57 +1051,61 @@
%D So, apart from an occasional switch, one should define an
%D environment at the outer level.
-\letvalue\??fonts\empty % so we default to empty
+% the lookup order is:
+%
+% [class] [dimension] [parameters]
+% [class] [default] [parameters] % factors
+% [dimension] [parameters]
+% [default] [parameters] % factors
+%
+% with defaults providing factors
+
+% todo: class:size
+% todo: make assignments global
+
+\letvalue\??fontenvironments\empty % so we default to empty
\def\bodyfontvariable#parameter%
- {\csname\??fonts
- \ifcsname\??fonts\fontclass\normalizedbodyfontsize#parameter\endcsname\fontclass\normalizedbodyfontsize#parameter\else
- \ifcsname\??fonts\fontclass #parameter\endcsname\fontclass #parameter\else
- \ifcsname\??fonts \normalizedbodyfontsize#parameter\endcsname \normalizedbodyfontsize#parameter\else
- \ifcsname\??fonts\s!default #parameter\endcsname\s!default #parameter\fi\fi\fi\fi
+ {\csname\??fontenvironments
+ \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\fontclass\normalizedbodyfontsize#parameter\else
+ \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\else
+ \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname \normalizedbodyfontsize#parameter\else
+ \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi\fi\fi\fi
\endcsname}
\def\bodyfontsizevariable#size#parameter%
- {\csname\??fonts
- \ifcsname\??fonts\fontclass#size#parameter\endcsname\fontclass#size#parameter\else
- \ifcsname\??fonts\fontclass #parameter\endcsname\fontclass #parameter\else
- \ifcsname\??fonts #size#parameter\endcsname #size#parameter\else
- \ifcsname\??fonts\s!default #parameter\endcsname\s!default #parameter\fi\fi\fi\fi
+ {\csname\??fontenvironments
+ \ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\fontclass#size#parameter\else
+ \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\else
+ \ifcsname\??fontenvironments #size#parameter\endcsname #size#parameter\else
+ \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi\fi\fi\fi
\endcsname}
\def\bodyfontinterlinespace{\bodyfontvariable\c!interlinespace} % used elsewhere
\def\bodyfontdimension#class#size#parameter#body%
{\the\dimexpr
- \ifcsname\??fonts#class #size#parameter\endcsname
- \csname\??fonts#class #size#parameter\endcsname \else
- \ifcsname\??fonts#class\s!default#parameter\endcsname
- \csname\??fonts#class\s!default#parameter\endcsname\dimexpr#body\relax \else % factor
- \ifcsname\??fonts #size#parameter\endcsname
- \csname\??fonts #size#parameter\endcsname \else
- \csname\??fonts \s!default#parameter\endcsname\dimexpr#body\relax \fi\fi\fi % factor
+ \ifcsname\??fontenvironments#class #size#parameter\endcsname
+ \csname\??fontenvironments#class #size#parameter\endcsname \else
+ \ifcsname\??fontenvironments#class\s!default#parameter\endcsname
+ \csname\??fontenvironments#class\s!default#parameter\endcsname\dimexpr#body\relax \else % factor
+ \ifcsname\??fontenvironments #size#parameter\endcsname
+ \csname\??fontenvironments #size#parameter\endcsname \else
+ \csname\??fontenvironments \s!default#parameter\endcsname\dimexpr#body\relax \fi\fi\fi % factor
\relax}
-\let\bodyfontenvironmentlist\empty % used in font-run
-
\unexpanded\def\definebodyfontenvironment
{\dotripleempty\font_basics_define_body_font_environment}
\let\setupbodyfontenvironment\definebodyfontenvironment
-% the lookup order is:
-%
-% [class] [dimension] [parameters]
-% [class] [default] [parameters] % factors
-% [dimension] [parameters]
-% [default] [parameters] % factors
-%
-% with defaults providing factors
+\installcorenamespace{fontsteps} % fast cache
+\installcorenamespace{fontenvironmentknown}
-% todo: class:size
-% todo: make assignments global
+\let\bodyfontenvironmentlist\empty % used in font-run (might change)
-\installcorenamespace{fontsteps} % fast cache
+\def\font_helpers_register_environment#class#body%
+ {\expandafter\let\csname\??fontenvironmentknown#class#body\endcsname\empty}
\let\m_font_body \empty
\let\m_font_body_normalized\empty
@@ -1837,94 +1115,102 @@
\singleexpandafter\font_basics_define_body_font_environment_class
\else\ifsecondargument
\doubleexpandafter\font_basics_define_body_font_environment_empty
+ \else
+ \doubleexpandafter\font_basics_define_body_font_environment_unset
\fi\fi}
-% First we handle the class specific case. Beware: you can change values before
-% a bodyfont is loaded but changing them afterwards can be sort of tricky as
-% values are not consulted afterwards.
+%D First we handle the class specific case. Beware: you can change values before
+%D a bodyfont is loaded but changing them afterwards can be sort of tricky as
+%D values are not consulted afterwards.
\def\font_basics_define_body_font_environment_class[#class][#body][#settings]%
{\edef\m_font_body{#body}%
\ifx\m_font_body\s!default
% these are the last resort within a class
- \getrawparameters[\??fonts#class\s!default][#settings]%
+ \getrawparameters[\??fontenvironments#class\s!default][#settings]%
\else
- \edef\m_font_body_normalized{\thenormalizedbodyfontsize\m_font_body}%
- \addtocommalist\m_font_body_normalized\bodyfontenvironmentlist
+ \normalizebodyfontsize\m_font_body_normalized\m_font_body
\font_basics_define_body_font_environment_size[#class][\m_font_body_normalized][#settings]%
- \letvalue{\??fonts#class#body\s!check}\empty % a signal that we have defined this one
+ \addtocommalist\m_font_body_normalized\bodyfontenvironmentlist
\fi}
-\def\font_basics_define_body_font_environment_size[#class][#body][#settings]% normalized body
- {\getrawparameters[\??fonts#class#body][#settings]%
- % don't check too soon as we can refer to later definitions
- % \font_helpers_process_relative_size_list{\font_basics_define_body_font_environment_size_step{#class}{#body}{#body}}%
- \ifproductionrun
- \ifcsname\??fontsize#body\endcsname
- % only once
- \else
- % \empty prevents loop
- \letvalueempty{\??fontsize#body}%
- \pushmacro\fontclass
- \edef\fontclass{#class}%
- \font_helpers_define_unknown_font{#body}%
- \popmacro\fontclass
- \fi
- \fi
- % so far
- \setevalue{\??fontsize#body}{\font_basics_complete_switch[#body]}}
+%D The empty case uses the same code but needs to ignore the current class
+%D settings (just to be sure, as it's not really needed).
+
+\def\font_basics_define_body_font_environment_empty[#body][#settings][#dummy]%
+ {\pushmacro\fontclass
+ \let\fontclass\empty
+ \font_basics_define_body_font_environment_class[][#body][#settings]%
+ \popmacro\fontclass}
+
+\def\font_basics_define_body_font_environment_unset[#body][#dummya][#dummyb]%
+ {\pushmacro\fontclass
+ \let\fontclass\empty
+ \font_basics_define_body_font_environment_class[][#body][]%
+ \popmacro\fontclass}
+
+%D We don't check too soon as we can refer to later definitions.
+
+\newconditional\c_font_defining_environment_state % controls messages
+
+\def\font_basics_define_body_font_environment_size[#class][#normalizedbody][#settings]% normalized body
+ {\getrawparameters[\??fontenvironments#class#normalizedbody][#settings]%
+ \ifcsname\??fontenvironmentknown#class#normalizedbody\endcsname
+ % environment and size already defined
+ \else\ifproductionrun
+ \pushmacro\fontclass
+ \edef\fontclass{#class}%
+ \font_helpers_register_environment{#class}{#normalizedbody}%
+ \settrue\c_font_defining_environment_state
+ \font_helpers_define_unknown_font{#normalizedbody}% current class
+ \setfalse\c_font_defining_environment_state
+ \popmacro\fontclass
+ \fi\fi
+ \font_helpers_register_fontbody{#normalizedbody}}
\def\font_basics_define_body_font_environment_size_step_normal#class#size#body#step%
- {\expandafter\normaledef\csname\??fontsteps#class#size#step\endcsname
- {\thenormalizedbodyfontsize{\bodyfontdimension{#class}{#size}{#step}{#body}}}}
+ {\expandafter\normalizebodyfontsize\csname\??fontsteps#class#size#step\endcsname
+ {\bodyfontdimension{#class}{#size}{#step}{#body}}}
\def\font_basics_define_body_font_environment_size_step_traced#class#size#body#step%
{\font_basics_define_body_font_environment_size_step_normal{#class}{#size}{#body}{#step}%
- \writestatus{size mapping}{#class #size #step => \csname\??fontsteps#class#size#step\endcsname}}
+ \writestatus\m!fonts{#class #size #step => \csname\??fontsteps#class#size#step\endcsname}}
\let\font_basics_define_body_font_environment_size_step\font_basics_define_body_font_environment_size_step_normal
-\unexpanded\def\tracefontsizemapping % todo, \enabletextracker
- {\let\font_basics_define_body_font_environment_size_step\font_basics_define_body_font_environment_size_step_traced}
+\appendtoks
+ \let\font_basics_define_body_font_environment_size_step\font_basics_define_body_font_environment_size_step_traced
+\to \t_font_tracers_definitions
% \tracefontsizemapping
-% The empty case uses the same code but needs to ignore the current class
-% settings (just to be sure, as it's not really needed).
-
-\def\font_basics_define_body_font_environment_empty[#body][#settings][#dummy]%
- {\pushmacro\fontclass
- \let\fontclass\empty
- \font_basics_define_body_font_environment_class[][#body][#settings]%
- \popmacro\fontclass}
-
-% Checking
+%DChecking
-\def\font_helpers_check_bodyfont_environment[#size]%
- {\ifcsname\??fonts\fontclass#size\s!check\endcsname \else
- \font_helpers_check_bodyfont_environment_indeed{#size}%
+\def\font_helpers_check_bodyfont_environment#normalizedbody#body%
+ {\ifcsname\??fontenvironmentknown\fontclass#normalizedbody\endcsname
+ % already defined
+ \else
+ \font_helpers_check_bodyfont_environment_indeed{#normalizedbody}{#body}%
\fi}
-\def\font_helpers_check_bodyfont_environment_indeed#size% class size (simplified version of definebodyfontenvironment)
- {\edef\m_font_body_normalized{\thenormalizedbodyfontsize{#size}}%
- \addtocommalist\m_font_body_normalized\bodyfontenvironmentlist
- \font_helpers_process_relative_size_list{\font_basics_define_body_font_environment_size_step\fontclass\m_font_body_normalized\fontbody}%
- \letvalue{\??fonts\fontclass#size\s!check}\empty
- \ifcsname\??fontsize\m_font_body_normalized\endcsname \else
- \letvalue{\??fontsize\m_font_body_normalized}\empty % prevent loop
- \normalexpanded{\font_helpers_define_unknown_font{\m_font_body_normalized}}% we can also inherit here
- \fi
- \setevalue{\??fontsize\fontclass}{\font_basics_complete_switch[\fontclass]}}
+\def\font_helpers_check_bodyfont_environment_indeed#normalizedbody#body%
+ {\font_helpers_register_environment\fontclass{#normalizedbody}%
+ %\writestatus\m!fonts{checking bodyfont environment [#normalizedbody] within [#body]}%
+ \font_helpers_process_relative_size_list{\font_basics_define_body_font_environment_size_step\fontclass{#normalizedbody}{#body}}%
+ \ifcsname\??fontbodyknown\m_font_body_normalized\endcsname
+ \else
+ \font_helpers_define_unknown_font{#normalizedbody}%
+ \fi}
-%D We default all parameters to the main bodyfont size, so the
-%D next setup is valid too:
+%D We default all parameters to the main bodyfont size, so the next
+%D setup is valid too:
%D
%D \starttyping
%D \definebodyfontenvironment[24pt]
%D \stoptyping
%D
-%D All parameters can be redefined when needed, so one does
-%D not have to stick to the default ones.
+%D All parameters can be redefined when needed, so one doesnot have to
+%D stick to the default ones.
%D \macros
%D {definebodyfont}
@@ -1999,19 +1285,27 @@
%D If we move design size info to the lfg file (after all only lm
%D has design sizes) we can get rid of much code .. 2012 or so.
-\installcorenamespace{fontdefaults}
+\installcorenamespace{fontdefinitions}
+
+% [class] [name] [rm,ss] [settings]
+% [class] [10pt,11pt] [rm,ss] [settings]
+% [class] [10pt,11pt] [rm,ss] [name]
+
+% [class] [name] [settings] == [name] [rm] [settings]
+% [class] [10pt,11pt] [settings] == [name] [rm] [settings]
+% [class] [10pt,11pt] [name] == [10pt,11pt] [rm] [name]
\unexpanded\def\definebodyfont
{\doquadrupleempty\font_basics_define_body_font}
\def\font_basics_define_body_font[#1][#2][#3][#4]%
{\iffourthargument
- \processcommacommand[#1]{\font_basics_define_body_font_by_class[#2][#3][#4]}%
+ \processcommacommand[#1]{\font_basics_define_body_font_class_given[#2][#3][#4]}%
\else
- \font_basics_define_body_font_indeed[#1][#2][#3]%
+ \font_basics_define_body_font_class_known[#1][#2][#3]%
\fi}
-\def\font_basics_define_body_font_by_class[#1][#2][#3]#4%
+\def\font_basics_define_body_font_class_given[#1][#2][#3]#4%
{\pushmacro\fontclass
\doifelse{#4}\s!default
{\let\fontclass\empty}
@@ -2019,321 +1313,242 @@
\definebodyfont[#1][#2][#3]%
\popmacro\fontclass}
-\def\font_basics_define_body_font_indeed
+\def\font_basics_define_body_font_class_known
{\ifthirdargument
- \singleexpandafter\font_basics_define_body_font_indeed_a
+ \singleexpandafter\font_basics_define_body_font_a
\else\ifsecondargument
- \doubleexpandafter\font_basics_define_body_font_indeed_b
+ \doubleexpandafter\font_basics_define_body_font_b
\else
- \doubleexpandafter\font_basics_define_body_font_indeed_c
+ \doubleexpandafter\font_basics_define_body_font_c
\fi\fi}
-\def\font_basics_define_body_font_indeed_a[#body][#style][#specification]% body|identifier style defs|identifier
- {\doifnumberelse{#body}
- {\doifassignmentelse{#specification}
- {% [12pt] [style] [settings]
- \ifcsname#style\endcsname\else\normalexpanded{\definefontstyle[#style][#style]}\fi % new
- \processcommalist[#1]{\font_basics_define_body_font_styles{#style}{#specification}}}
- {% [12pt] [style] [identifier]
- \font_basics_define_default_bodyfont[#body][#style][#specification]}} % body style identifier
- {% [identifier] [style] [settings] % see *** ... normalexpanded
- \setevalue{\??fontdefaults#body#style}{\font_basics_define_body_font_default{#specification}}}} % takes two extra arguments
-
-\def\font_basics_define_body_font_indeed_b[#body][#specification][#dummy]% body|identifier defs|identifier
- {\font_basics_define_body_font_indeed_a[#body][\s!rm][#specification]}
-
-\def\font_basics_define_body_font_indeed_c[#body][#dummya][#dummyb]% body|identifier
- {% Maybe there are default dependencies defined which we can use ([unknown]) and
- % if not, then we have at least to make sure some basics are set up.
- \ifcsname\??fontsize#1\endcsname \else
- \font_helpers_define_unknown_font{#body}%
- \fi
- \ifcsname\??fontsize#1\endcsname \else
- \font_basics_define_body_font_indeed_a[#body][\s!rm][]%
- \fi}
+\unexpanded\def\font_basics_define_body_font_b[#whatever][#specification][#dummy]% body|identifier defs|identifier
+ {\font_basics_define_body_font_a[#whatever][\s!rm][#specification]}
-\unexpanded\def\font_basics_define_body_font_default#specification#body#style%
- {\font_helpers_check_relative_font_size{#style}% rather new, inherit from other defs
- \ifcsname#style\endcsname\else\normalexpanded{\definefontstyle[#style][#style]}\fi % new
- \processcommalist[#body]{\font_basics_define_body_font_styles{#style}{#specification}}%
- \let\p_font_rscale\v_font_rscale_default}
+\unexpanded\def\font_basics_define_body_font_c[#whatever][#dummya][#dummyb]% body|identifier
+ {\font_basics_define_body_font_a[bwhatever][\s!rm][]}
+
+\unexpanded\def\font_basics_define_body_font_a[#whatever]%
+ {\doifnumberelse{#whatever}%
+ \font_basics_define_body_font_body
+ \font_basics_define_body_font_name
+ [#whatever]}
-\def\font_basics_define_body_font_styles#1#2#3% style defs body
- {\font_helpers_check_bodyfont_environment[#3]% just to be sure; can probably be omited now
- \processcommalist[#2]{\font_basics_define_body_font_defs{#1}{#3}}}
+\unexpanded\def\font_basics_define_body_font_body[#body][#style][#specification]%
+ {\doifassignmentelse{#specification}
+ \font_basics_define_body_font_body_assignment
+ \font_basics_define_body_font_body_identifier
+ [#body][#style][#specification]}%
-\def\font_basics_define_body_font_defs#1#2#3% style body def
- {\font_basics_define_body_font_defs_indeed{#1}{#2}[#3]}
+\unexpanded\def\font_basics_define_body_font_name[#name][#style][#specification]%
+ {\doifassignmentelse{#specification}
+ \font_basics_define_body_font_name_assignment
+ \font_basics_define_body_font_name_identifier
+ [#name][#style][#specification]}%
-\def\font_basics_define_body_font_defs_indeed
+\unexpanded\def\font_basics_define_body_font_body_assignment[#bodylist][#stylelist][#assignments]%
+ {\processcommalist[#bodylist]{\font_basics_define_body_font_body_assignment_a{#stylelist}{#assignments}}}
+
+\unexpanded\def\font_basics_define_body_font_body_assignment_a#stylelist#assignments#body%
+ {\normalizebodyfontsize\m_font_asked_body{#body}%
+ % normally we define quite a lot in advance, i.e global defs
+ \font_helpers_check_bodyfont_environment\m_font_asked_body\m_font_asked_body % !!
+ \processcommalist[#stylelist]{\font_basics_define_body_font_body_assignment_b{#assignments}}}
+
+\unexpanded\def\font_basics_define_body_font_body_assignment_b#assignments#style%
+ {\edef\m_font_asked_style{#style}%
+ \processcommalist[#assignments]\font_basics_define_body_font_defs}
+
+\unexpanded\def\font_basics_define_body_font_defs
{\ifx\fontclass\empty
\expandafter\font_basics_define_body_font_defs_nop
\else
\expandafter\font_basics_define_body_font_defs_yes
\fi}
-\def\font_basics_define_body_font_defs_yes#style% style body def
- {\edef\askedbodyfontstyle{#style}%
- \ifx\askedbodyfontstyle\s!mm
+\unexpanded\def\font_basics_define_body_font_defs_yes_normal#assignment%
+ {\ifx\m_font_asked_style\s!mm
\expandafter\font_basics_define_body_font_yes_mm
\else
\expandafter\font_basics_define_body_font_yes_xx
- \fi\askedbodyfontstyle}
+ \fi[#assignment]}
-\def\font_basics_define_body_font_defs_nop#style% style body def
- {\edef\askedbodyfontstyle{#style}%
- \ifx\askedbodyfontstyle\s!mm
+\unexpanded\def\font_basics_define_body_font_defs_nop_normal#assignment%
+ {\ifx\m_font_asked_style\s!mm
\expandafter\font_basics_define_body_font_nop_mm
\else
\expandafter\font_basics_define_body_font_nop_xx
- \fi\askedbodyfontstyle}
-
-% we split into two characters (first part of spec) and the rest
-
-\def\font_basics_define_body_font_nop_xx#style#body[#one#two#rest=#value]%
- {\ifcsname#style#one#two#rest\endcsname\else\font_basics_check_bodyfont{#style}{#one#two}{#rest}\fi
- \expandafter\let\csname\??fontsclass#body#style#one#two#rest\endcsname\undefined
- \unexpanded\expandafter\normaledef\csname#body#style#one#two#rest\endcsname{\font_helpers_trigger{#body#style#one#two#rest}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}}
-
-\def\font_basics_define_body_font_yes_xx#style#body[#one#two#rest=#value]%
- {\ifcsname#style#one#two#rest\endcsname\else\font_basics_check_bodyfont{#style}{#one#two}{#rest}\fi
- \global\expandafter\let\csname\??fontsclass\fontclass#body#style#one#two#rest\endcsname\undefined
- \unexpanded\expandafter\normalxdef\csname\fontclass#body#style#one#two#rest\endcsname{\font_helpers_trigger{#body#style#one#two#rest}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}}
-
-\def\font_basics_define_body_font_nop_mm#style#body[#one#two#rest=#value]%
- {\ifcsname#style#one#two#rest\endcsname\else\font_basics_check_bodyfont{#style}{#one#two}{#rest}\fi
- \expandafter\let\csname\??fontsclass#body#style#one#two#rest1\endcsname\undefined
- \expandafter\let\csname\??fontsclass#body#style#one#two#rest2\endcsname\undefined
- \expandafter\let\csname\??fontsclass#body#style#one#two#rest3\endcsname\undefined
- \unexpanded\expandafter\normaledef\csname#body#style#one#two#rest1\endcsname{\font_helpers_trigger{#body#style#one#two#rest1}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}%
- \unexpanded\expandafter\normaledef\csname#body#style#one#two#rest2\endcsname{\font_helpers_trigger{#body#style#one#two#rest2}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}%
- \unexpanded\expandafter\normaledef\csname#body#style#one#two#rest3\endcsname{\font_helpers_trigger{#body#style#one#two#rest3}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}}
-
-\def\font_basics_define_body_font_yes_mm#style#body[#one#two#rest=#value]%
- {\ifcsname#style#one#two#rest\endcsname\else\font_basics_check_bodyfont{#style}{#one#two}{#rest}\fi
- \global\expandafter\let\csname\??fontsclass\fontclass#body#style#one#two#rest1\endcsname\undefined
- \global\expandafter\let\csname\??fontsclass\fontclass#body#style#one#two#rest2\endcsname\undefined
- \global\expandafter\let\csname\??fontsclass\fontclass#body#style#one#two#rest3\endcsname\undefined
- \unexpanded\expandafter\normalxdef\csname\fontclass#body#style#one#two#rest1\endcsname{\font_helpers_trigger{#body#style#one#two#rest1}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}%
- \unexpanded\expandafter\normalxdef\csname\fontclass#body#style#one#two#rest2\endcsname{\font_helpers_trigger{#body#style#one#two#rest2}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}%
- \unexpanded\expandafter\normalxdef\csname\fontclass#body#style#one#two#rest3\endcsname{\font_helpers_trigger{#body#style#one#two#rest3}{\number\p_font_rscale}{#body}{\normalunexpanded{#value}}}}
+ \fi[#assignment]}
-\let\m_font_mm\empty
-
-\def\font_basics_check_bodyfont#style% tests for ttsl mmbf
- {\edef\m_font_mm{#style}%
- \ifx\m_font_mm\s!mm % prevents \max and alike (re)defs
- \expandafter\font_basics_check_math_bodyfont
+\unexpanded\def\font_basics_define_body_font_defs_yes_traced#assignment%
+ {\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] [#assignment]}%
+ \ifx\m_font_asked_style\s!mm
+ \expandafter\font_basics_define_body_font_yes_mm
\else
- \expandafter\font_basics_check_text_bodyfont
- \fi{#style}} % no \m_font_mm, not expanded later on
+ \expandafter\font_basics_define_body_font_yes_xx
+ \fi[#assignment]}
-% nb: We define the commands globally in the next two macros. After
-% all they are part of the formal font interface once defined.
-%
-% The size can be empty (so checking is needed as \bf is already
-% defined)
+\unexpanded\def\font_basics_define_body_font_defs_nop_traced#assignment%
+ {\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] [#assignment]}%
+ \ifx\m_font_asked_style\s!mm
+ \expandafter\font_basics_define_body_font_nop_mm
+ \else
+ \expandafter\font_basics_define_body_font_nop_xx
+ \fi[#assignment]}
-\def\font_basics_check_math_bodyfont#style#alternative#size%
- {%setugvalue{#alternative}{\font_helpers_set_current_font_alternative{#alternative}}% \mr \mb
- \setugvalue{#style}{\font_helpers_set_current_font_style{#style}}}% \mm
+\let\font_basics_define_body_font_defs_yes\font_basics_define_body_font_defs_yes_normal
+\let\font_basics_define_body_font_defs_nop\font_basics_define_body_font_defs_nop_normal
-\def\font_basics_check_text_bodyfont#style#alternative#size% nb: gdef % size can be empty (checking needed as \bf is already defined)
- {\setugvalue{#style#size}{\font_helpers_set_current_font_style_size{#style}{#size}}% \rma
- \setugvalue{#alternative#size}{\font_helpers_set_current_font_alternative_size{#alternative}{#size}}% \sla
- \setugvalue{#style#alternative#size}{\font_helpers_set_current_font_style_alternative_size{#style}{#alternative}{#size}}% \rmsla
- \ifcsname\s!normal#style\endcsname % text/math check
- \expandafter\let\csname#style\expandafter\endcsname\csname\s!normal#style\endcsname
- \else
- \setugvalue{#style}{\font_helpers_set_current_font_style{#style}}% \rm
- \fi
- \ifcsname\s!normal#alternative\endcsname % text/math check
- \expandafter\let\csname#alternative\expandafter\endcsname\csname\s!normal#alternative\endcsname
+\appendtoks
+ \let\font_basics_define_body_font_defs_yes\font_basics_define_body_font_defs_yes_traced
+ \let\font_basics_define_body_font_defs_nop\font_basics_define_body_font_defs_nop_traced
+\to \t_font_tracers_definitions
+
+% we split into two characters (first part of spec) and the rest .. do we need the ifcsname tests ?
+
+\unexpanded\def\font_basics_define_body_font_nop_xx[#one#two#rest=#value]%
+ {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi
+ \expandafter\let\csname\??fontinstanceclass\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname\undefined
+ \unexpanded\expandafter\normaledef\csname\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname{\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}}
+
+\unexpanded\def\font_basics_define_body_font_yes_xx[#one#two#rest=#value]%
+ {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi
+ \global\expandafter\let\csname\??fontinstanceclass\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname\undefined
+ \unexpanded\expandafter\normalxdef\csname\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname{\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}}
+
+\unexpanded\def\font_basics_define_body_font_nop_mm[#one#two#rest=#value]%
+ {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi
+ \expandafter\let\csname\??fontinstanceclass\m_font_asked_body\m_font_asked_style#one#two#rest1\endcsname\undefined
+ \expandafter\let\csname\??fontinstanceclass\m_font_asked_body\m_font_asked_style#one#two#rest2\endcsname\undefined
+ \expandafter\let\csname\??fontinstanceclass\m_font_asked_body\m_font_asked_style#one#two#rest3\endcsname\undefined
+ \unexpanded\expandafter\normaledef\csname\m_font_asked_body\m_font_asked_style#one#two#rest1\endcsname{\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest1}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ \unexpanded\expandafter\normaledef\csname\m_font_asked_body\m_font_asked_style#one#two#rest2\endcsname{\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest2}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ \unexpanded\expandafter\normaledef\csname\m_font_asked_body\m_font_asked_style#one#two#rest3\endcsname{\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest3}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}}
+
+\unexpanded\def\font_basics_define_body_font_yes_mm[#one#two#rest=#value]%
+ {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi
+ \global\expandafter\let\csname\??fontinstanceclass\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest1\endcsname\undefined
+ \global\expandafter\let\csname\??fontinstanceclass\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest2\endcsname\undefined
+ \global\expandafter\let\csname\??fontinstanceclass\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest3\endcsname\undefined
+ \unexpanded\expandafter\normalxdef\csname\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest1\endcsname{\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest1}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ \unexpanded\expandafter\normalxdef\csname\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest2\endcsname{\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest2}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}%
+ \unexpanded\expandafter\normalxdef\csname\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest3\endcsname{\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest3}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}}
+
+\unexpanded\def\font_basics_define_body_font_body_identifier[#bodylist][#stylelist][#name]%
+ {\processcommalist[#bodylist]{\font_basics_define_body_font_body_identifier_a{#stylelist}{#name}}}
+
+\unexpanded\def\font_basics_define_body_font_body_identifier_a#stylelist#name#body%
+ {\normalizebodyfontsize\m_font_asked_body{#body}%
+ \font_helpers_check_bodyfont_environment\m_font_asked_body\m_font_asked_body % !!
+ \processcommalist[#stylelist]{\font_basics_define_body_font_body_identifier_b{#name}}}
+
+\unexpanded\def\font_basics_define_body_font_body_identifier_b#name#style%
+ {\edef\m_font_asked_style{#style}%
+ %\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] => [#name]}%
+ \csname\??fontdefinitions#name:\m_font_asked_style\endcsname} % no checking
+
+\unexpanded\def\font_basics_define_body_font_name_assignment[#name][#stylelist][#assignments]%
+ {\processcommalist[#stylelist]{\font_basics_define_body_font_name_assignment_a{#name}{#assignments}}}
+
+\unexpanded\def\font_basics_define_body_font_name_assignment_a#name#assignments#style%
+ {%\writestatus\m!fonts{[#name:#style] => [#assignments]}%
+ \setevalue{\??fontdefinitions#name:#style}{\font_basics_define_body_font_default{#assignments}}}
+
+\unexpanded\def\font_basics_define_body_font_name_identifier[#name][#stylelist][#identifier]%
+ {\processcommalist[#stylelist]{\font_basics_define_body_font_name_identifier_a{#name}{#identifier}}}
+
+\unexpanded\def\font_basics_define_body_font_name_identifier_a#name#identifier#style%
+ {%\writestatus\m!fonts{[#name:#style] => [##identifier:#style]}%
+ \ifcsname\csname\??fontdefinitions#name:#style\endcsname
+ \expandafter\let\csname\??fontdefinitions#name:#style\expandafter\endcsname\csname\??fontdefinitions#identifier:#style\endcsname
\else
- \setugvalue{#alternative}{\font_helpers_set_current_font_alternative{#alternative}}% \sl
- \fi
- \setugvalue{#style\s!x}{\font_helpers_set_current_font_x_style_alternative{#style}}% \rmx
- \setugvalue{#style\s!xx}{\font_helpers_set_current_font_xx_style_alternative{#style}}% \rmxx
- \setugvalue{#alternative\s!x}{\font_helpers_set_current_font_x_alternative{#alternative}}% \slx
- \setugvalue{#alternative\s!xx}{\font_helpers_set_current_font_xx_alternative{#alternative}}% \slxx
- \setugvalue{#style#alternative}{\font_helpers_set_current_font_style_alternative{#style}{#alternative}}}% \rmsl
+ \expandafter\def\csname\??fontdefinitions#name:#style\endcsname{\csname\??fontdefinitions#identifier:#style\endcsname}%
+ \fi}
-\def\font_basics_define_default_bodyfont[#sizes][#styles][#specification]%
- {\def\font_basics_define_default_bodyfont_a#size%
- {\def\font_basics_define_default_bodyfont_b#style%
- {\def\font_basics_define_default_bodyfont_c#spec%
- {\ifcsname\??fontdefaults#spec#style\endcsname
- % [12pt] [style] [identifier]
- \csname\??fontdefaults#spec#style\endcsname{#size}{#style}%
- \fi}%
- \processcommalist[#specification]\font_basics_define_default_bodyfont_c}%
- \processcommalist[#styles]\font_basics_define_default_bodyfont_b}%
- \processcommalist[#sizes]\font_basics_define_default_bodyfont_a}
+%D The unknown:
\newconditional\c_font_defining_unknown
\newconditional\c_font_defining_state
-\def\font_helpers_define_unknown_font_indeed#body#relativesize%
- {\ifcsname\??fonts\s!default#relativesize\endcsname
- \settrue\c_font_defining_state
- \edef\m_font_body_normalized{\thenormalizedbodyfontsize{\csname\??fonts\s!default#relativesize\endcsname\dimexpr#body\relax}}%
- \letvalue{\??fonts#body#relativesize}\m_font_body_normalized
- \fi}
-
-\def\font_helpers_define_unknown_bodyfont_indeed#body#style% see ***
- {\ifcsname\??fontdefaults\s!default#style\endcsname % somehow related to */*
- \settrue\c_font_defining_state
- \csname\??fontdefaults\s!default#style\endcsname{#body}{#style}%
- \fi}
-
-\def\font_helpers_define_unknown_sub_font#body#relativesize%
- {\ifcsname\??fontsize\csname\??fonts#body#relativesize\endcsname\endcsname \else
- \settrue\c_font_defining_state
- \font_helpers_define_unknown_font{\csname\??fonts#body#relativesize\endcsname}%
- \fi}
-
-\unexpanded\def\font_helpers_define_unknown_font#body%
- {\setfalse\c_font_defining_state
- \font_helpers_process_relative_size_list{\font_helpers_define_unknown_font_indeed{#body}}%
+\unexpanded\def\font_helpers_define_unknown_font#body% one level only
+ {\font_helpers_register_fontbody{#body}% prevents loop, can go
+ \setfalse\c_font_defining_state
+ %\writestatus\m!fonts{checking relative sizes of body size #body}%
+ \font_helpers_process_relative_size_list{\font_helpers_define_unknown_check_sizes{#body}}%
\ifconditional\c_font_defining_state
\setfalse\c_font_defining_state
- \processcommacommand
- [\fontstylelist]
- {\font_helpers_define_unknown_bodyfont_indeed{#body}}%
+ %\writestatus\m!fonts{checking definitions of body size #body}%
+ \font_helpers_process_style_list{\font_helpers_define_unknown_check_definitions{#body}}%
\ifconditional\c_font_defining_state
+ \ifconditional\c_font_defining_environment_state\else
+ \showmessage\m!fonts{14}{#body}% main
+ \fi
\setfalse\c_font_defining_state
- \setevalue{\??fontsize#body}{\font_basics_complete_switch[#body]}%
- \ifconditional\c_font_defining_unknown \else
+ \font_helpers_register_fontbody{#body}%
+ % needed ?
+ \ifconditional\c_font_defining_unknown
+ %\writestatus\m!fonts{skipping relatives of body size #body}%
+ \else
+ %\writestatus\m!fonts{checking relatives of body size #body}%
\settrue\c_font_defining_unknown
- \font_helpers_process_relative_size_list{\font_helpers_define_unknown_sub_font{#body}}%
+ \font_helpers_process_relative_size_list{\font_helpers_define_unknown_check_relatives{#body}}%
\setfalse\c_font_defining_unknown
\fi
\fi
- \ifconditional\c_font_defining_state
- \showmessage\m!fonts{14}{#body}%
+ \ifconditional\c_font_defining_environment_state\else
+ \ifconditional\c_font_defining_state \else % not yet ok
+ \showmessage\m!fonts{14}{#body}% relative
+ \fi
\fi
\fi}
-%D These macros show that quite some definitions take place.
-%D Fonts are not loaded yet! This means that at format
-%D generation time, no font files are preloaded.
-
-%D \macros
-%D {everybodyfont,Everybodyfont,everyglobalbodyfont}
-%D
-%D Every change in bodyfont size has conseqences for the baseline
-%D distance and skips between paragraphs. These are initialized
-%D in other modules. Here we only provide the hooks that
-%D garantees their handling.
-
-%D At the system level one can initialize thing like:
-%D
-%D \starttyping
-%D \appendtoks \setupspacing \to \everybodyfont
-%D \stoptyping
-%D
-%D While users can add their own non standard commands like:
-%D
-%D \starttyping
-%D \EveryBodyFont{\message{changing to bodyfont \the\bodyfontsize}}
-%D \stoptyping
-%D
-%D Personnaly I never felt the need for such extensions, but
-%D at least its possible.
-
-%D \macros
-%D {globalbodyfontsize,localbodyfontsize}
-%D
-%D Next we'll do the tough job of font switching. Here we
-%D have to distinguish between the global (overal) bodyfont
-%D size and the local (sometimes in the textflow) size. We
-%D store these dimensions in two \DIMENSION\ registers.
-
-\ifdefined\globalbodyfontsize\else \newdimen\globalbodyfontsize \fi \globalbodyfontsize=12pt
-\ifdefined\localbodyfontsize \else \newdimen\localbodyfontsize \fi \localbodyfontsize =\globalbodyfontsize
-
-%D \macros
-%D {bodyfontsize}
-%D
-%D These two registers are not to be misused in calculations.
-%D For this purpose we keep a copy:
-
-\newdimen\bodyfontsize \bodyfontsize=\globalbodyfontsize
-
-%D \macros
-%D {bodyfontfactor,bodyfontpoints}
-%D
-%D For multiplication purposes we keep an auxiliary counter
-%D and macro (here the expansion is not explicitly needed):
-
-\newcount\bodyfontpoints \dimensiontocount\bodyfontsize\bodyfontpoints
-
-\edef\bodyfontfactor{\withoutpt\the\bodyfontsize}
-
-%D When we assign for instance 12pt to a \DIMENSION\ register
-%D the \type{\the}'d value comes out as 12.0pt, which is
-%D often not the way users specify the bodyfont size. Therefore
-%D we also store the normalized value.
-
-\setnewconstant\fontdigits\plustwo % was 1
-
-\def\normalizebodyfontsize#body\to#macro%
- {\edef#macro{\ctxcommand{nbfs(\number\dimexpr#body\relax,\number\fontdigits)}}}
-
-\def\thenormalizedbodyfontsize#body%
- {\ctxcommand{nbfs(\number\dimexpr#body\relax,\number\fontdigits)}}
-
-\edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}
-\edef\normalizedlocalbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
-\edef\normalizedbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
-
-%D \macros
-%D {fontstyle,fontalternative,fontsize}
-%D
-%D Within a bodyfont, fonts can come in different sizes. For
-%D instance \type{\tf} is accompanied by \type{\tfa},
-%D \type{\tfb} etc. The first two characters denote the
-%D alternative, while the third character in these sequences
-%D represents the size. The actual size is saved in a macro
-%D
-%D The style, being roman (\type{\rm}), sans serif (\type{\ss})
-%D etc. is also available in a macro in \type{rm}, \type{ss}
-%D etc. form:
-
-\let\defaultfontalternative = \s!tf
-\let\defaultfontstyle = \empty
-\let\defaultfontsize = \empty
+\def\font_helpers_define_unknown_check_sizes#body#relativesize%
+ {\ifcsname\??fontenvironments\s!default#relativesize\endcsname % fontclass ?
+ \expandafter\normalizebodyfontsize\csname\??fontenvironments#body#relativesize\endcsname{\csname\??fontenvironments\s!default#relativesize\endcsname\dimexpr#body\relax}%
+ %\writestatus\m!fonts{#body #relativesize => \csname\??fontenvironments#body#relativesize\endcsname}%
+ \settrue\c_font_defining_state
+ \fi}
-\let\fontalternative = \defaultfontalternative
-\let\fontstyle = \defaultfontstyle
-\let\fontsize = \defaultfontsize
+\def\font_helpers_define_unknown_check_definitions#body#style%
+ {\ifcsname\??fontdefinitions\s!default:#style\endcsname
+ \edef\m_font_asked_body{#body}%
+ \edef\m_font_asked_style{#style}%
+ \csname\??fontdefinitions\s!default:#style\endcsname % {#body}{#style}%
+ \settrue\c_font_defining_state
+ \fi}
-%D When \type {\loadfontfileoncetrue}, such files are
-%D only loaded once! This permits redundant loading, but at
-%D the same time forced grouping when we want continuously mix
-%D all kind of font, which of course is a kind of
-%D typographically sin. The \type{"} is made inactive if
-%D needed to prevent problems with loading files that use this
-%D character in numbers.
+\def\font_helpers_define_unknown_check_relatives#body#relativesize%
+ {\ifcsname\??fontbodyknown\csname\??fontenvironments#body#relativesize\endcsname\endcsname \else
+ \expandafter\font_helpers_define_unknown_font\csname\??fontenvironments#body#relativesize\endcsname
+ \settrue\c_font_defining_state
+ \fi}
-% can be made faster (only used internally now)
+\unexpanded\def\font_basics_define_body_font_default#assignments%
+ {% to be checked:
+ \font_helpers_check_relative_font_size\m_font_asked_style % still needed here?
+ % to be checked
+ \ifcsname\m_font_asked_style\endcsname\else
+ \normalexpanded{\definefontstyle[\m_font_asked_style][\m_font_asked_style]}%
+ \fi
+ %
+ \processcommalist[#assignments]\font_basics_define_body_font_defs
+ % to be checked
+ \let\p_font_rscale\v_font_rscale_default}
-% \def\font_basics_switch_points#body%
-% {\normalexpanded{\font_basics_switch_points_indeed{#body}}}
-%
-% \unexpanded\def\font_basics_switch_points_indeed#body%
-%
-% is expanded still handy here?
+%D These macros show that quite some definitions take place. Fonts are not loaded
+%D yet! This means that at format generation time, no font files are present.
\unexpanded\def\font_basics_switch_points#body%
- {\ifcsname\??fontsize#body\endcsname \else
+ {\ifcsname\??fontbodyknown#body\endcsname \else
+ % we need to check the relative sizes for this body
+ %\writestatus\m!fonts{checking switch points [#body]}%
\font_helpers_define_unknown_font{#body}%
\fi%
- \ifcsname\??fontsize#body\endcsname
- \csname\??fontsize#body\endcsname
+ \ifcsname\??fontbodyknown#body\endcsname % always true now
+ \font_basics_complete_switch{#body}%
\localbodyfontsize#body\relax
- \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\localbodyfontsize}%
- \font_helpers_check_bodyfont_environment[\normalizedbodyfontsize]%
+ \normalizebodyfontsize\normalizedbodyfontsize\localbodyfontsize
+ \font_helpers_check_bodyfont_environment\normalizedbodyfontsize\normalizedbodyfontsize % !!
\else
\showmessage\m!fonts4{#body}%
\fi}
@@ -2348,168 +1563,34 @@
\showmessage\m!fonts5{#style}%
\fi}
-%D Defining fonts using \type{\definebodyfont} takes time, so we
-%D prefer to predefine at least the Computer Modern Roman
-%D fonts. However, loading all those fonts at definition time
-%D would take both time and space. But even worse, once fonts
-%D are loaded into memory, their encoding vector is fixed,
-%D which is a handicap when we want to distribute the compact
-%D \type{fmt} files. So what we want to do is defining fonts in
-%D a way that postpones the loading. We accomplish this by only
-%D loading the fonts when we switch to another bodyfont size.
-%D Among the other alternatives, such as loading the font at
-%D the moment of activation and redefining the activation
-%D macro afterwards, this proved to be the most efficient
-%D alternative.
-%D
-%D The next few macros take care of the one exeption on this
-%D scheme. When at format generation time we load the default
-%D font file, the one that defines the Computer Modern Fonts,
-%D we don't want the fonts metrics to end up in the format
-%D file, so we temporary prohibit loading. This means that at
-%D runtime we have to load the default bodyfont size just before
-%D we start typesetting.
-%D
-%D Therefore we have to signal the font switching macros that
-%D we are preloading fonts.
-%D
-%D \macros
-%D {preloadfonts}
-%D
-%D Preloading is only called for once, during the startup
-%D sequence of a session. After the loading job is done, the
-%D macro relaxes itself and reset the signal.
-
-\fontslantperpoint \nullfont 0\scaledpoint
-\fontinterwordspace \nullfont 256377\scaledpoint
-\fontinterwordstretch\nullfont 128188\scaledpoint
-\fontinterwordshrink \nullfont 85459\scaledpoint
-\fontexheight \nullfont 338952\scaledpoint
-\fontemwidth \nullfont 786432\scaledpoint
-\fontextraspace \nullfont 85459\scaledpoint
-
-\fetchruntimecommand \showfontparameters {\f!fontprefix\s!run}
-
-\def\font_preloads_reset_nullfont % this is needed because some macro packages (tikz) misuse \nullfont
- {%\dorecurse7{\fontdimen\recurselevel\nullfont\zeropoint}% keep en eye on this as:
- \ctxcommand{resetnullfont()}% in luatex 0.70 this will also do the previous
- \globallet\font_preloads_reset_nullfont\relax}
-
-\def\font_preload_default_fonts
- {\font_preloads_reset
- \setupbodyfont[modern,\fontstyle,\fontbody]%
- \showmessage\m!fonts6{fallback modern \fontstyle\normalspace\normalizedbodyfontsize}}
-
-\def\font_preload_default_fonts_mm
- {\writestatus\m!fonts{preloading latin modern fonts (math)}%
- \definetypeface[\fontclass][\s!mm][\s!math][modern][\s!default]%
- \showmessage\m!fonts6{fallback modern mm \normalizedbodyfontsize}}
-
-\def\font_preload_default_fonts_tt
- {\writestatus\m!fonts{preloading latin modern fonts (mono)}%
- \definetypeface[\fontclass][\s!tt][\s!mono][modern][\s!default]%
- \showmessage\m!fonts6{fallback modern tt \normalizedbodyfontsize}}
-
-\def\font_preloads_reset
- {\glet\font_preload_default_fonts \relax
- %\glet\font_preload_default_fonts_tt\relax
- %\glet\font_preload_default_fonts_mm\relax
- \glet\font_preloads_zero_stage \relax
- \glet\font_preloads_first_stage \relax
- \glet\font_preloads_second_stage \relax
- %\glet\font_preloads_third_stage \relax
- \glet\fourthstagepreloadfonts \relax
- \global\everyhbox\emptytoks
- \global\everyvbox\emptytoks
- \font_preloads_reset_nullfont}
-
-\def\font_preloads_reset_checked
- {\glet\font_preload_default_fonts_tt\relax
- \glet\font_preload_default_fonts_mm\relax
- \glet\font_preloads_third_stage \relax}
-
-\def\font_preloads_zero_stage_indeed
- {\definedfont[\s!file:lmmono10-regular sa 1]}
-
-\unexpanded\def\font_preloads_zero_stage
- {\writestatus\m!fonts{beware: no fonts are loaded yet, using 'lm mono' in box}%
- \glet\font_preloads_zero_stage\font_preloads_zero_stage_indeed
- \font_preloads_zero_stage}
-
-\unexpanded\def\font_preloads_first_stage % % *nofonts -> *preloadfonts
- {\doifmodeelse{*preloadfonts}
- {\font_preload_default_fonts
- \writestatus\m!fonts{preloading latin modern fonts (first stage)}}
- {\writestatus\m!fonts{latin modern fonts are not preloaded}}}
-
-\unexpanded\def\font_preloads_second_stage
- {\writestatus\m!fonts{preloading latin modern fonts (second stage)}%
- \font_preload_default_fonts}
-
-\unexpanded\def\font_preloads_third_stage % always
- {\ifx\fontclass\empty
- \writestatus\m!fonts{preloading latin modern fonts (third stage)}%
- \font_preload_default_fonts
- \else
- \font_preloads_reset
- \pushmacro\fontstyle
- \ifcsname\??fontclass\fontclass\s!mm\s!features\endcsname \else
- \font_preload_default_fonts_mm
- \fi
- \ifcsname\??fontclass\fontclass\s!tt\s!features\endcsname \else
- \font_preload_default_fonts_tt
- \fi
- \popmacro\fontstyle
- \font_preloads_reset_checked % reset third, mm and tt
- \setupbodyfont[\fontstyle]%
- \fi}
-
-\unexpanded\def\font_preloads_fourth_stage
- {\begingroup
- %ifzeropt\fontcharwd\font\number`!\relax
- \setbox\scratchbox\hbox{context}%
- \ifzeropt\wd\scratchbox
- \writeline
- \writestatus\m!fonts{!! No bodyfont has been defined and no defaults have been}%
- \writestatus\m!fonts{!! loaded (maybe due to a missing \string\starttext).}%
- \writeline
- \fi
- \font_preloads_reset
- \endgroup}
-
-\appendtoks
- \everyhbox{\font_preloads_zero_stage}%
- \everyvbox{\font_preloads_zero_stage}%
-\to \everydump
-
-\def\font_preloads_at_every_job {\font_preloads_first_stage }
-\def\font_preloads_at_start_text{\font_preloads_second_stage}
-\def\font_preloads_at_stop_text {\font_preloads_fourth_stage}
-
-% \unexpanded\def\checkpreloadedbodyfont % no \let here
-% {\font_preloads_at_start_text}
-
%D Here comes the main font switching macros. These macros
%D handle changes in size as well as returning to the global
%D bodyfont size.
+\ifdefined\font_preloads_at_definition \else \let\font_preloads_at_definition\relax \fi
+
\def\font_helpers_set_font#method#specification%
- {\doifelse{#specification}\v!global
- {\restoreglobalbodyfont}
- {\processcommacommand[#specification]{\font_helpers_set_font_check_size}%
- \processcommacommand[#specification]{\font_helpers_set_font_set_font{#method}}%
- \ifproductionrun
- \font_preloads_third_stage
- \font_basics_switch_points\normalizedbodyfontsize
- \font_basics_switch_style\fontstyle
- \ifx\defaultfontclass\empty
- \let\defaultfontclass\fontclass
- \fi
- \fi}%
- \currentxfontsize\zerocount}
+ {\edef\m_font_specification{#specification}%
+ \ifx\m_font_specification\empty \else
+ \ifx\m_font_specification\v!global % we can have all kind of presets
+ \restoreglobalbodyfont
+ \else
+ \processcommacommand[\m_font_specification]{\font_helpers_set_font_check_size}%
+ \processcommacommand[\m_font_specification]{\font_helpers_set_font_set_font{#method}}%
+ \ifproductionrun
+ \font_preloads_at_definition
+ \font_basics_switch_points\normalizedbodyfontsize
+ \font_basics_switch_style\fontstyle
+ \ifx\defaultfontclass\empty
+ \let\defaultfontclass\fontclass
+ \fi
+ \fi
+ \fi
+ \currentxfontsize\zerocount
+ \fi}
\def\font_helpers_set_font_check_size#option%
- {\doifnumberelse{#option}{\font_helpers_check_bodyfont_environment[#option]}\donothing}
+ {\doifnumberelse{#option}{\font_helpers_check_bodyfont_environment{#option}{#option}}\donothing}
\def\font_helpers_set_font_set_font#method#option% method=1: set, method=2: switch
{\doifsomething{#option}{\font_helpers_set_font_set_font_option{#method}{#option}}}
@@ -2524,7 +1605,7 @@
\unexpanded\def\font_helpers_set_font_set_font_option_keyword#method#keyword#message%
{\edef\m_font_keyword{#keyword}%
- \ifcsname\??fonts\normalizedbodyfontsize\m_font_keyword\endcsname
+ \ifcsname\??fontenvironments\normalizedbodyfontsize\m_font_keyword\endcsname
\edef\m_font_step{\bodyfontvariable\m_font_keyword}%
\normalexpanded{\font_helpers_set_font_set_font_option_body{#method}{\m_font_step}{#message}}%
\else\ifx\m_font_keyword\v!reset
@@ -2568,34 +1649,16 @@
{\let\fontstyle\s!rm}
\unexpanded\def\font_helpers_set_font_set_font_option_body#method#body#message%
- {\edef\normalizedsetfont{\thenormalizedbodyfontsize{#body}}% redundant for some calls
- \ifcsname\??fontsize\normalizedsetfont\endcsname \else
+ {\normalizebodyfontsize\normalizedsetfont{#body}% redundant for some calls
+ \ifcsname\??fontbodyknown\normalizedsetfont\endcsname \else
\font_helpers_define_unknown_font{#body}%
\fi
- \ifcsname\??fontsize\normalizedsetfont\endcsname
+ \ifcsname\??fontbodyknown\normalizedsetfont\endcsname
\localbodyfontsize\normalizedsetfont
\let\normalizedbodyfontsize\normalizedsetfont
\else
\showmessage\m!fonts4{#message}%
- \font_helpers_set_font_set_font_option_body_fallbacks{#method}{#body}%
- \fi}
-
-%D When users specify for instance a 13 point bodyfont while no
-%D such bodyfont is defined, the system automatically tries to
-%D find a best fit, that is the nearest smaller defined
-%D bodyfontzize. A smaller one is definitely better than a larger
-%D one, simply because otherwise a lot of overfull box messages
-%D are more probable to occur. By taking a value slightly
-%D smaller than half a point, we can use the next method.
-
-\def\font_helpers_set_font_set_font_option_body_fallbacks#method#body%
- {\scratchdimen#body\relax
- \advance\scratchdimen .499\points
- \dimensiontocount\scratchdimen\scratchcounter
- \advance\scratchcounter \minusone
- \ifnum\scratchcounter>\plusthree
- %\font_helpers_set_font_set_font_option{#method}{\the\scratchcounter\s!pt}%
- \font_helpers_set_font_set_font_option_body{#method}{\the\scratchcounter\s!pt}\empty
+ %\font_helpers_set_font_set_font_option_body_fallbacks{#method}{#body}%
\fi}
% The following bunch of macros deals with the (run time)
@@ -2627,17 +1690,6 @@
\trycurrentfontclass{#class}%
\fi\fi} % \fi}
-% no prefix ?
-
-\installcorenamespace{fontclass}
-
-\unexpanded\def\savefontclassparameters#style#rscale#features#fallbacks#goodies#direction%
- {\setxvalue{\??fontclass\fontclass#style\s!rscale }{#rscale}%
- \setxvalue{\??fontclass\fontclass#style\s!features }{#features}%
- \setxvalue{\??fontclass\fontclass#style\s!fallbacks}{#fallbacks}%
- \setxvalue{\??fontclass\fontclass#style\s!goodies }{#goodies}%
- \setxvalue{\??fontclass\fontclass#style\s!direction}{#direction}}
-
\settrue\autotypescripts
\unexpanded\def\trycurrentfontclass#typeface%
@@ -2664,50 +1716,6 @@
\let\defaultfontalternative\s!tf
\let\defaultfontsize \empty
-%D \macros
-%D {bigmath,nobigmath}
-%D
-%D We can inhibit this slow||downer with:
-
-% these can best be combined
-
-% 0=never 1=everymath 2=always
-
-\setnewconstant\synchronizebigmathflag\plusone
-
-\appendtoks
- \ifcase\synchronizebigmathflag
- % never
- \or
- \synchronizebigmath
- \or
- % always
- \fi
-\to \everymathematics
-
-\unexpanded\def\nobigmath {\synchronizebigmathflag\zerocount}
-\unexpanded\def\autobigmath{\synchronizebigmathflag\plusone\synchronizebigmath}
-\unexpanded\def\bigmath {\synchronizebigmathflag\plustwo\synchronizebigmath}
-
-\let\bigmathfontsize\empty
-
-\unexpanded\def\synchronizebigmath
- {\ifx\bigmathfontsize\fontsize
- % already in sync
- \else
- \let\bigmathfontsize\fontsize
- \font_helpers_synchronize_math
- \fi}
-
-\unexpanded\def\font_helpers_check_big_math_synchronization
- {\ifcase\synchronizebigmathflag
- % never
- \or
- \ifmmode \synchronizebigmath \fi
- \or
- \synchronizebigmath
- \fi}
-
%D So far for synchronisation. (We can inline the following macros.)
\unexpanded\def\setcurrentfont#body#style#alternative#size%
@@ -2822,6 +1830,7 @@
\csname\fontclass\fontbody \defaultfontstyle \defaultfontalternative \defaultfontsize\endcsname
\else
\expandafter\font_helpers_check_strategy_class_f
+% \expandafter\font_helpers_check_strategy_a
\fi}
\def\font_helpers_check_strategy_class_f % def def def def % rm tf
@@ -2901,9 +1910,8 @@
%D in text mode the values defined by the bodyfontenvironment are
%D used. Here we also set \type{\currentxfontsize}.
-\def\font_helpers_set_current_font_xxx_alternative#alternative#size#xsize#scriptstyle%
- {\currentxfontsize#size\relax
- \ifmmode
+\def\font_helpers_set_current_font_xxx_alternative#alternative#xsize#scriptstyle%
+ {\ifmmode
#scriptstyle%
\else\ifcsname\??fontsteps\fontclass\fontbody#xsize\endcsname
\expandafter\font_helpers_set_current_fontbody_alternative\csname\??fontsteps\fontclass\fontbody#xsize\endcsname{#alternative}%
@@ -2912,11 +1920,13 @@
\fi\fi}
\def\font_helpers_set_current_font_x_alternative#alternative%
- {\font_helpers_set_current_font_xxx_alternative{#alternative}1\s!x\scriptstyle
+ {\font_helpers_set_current_font_xxx_alternative{#alternative}\s!x\scriptstyle
+ \currentxfontsize\plusone
\let\tx\txx}
\def\font_helpers_set_current_font_xx_alternative#alternative%
- {\font_helpers_set_current_font_xxx_alternative{#alternative}2\s!xx\scriptscriptstyle
+ {\font_helpers_set_current_font_xxx_alternative{#alternative}\s!xx\scriptscriptstyle
+ \currentxfontsize\plustwo
\let\tx\empty
\let\txx\empty}
@@ -2930,12 +1940,14 @@
\def\font_helpers_set_current_font_x_alternative#alternative%
{\font_helpers_check_nested_x_fontsize
- \font_helpers_set_current_font_xxx_alternative{#alternative}1\s!x\scriptstyle
+ \font_helpers_set_current_font_xxx_alternative{#alternative}\s!x\scriptstyle
+ \currentxfontsize\plusone
\let\tx\txx}
\def\font_helpers_set_current_font_xx_alternative#alternative%
{\font_helpers_check_nested_x_fontsize
- \font_helpers_set_current_font_xxx_alternative{#alternative}2\s!xx\scriptscriptstyle
+ \font_helpers_set_current_font_xxx_alternative{#alternative}\s!xx\scriptscriptstyle
+ \currentxfontsize\plustwo
\let\tx\empty
\let\txx\empty}
@@ -2974,30 +1986,6 @@
\let\normaltx \tx
\let\normaltxx\txx
-%D \macros
-%D {definefontstyle}
-%D
-%D When setting of switching the overall style we can use the
-%D short identifier like rm and ss, but when defined we can
-%D also use more verbose names like roman or sansserif. Such
-%D names are defined by:
-%D
-%D \starttyping
-%D \definefontstyle [serif,rm] [rm]
-%D \definefontstyle [sansserif,ss] [ss]
-%D \stoptyping
-
-\unexpanded\def\definefontstyle
- {\dodoubleargument\font_basics_define_fontstyle}
-
-\def\font_basics_define_fontstyle[#commands][#style]%
- {\rawdoifinsetelse{#style}{\fontstylelist}{}{\addtocommalist{#style}\fontstylelist}%
- \processcommalist[#commands]{\font_basics_define_fontstyle_indeed{#style}}}
-
-\def\font_basics_define_fontstyle_indeed#style#command%
- {\setvalue{\??fontshortstyle#command}{#style}%
- \setvalue{\??fontstyle #command}{\csname#style\endcsname}}
-
%D When asking for a complete font switch, for instance from 10
%D to 12~points, the next macro does the job. First we
%D normalize the size, next we define the current range of
@@ -3010,17 +1998,13 @@
\def\scriptface {\bodyfontvariable\s!script }
\def\scriptscriptface{\bodyfontvariable\s!scriptscript}
-\unexpanded\def\font_basics_complete_switch[#size]%
+\unexpanded\def\font_basics_complete_switch#size%
{\bodyfontsize#size\relax
- \dimensiontocount\bodyfontsize\bodyfontpoints % rounded, still used in m-chart
- \edef\bodyfontfactor{\withoutpt\the\bodyfontsize}%
- \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}%
+ \normalizebodyfontsize\normalizedbodyfontsize\bodyfontsize
\edef\textface {\bodyfontvariable\s!text }%
\edef\scriptface {\bodyfontvariable\s!script }%
\edef\scriptscriptface{\bodyfontvariable\s!scriptscript}}
-% \font_basics_complete_switch[12pt] % init
-
%D \macros
%D {setupbodyfont,switchtobodyfont}
%D
@@ -3064,7 +2048,7 @@
{\doifsomething{#specification}
{\font_helpers_set_font\plusone{#specification}%
\globalbodyfontsize\localbodyfontsize
- \edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\globalbodyfontsize}%
+ \normalizebodyfontsize\normalizedglobalbodyfontsize\globalbodyfontsize
\let\globalfontstyle\fontstyle
\ifproductionrun
\the\everybodyfont
@@ -3073,16 +2057,6 @@
\fi
\the\everysetupbodyfont}}
-% \unexpanded\def\switchtobodyfont[#specification]%
-% {\doifsomething{#specification}
-% {\ifcsname\??fonts\normalizedbodyfontsize#specification\endcsname
-% \font_helpers_set_bodyfont_step{#specification}% so we have a fast [small] switch
-% \else
-% \font_helpers_set_font\zerocount{#specification}%
-% \fi
-% \the\everybodyfont
-% \the\everyswitchtobodyfont}}
-
\unexpanded\def\switchtobodyfont[#specification]%
{\doifsomething{#specification}
{\edef\m_font_step{\bodyfontvariable{#specification}}%
@@ -3102,10 +2076,10 @@
%D switching and will be optimized.
\unexpanded\def\fastswitchtobodyfont#name%
- {\ifcsname\??fonts\normalizedbodyfontsize#name\endcsname
- \edef\futurebodyfontsize{\csname\??fonts\normalizedbodyfontsize#name\endcsname}%
- \ifcsname\??fontsize\futurebodyfontsize\endcsname
- \csname\??fontsize\futurebodyfontsize\endcsname
+ {\ifcsname\??fontenvironments\normalizedbodyfontsize#name\endcsname
+ \edef\futurebodyfontsize{\csname\??fontenvironments\normalizedbodyfontsize#name\endcsname}%
+ \ifcsname\??fontbodyknown\futurebodyfontsize\endcsname
+ \font_basics_complete_switch\futurebodyfontsize
\localbodyfontsize\futurebodyfontsize\relax
\fi
\fi
@@ -3116,63 +2090,11 @@
%D $\cases{& \ccaron}$ $x=\hbox{\ccaron $x=\hbox{\ccaron}$}$
%D \stoptyping
-\def\setfontcharacteristics
- {\the\everyfont}
-
%D Handy for manuals:
\unexpanded\def\fontchar#character%
{\ctxcommand{fontchar("#character")}}
-%D Feature management.
-
-\unexpanded\def\definefontfeature
- {\dotripleargument\font_basics_define_font_feature}
-
-\def\font_basics_define_font_feature[#featureset][#parent][#settings]%
- {\ctxcommand{definefontfeature("#featureset","#parent","#settings")}}
-
-\unexpanded\def\fontfeatureslist
- {\dodoubleargument\font_basics_features_list}
-
-\def\font_basics_features_list[#name][#separator]% todo: arg voor type
- {\cldcommand{featurelist("#name","otf","\luaescapestring{#separator}","yes","no",true,{"number"})}}
-
-\attribute\zerocount\zerocount % first in list, so fast match
-
-\let\currentfeature\empty
-
-% ! ! ! very experimental, some test code for idris advanced features ! ! !
-%
-% \startbuffer
-% \definefontfeature[smallcaps][smallcaps][script=latn]
-% \definefontfeature[oldstyle] [oldstyle] [script=latn]
-%
-% \definedfont[name:cambria at 15pt]
-%
-% Hello there {\setff{smallcaps}capped 123 \setff{oldstyle}123!} \blank
-% Hello there {\addff{smallcaps}capped 123 \addff{oldstyle}123!} \blank
-% Hello there {\addff{smallcaps}capped \subff{smallcaps}normal} \blank
-% \stopbuffer
-%
-% \typebuffer \getbuffer
-
-\unexpanded\def\featureattribute#feature{\ctxcommand{featureattribute("#feature")}}
-\unexpanded\def\setfontfeature #feature{\ctxcommand{setfontfeature("#feature")}\edef\currentfeature{#feature}}
-%unexpanded\def\resetfontfeature {\ctxcommand{resetfontfeature()}\let\currentfeature\empty} % initial value
-\unexpanded\def\resetfontfeature {\attribute\zerocount\zerocount \let\currentfeature\empty} % initial value
-
-\unexpanded\def\addfontfeaturetoset #feature{\ctxcommand{addfs("#feature")}} % merge
-\unexpanded\def\subtractfontfeaturefromset #feature{\ctxcommand{subfs("#feature")}} % merge
-\unexpanded\def\addfontfeaturetofont #feature{\ctxcommand{addff("#feature")}} % overload
-\unexpanded\def\subtractfontfeaturefromfont#feature{\ctxcommand{subff("#feature")}} % overload
-
-\let\setff\setfontfeature
-\let\addfs\addfontfeaturetoset
-\let\subfs\subtractfontfeaturefromset
-\let\addff\addfontfeaturetofont
-\let\subff\subtractfontfeaturefromfont
-
%D The next auxilliary macro is an alternative to \type
%D {\fontname}.
@@ -3202,19 +2124,6 @@
\the\everybodyfont} % needed ?
%D \macros
-%D {os}
-%D
-%D In good old \TEX, the old style numerals were often taken
-%D from the math fonts. No longer.
-
-\definefontfeature
- [just-os]
- [mode=node,onum=yes]
-
-%unexpanded\def\sc{\setfontfeature{smallcaps}}
-\unexpanded\def\os{\setfontfeature{just-os}}
-
-%D \macros
%D {definebodyfontswitch}
%D
%D \PLAIN\ \TEX\ defines some macro's like \type{\tenpoint}
@@ -3225,8 +2134,7 @@
%D \definebodyfontswitch [twelvepoint] [12pt]
%D \stoptyping
%D
-%D We don't support language specific synonyms here, mainly
-%D because \PLAIN\ \TEX\ is english anyway.
+%D We don't support language specific synonyms here.
\unexpanded\def\definebodyfontswitch
{\dodoubleargument\font_basics_define_bodyfont_switch}
@@ -3267,10 +2175,17 @@
%D Pagenumbers, footers, headers etc. however must be typeset
%D in the main bodyfont and style of the document. Returning to
%D the global state can be done with the next macro:
+%D
+%D This macro has to be called when entering the pagebody
+%D handling routine as well as the footnote insert routine.
+%D Users can access this feature |<|for instance when one wants
+%D to typeset tables and alike in the main bodyfont and style
+%D while the running text is temporary set to a smaller one|>|
+%D by saying \type{\switchtobodyfont[global]}.
\let\globalfontstyle\s!rm
-\def\fullrestoreglobalbodyfont
+\unexpanded\def\fullrestoreglobalbodyfont
{\let\fontsize\defaultfontsize
\let\fontbody\defaultfontbody
\currentxfontsize\zerocount
@@ -3283,7 +2198,7 @@
\the\everyglobalbodyfont
\saveinterlinespace}
-\def\partialrestoreglobalbodyfont
+\unexpanded\def\partialrestoreglobalbodyfont
{\let\fontsize\defaultfontsize
\let\fontbody\defaultfontbody
\currentxfontsize\zerocount
@@ -3293,7 +2208,7 @@
\the\everyglobalbodyfont % indeed needed
\saveinterlinespace}
-\def\restoreglobalbodyfont % ook style etc
+\unexpanded\def\restoreglobalbodyfont % ook style etc
{\ifx\fontclass\globalfontclass
\ifx\fontstyle\globalfontstyle
\ifx\normalizedbodyfontsize\normalizedglobalbodyfontsize
@@ -3310,712 +2225,4 @@
% in case of troubles: \let\restorebodyfont\fullrestoreglobalbodyfont
-%D This macro has to be called when entering the pagebody
-%D handling routine as well as the footnote insert routine.
-%D Users can access this feature |<|for instance when one wants
-%D to typeset tables and alike in the main bodyfont and style
-%D while the running text is temporary set to a smaller one|>|
-%D by saying \type{\switchtobodyfont[global]}.
-
-%D \macros
-%D {definealternativestyle}
-%D
-%D In the main modules we are going to implement lots of
-%D parameterized commands and one of these parameters will
-%D concern the font to use. To suit consistent use of fonts we
-%D here implement a mechanism for defining the keywords that
-%D present a particular style or alternative.
-%D
-%D \starttyping
-%D \definealternativestyle [keywords] [\style] [\nostyle]
-%D \stoptyping
-%D
-%D The first command is used in the normal textflow, while the
-%D second command takes care of headings and alike. Consider
-%D the next two definitions:
-%D
-%D \starttyping
-%D \definealternativestyle [bold] [\bf] []
-%D \definealternativestyle [cap] [\cap] [\cap]
-%D \stoptyping
-%D
-%D A change \type{\bf} in a heading which is to be set in
-%D \type{\tfd} does not look that well, so therefore we leave
-%D the second argument of \type{\definealternativestyle} empty.
-%D When we capatalize characters using the pseudo small cap
-%D command \type{\cap}, we want this to take effect in both
-%D text and headings, which is accomplished by assigning both
-%D arguments.
-
-\installcorenamespace{alternativestyles}
-
-\setnewconstant \c_font_current_alternative_style_index \plusone
-
-\unexpanded\def\definealternativestyle
- {\dotripleempty\font_basics_define_alternative_style}
-
-\def\font_basics_define_alternative_style[#commands][#variantone][#varianttwo]%
- {\processcommalist[#commands]{\font_basics_define_alternative_style_indeed{#variantone}{#varianttwo}}}
-
-\let\definestyle\definealternativestyle % later redefined
-
-\def\font_basics_define_alternative_style_indeed#variantone#varianttwo#command%
- {\ifcsname#command\endcsname
- % no redefinition
- \else
- \setuvalue{#command}{\groupedcommand{#variantone}{}}%
- \fi
- \setvalue{\??alternativestyles#command}{\font_helpers_apply_alternative_style{#variantone}{#varianttwo}}}%
-
-\def\font_helpers_apply_alternative_style
- {\ifcase\c_font_current_alternative_style_index
- \expandafter\gobbletwoarguments
- \or
- \expandafter\firstoftwoarguments
- \or
- \expandafter\secondoftwoarguments
- \else
- \expandafter\firstoftwoarguments
- \fi}
-
-\def\applyalternativestyle#name% public
- {\ifcsname\??alternativestyles#name\endcsname\csname\??alternativestyles#name\expandafter\endcsname\fi}
-
-%D Maybe too geneneric, but probably ok is the following. (Maybe one
-%D day we will use a dedicated grouped command for styles.)
-
-% \appendtoks
-% \let\groupedcommand\thirdofthreearguments
-% \to \simplifiedcommands
-
-%D This command also defines the keyword as command. This means
-%D that the example definition of \type{bold} we gave before,
-%D results in a command \type{\bold} which can be used as:
-%D
-%D \startbuffer
-%D He's a \bold{bold} man with a {\bold head}.
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D or
-%D
-%D \startexample
-%D \definealternativestyle[bold][\bf][]\getbuffer
-%D \stopexample
-%D
-%D Such definitions are of course unwanted for \type{\cap}
-%D because this would result in an endless recursive call.
-%D Therefore we check on the existance of both the command and
-%D the substitution. The latter is needed because for instance
-%D \type{\type} is an entirely diferent command. That command
-%D handles verbatim, while the style command would just switch
-%D to teletype font. This is just an example of a tricky
-%D naming coincidence.
-
-%D \macros
-%D {doconvertfont,noconvertfont,
-%D dontconvertfont,redoconvertfont}
-%D
-%D After having defined such keywords, we can call for them by
-%D using
-%D
-%D \starttyping
-%D \doconvertfont{keyword}{text}
-%D \stoptyping
-%D
-%D We deliberately pass an argument. This enables us to
-%D assign converters that handle one argument, like
-%D \type{\cap}.
-%D
-%D By default the first specification is used to set the style,
-%D exept when we say \type{\dontconvertfont}, after which the
-%D second specification is used. We can also directly call for
-%D \type{\noconvertfont}. In nested calls, we can restore the
-%D conversion by saying \type{\redoconvertfont}.
-
-%D These commands are not grouped! Grouping is most probably
-%D done by the calling macro's and would lead to unnecessary
-%D overhead.
-
-\let\m_current_convert_font \empty
-\let\m_current_convert_font_dt\empty
-
-\unexpanded\def\doconvertfont#specification% takes second argument / this command is obsolete
- {\edef\m_current_convert_font{#specification}%
- \ifx\m_current_convert_font\empty
- %\expandafter\firstofoneargument
- \else
- \expandafter\font_helpers_do_convert_font
- \fi}
-
-\def\font_helpers_do_convert_font
- {\edef\m_current_convert_font_dt{\detokenize\expandafter{\m_current_convert_font}}%
- \ifcsname\??alternativestyles\m_current_convert_font_dt\endcsname
- \csname\??alternativestyles\m_current_convert_font_dt\expandafter\endcsname
- \else\ifcsname\m_current_convert_font_dt\endcsname
- \csname\m_current_convert_font_dt\expandafter\endcsname
- \else
- \doubleexpandafter\m_current_convert_font
- \fi\fi}
-
-%D Low level switches (downward compatible):
-
-\unexpanded\def\dontconvertfont{\c_font_current_alternative_style_index\plustwo} % needs checking in usage
-\unexpanded\def\redoconvertfont{\c_font_current_alternative_style_index\plusone} % needs checking in usage
-
-%D The new one:
-
-\unexpanded\def\dousestyleparameter#value%
- {\edef\currentstyleparameter{#value}%
- \ifx\currentstyleparameter\empty\else
- \expandafter\dousecurrentstyleparameter
- \fi}
-
-\unexpanded\def\dousestylehashparameter#hash#parameter%
- {\ifcsname#hash#parameter\endcsname
- \expandafter\dousestyleparameter\csname#hash#parameter\endcsname
- \fi}
-
-\unexpanded\def\dousecurrentstyleparameter % empty check outside here
- {\edef\detokenizedstyleparameter{\detokenize\expandafter{\currentstyleparameter}}%
- \settrue\fontattributeisset % reset is done elsewhere
- \ifcsname\??alternativestyles\detokenizedstyleparameter\endcsname
- \csname\??alternativestyles\detokenizedstyleparameter\endcsname
- \else\ifcsname\detokenizedstyleparameter\endcsname
- \csname\detokenizedstyleparameter\endcsname
- \else
- \currentstyleparameter
- \fi\fi}
-
-\let\dosetfontattribute\dousestylehashparameter % for a while
-
-%D \macros
-%D {setfont}
-%D
-%D Every now and then we want to define a font directly, for
-%D instance when we typeset title pages. The next macro saves
-%D some typing:
-
-\unexpanded\def\setfont% geen \font_helpers_set_font mogelijk
- {\afterassignment\font_basics_set_font\font\nextfont=}
-
-\def\font_basics_set_font
- {\nextfont\setupinterlinespace}% hm, we need to use \setuplocalinterlinespace
-
-%D One can call this macro as:
-%D
-%D \starttyping
-%D \setfont cmr10 at 60pt
-%D \stoptyping
-%D
-%D After which the font is active and the baselines and
-%D struts are set.
-
-%D \macros
-%D {showbodyfont}
-%D
-%D One can call for a rather simple overview of a bodyfont and the
-%D relations between its alternative fonts.
-%D
-%D \showsetup{showbodyfont}
-%D
-%D The current bodyfont (here we omitted the argument) looks like:
-%D
-%D \showbodyfont
-%D
-%D The implementation is rather straightforward in using
-%D \type{\halign}.
-
-\fetchruntimecommand \showbodyfont {\f!fontprefix\s!run}
-
-%D \macros
-%D {showfontstrip, testminimalbaseline, showminimalbaseline}
-%D
-%D The next command can come in handy when combining
-%D different fonts into a collection (typeface) and
-%D determining optimal baseline distances.
-%D
-%D \showfontstrip \blank \showminimalbaseline
-
-\fetchruntimecommand \showfontstrip {\f!fontprefix\s!run}
-\fetchruntimecommand \testminimalbaseline {\f!fontprefix\s!run}
-\fetchruntimecommand \showminimalbaseline {\f!fontprefix\s!run}
-
-%D \macros
-%D {showkerning}
-%D
-%D A goody is:
-%D
-%D \showkerning{Can you guess what kerning is?}
-
-\fetchruntimecommand \showkerning {\f!fontprefix\s!run}
-
-%D \macros
-%D {showbodyfontenvironment}
-%D
-%D The current bodyfontenvironment is:
-%D
-%D \showbodyfontenvironment
-%D
-%D This overview is generated using:
-%D
-%D \showsetup{showbodyfontenvironment}
-
-\fetchruntimecommand \showbodyfontenvironment {\f!fontprefix\s!run}
-
-%D \macros
-%D {showfont,showfontstyle,showligatures}
-%D
-%D The following command generates a fontmap:
-%D
-%D \startbuffer
-%D \showfont[SansBold at 12pt]
-%D \stopbuffer
-%D
-%D \typebuffer
-%D \getbuffer
-
-% to be internationalized
-
-\fetchruntimecommand \showfont {\f!fontprefix\s!run}
-\fetchruntimecommand \showfontstyle {\f!fontprefix\s!run}
-\fetchruntimecommand \showligature {\f!fontprefix\s!run}
-\fetchruntimecommand \showligatures {\f!fontprefix\s!run}
-\fetchruntimecommand \showcharratio {\f!fontprefix\s!run}
-
-%D \macros
-%D {getglyph, symbolicfont}
-%D
-%D Individual glyphs can be accessed by using
-%D
-%D \starttyping
-%D \getglyph{fontname}{character}
-%D \stoptyping
-%D
-%D This macro is used in for instance the symbol modules and
-%D as one can see, it does obey the small and even smaller
-%D sizes. The \type {\symbolicfont} macro can be used to
-%D switch to a font named \type {fontname} (see \type
-%D {cont-log} and \type {symb-eur} for examples of symbolic
-%D definitions.
-
-\def\v_font_string_a
- {\ifx\fontstyle\s!rm \s!Serif \else
- \ifx\fontstyle\s!ss \s!Sans \else
- \ifx\fontstyle\s!tt \s!Mono \else
- \s!Serif \fi\fi\fi}
-
-\def\v_font_string_b
- {\ifx\fontstyle\s!rm \s!Regular \else
- \ifx\fontstyle\s!ss \s!Support \else
- \ifx\fontstyle\s!tt \s!Type \else
- \s!Serif \fi\fi\fi}
-
-\def\v_font_string_c
- {\ifx\fontalternative\s!bf \s!Bold \else
- \ifx\fontalternative\s!sl \s!Slanted \else
- \ifx\fontalternative\s!it \s!Italic \else
- \ifx\fontalternative\s!bs \s!BoldSlanted \else
- \ifx\fontalternative\s!bi \s!BoldItalic \fi\fi\fi\fi\fi}
-
-\let\v_font_string_d\s!Serif % default fontstyle (will be redefined in type-ini)
-
-% potential generalization:
-%
-% \letvalue{\??fontfile:t:\s!rm}\s!Serif
-% \letvalue{\??fontfile:t:\s!ss}\s!Sans
-% \letvalue{\??fontfile:t:\s!tt}\s!Mono
-%
-% \letvalue{\??fontfile:a:\s!rm}\s!Regular
-% \letvalue{\??fontfile:a:\s!ss}\s!Support
-% \letvalue{\??fontfile:a:\s!tt}\s!Type
-%
-% \letvalue{\??fontfile:s:\s!bf}\s!Bold
-% \letvalue{\??fontfile:s:\s!sl}\s!Slanted
-% \letvalue{\??fontfile:s:\s!it}\s!Italic
-% \letvalue{\??fontfile:s:\s!bs}\s!BoldSlanted
-% \letvalue{\??fontfile:s:\s!bi}\s!BoldItalic
-%
-% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif}
-% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif}
-% \def\v_font_string_b{\executeifdefined{\??fontfile:a:\fontstyle}\s!Serif}
-% \def\v_font_string_c{\executeifdefined{\??fontfile:s:\fontstyle}\empty}
-% \def\v_font_string_d{\executeifdefined{\??fontfile:t:\csname\??typescriptdefaultstyles\fontclass\endcsname}\s!Serif}
-
-%D \macros
-%D {fontstylesuffix}
-%D
-%D The next macro is used to map non latin fontnames on fonts. See \type
-%D {font-uni} for an example of its use.
-
-\def\fontstylesuffix% why the \s!Regular ? see \getglyph
- {\ifx\fontalternative\s!tf \s!Regular \else
- \ifx\fontalternative\s!bf \s!Bold \else
- \ifx\fontalternative\s!sl \s!Slanted \else
- \ifx\fontalternative\s!it \s!Italic \else
- \ifx\fontalternative\s!bs \s!BoldSlanted \else
- \ifx\fontalternative\s!bi \s!BoldItalic \else
- \ifx\fontalternative\s!sc \s!Caps \else
- \s!Regular \fi\fi\fi\fi\fi\fi\fi}%
-
-\def\glyphfontfile#base% appends
- {#base%
- \ifcsname\??fontfile#base\v_font_string_a\v_font_string_c\endcsname
- \v_font_string_a\v_font_string_c
- \else\ifcsname\??fontfile#base\v_font_string_b\v_font_string_c\endcsname
- \v_font_string_b\v_font_string_c
- \else\ifcsname\??fontfile#base\v_font_string_a\endcsname
- \v_font_string_a
- \else\ifcsname\??fontfile#base\v_font_string_b\endcsname
- \v_font_string_b
- \else\ifcsname\??fontfile#base\v_font_string_c\endcsname
- \v_font_string_c
- \fi\fi\fi\fi\fi}
-
-%D The next macro can be used to make decisions based on the shape:
-
-\def\doifitalicelse#yes#nop%
- {\ifx\fontalternative\s!sl#yes\else
- \ifx\fontalternative\s!it#yes\else
- \ifx\fontalternative\s!bs#yes\else
- \ifx\fontalternative\s!bi#yes\else#nop\fi\fi\fi\fi}
-
-%D For an example of usage of the following command,
-%D see \type {cont-log.tex}.
-%D
-%D \starttyping
-%D \def\symbolicfont#specification{\definedfont[\glyphfontfile{#specification} sa *]}
-%D \stoptyping
-%D
-%D Since we know what scaling it to be applied, we can
-%D implement a much faster alternative:
-
-\installcorenamespace{symbolfont}
-
-\let\thedefinedfont\relax
-
-\def\setscaledstyledsymbolicfont#1#2#3% quite a slowdown, glyphfontfile
- {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#3}} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}%
- \ifcsname\??symbolfont\askedsymbolfont\endcsname
- \csname\??symbolfont\askedsymbolfont\endcsname
- \else
- \font_basics_define_symbolic_font
- \fi}
-
-\def\setscaleddirectsymbolicfont#1#2#3% quite a slowdown, glyphfontfile
- {\edef\askedsymbolfont{\truefontname{#3} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}%
- \ifcsname\??symbolfont\askedsymbolfont\endcsname
- \csname\??symbolfont\askedsymbolfont\endcsname
- \else
- \font_basics_define_symbolic_font
- \fi}
-
-\def\setstyledsymbolicfont#fontname% quite a slowdown, glyphfontfile
- {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#fontname}} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}%
- \ifcsname\??symbolfont\askedsymbolfont\endcsname
- \csname\??symbolfont\askedsymbolfont\endcsname
- \else
- \font_basics_define_symbolic_font
- \fi}
-
-\def\setdirectsymbolicfont#fontname%
- {\edef\askedsymbolfont{\truefontname{#fontname} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}%
- \ifcsname\??symbolfont\askedsymbolfont\endcsname
- \csname\??symbolfont\askedsymbolfont\endcsname
- \else
- \font_basics_define_symbolic_font
- \fi}
-
-\def\font_basics_define_symbolic_font
- {\definefont[currentsymbolfont][\askedsymbolfont]%
- \currentsymbolfont
- \global\expandafter\let\csname\??symbolfont\askedsymbolfont\endcsname\lastrawfontcall}
-
-\unexpanded\def\getnamedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\ctxcommand{fontchar("#character")}}}
-\unexpanded\def\getnamedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\ctxcommand{fontchar("#character")}}}
-\unexpanded\def\getglyphstyled #fontname#character{{\setstyledsymbolicfont{#fontname}\doifnumberelse{#character}\char\donothing#2}}
-\unexpanded\def\getglyphdirect #fontname#character{{\setdirectsymbolicfont{#fontname}\doifnumberelse{#character}\char\donothing#2}}
-
-% this one is wrong:
-
-\unexpanded\def\getscaledglyph#scale#name#content%
- {{\setscaledstyledsymbolicfont\fontbody{#scale}{#name}\doifnumberelse{#content}\char\donothing#content}}
-
-\let\getglyph \getglyphstyled % old
-\let\getrawglyph \getglyphdirect % old
-\let\symbolicsizedfont\setscaledstyledsymbolicfont % old
-\let\symbolicfont \setstyledsymbolicfont % old
-
-\unexpanded\def\symbolicscaledfont{\setsscaledstyledsymbolicfont\fontbody}
-\unexpanded\def\symbolicscaledfont{\setscaledstyledsymbolicfont\fontbody}
-
-%D The last implementation of \type {\getglyph} permits
-%D definitions like:
-%D
-%D \starttyping
-%D \definefontsynonym [EuroSans] [eurose]
-%D \definefontsynonym [EuroSansBold] [euroseb]
-%D \definefontsynonym [EuroSansItalic] [eurosei]
-%D \definefontsynonym [EuroSansSlanted] [eurosei]
-%D \definefontsynonym [EuroSansBoldItalic] [eurosebi]
-%D \definefontsynonym [EuroSansBoldSlanted] [eurosebi]
-%D
-%D \definesymbol [euro] [\getglyph{Euro}{\char160}]
-%D
-%D \def\euro{\symbol[euro]}
-%D \stoptyping
-%D
-%D These definitions guarantee that the next calls work okay:
-%D
-%D \starttyping
-%D \ss \tf\euro \bf\euro \sla\euro \itd\euro \bs\euro \bic\euro
-%D \stoptyping
-%D
-%D The shape as well as the size is adapted to the current
-%D environment.
-
-%D Personally I think that using \TEX\ macro packages is
-%D complicated by the way fonts are handled. Apart from the
-%D many encodings, we also deal with different naming schemes.
-%D Confronted with this problem, I decided to change the
-%D definitions into:
-%D
-%D \starttyping
-%D \definebodyfont [12pt] [rm] [tf=Times-Roman at 12pt]
-%D \stoptyping
-%D
-%D combined with for instance:
-%D
-%D \starttyping
-%D \definefontsynonym [Times-Roman] [tir]
-%D \stoptyping
-
-% this needs some interfacing
-%
-% \setupfonts[check=...]
-
-\unexpanded\def\checkcharactersinfont {\ctxcommand{checkcharactersinfont }}
-\unexpanded\def\removemissingcharacters{\ctxcommand{removemissingcharacters}}
-
-%D New commands (not yet interfaced):
-%D
-%D \startbuffer
-%D \definestyle[one][style=bold,color=darkblue]
-%D
-%D test \one{test} test
-%D test \style[one]{test} test
-%D test \style[color=red]{test} test
-%D test \style[Serif at 20pt]{test} test
-%D \stopbuffer
-%D
-%D \typebuffer \startlines \getbuffer \stoplines
-
-% definitions .. no tagging here
-
-\installcorenamespace{style}
-\installcorenamespace{stylecheck}
-
-\installcommandhandler \??style {style} \??style
-
-\appendtoks
- \letvalue{\??stylecheck\currentstyle}\relax
- \setuevalue{\e!start\currentstyle}{\font_styles_apply_start{\currentstyle}}%
- \setuevalue{\e!stop \currentstyle}{\font_styles_apply_stop}%
- \setuevalue {\currentstyle}{\font_styles_apply_grouped{\currentstyle}}% no longer groupedcommand here
-\to \everydefinestyle
-
-\unexpanded\def\font_styles_apply_start#name%
- {\begingroup
- \font_styles_use_defined{#name}}
-
-\unexpanded\def\font_styles_apply_stop
- {\endgroup}
-
-\unexpanded\def\font_styles_apply_grouped#name% assumes that the next is { or \bgroup
- {\bgroup
- \def\g_style{\font_styles_use_defined{#name}}%
- \afterassignment\g_style
- \let\nexttoken}
-
-\unexpanded\def\font_styles_use_defined#name%
- {\edef\currentstyle{#name}%
- \usestylestyleandcolor\c!style\c!color}
-
-\unexpanded\def\font_styles_use_generic#specification%
- {\let\currentstyle\s!unknown % reasonable generic tag
- \setupcurrentstyle[\c!style=,\c!color=,#specification]%
- \usestylestyleandcolor\c!style\c!color}
-
-% commands
-
-\installcorenamespace{styleargument}
-
-\unexpanded\def\style[#name]% as this is can be a switch we use groupedcommand
- {\csname\??styleargument
- \ifcsname#name\endcsname1\else\ifcsname\??stylecheck#name\endcsname2\else3\fi\fi
- \endcsname{#name}}
-
-\setvalue{\??styleargument1}#name%
- {\csname#name\endcsname}
-
-\setvalue{\??styleargument2}#name%
- {\groupedcommand{\font_styles_use_defined{#name}}{}}
-
-\setvalue{\??styleargument3}#specification%
- {\doifassignmentelse{#specification}\font_styles_assignment\font_styles_direct{#specification}}
-
-\def\font_styles_assignment#specification{\groupedcommand{\font_styles_use_generic{#specification}}{}}
-\def\font_styles_direct #specification{\groupedcommand{\definedfont[#specification]}{}}
-
-% environments
-
-\installcorenamespace{styleenvironment}
-
-\unexpanded\def\startstyle[#name]%
- {\begingroup
- \csname\??styleenvironment
- \ifcsname#name\endcsname1\else\ifcsname\??stylecheck#name\endcsname2\else3\fi\fi
- \endcsname{#name}}
-
-\unexpanded\def\stopstyle
- {\endgroup
- \autoinsertnextspace} % will be configurable, maybe also in \definestartstop
-
-\setvalue{\??styleenvironment1}#name%
- {\csname#name\endcsname}
-
-\setvalue{\??styleenvironment2}#name%
- {\font_styles_use_defined{#name}}
-
-\setvalue{\??styleenvironment3}#specification%
- {\doifassignmentelse{#specification}\font_styles_start_assignment\font_styles_start_direct{#specification}}
-
-\def\font_styles_start_assignment#specification{\usegenericstyle{#specification}}
-\def\font_styles_start_direct #specification{\definedfont[#specification]\relax}
-
-%D Still experimental (might even go away).
-
-% \definestylecollection[mine]
-
-% \definestyleinstance[mine][default][sorry]
-% \definestyleinstance[mine][tt][bs][ttbs:\rm\sl]
-% \definestyleinstance[mine][tt][bf][ttbf:\rm\sl]
-% \definestyleinstance[mine][bf][\sl]
-% \definestyleinstance[mine][sl][\tt]
-
-% {\bf test \mine test \sl test \mine test \bs oeps \mine oeps {\tt test \mine \bf test}}
-
-\installcorenamespace{stylecollection}
-
-\unexpanded\def\definestylecollection
- {\dosingleargument\font_styles_define_style_collection}
-
-\def\font_styles_define_style_collection[#name]%
- {\iffirstargument
- \setuvalue{#name}{\styleinstance[#name]}%
- \def\font_styles_define_style_collection_a#style%
- {\def\font_styles_define_style_collection_b#alternative{\letbeundefined{\??stylecollection#name:#style:#alternative}}%
- \processcommacommand[\fontalternativelist,\s!default]\font_styles_define_style_collection_b}%
- \processcommacommand[\fontstylelist,\s!default]\font_styles_define_style_collection_a
- \fi}
-
-\unexpanded\def\definestyleinstance
- {\doquadrupleargument\font_styles_define_style_instance}
-
-\def\font_styles_define_style_instance[#instance][#2][#3][#4]% [name] [rm|ss|tt|..] [sl|bf|...] [whatever]
- {\iffirstargument
- \ifcsname#1\endcsname\else\font_styles_define_style_collection[#instance]\fi
- \fi
- \iffourthargument
- \setvalue{\??stylecollection#instance:#2:#3}{#4}%
- \else\ifthirdargument
- \setvalue{\??stylecollection#instance::#2}{#3}%
- \else\ifsecondargument
- \letvalueempty{\??stylecollection#instance::#2}%
- \fi\fi\fi}
-
-\unexpanded\def\styleinstance[#instance]% will be made faster
- {%\begingroup\normalexpanded{\noexpand\infofont[#1:\fontstyle:\fontalternative]}\endgroup
- \executeifdefined{\??stylecollection#instance:\fontstyle:\fontalternative}%
- {\executeifdefined{\??stylecollection#instance:\fontstyle:\s!default}%
- {\executeifdefined{\??stylecollection#instance::\fontalternative}
- {\getvalue {\??stylecollection#instance::\s!default}}}}}
-
-% \unexpanded\def\styleinstance[#instance]%
-% {\csname\??stylecollection#instance%
-% \ifcsname\??stylecollection#instance:\fontstyle:\fontalternative\endcsname
-% :\fontstyle:\fontalternative
-% \else\ifcsname\??stylecollection#instance:\fontstyle:\s!default\endcsname
-% :\fontstyle:\s!default
-% \else\ifcsname\??stylecollection#instance::\fontalternative\endcsname
-% ::\fontalternative
-% \else % \ifcsname\??stylecollection#instance::\s!default\endcsname
-% ::\s!default
-% % \else
-% % % nothing, \relax
-% \fi\fi\fi % \fi
-% \endcsname}
-
-%D goodies:
-
-\unexpanded\def\showchardata#character{\ctxcommand{showchardata("#character")}}
-\unexpanded\def\showfontdata {\ctxcommand{showfontparameters()}}
-
-%D some low level helpers
-%D
-%D \starttyping
-%D \def\TestLookup#specification%
-%D {\dolookupfontbyspec{#specification}
-%D pattern: #specification, found: \dolookupnoffound
-%D \blank
-%D \dorecurse {\dolookupnoffound} {%
-%D \recurselevel:~\dolookupgetkeyofindex{fontname}{\recurselevel}\quad
-%D }%
-%D \blank}
-%D
-%D \TestLookup{familyname=helveticaneue}
-%D \TestLookup{familyname=helveticaneue,weight=bold}
-%D \TestLookup{familyname=helveticaneue,weight=bold,style=italic}
-%D \stoptyping
-
-% we can also move the lookups to the fonts.namespace (of commands)
-
-% these will be renamed but it needs synchronization with WS
-
-\def\dolookupfontbyspec #1{\ctxcommand{fontlookupinitialize("#1")}}
-\def\dolookupnoffound {\ctxcommand{fontlookupnoffound()}}
-\def\dolookupgetkeyofindex#1#2{\ctxcommand{fontlookupgetkeyofindex("#1",#2)}}
-\def\dolookupgetkey #1{\ctxcommand{fontlookupgetkey("#1")}}
-\def\cleanfontname #1{\ctxcommand{cleanfontname("#1")}}
-
-% \doifelsecurrentfonthasfeature{smcp}{YES}{NO}
-% \doifelsecurrentfonthasfeature{crap}{YES}{NO}
-% \doifelsecurrentfonthasfeature{kern}{YES}{NO}
-
-\def\doifelsecurrentfonthasfeature#feature%
- {\ctxcommand{doifelsecurrentfonthasfeature("#feature")}}
-
-%D variant selectors
-%D
-%D \starttyping
-%D \mathematics {\vsone{\utfchar{"2229}}}
-%D \mathematics {\utfchar{"2229}\vsone{}}
-%D \stoptyping
-
-\unexpanded\edef\vsone#character{#character\utfchar{"FE00}} % used
-\unexpanded\edef\vstwo#character{#character\utfchar{"FE01}} % not used but handy for testing
-
-% new:
-
-\unexpanded\def\setfontofid#1{\ctxcommand{setfontofid(#1)}}
-
-%D Watch the \type {\normal} hackery: this makes the mkvi parser happy.
-
-\normaldef\fntsetdefname {\global\let\somefontname\defaultfontfile}
-\normaldef\fntsetsomename{\normalgdef\somefontname} % takes argument
-\normaldef\fntsetnopsize {\let\somefontsize\empty}
-\normaldef\fntsetsomesize{\normaldef\somefontsize} % takes argument
-
\protect \endinput
-
diff --git a/tex/context/base/font-lib.mkvi b/tex/context/base/font-lib.mkvi
new file mode 100644
index 000000000..d9c04f0a2
--- /dev/null
+++ b/tex/context/base/font-lib.mkvi
@@ -0,0 +1,94 @@
+%D \module
+%D [ file=font-lib,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Libraries,
+%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 Macros / Libraries}
+
+\unprotect
+
+\registerctxluafile{font-ini}{1.001}
+\registerctxluafile{font-log}{1.001}
+\registerctxluafile{font-con}{1.001}
+\registerctxluafile{font-enc}{1.001}
+%registerctxluafile{font-agl}{1.001} % loaded when needed, saves 100K in format
+\registerctxluafile{font-cid}{1.001} % cid maps
+\registerctxluafile{font-map}{1.001}
+\registerctxluafile{font-syn}{1.001}
+
+\registerctxluafile{font-tfm}{1.001}
+
+\registerctxluafile{font-afm}{1.001}
+
+\registerctxluafile{font-oti}{1.001} % otf initialization
+\registerctxluafile{font-ott}{1.001} % otf tables (first)
+\registerctxluafile{font-otf}{1.001} % otf main
+\registerctxluafile{font-otb}{1.001} % otf main base
+\registerctxluafile{node-inj}{1.001} % we might split it off
+\registerctxluafile{font-otn}{1.001} % otf main node
+\registerctxluafile{font-otd}{1.001} % otf dynamics (does an overload)
+\registerctxluafile{font-ota}{1.001} % otf analyzers (needs dynamics)
+\registerctxluafile{font-otp}{1.001} % otf pack
+\registerctxluafile{font-otc}{1.001} % otf context
+\registerctxluafile{font-oth}{1.001} % otf helpers
+
+\registerctxluafile{font-pat}{1.001} % patchers
+
+\registerctxluafile{node-fnt}{1.001} % here
+
+\registerctxluafile{font-lua}{1.001}
+
+\registerctxluafile{font-vf} {1.001}
+\registerctxluafile{font-enh}{1.001}
+
+\registerctxluafile{font-gds}{1.001} % currently only otf
+
+\registerctxluafile{font-def}{1.001}
+\registerctxluafile{font-ctx}{1.001} % after def as it overloads
+
+\registerctxluafile{font-ext}{1.001}
+\registerctxluafile{font-fbk}{1.001}
+\registerctxluafile{font-chk}{1.001}
+
+\registerctxluafile{font-aux}{1.001}
+
+%D Some low level helpers
+%D
+%D \starttyping
+%D \def\TestLookup#specification%
+%D {\dolookupfontbyspec{#specification}
+%D pattern: #specification, found: \dolookupnoffound
+%D \blank
+%D \dorecurse {\dolookupnoffound} {%
+%D \recurselevel:~\dolookupgetkeyofindex{fontname}{\recurselevel}\quad
+%D }%
+%D \blank}
+%D
+%D \TestLookup{familyname=helveticaneue}
+%D \TestLookup{familyname=helveticaneue,weight=bold}
+%D \TestLookup{familyname=helveticaneue,weight=bold,style=italic}
+%D \stoptyping
+
+% we can also move the lookups to the fonts.namespace (of commands)
+
+% these will be renamed but it needs synchronization with WS
+
+\def\dolookupfontbyspec #1{\ctxcommand{fontlookupinitialize("#1")}}
+\def\dolookupnoffound {\ctxcommand{fontlookupnoffound()}}
+\def\dolookupgetkeyofindex#1#2{\ctxcommand{fontlookupgetkeyofindex("#1",#2)}}
+\def\dolookupgetkey #1{\ctxcommand{fontlookupgetkey("#1")}}
+\def\cleanfontname #1{\ctxcommand{cleanfontname("#1")}}
+
+% new:
+
+\unexpanded\def\setfontofid#1{\ctxcommand{setfontofid(#1)}}
+
+\protect \endinput
diff --git a/tex/context/base/font-mat.mkvi b/tex/context/base/font-mat.mkvi
new file mode 100644
index 000000000..85a10bf3a
--- /dev/null
+++ b/tex/context/base/font-mat.mkvi
@@ -0,0 +1,408 @@
+%D \module
+%D [ file=font-mat,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Math,
+%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 Macros / Math}
+
+\unprotect
+
+%D \macros
+%D {textonly}
+%D
+%D Traditionally math has a big impact on font definitions, mainly
+%D because we need to define alphabet variants using families and
+%D fonts. This means that one can easily get 10 fonts loaded per
+%D math size. In \MKIV\ we use a different approach: one family
+%D which has either a virtual font made of traditional fonts, or
+%D an \OPENTYPE\ font that has it all.
+%D
+%D We currently use only one math family but in the future we
+%D might consider using a second one for bold math. For the
+%D moment we keep the \MKII\ method of using a token register
+%D for definitions but we already dropped the text and symbols
+%D ones since they now live in the same family.
+
+\newtoks \t_font_math_strategies
+\newconditional\c_font_synchronize_math_fonts \settrue\c_font_synchronize_math_fonts
+
+\unexpanded\def\font_helpers_synchronize_math % math stuff in mmode
+ {\ifconditional\c_font_synchronize_math_fonts\the\t_font_math_strategies\fi}
+
+\unexpanded\def\textonly{\setfalse\c_font_synchronize_math_fonts} % document this
+
+%D The main math font definer. We have removed some optimized
+%D code simply because we now always have a fontclass. We could
+%D check for fontclass being default or empty and save a few
+%D tests but it does not help us when no math is defined.
+
+%D Because we want to keep mr=.. and mb=... settings (read: not
+%D break downward compatibility by enforcing mrlr etc) we need a
+%D bit more code that optimal.
+
+% todo: \c_font_fam_mr
+
+\let\c_font_fam_mr \zerocount % math regular
+\let\c_font_fam_mr_lr\plusone % math regular l2r
+\let\c_font_fam_mr_rl\plustwo % math regular r2l
+
+\let\c_font_fam_mb \plusthree % math bold
+\let\c_font_fam_mb_lr\plusfour % math bold l2r
+\let\c_font_fam_mb_rl\plusfive % math bold r2l
+
+\definesystemattribute[mathfamily][public]
+
+\newconditional\c_font_bidirectional_math_strategy % can be default, not that much overhead: \settrue\c_font_bidirectional_math_strategy
+\newconditional\c_font_complete_bold_math_strategy \settrue\c_font_complete_bold_math_strategy
+
+\def\mathtextsuffix {-text}
+\def\mathscriptsuffix {-script}
+\def\mathscriptscriptsuffix{-scriptscript}
+
+\let\currentmathsize\empty
+
+\def\mathsizesuffix{\ifcase0\currentmathsize\or\mathtextsuffix\or\mathscriptsuffix\or\mathscriptscriptsuffix\fi}
+
+% Beware: truefontname also does a fallback on defaultfontclass so there
+% can be some interference here, which is why we use a different method
+% for bold.
+
+\def\font_helpers_set_math_family_a
+ {\ifcsname\fontclass \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size
+ \csname\fontclass \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \else
+ \ifcsname\fontclass \fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size
+ \csname\fontclass \fontbody\s!mm\fontfamily \currentmathsize\endcsname \else
+ \font_helpers_set_math_family_b
+ \fi\fi}
+
+\def\font_helpers_set_math_family_b
+ {\ifcsname\defaultfontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size
+ \csname\defaultfontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \else
+ \ifcsname\defaultfontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size
+ \csname\defaultfontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname \else
+ \font_helpers_set_math_family_c
+ \fi\fi}
+
+\def\font_helpers_set_math_family_c
+ {\ifcsname \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size
+ \csname \fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \else
+ \ifcsname \fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size
+ \csname \fontbody\s!mm\fontfamily \currentmathsize\endcsname \else
+ \nullfont \settrue\font_auto_font_size
+ \fi\fi}
+
+\def\font_helpers_set_math_family_indeed#mrtag#family% \currentmathsize etc are also used later on
+ {\let\savedfontbody\fontbody
+ \let\fontfamily#family%
+ \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\font_helpers_set_math_family_a\scriptscriptfont#mrtag\font
+ \let\currentmathsize\!!plustwo \let\fontbody\scriptface \font_helpers_set_math_family_a\scriptfont #mrtag\font
+ \let\currentmathsize\!!plusone \let\fontbody\textface \font_helpers_set_math_family_a\textfont #mrtag\font
+ \let\currentmathsize\empty
+ \let\fontbody\savedfontbody
+ \setfalse\font_auto_font_size}
+
+\def\font_helpers_set_math_family_bold_a#font#mbfam#mrfam%
+ {\ifcsname\fontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname \setfalse\font_auto_font_size
+ \csname\fontclass\fontbody\s!mm\fontfamily\fontsize\currentmathsize\endcsname #font#mbfam\font \else
+ \ifcsname\fontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname \settrue\font_auto_font_size
+ \csname\fontclass\fontbody\s!mm\fontfamily \currentmathsize\endcsname #font#mbfam\font \else
+ #font#mbfam#font#mrfam%
+ \fi\fi}
+
+\def\font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam% \c_font_fam_mb \s!mb \c_font_fam_mr
+ {\let\savedfontclass\defaultfontclass
+ \let\defaultfontclass\fontclass % else truefontname falls back on the wrong one
+ \let\savedfontbody\fontbody
+ \let\fontfamily#familytag%
+ \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\font_helpers_set_math_family_bold_a\scriptscriptfont#mbfam#mrfam%
+ \let\currentmathsize\!!plustwo \let\fontbody\scriptface \font_helpers_set_math_family_bold_a\scriptfont #mbfam#mrfam%
+ \let\currentmathsize\!!plusone \let\fontbody\textface \font_helpers_set_math_family_bold_a\textfont #mbfam#mrfam%
+ \let\currentmathsize\empty
+ \let\fontbody\savedfontbody
+ \let\defaultfontclass\savedfontclass
+ \setfalse\font_auto_font_size}
+
+% optimized: math fonts are never changed (10K \bfa $x$: 3.2 => 2.5 (baseline 1.0))
+%
+% sort of tricky: we cannot reset in \everybeforedefinetypeface as we don't know
+% all sizes so we postpone the optimization to the first starttext
+%
+% pitfall: we should reset 'm when a fontclass name is reused
+
+\newconditional\optimizemathfontdefinitions \settrue\optimizemathfontdefinitions
+
+\def\font_helpers_set_math_family#mrfam#familytag%
+ {\ifconditional\optimizemathfontdefinitions
+ \ifcsname\??fontinstanceclass\fontclass\textface\s!mm#familytag1\fontsize1\endcsname
+ \font_helpers_preset_math_family_indeed#mrfam#familytag%
+ \else
+ \font_helpers_set_math_family_indeed#mrfam#familytag%
+ \fi
+ \else
+ \font_helpers_set_math_family_indeed#mrfam#familytag%
+ \fi}
+
+\def\font_helpers_set_math_family_bold#mbfam#familytag#mrfam%
+ {\ifconditional\optimizemathfontdefinitions
+ \ifcsname\??fontinstanceclass\fontclass\textface\s!mm#familytag1\fontsize1\endcsname
+ \font_helpers_preset_math_family_indeed#mbfam#familytag%
+ \else
+ \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam%
+ \fi
+ \else
+ \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam%
+ \fi}
+
+\def\font_helpers_preset_math_family_indeed#fam#familytag%
+ {\scriptscriptfont#fam\csname\??fontinstanceclass\fontclass\scriptscriptface\s!mm#familytag3\fontsize3\endcsname
+ \scriptfont #fam\csname\??fontinstanceclass\fontclass\scriptface \s!mm#familytag2\fontsize2\endcsname
+ \textfont #fam\csname\??fontinstanceclass\fontclass\textface \s!mm#familytag1\fontsize1\endcsname}
+
+\let\font_helpers_reset_fontclass_math_families\gobbleoneargument
+
+% It would be nice if characters could be defined in a neutral way (say fam 255) and
+% be mapped to a real family during noad list construction. However, this changes
+% tex in critical places so for the moment we simulate this using manipulation.
+
+% For tracing purposes we use three families but in l2r mode 1 and 2 are copies of 0
+% while in rl mode 0 is a copy of 1. There is no real overhead involved in this. This
+% also permits different font definitions for normal and mixed.
+
+\let\m_font_class_direction\empty
+\let\m_font_class_features \empty
+\let\m_font_class_fallbacks\empty
+\let\m_font_class_goodies \empty
+
+\let\m_font_direction\empty
+\let\m_font_features \empty
+\let\m_font_fallbacks\empty
+\let\m_font_goodies \empty
+
+\appendtoks % can be analyzed once
+ % why here ..
+ \edef\m_font_class_direction{\ifcsname\??fontclass\fontclass\s!mm\s!direction\endcsname\csname\??fontclass\fontclass\s!mm\s!direction\endcsname\fi}%
+ % ...
+ \ifx\m_font_class_direction\v!both
+ \settrue\c_font_bidirectional_math_strategy
+ \else
+ \setfalse\c_font_bidirectional_math_strategy
+ \fi
+\to \t_font_math_strategies
+
+\def\font_helpers_bidirectional_mathstrategy_yes
+ {\font_helpers_set_math_family\c_font_fam_mr_lr\s!mrlr
+ \font_helpers_set_math_family\c_font_fam_mr_rl\s!mrrl
+ \textfont \c_font_fam_mr\textfont \c_font_fam_mr_lr
+ \scriptfont \c_font_fam_mr\scriptfont \c_font_fam_mr_lr
+ \scriptscriptfont\c_font_fam_mr\scriptscriptfont\c_font_fam_mr_lr}
+
+\def\font_helpers_bidirectional_mathstrategy_nop
+ {\font_helpers_set_math_family\c_font_fam_mr\s!mr
+ \textfont \c_font_fam_mr_rl\textfont \c_font_fam_mr
+ \scriptfont \c_font_fam_mr_rl\scriptfont \c_font_fam_mr
+ \scriptscriptfont\c_font_fam_mr_rl\scriptscriptfont\c_font_fam_mr
+ \textfont \c_font_fam_mr_lr\textfont \c_font_fam_mr
+ \scriptfont \c_font_fam_mr_lr\scriptfont \c_font_fam_mr
+ \scriptscriptfont\c_font_fam_mr_lr\scriptscriptfont\c_font_fam_mr}
+
+\appendtoks
+ \ifconditional\c_font_bidirectional_math_strategy
+ \font_helpers_bidirectional_mathstrategy_yes
+ \else
+ \font_helpers_bidirectional_mathstrategy_nop
+ \fi
+\to \t_font_math_strategies
+
+\def\font_helpers_complete_bold_math_strategy_yes_bidi
+ {\font_helpers_set_math_family_bold\c_font_fam_mb_lr\s!mblr\c_font_fam_mr_lr
+ \font_helpers_set_math_family_bold\c_font_fam_mb_rl\s!mbrl\c_font_fam_mr_rl
+ \textfont \c_font_fam_mb\textfont \c_font_fam_mb_lr
+ \scriptfont \c_font_fam_mb\scriptfont \c_font_fam_mb_lr
+ \scriptscriptfont\c_font_fam_mb\scriptscriptfont\c_font_fam_mb_lr}
+
+\def\font_helpers_complete_bold_math_strategy_yes
+ {\font_helpers_set_math_family_bold\c_font_fam_mb\s!mb\c_font_fam_mr
+ \textfont \c_font_fam_mb_rl\textfont \c_font_fam_mb
+ \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mb
+ \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mb
+ \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mb
+ \scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mb
+ \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mb}
+
+\def\font_helpers_complete_bold_math_strategy_nop
+ {\textfont \c_font_fam_mb \textfont \c_font_fam_mr
+ \scriptfont \c_font_fam_mb \scriptfont \c_font_fam_mr
+ \scriptscriptfont\c_font_fam_mb \scriptscriptfont\c_font_fam_mr
+ \textfont \c_font_fam_mb_rl\textfont \c_font_fam_mr_rl
+ \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mr_rl
+ \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mr_rl
+ \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mr_lr
+ \scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mr_lr
+ \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mr_lr}
+
+\def\font_helpers_apply_complete_bold_math_strategy
+ {\ifconditional\c_font_complete_bold_math_strategy
+ \ifconditional\c_font_bidirectional_math_strategy
+ \font_helpers_complete_bold_math_strategy_yes_bidi
+ \else
+ \font_helpers_complete_bold_math_strategy_yes
+ \fi
+ \else
+ \font_helpers_complete_bold_math_strategynop
+ \fi}
+
+\appendtoks
+ \font_helpers_apply_complete_bold_math_strategy
+\to \t_font_math_strategies
+
+\ifdefined\defaultmathfamily \else
+ \setnewconstant\defaultmathfamily\zerocount
+\fi
+
+\appendtoks
+ \fam\defaultmathfamily % all characters and symbols are in this family
+\to \everymathematics
+
+\unexpanded\def\font_helpers_synchronize_math_family_mr
+ {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_math_strategy
+ \ifconditional\c_math_right_to_left
+ \plustwo
+ \else
+ \plusone
+ \fi
+ \else
+ \zerocount
+ \fi}
+
+\unexpanded\def\font_helpers_synchronize_math_family_mb
+ {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_math_strategy
+ \ifconditional\c_math_right_to_left
+ \ifconditional\c_font_pseudo_bold_math_state\pluseight\else\plusfive\fi
+ \else
+ \ifconditional\c_font_pseudo_bold_math_state\plusseven\else\plusfour\fi
+ \fi
+ \else
+ \ifconditional\c_font_pseudo_bold_math_state\plussix\else\plusthree\fi
+ \fi}
+
+\installcorenamespace{fontmathsynchronizer}
+\installcorenamespace{fontmathstoredstrategy}
+
+\letvalue{\??fontmathsynchronizer\s!tf }\font_helpers_synchronize_math_family_mr
+\letvalue{\??fontmathsynchronizer\s!sl }\font_helpers_synchronize_math_family_mr
+\letvalue{\??fontmathsynchronizer\s!it }\font_helpers_synchronize_math_family_mr
+\letvalue{\??fontmathsynchronizer\s!bf }\font_helpers_synchronize_math_family_mb
+\letvalue{\??fontmathsynchronizer\s!bs }\font_helpers_synchronize_math_family_mb
+\letvalue{\??fontmathsynchronizer\s!bi }\font_helpers_synchronize_math_family_mb
+\letvalue{\??fontmathsynchronizer\empty}\font_helpers_synchronize_math_family_mr
+
+\def\font_helpers_synchronize_math_family
+ {\csname\??fontmathsynchronizer\ifcsname\??fontmathsynchronizer\fontalternative\endcsname\fontalternative\fi\endcsname}
+
+\ifdefined \fontid % we need to keep this test for a while
+ \appendtoks
+ \ifnum\fontid\textfont\zerocount=\fontid\textfont\plusthree
+ \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_partial_bold_strategy
+ \else
+ \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_full_bold_strategy
+ \fi
+ \to \t_font_math_strategies
+\else
+ \appendtoks
+ \edef\currentmathfontmr{\fontname\textfont\zerocount}%
+ \edef\currentmathfontmb{\fontname\textfont\plusthree}%
+ \ifx\currentmathfontmr\currentmathfontmb
+ \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_partial_bold_strategy
+ \else
+ \letvalue{\??fontmathstoredstrategy\fontclass}\font_helpers_set_math_full_bold_strategy
+ \fi
+ \to \t_font_math_strategies
+\fi
+
+\def\font_helpers_synchronize_math_bold_strategy{\csname\??fontmathstoredstrategy\fontclass\endcsname}
+
+\newconditional\c_font_pseudo_bold_math_state
+
+\def\font_helpers_set_math_partial_bold_strategy{\settrue \c_font_pseudo_bold_math_state}
+\def\font_helpers_set_math_full_bold_strategy {\setfalse\c_font_pseudo_bold_math_state}
+
+\appendtoks
+ \font_helpers_synchronize_math_bold_strategy
+\to \everymathematics
+
+% Bold is somewhat special as we might want both full-bold-math mixed
+% regular-math, as well as automatic adaption to outer bold (in titles
+% and inline text bold) so we will need explicit switches as well as
+% an automatic one. (We will use lucida as an example.)
+
+\unexpanded\def\mr
+ {\ifmmode
+ \font_helpers_synchronize_math_family_mr
+ \else
+ \font_helpers_set_current_font_alternative\s!mr
+ \fi}
+
+\unexpanded\def\mb
+ {\ifmmode
+ \font_helpers_synchronize_math_family_mb
+ \else
+ \font_helpers_set_current_font_alternative\s!mb
+ \fi}
+
+\appendtoks
+ \font_helpers_synchronize_math_family % auto bold
+\to \everymathematics
+
+%D \macros
+%D {bigmath,nobigmath}
+%D
+%D We can inhibit this slow||downer with:
+
+% these can best be combined
+
+% 0=never 1=everymath 2=always
+
+\setnewconstant\synchronizebigmathflag\plusone
+
+\appendtoks
+ \ifcase\synchronizebigmathflag
+ % never
+ \or
+ \synchronizebigmath
+ \or
+ % always
+ \fi
+\to \everymathematics
+
+\unexpanded\def\nobigmath {\synchronizebigmathflag\zerocount}
+\unexpanded\def\autobigmath{\synchronizebigmathflag\plusone\synchronizebigmath}
+\unexpanded\def\bigmath {\synchronizebigmathflag\plustwo\synchronizebigmath}
+
+\let\bigmathfontsize\empty
+
+\unexpanded\def\synchronizebigmath
+ {\ifx\bigmathfontsize\fontsize
+ % already in sync
+ \else
+ \let\bigmathfontsize\fontsize
+ \font_helpers_synchronize_math
+ \fi}
+
+\unexpanded\def\font_helpers_check_big_math_synchronization
+ {\ifcase\synchronizebigmathflag
+ % never
+ \or
+ \ifmmode \synchronizebigmath \fi
+ \or
+ \synchronizebigmath
+ \fi}
+
+\protect \endinput
diff --git a/tex/context/base/font-mis.lua b/tex/context/base/font-mis.lua
index fdb44bb12..e5971e524 100644
--- a/tex/context/base/font-mis.lua
+++ b/tex/context/base/font-mis.lua
@@ -22,7 +22,7 @@ local handlers = fonts.handlers
handlers.otf = handlers.otf or { }
local otf = handlers.otf
-otf.version = otf.version or 2.735
+otf.version = otf.version or 2.736
otf.cache = otf.cache or containers.define("fonts", "otf", otf.version, true)
function otf.loadcached(filename,format,sub)
diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua
index 03376f94b..7b2936dbf 100644
--- a/tex/context/base/font-otf.lua
+++ b/tex/context/base/font-otf.lua
@@ -49,7 +49,7 @@ local otf = fonts.handlers.otf
otf.glists = { "gsub", "gpos" }
-otf.version = 2.735 -- beware: also sync font-mis.lua
+otf.version = 2.736 -- beware: also sync font-mis.lua
otf.cache = containers.define("fonts", "otf", otf.version, true)
local fontdata = fonts.hashes.identifiers
@@ -1029,7 +1029,8 @@ actions["reorganize subtables"] = function(data,filename,raw)
for k=1,#dw do
local gk = dw[k]
local features = gk.features
- if features and supported(features) then
+-- if features and supported(features) then
+ if not features or supported(features) then -- not always features !
local typ = gk.type
local chain = g_directions[typ] or 0
local subtables = gk.subtables
@@ -1057,7 +1058,6 @@ actions["reorganize subtables"] = function(data,filename,raw)
--
local name = gk.name
--
- local features = gk.features
if features then
-- scripts, tag, ismac
local f = { }
diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua
index 12ea97561..7512abfb6 100644
--- a/tex/context/base/font-otn.lua
+++ b/tex/context/base/font-otn.lua
@@ -1806,11 +1806,15 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence
if nofchainlookups == 1 then
local chainlookupname = chainlookups[1]
local chainlookup = lookuptable[chainlookupname]
- local cp = chainprocs[chainlookup.type]
- if cp then
- start, done = cp(start,last,kind,chainname,ck,lookuphash,chainlookup,chainlookupname,nil,sequence)
- else
- logprocess("%s: %s is not yet supported",cref(kind,chainname,chainlookupname),chainlookup.type)
+ if chainlookup then
+ local cp = chainprocs[chainlookup.type]
+ if cp then
+ start, done = cp(start,last,kind,chainname,ck,lookuphash,chainlookup,chainlookupname,nil,sequence)
+ else
+ logprocess("%s: %s is not yet supported",cref(kind,chainname,chainlookupname),chainlookup.type)
+ end
+ else -- shouldn't happen
+ logprocess("%s is not yet supported",cref(kind,chainname,chainlookupname))
end
else
local i = 1
diff --git a/tex/context/base/font-pre.mkiv b/tex/context/base/font-pre.mkiv
index a7769dffb..cc3e95a8c 100644
--- a/tex/context/base/font-pre.mkiv
+++ b/tex/context/base/font-pre.mkiv
@@ -75,12 +75,22 @@
liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes,
mark=yes,mkmk=yes,kern=yes,curs=yes]
+\definefontfeature
+ [hebrew]
+ [arabic]
+ [script=hebr]
+
\definefontfeature % might move
[simplearabic]
[mode=node,language=dflt,script=arab,
init=yes,medi=yes,fina=yes,calt=yes,
rlig=yes,curs=yes,mark=yes,mkmk=yes]
+\definefontfeature
+ [simplehebrew]
+ [simplearabic]
+ [script=hebr]
+
% symbols:
\definefontfeature
@@ -313,7 +323,7 @@
%D So far.
-\definefontstyle [\s!mm] [\s!mm]
+% \definefontstyle [\s!mm] [\s!mm]
\definefontstyle [\s!rm,\v!roman,\v!serif,\v!regular] [\s!rm]
\definefontstyle [\s!ss,\v!sansserif,\v!sans,\v!support] [\s!ss]
\definefontstyle [\s!tt,\v!teletype,\v!type,\v!mono] [\s!tt]
diff --git a/tex/context/base/font-run.mkiv b/tex/context/base/font-run.mkiv
index cc72b1b31..b346de5e1 100644
--- a/tex/context/base/font-run.mkiv
+++ b/tex/context/base/font-run.mkiv
@@ -210,24 +210,22 @@
\gdef\redoshowfontstyle {\dotripleempty \dododoshowfontstyle}
\gdef\redodoshowfontstyle{\doquadrupleempty\dodododoshowfontstyle}
+% no lists any more, so no 'all' any longer
+
\gdef\dodoshowfontstyle[#1][#2]%
- {\doifelse{#2}\v!all
- {\dodoshowfontstyle[#1][\s!rm,\s!ss,\s!tt,\s!mm]}
- {\doifelsenothing{#2}
- {\redoshowfontstyle[#1][\s!rm,\s!ss,\s!tt,\s!mm]}
- {\redoshowfontstyle[#1][#2]}}}
+ {\doifelsenothing{#2}
+ {\redoshowfontstyle[#1][\s!rm,\s!ss,\s!tt,\s!mm]}
+ {\redoshowfontstyle[#1][#2]}}
\gdef\dododoshowfontstyle[#1][#2][#3]%
- {\doifelse{#3}\v!all
- {\redodoshowfontstyle[#1][#2][\fontalternativelist]}
- {\doifelsenothing{#3}
- {\redodoshowfontstyle[#1][#2][\fontalternativelist]}
- {\redodoshowfontstyle[#1][#2][#3]}}}
+ {\doifelsenothing{#3}
+ {\redodoshowfontstyle[#1][#2][\s!tf,\s!bf,\s!it,\s!sl,\s!bs,\s!bi]}
+ {\redodoshowfontstyle[#1][#2][#3]}}
\gdef\dodododoshowfontstyle[#1][#2][#3][#4]%
- {\doifelsenothing{#4}
- {\doshowfontstyleindeed[#1][#2][#3][\v!all]}
- {\doshowfontstyleindeed[#1][#2][#3][#4]}}
+ {\doshowfontstyleindeed[#1][#2][#3][#4]}
+
+% so far
\gdef\doshowfontstyleindeed[#1][#2][#3][#4]%
{\bgroup
diff --git a/tex/context/base/font-set.mkvi b/tex/context/base/font-set.mkvi
new file mode 100644
index 000000000..2d7a5888e
--- /dev/null
+++ b/tex/context/base/font-set.mkvi
@@ -0,0 +1,142 @@
+%D \module
+%D [ file=font-set,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Initial Loading,
+%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 Macros / Initial Loading}
+
+\unprotect
+
+%D Defining fonts using \type{\definebodyfont} takes time, so we
+%D prefer to predefine at least the Computer Modern Roman
+%D fonts. However, loading all those fonts at definition time
+%D would take both time and space. But even worse, once fonts
+%D are loaded into memory, their encoding vector is fixed,
+%D which is a handicap when we want to distribute the compact
+%D \type{fmt} files. So what we want to do is defining fonts in
+%D a way that postpones the loading. We accomplish this by only
+%D loading the fonts when we switch to another bodyfont size.
+%D Among the other alternatives, such as loading the font at
+%D the moment of activation and redefining the activation
+%D macro afterwards, this proved to be the most efficient
+%D alternative.
+%D
+%D The next few macros take care of the one exeption on this
+%D scheme. When at format generation time we load the default
+%D font file, the one that defines the Computer Modern Fonts,
+%D we don't want the fonts metrics to end up in the format
+%D file, so we temporary prohibit loading. This means that at
+%D runtime we have to load the default bodyfont size just before
+%D we start typesetting.
+
+\def\font_preloads_reset_nullfont % this is needed because some macro packages (tikz) misuse \nullfont
+ {%\dorecurse7{\fontdimen\recurselevel\nullfont\zeropoint}% keep en eye on this as:
+ \ctxcommand{resetnullfont()}% in luatex 0.70 this will also do the previous
+ \globallet\font_preloads_reset_nullfont\relax}
+
+\def\font_preload_default_fonts
+ {\font_preloads_reset
+ \setupbodyfont[modern,\fontstyle,\fontbody]%
+ \showmessage\m!fonts6{fallback modern \fontstyle\normalspace\normalizedbodyfontsize}}
+
+\def\font_preload_default_fonts_mm
+ {\writestatus\m!fonts{preloading latin modern fonts (math)}%
+ \definetypeface[\fontclass][\s!mm][\s!math][modern][\s!default]%
+ \showmessage\m!fonts6{fallback modern mm \normalizedbodyfontsize}}
+
+\def\font_preload_default_fonts_tt
+ {\writestatus\m!fonts{preloading latin modern fonts (mono)}%
+ \definetypeface[\fontclass][\s!tt][\s!mono][modern][\s!default]%
+ \showmessage\m!fonts6{fallback modern tt \normalizedbodyfontsize}}
+
+\def\font_preloads_reset
+ {\glet\font_preload_default_fonts \relax
+ %\glet\font_preload_default_fonts_tt\relax
+ %\glet\font_preload_default_fonts_mm\relax
+ \glet\font_preloads_zero_stage \relax
+ \glet\font_preloads_first_stage \relax
+ \glet\font_preloads_second_stage \relax
+ %\glet\font_preloads_third_stage \relax
+ \glet\fourthstagepreloadfonts \relax
+ \global\everyhbox\emptytoks
+ \global\everyvbox\emptytoks
+ \font_preloads_reset_nullfont}
+
+\def\font_preloads_reset_checked
+ {\glet\font_preload_default_fonts_tt\relax
+ \glet\font_preload_default_fonts_mm\relax
+ \glet\font_preloads_third_stage \relax}
+
+\def\font_preloads_zero_stage_indeed
+ {\definedfont[\s!file:lmmono10-regular sa 1]}
+
+\unexpanded\def\font_preloads_zero_stage
+ {\writestatus\m!fonts{beware: no fonts are loaded yet, using 'lm mono' in box}%
+ \glet\font_preloads_zero_stage\font_preloads_zero_stage_indeed
+ \font_preloads_zero_stage}
+
+\unexpanded\def\font_preloads_first_stage % % *nofonts -> *preloadfonts
+ {\doifmodeelse{*preloadfonts}
+ {\font_preload_default_fonts
+ \writestatus\m!fonts{preloading latin modern fonts (first stage)}}
+ {\writestatus\m!fonts{latin modern fonts are not preloaded}}}
+
+\unexpanded\def\font_preloads_second_stage
+ {\writestatus\m!fonts{preloading latin modern fonts (second stage)}%
+ \font_preload_default_fonts}
+
+\unexpanded\def\font_preloads_third_stage % always
+ {\ifx\fontclass\empty
+ \writestatus\m!fonts{preloading latin modern fonts (third stage)}%
+ \font_preload_default_fonts
+ \else
+ \font_preloads_reset
+ \pushmacro\fontstyle
+ \ifcsname\??fontclass\fontclass\s!mm\s!features\endcsname \else
+ \font_preload_default_fonts_mm
+ \fi
+ \ifcsname\??fontclass\fontclass\s!tt\s!features\endcsname \else
+ \font_preload_default_fonts_tt
+ \fi
+ \popmacro\fontstyle
+ \font_preloads_reset_checked % reset third, mm and tt
+ \setupbodyfont[\fontstyle]%
+ \fi}
+
+\unexpanded\def\font_preloads_fourth_stage
+ {\begingroup
+ %ifzeropt\fontcharwd\font\number`!\relax
+ \setbox\scratchbox\hbox{context}%
+ \ifzeropt\wd\scratchbox
+ \writeline
+ \writestatus\m!fonts{!! No bodyfont has been defined and no defaults have been}%
+ \writestatus\m!fonts{!! loaded (maybe due to a missing \string\starttext).}%
+ \writeline
+ \fi
+ \font_preloads_reset
+ \endgroup}
+
+\appendtoks
+ \everyhbox{\font_preloads_zero_stage}%
+ \everyvbox{\font_preloads_zero_stage}%
+\to \everydump
+
+\unexpanded\def\font_preloads_at_every_job {\font_preloads_first_stage }
+\unexpanded\def\font_preloads_at_start_text{\font_preloads_second_stage}
+\unexpanded\def\font_preloads_at_stop_text {\font_preloads_fourth_stage}
+\unexpanded\def\font_preloads_at_definition{\font_preloads_third_stage
+ \glet\font_preloads_at_definition\relax}
+
+% \unexpanded\def\checkpreloadedbodyfont % no \let here
+% {\font_preloads_at_start_text}
+
+
+\protect \endinput
diff --git a/tex/context/base/font-sty.mkvi b/tex/context/base/font-sty.mkvi
new file mode 100644
index 000000000..b8355bee2
--- /dev/null
+++ b/tex/context/base/font-sty.mkvi
@@ -0,0 +1,360 @@
+%D \module
+%D [ file=font-sty,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Styles,
+%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 Macros / Styles}
+
+\unprotect
+
+%D \macros
+%D {definealternativestyle}
+%D
+%D In the main modules we are going to implement lots of
+%D parameterized commands and one of these parameters will
+%D concern the font to use. To suit consistent use of fonts we
+%D here implement a mechanism for defining the keywords that
+%D present a particular style or alternative.
+%D
+%D \starttyping
+%D \definealternativestyle [keywords] [\style] [\nostyle]
+%D \stoptyping
+%D
+%D The first command is used in the normal textflow, while the
+%D second command takes care of headings and alike. Consider
+%D the next two definitions:
+%D
+%D \starttyping
+%D \definealternativestyle [bold] [\bf] []
+%D \definealternativestyle [cap] [\cap] [\cap]
+%D \stoptyping
+%D
+%D A change \type{\bf} in a heading which is to be set in
+%D \type{\tfd} does not look that well, so therefore we leave
+%D the second argument of \type{\definealternativestyle} empty.
+%D When we capatalize characters using the pseudo small cap
+%D command \type{\cap}, we want this to take effect in both
+%D text and headings, which is accomplished by assigning both
+%D arguments.
+
+\installcorenamespace{alternativestyles}
+
+\setnewconstant \c_font_current_alternative_style_index \plusone
+
+\unexpanded\def\definealternativestyle
+ {\dotripleempty\font_basics_define_alternative_style}
+
+\def\font_basics_define_alternative_style[#commands][#variantone][#varianttwo]%
+ {\processcommalist[#commands]{\font_basics_define_alternative_style_indeed{#variantone}{#varianttwo}}}
+
+\let\definestyle\definealternativestyle % later redefined
+
+\def\font_basics_define_alternative_style_indeed#variantone#varianttwo#command%
+ {\ifcsname#command\endcsname
+ % no redefinition
+ \else
+ \setuvalue{#command}{\groupedcommand{#variantone}{}}%
+ \fi
+ \setvalue{\??alternativestyles#command}{\font_helpers_apply_alternative_style{#variantone}{#varianttwo}}}%
+
+\def\font_helpers_apply_alternative_style
+ {\ifcase\c_font_current_alternative_style_index
+ \expandafter\gobbletwoarguments
+ \or
+ \expandafter\firstoftwoarguments
+ \or
+ \expandafter\secondoftwoarguments
+ \else
+ \expandafter\firstoftwoarguments
+ \fi}
+
+\def\applyalternativestyle#name% public
+ {\ifcsname\??alternativestyles#name\endcsname\csname\??alternativestyles#name\expandafter\endcsname\fi}
+
+%D Maybe too geneneric, but probably ok is the following. (Maybe one
+%D day we will use a dedicated grouped command for styles.)
+
+% \appendtoks
+% \let\groupedcommand\thirdofthreearguments
+% \to \simplifiedcommands
+
+%D This command also defines the keyword as command. This means
+%D that the example definition of \type{bold} we gave before,
+%D results in a command \type{\bold} which can be used as:
+%D
+%D \startbuffer
+%D He's a \bold{bold} man with a {\bold head}.
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D or
+%D
+%D \startexample
+%D \definealternativestyle[bold][\bf][]\getbuffer
+%D \stopexample
+%D
+%D Such definitions are of course unwanted for \type{\cap}
+%D because this would result in an endless recursive call.
+%D Therefore we check on the existance of both the command and
+%D the substitution. The latter is needed because for instance
+%D \type{\type} is an entirely diferent command. That command
+%D handles verbatim, while the style command would just switch
+%D to teletype font. This is just an example of a tricky
+%D naming coincidence.
+
+%D \macros
+%D {doconvertfont,noconvertfont,
+%D dontconvertfont,redoconvertfont}
+%D
+%D After having defined such keywords, we can call for them by
+%D using
+%D
+%D \starttyping
+%D \doconvertfont{keyword}{text}
+%D \stoptyping
+%D
+%D We deliberately pass an argument. This enables us to
+%D assign converters that handle one argument, like
+%D \type{\cap}.
+%D
+%D By default the first specification is used to set the style,
+%D exept when we say \type{\dontconvertfont}, after which the
+%D second specification is used. We can also directly call for
+%D \type{\noconvertfont}. In nested calls, we can restore the
+%D conversion by saying \type{\redoconvertfont}.
+
+%D These commands are not grouped! Grouping is most probably
+%D done by the calling macro's and would lead to unnecessary
+%D overhead.
+
+\let\m_current_convert_font \empty
+\let\m_current_convert_font_dt\empty
+
+\unexpanded\def\doconvertfont#specification% takes second argument / this command is obsolete
+ {\edef\m_current_convert_font{#specification}%
+ \ifx\m_current_convert_font\empty
+ %\expandafter\firstofoneargument
+ \else
+ \expandafter\font_helpers_do_convert_font
+ \fi}
+
+\def\font_helpers_do_convert_font
+ {\edef\m_current_convert_font_dt{\detokenize\expandafter{\m_current_convert_font}}%
+ \ifcsname\??alternativestyles\m_current_convert_font_dt\endcsname
+ \csname\??alternativestyles\m_current_convert_font_dt\expandafter\endcsname
+ \else\ifcsname\m_current_convert_font_dt\endcsname
+ \csname\m_current_convert_font_dt\expandafter\endcsname
+ \else
+ \doubleexpandafter\m_current_convert_font
+ \fi\fi}
+
+%D Low level switches (downward compatible):
+
+\unexpanded\def\dontconvertfont{\c_font_current_alternative_style_index\plustwo} % needs checking in usage
+\unexpanded\def\redoconvertfont{\c_font_current_alternative_style_index\plusone} % needs checking in usage
+
+%D The new one:
+
+\unexpanded\def\dousestyleparameter#value%
+ {\edef\currentstyleparameter{#value}%
+ \ifx\currentstyleparameter\empty\else
+ \expandafter\dousecurrentstyleparameter
+ \fi}
+
+\unexpanded\def\dousestylehashparameter#hash#parameter%
+ {\ifcsname#hash#parameter\endcsname
+ \expandafter\dousestyleparameter\csname#hash#parameter\endcsname
+ \fi}
+
+\unexpanded\def\dousecurrentstyleparameter % empty check outside here
+ {\edef\detokenizedstyleparameter{\detokenize\expandafter{\currentstyleparameter}}%
+ \settrue\fontattributeisset % reset is done elsewhere
+ \ifcsname\??alternativestyles\detokenizedstyleparameter\endcsname
+ \csname\??alternativestyles\detokenizedstyleparameter\endcsname
+ \else\ifcsname\detokenizedstyleparameter\endcsname
+ \csname\detokenizedstyleparameter\endcsname
+ \else
+ \currentstyleparameter
+ \fi\fi}
+
+\let\dosetfontattribute\dousestylehashparameter % for a while
+
+%D New commands (not yet interfaced):
+%D
+%D \startbuffer
+%D \definestyle[one][style=bold,color=darkblue]
+%D
+%D test \one{test} test
+%D test \style[one]{test} test
+%D test \style[color=red]{test} test
+%D test \style[Serif at 20pt]{test} test
+%D \stopbuffer
+%D
+%D \typebuffer \startlines \getbuffer \stoplines
+
+% definitions .. no tagging here
+
+\installcorenamespace{style}
+\installcorenamespace{stylecheck}
+
+\installcommandhandler \??style {style} \??style
+
+\appendtoks
+ \letvalue{\??stylecheck\currentstyle}\relax
+ \setuevalue{\e!start\currentstyle}{\font_styles_apply_start{\currentstyle}}%
+ \setuevalue{\e!stop \currentstyle}{\font_styles_apply_stop}%
+ \setuevalue {\currentstyle}{\font_styles_apply_grouped{\currentstyle}}% no longer groupedcommand here
+\to \everydefinestyle
+
+\unexpanded\def\font_styles_apply_start#name%
+ {\begingroup
+ \font_styles_use_defined{#name}}
+
+\unexpanded\def\font_styles_apply_stop
+ {\endgroup}
+
+\unexpanded\def\font_styles_apply_grouped#name% assumes that the next is { or \bgroup
+ {\bgroup
+ \def\g_style{\font_styles_use_defined{#name}}%
+ \afterassignment\g_style
+ \let\nexttoken}
+
+\unexpanded\def\font_styles_use_defined#name%
+ {\edef\currentstyle{#name}%
+ \usestylestyleandcolor\c!style\c!color}
+
+\unexpanded\def\font_styles_use_generic#specification%
+ {\let\currentstyle\s!unknown % reasonable generic tag
+ \setupcurrentstyle[\c!style=,\c!color=,#specification]%
+ \usestylestyleandcolor\c!style\c!color}
+
+% commands
+
+\installcorenamespace{styleargument}
+
+\unexpanded\def\style[#name]% as this is can be a switch we use groupedcommand
+ {\csname\??styleargument
+ \ifcsname#name\endcsname1\else\ifcsname\??stylecheck#name\endcsname2\else3\fi\fi
+ \endcsname{#name}}
+
+\setvalue{\??styleargument1}#name%
+ {\csname#name\endcsname}
+
+\setvalue{\??styleargument2}#name%
+ {\groupedcommand{\font_styles_use_defined{#name}}{}}
+
+\setvalue{\??styleargument3}#specification%
+ {\doifassignmentelse{#specification}\font_styles_assignment\font_styles_direct{#specification}}
+
+\def\font_styles_assignment#specification{\groupedcommand{\font_styles_use_generic{#specification}}{}}
+\def\font_styles_direct #specification{\groupedcommand{\definedfont[#specification]}{}}
+
+% environments
+
+\installcorenamespace{styleenvironment}
+
+\unexpanded\def\startstyle[#name]%
+ {\begingroup
+ \csname\??styleenvironment
+ \ifcsname#name\endcsname1\else\ifcsname\??stylecheck#name\endcsname2\else3\fi\fi
+ \endcsname{#name}}
+
+\unexpanded\def\stopstyle
+ {\endgroup
+ \autoinsertnextspace} % will be configurable, maybe also in \definestartstop
+
+\setvalue{\??styleenvironment1}#name%
+ {\csname#name\endcsname}
+
+\setvalue{\??styleenvironment2}#name%
+ {\font_styles_use_defined{#name}}
+
+\setvalue{\??styleenvironment3}#specification%
+ {\doifassignmentelse{#specification}\font_styles_start_assignment\font_styles_start_direct{#specification}}
+
+\def\font_styles_start_assignment#specification{\usegenericstyle{#specification}}
+\def\font_styles_start_direct #specification{\definedfont[#specification]\relax}
+
+%D Still experimental (might even go away).
+
+% \definestylecollection[mine]
+
+% \definestyleinstance[mine][default][sorry]
+% \definestyleinstance[mine][tt][bs][ttbs:\rm\sl]
+% \definestyleinstance[mine][tt][bf][ttbf:\rm\sl]
+% \definestyleinstance[mine][bf][\sl]
+% \definestyleinstance[mine][sl][\tt]
+
+% {\bf test \mine test \sl test \mine test \bs oeps \mine oeps {\tt test \mine \bf test}}
+
+\installcorenamespace{stylecollection}
+
+\unexpanded\def\definestylecollection
+ {\dosingleargument\font_styles_define_style_collection}
+
+\def\font_styles_define_style_collection[#name]%
+ {\iffirstargument
+ \setuvalue{#name}{\styleinstance[#name]}%
+ \def\font_styles_define_style_collection_a#style%
+ {\def\font_styles_define_style_collection_b#alternative{\letbeundefined{\??stylecollection#name:#style:#alternative}}%
+ \font_helpers_process_alternative_list\font_styles_define_style_collection_b
+ \font_styles_define_style_collection_b\s!default}%
+ \font_helpers_process_style_list\font_styles_define_style_collection_a
+ \font_styles_define_style_collection_a\s!default
+ \fi}
+
+\unexpanded\def\definestyleinstance
+ {\doquadrupleargument\font_styles_define_style_instance}
+
+\def\font_styles_define_style_instance[#instance][#2][#3][#4]% [name] [rm|ss|tt|..] [sl|bf|...] [whatever]
+ {\iffirstargument
+ \ifcsname#1\endcsname\else\font_styles_define_style_collection[#instance]\fi
+ \fi
+ \iffourthargument
+ \setvalue{\??stylecollection#instance:#2:#3}{#4}%
+ \else\ifthirdargument
+ \setvalue{\??stylecollection#instance::#2}{#3}%
+ \else\ifsecondargument
+ \letvalueempty{\??stylecollection#instance::#2}%
+ \fi\fi\fi}
+
+% \unexpanded\def\styleinstance[#instance]% will be made faster
+% {%\begingroup\normalexpanded{\noexpand\infofont[#1:\fontstyle:\fontalternative]}\endgroup
+% \executeifdefined{\??stylecollection#instance:\fontstyle:\fontalternative}%
+% {\executeifdefined{\??stylecollection#instance:\fontstyle:\s!default}%
+% {\executeifdefined{\??stylecollection#instance::\fontalternative}
+% {\getvalue {\??stylecollection#instance::\s!default}}}}}
+
+\unexpanded\def\styleinstance[#instance]%
+ {\csname\??stylecollection#instance:%
+ \ifcsname\??stylecollection#instance:\fontstyle:\fontalternative\endcsname
+ \fontstyle:\fontalternative
+ \else\ifcsname\??stylecollection#instance:\fontstyle:\s!default\endcsname
+ \fontstyle:\s!default
+ \else\ifcsname\??stylecollection#instance::\fontalternative\endcsname
+ :\fontalternative
+ \else
+ :\s!default
+ \fi\fi\fi
+ \endcsname}
+
+%D Variant selectors
+%D
+%D \starttyping
+%D \mathematics {\vsone{\utfchar{"2229}}}
+%D \mathematics {\utfchar{"2229}\vsone{}}
+%D \stoptyping
+
+\unexpanded\edef\vsone#character{#character\utfchar{"FE00}} % used
+\unexpanded\edef\vstwo#character{#character\utfchar{"FE01}} % not used but handy for testing
+
+\protect \endinput
diff --git a/tex/context/base/font-sym.mkvi b/tex/context/base/font-sym.mkvi
new file mode 100644
index 000000000..1ce76fc0b
--- /dev/null
+++ b/tex/context/base/font-sym.mkvi
@@ -0,0 +1,231 @@
+%D \module
+%D [ file=font-mat,
+%D version=2011.01.13, % (copied fron font-ini)
+%D title=\CONTEXT\ Font Macros,
+%D subtitle=Symbolic Access,
+%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 Macros / Symbolic Access}
+
+\unprotect
+
+%D \macros
+%D {getglyph, symbolicfont}
+%D
+%D Individual glyphs can be accessed by using
+%D
+%D \starttyping
+%D \getglyph{fontname}{character}
+%D \stoptyping
+%D
+%D This macro is used in for instance the symbol modules and
+%D as one can see, it does obey the small and even smaller
+%D sizes. The \type {\symbolicfont} macro can be used to
+%D switch to a font named \type {fontname} (see \type
+%D {cont-log} and \type {symb-eur} for examples of symbolic
+%D definitions.
+
+\def\v_font_string_a
+ {\ifx\fontstyle\s!rm \s!Serif \else
+ \ifx\fontstyle\s!ss \s!Sans \else
+ \ifx\fontstyle\s!tt \s!Mono \else
+ \s!Serif \fi\fi\fi}
+
+\def\v_font_string_b
+ {\ifx\fontstyle\s!rm \s!Regular \else
+ \ifx\fontstyle\s!ss \s!Support \else
+ \ifx\fontstyle\s!tt \s!Type \else
+ \s!Serif \fi\fi\fi}
+
+\def\v_font_string_c
+ {\ifx\fontalternative\s!bf \s!Bold \else
+ \ifx\fontalternative\s!sl \s!Slanted \else
+ \ifx\fontalternative\s!it \s!Italic \else
+ \ifx\fontalternative\s!bs \s!BoldSlanted \else
+ \ifx\fontalternative\s!bi \s!BoldItalic \fi\fi\fi\fi\fi}
+
+\let\v_font_string_d\s!Serif % default fontstyle (will be redefined in type-ini)
+
+% potential generalization:
+%
+% \letvalue{\??fontfile:t:\s!rm}\s!Serif
+% \letvalue{\??fontfile:t:\s!ss}\s!Sans
+% \letvalue{\??fontfile:t:\s!tt}\s!Mono
+%
+% \letvalue{\??fontfile:a:\s!rm}\s!Regular
+% \letvalue{\??fontfile:a:\s!ss}\s!Support
+% \letvalue{\??fontfile:a:\s!tt}\s!Type
+%
+% \letvalue{\??fontfile:s:\s!bf}\s!Bold
+% \letvalue{\??fontfile:s:\s!sl}\s!Slanted
+% \letvalue{\??fontfile:s:\s!it}\s!Italic
+% \letvalue{\??fontfile:s:\s!bs}\s!BoldSlanted
+% \letvalue{\??fontfile:s:\s!bi}\s!BoldItalic
+%
+% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif}
+% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif}
+% \def\v_font_string_b{\executeifdefined{\??fontfile:a:\fontstyle}\s!Serif}
+% \def\v_font_string_c{\executeifdefined{\??fontfile:s:\fontstyle}\empty}
+% \def\v_font_string_d{\executeifdefined{\??fontfile:t:\csname\??typescriptdefaultstyles\fontclass\endcsname}\s!Serif}
+
+%D \macros
+%D {fontstylesuffix}
+%D
+%D The next macro is used to map non latin fontnames on fonts. See \type
+%D {font-uni} for an example of its use.
+
+\def\fontstylesuffix% why the \s!Regular ? see \getglyph
+ {\ifx\fontalternative\s!tf \s!Regular \else
+ \ifx\fontalternative\s!bf \s!Bold \else
+ \ifx\fontalternative\s!sl \s!Slanted \else
+ \ifx\fontalternative\s!it \s!Italic \else
+ \ifx\fontalternative\s!bs \s!BoldSlanted \else
+ \ifx\fontalternative\s!bi \s!BoldItalic \else
+ \ifx\fontalternative\s!sc \s!Caps \else
+ \s!Regular \fi\fi\fi\fi\fi\fi\fi}%
+
+\def\glyphfontfile#base% appends
+ {#base%
+ \ifcsname\??fontfile#base\v_font_string_a\v_font_string_c\endcsname
+ \v_font_string_a\v_font_string_c
+ \else\ifcsname\??fontfile#base\v_font_string_b\v_font_string_c\endcsname
+ \v_font_string_b\v_font_string_c
+ \else\ifcsname\??fontfile#base\v_font_string_a\endcsname
+ \v_font_string_a
+ \else\ifcsname\??fontfile#base\v_font_string_b\endcsname
+ \v_font_string_b
+ \else\ifcsname\??fontfile#base\v_font_string_c\endcsname
+ \v_font_string_c
+ \fi\fi\fi\fi\fi}
+
+%D The next macro can be used to make decisions based on the shape:
+
+\def\doifitalicelse#yes#nop%
+ {\ifx\fontalternative\s!sl#yes\else
+ \ifx\fontalternative\s!it#yes\else
+ \ifx\fontalternative\s!bs#yes\else
+ \ifx\fontalternative\s!bi#yes\else#nop\fi\fi\fi\fi}
+
+%D For an example of usage of the following command,
+%D see \type {cont-log.tex}.
+%D
+%D \starttyping
+%D \def\symbolicfont#specification{\definedfont[\glyphfontfile{#specification} sa *]}
+%D \stoptyping
+%D
+%D Since we know what scaling it to be applied, we can
+%D implement a much faster alternative:
+
+\installcorenamespace{symbolfont}
+
+\let\thedefinedfont\relax
+
+\def\setscaledstyledsymbolicfont#1#2#3% quite a slowdown, glyphfontfile
+ {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#3}} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}%
+ \ifcsname\??symbolfont\askedsymbolfont\endcsname
+ \csname\??symbolfont\askedsymbolfont\endcsname
+ \else
+ \font_basics_define_symbolic_font
+ \fi}
+
+\def\setscaleddirectsymbolicfont#1#2#3% quite a slowdown, glyphfontfile
+ {\edef\askedsymbolfont{\truefontname{#3} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}%
+ \ifcsname\??symbolfont\askedsymbolfont\endcsname
+ \csname\??symbolfont\askedsymbolfont\endcsname
+ \else
+ \font_basics_define_symbolic_font
+ \fi}
+
+\def\setstyledsymbolicfont#fontname% quite a slowdown, glyphfontfile
+ {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#fontname}} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}%
+ \ifcsname\??symbolfont\askedsymbolfont\endcsname
+ \csname\??symbolfont\askedsymbolfont\endcsname
+ \else
+ \font_basics_define_symbolic_font
+ \fi}
+
+\def\setdirectsymbolicfont#fontname%
+ {\edef\askedsymbolfont{\truefontname{#fontname} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}%
+ \ifcsname\??symbolfont\askedsymbolfont\endcsname
+ \csname\??symbolfont\askedsymbolfont\endcsname
+ \else
+ \font_basics_define_symbolic_font
+ \fi}
+
+\def\font_basics_define_symbolic_font
+ {\definefont[currentsymbolfont][\askedsymbolfont]%
+ \currentsymbolfont
+ \global\expandafter\let\csname\??symbolfont\askedsymbolfont\endcsname\lastrawfontcall}
+
+\unexpanded\def\getnamedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\ctxcommand{fontchar("#character")}}}
+\unexpanded\def\getnamedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\ctxcommand{fontchar("#character")}}}
+\unexpanded\def\getglyphstyled #fontname#character{{\setstyledsymbolicfont{#fontname}\doifnumberelse{#character}\char\donothing#2}}
+\unexpanded\def\getglyphdirect #fontname#character{{\setdirectsymbolicfont{#fontname}\doifnumberelse{#character}\char\donothing#2}}
+
+% this one is wrong:
+
+\unexpanded\def\getscaledglyph#scale#name#content%
+ {{\setscaledstyledsymbolicfont\fontbody{#scale}{#name}\doifnumberelse{#content}\char\donothing#content}}
+
+\let\getglyph \getglyphstyled % old
+\let\getrawglyph \getglyphdirect % old
+\let\symbolicsizedfont\setscaledstyledsymbolicfont % old
+\let\symbolicfont \setstyledsymbolicfont % old
+
+\unexpanded\def\symbolicscaledfont{\setsscaledstyledsymbolicfont\fontbody}
+\unexpanded\def\symbolicscaledfont{\setscaledstyledsymbolicfont\fontbody}
+
+%D The last implementation of \type {\getglyph} permits
+%D definitions like:
+%D
+%D \starttyping
+%D \definefontsynonym [EuroSans] [eurose]
+%D \definefontsynonym [EuroSansBold] [euroseb]
+%D \definefontsynonym [EuroSansItalic] [eurosei]
+%D \definefontsynonym [EuroSansSlanted] [eurosei]
+%D \definefontsynonym [EuroSansBoldItalic] [eurosebi]
+%D \definefontsynonym [EuroSansBoldSlanted] [eurosebi]
+%D
+%D \definesymbol [euro] [\getglyph{Euro}{\char160}]
+%D
+%D \def\euro{\symbol[euro]}
+%D \stoptyping
+%D
+%D These definitions guarantee that the next calls work okay:
+%D
+%D \starttyping
+%D \ss \tf\euro \bf\euro \sla\euro \itd\euro \bs\euro \bic\euro
+%D \stoptyping
+%D
+%D The shape as well as the size is adapted to the current
+%D environment.
+
+%D \macros
+%D {setfont}
+%D
+%D Every now and then we want to define a font directly, for
+%D instance when we typeset title pages. The next macro saves
+%D some typing:
+
+\unexpanded\def\setfont% geen \font_helpers_set_font mogelijk
+ {\afterassignment\font_basics_set_font\font\nextfont=}
+
+\def\font_basics_set_font
+ {\nextfont\setupinterlinespace}% hm, we need to use \setuplocalinterlinespace
+
+%D One can call this macro as:
+%D
+%D \starttyping
+%D \setfont cmr10 at 60pt
+%D \stoptyping
+%D
+%D After which the font is active and the baselines and
+%D struts are set.
+
+\protect \endinput
diff --git a/tex/context/base/font-tra.mkiv b/tex/context/base/font-tra.mkiv
index 41bd3dd80..353d9e7a5 100644
--- a/tex/context/base/font-tra.mkiv
+++ b/tex/context/base/font-tra.mkiv
@@ -14,6 +14,80 @@
\unprotect
%D \macros
+%D {showbodyfont}
+%D
+%D One can call for a rather simple overview of a bodyfont and the
+%D relations between its alternative fonts.
+%D
+%D \showsetup{showbodyfont}
+%D
+%D The current bodyfont (here we omitted the argument) looks like:
+%D
+%D \showbodyfont
+%D
+%D The implementation is rather straightforward in using
+%D \type{\halign}.
+
+\fetchruntimecommand \showbodyfont {\f!fontprefix\s!run}
+
+%D \macros
+%D {showfontstrip, testminimalbaseline, showminimalbaseline}
+%D
+%D The next command can come in handy when combining
+%D different fonts into a collection (typeface) and
+%D determining optimal baseline distances.
+%D
+%D \showfontstrip \blank \showminimalbaseline
+
+\fetchruntimecommand \showfontstrip {\f!fontprefix\s!run}
+\fetchruntimecommand \testminimalbaseline {\f!fontprefix\s!run}
+\fetchruntimecommand \showminimalbaseline {\f!fontprefix\s!run}
+
+%D \macros
+%D {showkerning}
+%D
+%D A goody is:
+%D
+%D \showkerning{Can you guess what kerning is?}
+
+\fetchruntimecommand \showkerning {\f!fontprefix\s!run}
+
+%D \macros
+%D {showbodyfontenvironment,showfont,showfontstyle,showligatures}
+%D
+%D The current bodyfontenvironment is:
+%D
+%D \showbodyfontenvironment
+%D
+%D This overview is generated using:
+%D
+%D \showsetup{showbodyfontenvironment}
+
+\fetchruntimecommand \showbodyfontenvironment {\f!fontprefix\s!run}
+
+%D
+%D The following command generates a fontmap:
+%D
+%D \startbuffer
+%D \showfont[SansBold at 12pt]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D \getbuffer
+
+\fetchruntimecommand \showfont {\f!fontprefix\s!run}
+\fetchruntimecommand \showfontstyle {\f!fontprefix\s!run}
+\fetchruntimecommand \showligature {\f!fontprefix\s!run}
+\fetchruntimecommand \showligatures {\f!fontprefix\s!run}
+\fetchruntimecommand \showcharratio {\f!fontprefix\s!run}
+\fetchruntimecommand \showfontparameters {\f!fontprefix\s!run}
+
+\unexpanded\def\checkcharactersinfont {\ctxcommand{checkcharactersinfont }}
+\unexpanded\def\removemissingcharacters{\ctxcommand{removemissingcharacters}}
+\unexpanded\def\showchardata #1{\ctxcommand{showchardata("#1")}}
+\unexpanded\def\showfontdata {\ctxcommand{showfontparameters()}}
+
+%D \macros
%D {doiffontpresentelse}
%D
%D \starttyping
diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua
index 11922cf18..607101ae9 100644
--- a/tex/context/base/lxml-lpt.lua
+++ b/tex/context/base/lxml-lpt.lua
@@ -1105,9 +1105,9 @@ end
expressions.child = function(e,pattern)
return applylpath(e,pattern) -- todo: cache
end
-expressions.count = function(e,pattern)
+expressions.count = function(e,pattern) -- what if pattern == empty or nil
local collected = applylpath(e,pattern) -- todo: cache
- return (collected and #collected) or 0
+ return pattern and (collected and #collected) or 0
end
-- external
@@ -1116,7 +1116,7 @@ expressions.oneof = function(s,...) -- slow
local t = {...} for i=1,#t do if s == t[i] then return true end end return false
end
expressions.error = function(str)
- xml.errorhandler("unknown function in lpath expression",tostring(str or "?"))
+ xml.errorhandler(format("unknown function in lpath expression: %s",tostring(str or "?")))
return false
end
expressions.undefined = function(s)
diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua
index 2d99577b6..9799d1f2a 100644
--- a/tex/context/base/lxml-tab.lua
+++ b/tex/context/base/lxml-tab.lua
@@ -809,7 +809,7 @@ function xml.is_valid(root)
return root and not root.error
end
-xml.errorhandler = report
+xml.errorhandler = report_xml
--[[ldx--
<p>We cannot load an <l n='lpeg'/> from a filehandle so we need to load
diff --git a/tex/context/base/lxml-xml.lua b/tex/context/base/lxml-xml.lua
index 7ecb69196..7e7922cfb 100644
--- a/tex/context/base/lxml-xml.lua
+++ b/tex/context/base/lxml-xml.lua
@@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['lxml-xml'] = {
}
local concat = table.concat
+local find = string.find
local xml = xml
@@ -256,7 +257,7 @@ local function tags(collected,nonamespace)
return t
end
-local function empty(collected)
+local function empty(collected,spacesonly)
if not collected then
return true
end
@@ -275,7 +276,9 @@ local function empty(collected)
local typ = type(edk)
if typ == "table" then
return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
+ elseif edk ~= "" then
+ return false
+ elseif spacesonly and not find(edk,"%S") then
return false
end
elseif n > 1 then
@@ -359,8 +362,8 @@ function xml.match(id,pattern) -- number
return match(xmlfilter(id,pattern))
end
-function xml.empty(id,pattern)
- return empty(xmlfilter(id,pattern))
+function xml.empty(id,pattern,spacesonly)
+ return empty(xmlfilter(id,pattern),spacesonly)
end
xml.all = xml.filter
diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv
index d9ac110c9..283c63cab 100644
--- a/tex/context/base/mult-aux.mkiv
+++ b/tex/context/base/mult-aux.mkiv
@@ -121,6 +121,13 @@
\fi\fi
\m_mult_interfaces_namespace{#1}{#2}}
+\newif\ifassignment
+
+\def\mult_check_for_assignment#1=#2#3\_end_
+ {\expandafter\if\detokenize{#2}@\assignmentfalse\else\assignmenttrue\fi}
+
+% usage: \mult_check_for_assignment##1=@@_end_
+
% End of experimental code.
\unexpanded\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8#9% inlining \csname*\endcsname is more efficient (#3 and #6 only)
@@ -129,7 +136,6 @@
\def#3##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}%
\def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}%
\def#5##1##2{\ifx##1\relax\s!empty\else#4{##1}{##2}\fi}% is {} needed around ##1 ?
- %\def#6##1##2{\csname#4{#1##1}{##2}\endcsname}%
\def#6##1##2{\csname\ifcsname#1##1:##2\endcsname#1##1:##2\else\expandafter#5\csname#1##1:\s!parent\endcsname{##2}\fi\endcsname}%
\def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2:##1\endcsname}}% always root, no backtrack
\def#8##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\s!empty\fi\endcsname}%
@@ -243,34 +249,38 @@
\let\definehandlerparent\empty
-\unexpanded\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8%
+\unexpanded\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8#9%
{\ifx#4\relax\let#4\empty\fi
\unexpanded\def#2{\dotripleempty#5}%
\newtoks#6%
\newtoks#7%
\def#5[##1][##2][##3]% [child][parent][settings] | [child][settings] | [child][parent] | [child]
- {\let\saveddefinewhatever#4%
+ {\let#9#4%
\edef#4{##1}%
\the#6% predefine
\ifthirdargument
\edef#8{##2}%
- % \getparameters[#1#4:][\s!parent=#1##2,##3]%
\mult_interfaces_get_parameters{#1#4:}[\s!parent=#1##2,##3]%
\else\ifsecondargument
- \doifassignmentelse{##2}
- {\let#8\empty
- % \getparameters[#1#4:][\s!parent=#3,##2]}
- \mult_interfaces_get_parameters{#1#4:}[\s!parent=#3,##2]}
- {\edef#8{##2}%
- % \getparameters[#1#4:][\s!parent=#1##2]}%
- \mult_interfaces_get_parameters{#1#4:}[\s!parent=#1##2]}%
+% \doifassignmentelse{##2}
+% {\let#8\empty
+% \mult_interfaces_get_parameters{#1#4:}[\s!parent=#3,##2]}
+% {\edef#8{##2}%
+% \mult_interfaces_get_parameters{#1#4:}[\s!parent=#1##2]}%
+ \mult_check_for_assignment##2=@@\_end_
+ \ifassignment
+ \let#8\empty
+ \mult_interfaces_get_parameters{#1#4:}[\s!parent=#3,##2]%
+ \else
+ \edef#8{##2}%
+ \mult_interfaces_get_parameters{#1#4:}[\s!parent=#1##2]%
+ \fi
\else
\let#8\empty
- % \getparameters[#1#4:][\s!parent=#3]%
\mult_interfaces_get_parameters{#1#4:}[\s!parent=#3]%
\fi\fi
\the#7%
- \let#4\saveddefinewhatever}}
+ \let#4#9}}
\unexpanded\def\installdefinehandler#1#2#3%
{\normalexpanded
@@ -282,30 +292,28 @@
\expandafter\noexpand\csname define_#2\endcsname % semi-public
\expandafter\noexpand\csname everypreset#2\endcsname
\expandafter\noexpand\csname everydefine#2\endcsname
- \expandafter\noexpand\csname current#2parent\endcsname}}
+ \expandafter\noexpand\csname current#2parent\endcsname
+ \expandafter\noexpand\csname saved_defined_#2\endcsname}}
-\unexpanded\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6%
+\unexpanded\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dodoubleempty#4}%
- % \unexpanded\def#6{\getparameters[#1#3:]}% no every ! don't change it
\unexpanded\def#6{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it
\newtoks#5%
\def#4[##1][##2]% maybe helper
- {\let\savedsetupwhatever#3%
+ {\let#7#3%
\ifsecondargument
\def\mult_interfaces_with_comma_list_element####1% we will have a simple one as well
{\edef#3{####1}%
- % \getparameters[#1#3:][##2]%
\mult_interfaces_get_parameters{#1#3:}[##2]%
\the#5}%
\processcommalist[##1]\mult_interfaces_with_comma_list_element
\else
\let#3\empty
- % \getparameters[#1:][##1]%
\mult_interfaces_get_parameters{#1:}[##1]%
\the#5%
\fi
- \let#3\savedsetupwhatever}}
+ \let#3#7}}
\unexpanded\def\installsetuphandler#1#2%
{\normalexpanded
@@ -315,59 +323,88 @@
\expandafter\noexpand\csname current#2\endcsname
\expandafter\noexpand\csname setup_#2\endcsname % semi-public
\expandafter\noexpand\csname everysetup#2\endcsname
- \expandafter\noexpand\csname setupcurrent#2\endcsname}}
+ \expandafter\noexpand\csname setupcurrent#2\endcsname
+ \expandafter\noexpand\csname saved_setup_current#2\endcsname}}
+
+\let\doingrootsetupnamed\plusone % \setuplayout[name][key=value]
+\let\doingrootsetuproot \plustwo % \setuplayout [key=value]
+\let\doingrootsetnamed \plusthree % \setuplayout[name]
+\let\doingrootsetroot \plusfour % \setuplayout
-\unexpanded\def\mult_interfaces_install_switch_setup_handler#1#2#3#4#5#6%
+\unexpanded\def\mult_interfaces_install_switch_setup_handler_a#1#2#3#4#5%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dodoubleempty#4}%
- % \unexpanded\def#6{\getparameters[#1#3:]}%
- \unexpanded\def#6{\mult_interfaces_get_parameters{#1#3:}}%
- \newtoks#5%
+ \unexpanded\def#5{\mult_interfaces_get_parameters{#1#3:}}}
+
+\unexpanded\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7%
+ {\newtoks#5%
+ \newconstant#2%
+ \ifx#6\relax\let#6\empty\fi
\def#4[##1][##2]% maybe helper
{\ifsecondargument % no commalist here
- \let\savedsetupwhatever#3%
+ % \setuplayout[whatever][key=value]
+ \let#7#3%
+ \let#6#3%
\edef#3{##1}%
- % \getparameters[#1#3:][##2]%
+ #2\doingrootsetupnamed
\mult_interfaces_get_parameters{#1#3:}[##2]%
\the#5%
- \let#3\savedsetupwhatever
+ \let#3#7%
\else\iffirstargument
- \doifassignmentelse{##1}
- {\let\savedsetupwhatever#3%
- \let#3\empty
- % \getparameters[#1:][##1]%
- \mult_interfaces_get_parameters{#1:}[##1]%
- \the#5%
- \let#3\savedsetupwhatever}
- {\edef#3{##1}% this will catch reset
- \the#5}%
+ \mult_check_for_assignment##1=@@\_end_ % \docheckassignment{##1}%
+ \ifassignment
+ % \setuplayout[key=value]
+ \let#7#3%
+ \let#6#3%
+ \let#3\empty
+ #2\doingrootsetuproot
+ \mult_interfaces_get_parameters{#1:}[##1]%
+ \the#5%
+ \let#3#7%
+ \else
+ % \setuplayout[whatever]
+ \let#6#3% % previous becomes current
+ \edef#3{##1}% this will catch reset so one needs to test for it
+ #2\doingrootsetnamed
+ \the#5% % we can check for previous vs current
+ \fi
\else
- \let#3\empty
+ % \setuplayout
+ \let#6#3% % previous becomes current
+ \let#3\empty % current becomes empty
+ #2\doingrootsetroot
\the#5%
- \fi\fi}}
+ \fi\fi
+ #2\zerocount}} % mode is always zero at the end
\unexpanded\def\installswitchsetuphandler#1#2%
{\normalexpanded
- {\mult_interfaces_install_switch_setup_handler
+ {\mult_interfaces_install_switch_setup_handler_a
{\noexpand#1}% \??aa
\expandafter\noexpand\csname setup#2\endcsname
\expandafter\noexpand\csname current#2\endcsname
\expandafter\noexpand\csname setup_#2\endcsname % semi-public
+ \expandafter\noexpand\csname setupcurrent#2\endcsname
+ \mult_interfaces_install_switch_setup_handler_b
+ {\noexpand#1}% \??aa
+ \expandafter\noexpand\csname #2setupmode\endcsname
+ \expandafter\noexpand\csname current#2\endcsname
+ \expandafter\noexpand\csname setup_#2\endcsname % semi-public
\expandafter\noexpand\csname everysetup#2\endcsname
- \expandafter\noexpand\csname setupcurrent#2\endcsname}}
+ \expandafter\noexpand\csname previous#2\endcsname
+ \expandafter\noexpand\csname saved_setup_current#2\endcsname}}
+
-\unexpanded\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7%
+\unexpanded\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dotripleempty#4}%
- % \unexpanded\def#6{\getparameters[#1#3:]}%
\unexpanded\def#6{\mult_interfaces_get_parameters{#1#3:}}%
\newtoks#5%
\def#4[##1][##2][##3]%
- {\let\savedsetupwhatever#3%
+ {\let#8#3%
\ifthirdargument
\def\mult_interfaces_with_comma_list_element####1%
{\edef#3{####1}%
- % \getparameters[#1#3:][\s!parent=#1##2,##3]%
\mult_interfaces_get_parameters{#1#3:}[\s!parent=#1##2,##3]% always sets parent
\the#5}%
\processcommalist[##1]\mult_interfaces_with_comma_list_element
@@ -375,17 +412,15 @@
\def\mult_interfaces_with_comma_list_element####1%
{\edef#3{####1}%
#7% checks parent and sets if needed
- % \getparameters[#1#3:][##2]%
\mult_interfaces_get_parameters{#1#3:}[##2]%
\the#5}%
\processcommalist[##1]\mult_interfaces_with_comma_list_element
\else
\let#3\empty
- % \getparameters[#1:][##1]%
\mult_interfaces_get_parameters{#1:}[##1]%
\the#5%
\fi\fi
- \let#3\savedsetupwhatever}}
+ \let#3#8}}
\unexpanded\def\installautosetuphandler#1#2%
{\normalexpanded
@@ -396,7 +431,8 @@
\expandafter\noexpand\csname setup_#2\endcsname % semi-public
\expandafter\noexpand\csname everysetup#2\endcsname
\expandafter\noexpand\csname setupcurrent#2\endcsname
- \expandafter\noexpand\csname check#2parent\endcsname}}
+ \expandafter\noexpand\csname check#2parent\endcsname
+ \expandafter\noexpand\csname saved_setup_current#2\endcsname}}
\unexpanded\def\installbasicparameterhandler#1#2%
{\installparameterhandler {#1}{#2}%
@@ -566,6 +602,9 @@
{\ifnum\c_mult_interfaces_n_of_namespaces<\plusten00\else\ifnum\c_mult_interfaces_n_of_namespaces<\plushundred0\fi\fi
\number\c_mult_interfaces_n_of_namespaces>}
+\def\v_interfaces_prefix_template % consistently %03i>
+ {\number\c_mult_interfaces_n_of_namespaces>}
+
\unexpanded\def\installnamespace#1% for modules and users
{\ifcsname ????#1\endcsname
\writestatus\m!system{duplicate user namespace '#1'}\wait
@@ -583,6 +622,12 @@
\ctxcommand{registernamespace(\number\c_mult_interfaces_n_of_namespaces,"#1")}%
\fi}
+% We install two core namespaces here, as we want nice error messages. Maybe
+% we will reserve the first 9.
+
+\installcorenamespace{fontinstancebasic}
+\installcorenamespace{fontinstanceclass}
+
% \enabletrackers[interfaces.namespaces,context.flush]
%
% \definenamespace
diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index f059faad0..130f666b6 100644
--- a/tex/context/base/mult-low.lua
+++ b/tex/context/base/mult-low.lua
@@ -194,7 +194,7 @@ return {
"gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments",
"gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals",
--
- "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth",
+ "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs",
--
"newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "setconstant",
--
diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv
index 205e67009..8c12eb857 100644
--- a/tex/context/base/mult-sys.mkiv
+++ b/tex/context/base/mult-sys.mkiv
@@ -439,7 +439,6 @@
\definesystemvariable {br} % sideBaR
\definesystemvariable {bx} % BackendExport
\definesystemvariable {cb} % CollectBox
-% \definesystemvariable {ci} % CItaat
\definesystemvariable {cm} % CheMical
\definesystemvariable {cp} % CliP
\definesystemvariable {da} % DAte
@@ -460,7 +459,6 @@
\definesystemvariable {fc} % FramedContent
\definesystemvariable {fi} % FIle Once
\definesystemvariable {fo} % xml FO (xtag)
-\definesystemvariable {fr} % Division
\definesystemvariable {fu} % FontSolution
\definesystemvariable {fw} % simpleFonts by Wolfgang
\definesystemvariable {fx} % FoXet
@@ -483,7 +481,6 @@
\definesystemvariable {ks} % KolomSpan
\definesystemvariable {kt} % KonTakten
\definesystemvariable {kw} % KontaktWaarde
-\definesystemvariable {ld} % LegenDa
\definesystemvariable {le} % LinetablE
\definesystemvariable {lf} % LocalFigures
\definesystemvariable {lg} % taal (LanGuage)
@@ -555,9 +552,13 @@
% still used but defined locally
-\definesystemvariable{cs} % CharacterSpacing
-\definesystemvariable{ts} % TypeScript
-\definesystemvariable{kk} % Kapitalen
+\definesystemvariable {cs} % CharacterSpacing
+\definesystemvariable {ts} % TypeScript
+\definesystemvariable {kk} % Kapitalen
+
+% obsolete but kept for a while (core-obs)
+
+\definesystemvariable {fr} % Division
%D Next we define some language independant one letter
%D variables and keywords. We can actually make these
diff --git a/tex/context/base/node-bck.mkiv b/tex/context/base/node-bck.mkiv
index f44852a45..858bd40b7 100644
--- a/tex/context/base/node-bck.mkiv
+++ b/tex/context/base/node-bck.mkiv
@@ -22,7 +22,7 @@
\def\node_backgrounds_boxes_initialize % will move to lua
{\ctxlua{nodes.tasks.enableaction("shipouts","nodes.handlers.backgrounds")}%
- \glet\doinitializeboxbackgrounds\donothing}
+ \glet\node_backgrounds_boxes_initialize\donothing}
% \backgroundvbox[green] {\input tufte } \par
% \backgroundvbox[blue] {\input ward } \par
@@ -71,7 +71,8 @@
% more efficient:
\def\node_backgrounds_boxes_add#1[#2]%
- {\node_backgrounds_boxes_initialize#1\backgroundcolorattr{#2}}
+ {\node_backgrounds_boxes_initialize
+ #1\backgroundcolorattr{#2}}
% less argument carry over:
%
diff --git a/tex/context/base/pack-com.mkiv b/tex/context/base/pack-com.mkiv
index be06b2e86..8a319d8e5 100644
--- a/tex/context/base/pack-com.mkiv
+++ b/tex/context/base/pack-com.mkiv
@@ -25,8 +25,37 @@
% \startcombination[2*1] {alpha} {a} {beta} {b} \stopcombination
% \startcombination[1*2] {alpha} {a} {beta} {b} \stopcombination
% \startcombination[2] {alpha} {a} {beta} {b} \stopcombination
+% \startcombination[2] \combination {alpha} {a} \combination{beta} {b} \stopcombination
-% todo: \startcombination \startcomb \stopcomb ...
+%D We do support some structure but the order matters and currently it's
+%D only window dressing:
+%D
+%D \starttyping
+%D \let\startcontent\bgroup
+%D \let\stopcontent \egroup
+%D \let\startcaption\bgroup
+%D \let\stopcaption \egroup
+%D \stoptyping
+%D
+%D Of course we should have started with more structure as it would
+%D simply the code.
+%D
+%D \starttyping
+%D \startcombination
+%D \startcontent
+%D \externalfigure[cow]
+%D \stopcontent
+%D \startcaption
+%D Some cow.
+%D \stopcaption
+%D \startcontent
+%D \externalfigure[cow]
+%D \stopcontent
+%D \startcaption
+%D The same cow.
+%D \stopcaption
+%D \stopcombination
+%D \stoptyping
\ifdefined\dotagcombination \else \let\dotagcombination\relax \fi
@@ -54,10 +83,12 @@
\c!distance=\emwidth,
\c!location=\v!bottom, % can be something {top,left}
\c!before=\blank,
+ \c!after=,
\c!inbetween={\blank[\v!medium]},
%\c!style=,
%\c!color=,
- %\c!after=,
+ \c!nx=2, % new
+ \c!ny=1, % new
\c!align=\v!middle]
\let\setupcombinations\setupcombination % for the moment (we might distinguish)
@@ -116,24 +147,6 @@
\def\pack_combinations_start[#1][#2]% needs a cleanup, also nx ny (pretty old, this one)
{\global\setsystemmode{combination}%
%
-% \doifnothing{#1}\firstargumentfalse % to be sure (when called in macros)
-% \doifnothing{#2}\secondargumentfalse % to be sure (when called in macros)
-% \ifsecondargument % todo: nx ny
-% \edef\currentcombination{#1}%
-% \edef\currentcombinationspec{#2*\plusone*}%
-% \else % better : \doifcombinationelse ... \??co#1\c!location
-% \doifinstringelse{*}{#1}
-% {\let\currentcombination\empty
-% \edef\currentcombinationspec{#1*\plusone*}}
-% {\doifnumberelse{#1}
-% {\let\currentcombination\empty
-% \edef\currentcombinationspec{#1*\plusone*}}
-% {\edef\currentcombination{#1}%
-% \edef\currentcombinationspec{\plustwo*\plusone*}}}%
-% \fi
- %
- % todo : move split to here
- %
\edef\currentcombination{#1}%
\edef\currentcombinationspec{#2}%
\ifx\currentcombinationspec\empty
@@ -143,13 +156,18 @@
{\doifnumberelse\currentcombination
{\edef\currentcombinationspec{\currentcombination*\plusone*}%
\let\currentcombination\empty}
- {\edef\currentcombinationspec{\plustwo*\plusone*}}}%
+ {\edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}}}%
\else
\edef\currentcombinationspec{\currentcombinationspec*\plusone*}%
\fi
%
\forgetall
%
+ \let\startcontent\bgroup
+ \let\stopcontent \egroup
+ \let\startcaption\bgroup
+ \let\stopcaption \egroup
+ %
\edef\p_height {\combinationparameter\c!height}%
\edef\p_width {\combinationparameter\c!width}%
\edef\p_location{\combinationparameter\c!location}%
@@ -164,7 +182,6 @@
\dostarttagged\t!combination\currentcombination
\vbox \ifx\p_height\v!fit\else to \p_height \fi \bgroup
\let\combination\empty % permits \combination{}{} handy for cld
- \setuphorizontaldivision[\c!n=\v!fit,\c!distance=\p_distance]%
\normalexpanded{\pack_combinations_start_indeed[\currentcombinationspec]}}
\unexpanded\def\pack_combinations_start_indeed[#1*#2*#3]%
@@ -346,5 +363,424 @@
\resetlocalfloats
\egroup}
+%D \macros
+%D {definepairedbox, setuppairedbox, placepairedbox}
+%D
+%D Paired boxes, formally called legends, but from now on a
+%D legend is just an instance, are primarily meant for
+%D typesetting some text alongside an illustration. Although
+%D there is quite some variation possible, the functionality is
+%D kept simple, if only because in most cases such pairs are
+%D typeset sober.
+%D
+%D The location specification accepts a pair, where the first
+%D keyword specifies the arrangement, and the second one the
+%D alignment. The first key of the location pair is one of
+%D \type {left}, \type {right}, \type {top} or \type {bottom},
+%D while the second key can also be \type {middle}.
+%D
+%D The first box is just collected in an horizontal box, but
+%D the second one is a vertical box that gets passed the
+%D bodyfont and alignment settings.
+
+%D In many cases the table builders can be used instead, but as
+%D this mechanism is a traditional \CONTEXT\ one we keep it
+%D around.
+
+%D \macros
+%D {setuplegend, placelegend}
+%D
+%D It makes sense to typeset a legend to a figure in \TEX\
+%D and not in a drawing package. The macro \type {\placelegend}
+%D combines a figure (or something else) and its legend. This
+%D command is just a paired box.
+%D
+%D The legend is placed according to \type {location}, being
+%D \type {bottom} or \type {right}. The macro macro is used as
+%D follows.
+%D
+%D \starttyping
+%D \placefigure
+%D {whow}
+%D {\placelegend
+%D {\externalfigure[cow]}
+%D {\starttabulate
+%D \NC 1 \NC head \NC \NR
+%D \NC 2 \NC legs \NC \NR
+%D \NC 3 \NC tail \NC \NR
+%D \stoptabulate}}
+%D
+%D \placefigure
+%D {whow}
+%D {\placelegend
+%D {\externalfigure[cow]}
+%D {\starttabulate[|l|l|l|l|]
+%D \NC 1 \NC head \NC 3 \NC tail \NC \NR
+%D \NC 2 \NC legs \NC \NC \NC \NR
+%D \stoptabulate}}
+%D
+%D \placefigure
+%D {whow}
+%D {\placelegend[n=2]
+%D {\externalfigure[cow]}
+%D {\starttabulate
+%D \NC 1 \NC head \NC \NR
+%D \NC 2 \NC legs \NC \NR
+%D \NC 3 \NC tail \NC \NR
+%D \stoptabulate}}
+%D
+%D \placefigure
+%D {whow}
+%D {\placelegend[n=2]
+%D {\externalfigure[cow]}
+%D {head \par legs \par tail}}
+%D
+%D \placefigure
+%D {whow}
+%D {\placelegend[n=2]
+%D {\externalfigure[cow]}
+%D {\startitemize[packed]
+%D \item head \item legs \item tail \item belly \item horns
+%D \stopitemize}}
+%D
+%D \placefigure
+%D {whow}
+%D {\placelegend[n=2,width=.8\hsize]
+%D {\externalfigure[cow]}
+%D {\startitemize[packed]
+%D \item head \item legs \item tail \item belly \item horns
+%D \stopitemize}}
+%D
+%D \def\MytTestTwo#1#2%
+%D {\placefigure
+%D {whow}
+%D {\placelegend[location={#1,#2}]
+%D {\externalfigure[cow]}
+%D {\starttabulate
+%D \NC 1 \NC head \NC \NR
+%D \NC 2 \NC legs \NC \NR
+%D \NC 3 \NC tail \NC \NR
+%D \stoptabulate}}}
+%D
+%D \def\MytTestOne#1{\processcommalist[left,right,top,bottom]{\MytTestTwo{#1}}}
+%D
+%D \processcommalist[left,right,top,bottom,middle]\MytTestOne
+%D \stoptyping
+%D
+%D More structure is also possible (the order matters!):
+%D
+%D \starttyping
+%D \startplacefigure[title=whow]
+%D \startplacelegend[location={bottom,middle},color=red]
+%D \startcontent
+%D \externalfigure[cow]
+%D \stopcontent
+%D \startcaption
+%D \starttabulate[|l|l|]
+%D \NC 1 \NC head \NC \NR
+%D \NC 2 \NC legs \NC \NR
+%D \NC 3 \NC tail \NC \NR
+%D \stoptabulate
+%D \stopcaption
+%D \stopplacelegend
+%D \stopplacefigure
+%D \stoptyping
+
+% todo: natural size
+
+\newsystemmode{pairedbox}
+
+\appendtoks
+ \global\resetsystemmode{pairedbox}%
+\to \everyinsidefloat
+
+\installcorenamespace {pairedbox}
+
+\installcommandhandler \??pairedbox {pairedbox} \??pairedbox
+
+\setuppairedbox
+ [\c!n=1,
+ \c!distance=\bodyfontsize,
+ %\c!before=,
+ %\c!after=,
+ %\c!color=,
+ %\c!style=,
+ \c!inbetween={\blank[\v!medium]},
+ \c!width=\hsize,
+ \c!height=\vsize,
+ \c!maxwidth=\textwidth, % \makeupwidth,
+ \c!maxheight=\textheight, % \makeupheight,
+ %\c!bodyfont=,
+ %\c!align=,
+ \c!location=\v!bottom]
+
+% watch the hsize/vsize tricks
+
+\newbox \b_pack_pairedboxes_first
+\newbox \b_pack_pairedboxes_second
+\newdimen\s_pack_pairedboxes_size
+
+\appendtoks
+ \setuevalue{\e!setup\currentpairedbox\e!endsetup}{\setuppairedbox [\currentpairedbox]}%
+ \setuevalue{\e!place\currentpairedbox }{\placepairedbox [\currentpairedbox]}% one argument is mandate anyway
+ \setuevalue{\e!start\e!place\currentpairedbox }{\startplacepairedbox[\currentpairedbox]}% one argument is mandate anyway
+ \setuevalue{\e!stop\e!place \currentpairedbox }{\stopplacepairedbox }%
+\to \everydefinepairedbox
+
+\unexpanded\def\placepairedbox[#1]%
+ {\bgroup
+ \edef\currentpairedbox{#1}%
+ \doifnextoptionalelse\pack_pairedboxes_place\pack_pairedboxes_place_indeed}
+
+\unexpanded\def\startplacepairedbox[#1]%
+ {\bgroup
+ \edef\currentpairedbox{#1}%
+ \doifnextoptionalelse\pack_pairedboxes_place\pack_pairedboxes_place_indeed}
+
+\unexpanded\def\stopplacepairedbox
+ {}
+
+\def\pack_pairedboxes_place[#1]%
+ {\setupcurrentpairedbox[#1]%
+ \pack_pairedboxes_place_indeed}
+
+\def\pack_pairedboxes_place_indeed
+ {\pairedboxparameter\c!before
+ \bgroup
+ \edef\p_location{\pairedboxparameter\c!location}%
+ \edef\p_n {\pairedboxparameter\c!n}%
+ %
+ \let\startcontent\bgroup
+ \let\stopcontent \egroup
+ \let\startcaption\bgroup
+ \let\stopcaption \egroup
+ %
+ \global\setsystemmode{pairedbox}%
+ \pack_pairedboxes_before
+ \dowithnextboxcs\pack_pairedboxes_first\hbox}
+
+\def\pack_pairedboxes_first
+ {\pack_pairedboxes_between
+ \dowithnextboxcs\pack_pairedboxes_second\vbox
+ \bgroup
+ \pack_pairedboxes_inside_second
+ \let\next=}
+
+\def\pack_pairedboxes_second
+ {\pack_pairedboxes_after
+ \egroup
+ \pairedboxparameter\c!after
+ \egroup}
+
+\newconditional\c_pack_pairedboxes_horizontal \settrue\c_pack_pairedboxes_horizontal
+
+\installcorenamespace{pairedboxnature}
+\installcorenamespace{pairedboxalign}
+
+\let\pack_pairedboxes_fill_top \relax
+\let\pack_pairedboxes_fill_bottom\relax
+
+\setvalue{\??pairedboxnature\v!left}%
+ {\settrue\c_pack_pairedboxes_horizontal
+ \let\pack_pairedboxes_flush\pack_pairedboxes_flush_left}
+
+\setvalue{\??pairedboxnature\v!right}%
+ {\settrue\c_pack_pairedboxes_horizontal
+ \let\pack_pairedboxes_flush\pack_pairedboxes_flush_right}
+
+\setvalue{\??pairedboxnature\v!top}%
+ {\setfalse\c_pack_pairedboxes_horizontal
+ \let\pack_pairedboxes_fill_top\relax
+ \let\pack_pairedboxes_fill_bottom\vss
+ \let\pack_pairedboxes_flush\pack_pairedboxes_flush_top}
+
+\setvalue{\??pairedboxnature\v!bottom}%
+ {\setfalse\c_pack_pairedboxes_horizontal
+ \let\pack_pairedboxes_fill_top\vss
+ \let\pack_pairedboxes_fill_bottom\relax
+ \let\pack_pairedboxes_flush\pack_pairedboxes_flush_bottom}
+
+\def\pack_pairedboxes_flush_left
+ {\box\b_pack_pairedboxes_second
+ \hskip\pairedboxparameter\c!distance
+ \box\b_pack_pairedboxes_first}
+
+\def\pack_pairedboxes_flush_right
+ {\box\b_pack_pairedboxes_first
+ \hskip\pairedboxparameter\c!distance
+ \box\b_pack_pairedboxes_second}
+
+\def\pack_pairedboxes_flush_top
+ {\box\b_pack_pairedboxes_second
+ \endgraf
+ \nointerlineskip
+ \pairedboxparameter\c!inbetween
+ \box\b_pack_pairedboxes_first}
+
+\def\pack_pairedboxes_flush_bottom
+ {\box\b_pack_pairedboxes_first
+ \endgraf
+ \nointerlineskip
+ \pairedboxparameter\c!inbetween
+ \box\b_pack_pairedboxes_second}
+
+\setvalue{\??pairedboxalign \v!left}% 0
+ {\let\pack_pairedboxes_align_l\relax
+ \let\pack_pairedboxes_align_r\hss
+ \let\pack_pairedboxes_align_t\relax
+ \let\pack_pairedboxes_align_b\relax}
+
+\setvalue{\??pairedboxalign \v!right}% 1
+ {\let\pack_pairedboxes_align_l\hss
+ \let\pack_pairedboxes_align_r\relax
+ \let\pack_pairedboxes_align_t\relax
+ \let\pack_pairedboxes_align_b\relax}
+
+\setvalue{\??pairedboxalign \v!high}% 2
+ {\let\pack_pairedboxes_align_l\relax
+ \let\pack_pairedboxes_align_r\relax
+ \let\pack_pairedboxes_align_t\relax
+ \let\pack_pairedboxes_align_b\vss}
+
+\setvalue{\??pairedboxalign \v!low}% 3
+ {\let\pack_pairedboxes_align_l\relax
+ \let\pack_pairedboxes_align_r\relax
+ \let\pack_pairedboxes_align_t\vss
+ \let\pack_pairedboxes_align_b\relax}
+
+\setvalue{\??pairedboxalign\v!middle}% 4
+ {\let\pack_pairedboxes_align_l\hss
+ \let\pack_pairedboxes_align_r\hss
+ \let\pack_pairedboxes_align_t\hss
+ \let\pack_pairedboxes_align_b\hss}
+
+\setvalue{\??pairedboxalign\v!bottom}{\getvalue{\??pairedboxalign\v!low }}
+\setvalue{\??pairedboxalign \v!top}{\getvalue{\??pairedboxalign\v!high}}
+
+\def\pack_pairedbox_valign#1{\setbox#1\vbox to \s_pack_pairedboxes_size{\pack_pairedboxes_align_t\box#1\pack_pairedboxes_align_b}}
+\def\pack_pairedbox_halign#1{\setbox#1\hbox to \s_pack_pairedboxes_size{\pack_pairedboxes_align_l\box#1\pack_pairedboxes_align_r}}
+
+\def\pack_pairedboxes_before
+ {\ifx\p_location\empty
+ \csname\??pairedboxnature\v!left \endcsname
+ \csname\??pairedboxalign \v!middle\endcsname
+ \else
+ \getfromcommacommand[\p_location][1]%
+ \csname\??pairedboxnature
+ \ifcsname\??pairedboxnature\commalistelement\endcsname\commalistelement\else\v!left\fi
+ \endcsname
+ \getfromcommacommand[\p_location][2]%
+ \csname\??pairedboxalign
+ \ifcsname\??pairedboxalign\commalistelement\endcsname\commalistelement\else\v!middle\fi
+ \endcsname
+ \fi}
+
+\def\pack_pairedboxes_between
+ {\switchtobodyfont[\pairedboxparameter\c!bodyfont]% split under same regime
+ \setbox\b_pack_pairedboxes_first\box\nextbox
+ \ifconditional\c_pack_pairedboxes_horizontal
+ \pack_pairedboxes_between_horizontal
+ \else
+ \pack_pairedboxes_between_vertical
+ \fi
+ \ifnum\p_n>\plusone
+ \setrigidcolumnhsize\hsize{\pairedboxparameter\c!distance}\p_n
+ \fi}
+
+\def\pack_pairedboxes_between_horizontal
+ {\hsize\wd\b_pack_pairedboxes_first % trick
+ \hsize\pairedboxparameter\c!width % can be \hsize
+ \scratchdimen\dimexpr\wd\b_pack_pairedboxes_first+\pairedboxparameter\c!distance\relax
+ \ifdim\dimexpr\hsize+\scratchdimen\relax>\pairedboxparameter\c!maxwidth\relax
+ \hsize\dimexpr\pairedboxparameter\c!maxwidth-\scratchdimen\relax
+ \fi}
+
+\def\pack_pairedboxes_between_vertical
+ {\hsize\wd\b_pack_pairedboxes_first
+ \hsize\pairedboxparameter\c!width % can be \hsize
+ \ifdim\hsize>\pairedboxparameter\c!maxwidth\relax
+ \hsize\pairedboxparameter\c!maxwidth % can be \hsize
+ \fi}
+
+\def\pack_pairedboxes_after
+ {\setbox\b_pack_pairedboxes_second\vbox
+ {\ifnum\p_n>\plusone
+ \rigidcolumnbalance\nextbox
+ \else
+ \box\nextbox
+ \fi}%
+ \ifconditional\c_pack_pairedboxes_horizontal
+ \pack_pairedboxes_pack_horizontal
+ \else
+ \pack_pairedboxes_pack_vertical
+ \fi}
+
+\def\pack_pairedboxes_pack_horizontal
+ {\hbox\bgroup
+ \forgetall
+ \s_pack_pairedboxes_size\ht
+ \ifdim\ht\b_pack_pairedboxes_first>\ht\b_pack_pairedboxes_second
+ \b_pack_pairedboxes_first
+ \else
+ \b_pack_pairedboxes_second
+ \fi
+ \vsize\s_pack_pairedboxes_size
+ \ifdim\s_pack_pairedboxes_size<\pairedboxparameter\c!height\relax % can be \vsize
+ \s_pack_pairedboxes_size\pairedboxparameter\c!height
+ \fi
+ \ifdim\s_pack_pairedboxes_size>\pairedboxparameter\c!maxheight\relax
+ \s_pack_pairedboxes_size\pairedboxparameter\c!maxheight
+ \fi
+ \pack_pairedbox_valign\b_pack_pairedboxes_first
+ \pack_pairedbox_valign\b_pack_pairedboxes_second
+ \pack_pairedboxes_flush
+ \egroup}
+
+\def\pack_pairedboxes_pack_vertical
+ {\vbox\bgroup
+ \forgetall
+ \s_pack_pairedboxes_size\wd
+ \ifdim\wd\b_pack_pairedboxes_first>\wd\b_pack_pairedboxes_second
+ \b_pack_pairedboxes_first
+ \else
+ \b_pack_pairedboxes_second
+ \fi
+ \pack_pairedbox_halign\b_pack_pairedboxes_first
+ \pack_pairedbox_halign\b_pack_pairedboxes_second
+ \s_pack_pairedboxes_size\ht\b_pack_pairedboxes_second
+ \vsize\s_pack_pairedboxes_size
+ \ifdim\ht\b_pack_pairedboxes_second<\pairedboxparameter\c!height\relax % can be \vsize
+ \s_pack_pairedboxes_size\pairedboxparameter\c!height\relax % \relax needed
+ \fi
+ \ifdim\s_pack_pairedboxes_size>\pairedboxparameter\c!maxheight\relax % todo: totale hoogte
+ \s_pack_pairedboxes_size\pairedboxparameter\c!maxheight\relax % \relax needed
+ \fi
+ \ifdim\s_pack_pairedboxes_size>\ht\b_pack_pairedboxes_second
+ \setbox\b_pack_pairedboxes_second\vbox to \s_pack_pairedboxes_size
+ {\pack_pairedboxes_fill_top
+ \box\b_pack_pairedboxes_second
+ \pack_pairedboxes_fill_bottom}% \kern\zeropoint
+ \fi
+ \pack_pairedboxes_flush
+ \egroup}
+
+\def\pack_pairedboxes_inside_second
+ {\forgetall
+ \setupalign[\pairedboxparameter\c!align]%
+ \usepairedboxstyleandcolor\c!style\c!color
+ \tolerantTABLEbreaktrue % hm.
+ \blank[\v!disable]% use fast one
+ \everypar{\begstrut}}
+
+\definepairedbox[\v!legend]
+
+\unexpanded\def\placeontopofeachother{\bgroup\dowithnextboxcs\pack_topofeachother_one\hbox}
+\unexpanded\def\placesidebyside {\bgroup\dowithnextboxcs\pack_sidebyside_one \hbox}
+
+\def\pack_topofeachother_one{\bgroup\setbox0\box\nextbox\dowithnextboxcs\pack_topofeach_two \hbox}
+\def\pack_sidebyside_one {\bgroup\setbox0\box\nextbox\dowithnextboxcs\pack_sidebyside_two\hbox}
+
+\def\pack_topofeachother_two{\setbox2\box\nextbox\halign{\hss####\hss\cr\box0\cr\box2\cr}\egroup\egroup}
+\def\pack_sidebyside_two {\setbox2\box\nextbox\valign{\vss####\vss\cr\box0\cr\box2\cr}\egroup\egroup}
\protect \endinput
diff --git a/tex/context/base/pack-mis.mkvi b/tex/context/base/pack-mis.mkvi
index af6a32070..ab9d8a5c4 100644
--- a/tex/context/base/pack-mis.mkvi
+++ b/tex/context/base/pack-mis.mkvi
@@ -46,13 +46,14 @@
\unexpanded\def\pack_placement#tag%
{\bgroup
\edef\currentplacement{#tag}%
- \dosingleempty\pack_placement_indeed}
+ \doifnextoptionalelse\pack_placement_yes\pack_placement_nop}
-\def\pack_placement_indeed[#settings]% set test can be sped up but non critical
- {\iffirstargument
- \setupcurrentplacement[#settings]%
- \fi
- \dowithnextboxcontentcs\forgetall\pack_placement_flush\vbox}
+\def\pack_placement_yes[#settings]%
+ {\setupcurrentplacement[#settings]%
+ \pack_placement_nop}
+
+\def\pack_placement_nop
+ {\dowithnextboxcontentcs\forgetall\pack_placement_flush\vbox}
\def\pack_placement_flush
{\setlocalhsize
@@ -67,21 +68,44 @@
\page_backgrounds_add_local_to_box\nextbox
\fi
\ifgridsnapping
- \doifinset{\placementparameter\c!margin}{\v!standard,\v!yes}\noindent % unchecked
- \doifelsenothing{\placementparameter\c!grid}
- {\snaptogrid[\v!middle]}
- {\snaptogrid[\placementparameter\c!grid]}%
- \hbox{\flushnextbox}%
+ \pack_placement_flush_grid_yes
\else
- \doif{\placementparameter\c!linecorrection}\v!on \startbaselinecorrection
- \doifinset{\placementparameter\c!margin}{\v!standard,\v!yes}\noindent
- \flushnextbox
- \doif{\placementparameter\c!depthcorrection}\v!on\baselinecorrection
- \doif{\placementparameter\c!linecorrection }\v!on\stopbaselinecorrection
+ \pack_placement_flush_grid_nop
\fi
\endgroup
\placementparameter\c!after
\egroup}
+\def\pack_placement_flush_grid_yes
+ {\edef\p_grid{\placementparameter\c!grid}%
+ \ifx\p_grid\empty
+ \let\p_grid\v!middle
+ \fi
+ \pack_placement_flush_grid_noindent
+ \snaptogrid[\p_grid]\hbox{\box\nextbox}}
+
+\def\pack_placement_flush_grid_nop
+ {\edef\p_linecorrection {\placementparameter\c!linecorrection}%
+ \edef\p_depthcorrection{\placementparameter\c!depthcorrection}%
+ \ifx\p_linecorrection\v!on
+ \startbaselinecorrection
+ \fi
+ \pack_placement_flush_grid_noindent
+ \box\nextbox
+ \ifx\p_depthcorrection\v!on
+ \baselinecorrection
+ \fi
+ \ifx\p_linecorrection\v!on
+ \stopbaselinecorrection
+ \fi}
+
+\def\pack_placement_flush_grid_noindent
+ {\edef\p_margin{\placementparameter\c!margin}%
+ \ifx\p_margin\v!standard
+ \noindent
+ \else\ifx\p_margin\v!yes
+ \noindent
+ \fi\fi}
+
\protect \endinput
diff --git a/tex/context/base/page-app.mkiv b/tex/context/base/page-app.mkiv
index fd9822fd6..df9607daa 100644
--- a/tex/context/base/page-app.mkiv
+++ b/tex/context/base/page-app.mkiv
@@ -39,9 +39,6 @@
\definelayout
[fittingpage]
[\v!page]
-
-\setuplayout
- [fittingpage]
[\c!width=\d_page_fitting_width,
\c!height=\d_page_fitting_height,
\c!location=\v!middle]
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index d00de2c31..5af50aa8a 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -123,16 +123,35 @@
\to \everydefinelayout
\appendtoks
- \ifx\currentlayout\v!reset
+ \ifcase\layoutsetupmode
+ % can't happen
+ \or % \setuplayout[name][key=value]
+ \ifx\previouslayout\currentlayout
+ \letlayoutparameter\c!state\v!normal % global ? still needed ?
+ \let\currentlayout\currentlayout
+ \page_layouts_synchronize
+ \page_layouts_check_next
+ \fi
+ \or % \setuplayout[key=value]
+ % we can inherit so we always synchronize
+ \letlayoutparameter\c!state\v!normal % global ? still needed ?
+ \let\currentlayout\previouslayout
+ \page_layouts_synchronize
+ \page_layouts_check_next
+ \or % \setuplayout[name]
+ \ifx\currentlayout\v!reset
\let\currentlayout\empty
- \letlayoutparameter\c!state\v!normal % global ?
+ \fi
+ \letlayoutparameter\c!state\v!normal % global ? still needed ?
+ \global\let\currentlayout\currentlayout % global
+ \page_layouts_synchronize
+ \page_layouts_check_next
+ \or % \setuplayout (reverts to main layout)
+ \letlayoutparameter\c!state\v!normal % global ? still needed ?
+ \global\let\currentlayout\empty % global
+ \page_layouts_synchronize
+ \page_layouts_check_next
\fi
- \globallet\currentlayout\currentlayout
-\to \everysetuplayout
-
-\appendtoks
- \page_layouts_synchronize
- \page_layouts_check_next
\to \everysetuplayout
\def\doiflayoutdefinedelse#1%
diff --git a/tex/context/base/scrn-ini.mkvi b/tex/context/base/scrn-ini.mkvi
index 561f2e572..842d83812 100644
--- a/tex/context/base/scrn-ini.mkvi
+++ b/tex/context/base/scrn-ini.mkvi
@@ -31,12 +31,12 @@
\installswitchcommandhandler \??interaction {interaction} \??interaction
-\let\currentinteraction\empty
-
\appendtoks
- \doifelse{\interactionparameter\c!state}\v!start
- {\locationtrue \setsystemmode \v!interaction}%
- {\locationfalse \resetsystemmode\v!interaction}%
+ \ifx\currentinteraction\previousinteraction
+ \doifelse{\interactionparameter\c!state}\v!start
+ {\locationtrue \setsystemmode \v!interaction}%
+ {\locationfalse \resetsystemmode\v!interaction}%
+ \fi
\to \everysetupinteraction
\def\doifelselocation
diff --git a/tex/context/base/spac-grd.mkiv b/tex/context/base/spac-grd.mkiv
index 54f1e5ce4..0fd837bba 100644
--- a/tex/context/base/spac-grd.mkiv
+++ b/tex/context/base/spac-grd.mkiv
@@ -139,7 +139,7 @@
\def\dobotbaselinecorrection
{\hrule\!!height\thebotbaselinecorrection}}
-\def\dobaselinecorrection
+\def\dobaselinecorrection % beware, this one is redefined / used locally elsewhere
{\ifdim\prevdepth>\zeropoint\kern-\prevdepth\fi
\kern\strutdp
\prevdepth\strutdp}
diff --git a/tex/context/base/spac-pag.mkiv b/tex/context/base/spac-pag.mkiv
index 7107d9a22..e44411fba 100644
--- a/tex/context/base/spac-pag.mkiv
+++ b/tex/context/base/spac-pag.mkiv
@@ -184,29 +184,31 @@
% % \ifpagechanged TRUE\else FALSE\fi}
% %
% % \Test\page \Test\par \Test\page \Test\par \Test\page \Test\page
-%
-% \newif\ifpagechanged \let\lastchangedpage\empty
-%
-% \def\docheckpagestatechange#1#2#3%
-% {\pagechangedfalse
-% \doforcedtrackpagestate{#2}{#3}%
-% \findtwopassdata{#2}{\number#3}%
-% \ifconditional\twopassdatafound
-% \ifnum\twopassdata>0\getvalue{#2:p:#1}\relax
-% \pagechangedtrue
-% \fi
-% \fi
-% \ifpagechanged
-% \letgvalue{#2:p:#1}\twopassdata
-% \globallet\lastchangedpage\twopassdata
-% \else
-% \globallet\lastchangedpage\realfolio
-% \fi}
-%
-% \def\changedpagestate#1#2%
-% {\executeifdefined{#2:p:#1}{0}}
-%
-% \def\checkpagechange#1{\docheckpagestatechange{#1}\s!paragraph\nofraggedparagraphs}
-% \def\changedpage #1{\changedpagestate{#1}\s!paragraph}
+
+\installcorenamespace{pagechanges}
+
+\newif\ifpagechanged \let\lastchangedpage\empty
+
+\def\spac_pagechanges_check#1#2#3%
+ {\pagechangedfalse
+ \doforcedtrackpagestate{#2}{#3}%
+ \findtwopassdata{#2}{\number#3}%
+ \ifconditional\twopassdatafound
+ \ifnum\twopassdata>0\getvalue{\??pagechanges#2:#1}\relax
+ \pagechangedtrue
+ \fi
+ \fi
+ \ifpagechanged
+ \letgvalue{\??pagechanges#2:#1}\twopassdata
+ \globallet\lastchangedpage\twopassdata
+ \else
+ \globallet\lastchangedpage\realfolio
+ \fi}
+
+\def\changedpagestate#1#2%
+ {\executeifdefined{\??pagechanges#2:#1}0}
+
+\def\checkpagechange#1{\spac_pagechanges_check{#1}\s!paragraph\nofraggedparagraphs}
+\def\changedpage #1{\changedpagestate{#1}\s!paragraph}
\protect \endinput
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index e8412cf30..e0ea0e265 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 af0fbaf85..81fbe2332 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 320bcd414..33325aa63 100644
--- a/tex/context/base/status-mkiv.lua
+++ b/tex/context/base/status-mkiv.lua
@@ -1,7 +1,7 @@
-- colo-run.mkiv colo-imp-*.mkiv ...
return {
- preloaded = {
+ core = {
{
filename = "syst-ini",
marktype = "mkiv",
@@ -164,12 +164,12 @@ return {
marktype = "mkiv",
status = "okay",
},
- {
+ {
filename = "mult-dim",
marktype = "mkvi",
status = "okay",
},
- {
+ {
filename = "cldf-int",
marktype = "mkiv",
status = "okay",
@@ -883,7 +883,8 @@ return {
{
filename = "tabl-com",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "somewhat weird",
},
{
filename = "tabl-pln",
@@ -898,7 +899,8 @@ return {
{
filename = "tabl-tbl",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "can probably be improved (names and such)",
},
{
filename = "tabl-ntb",
@@ -914,6 +916,7 @@ return {
filename = "tabl-ltb",
marktype = "mkiv",
status = "unknown",
+ comment = "will be redone when needed",
},
{
filename = "tabl-tsp",
@@ -949,12 +952,57 @@ return {
status = "okay",
},
{
+ filename = "font-lib",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
+ filename = "font-fil",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
+ filename = "font-fea",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
+ filename = "font-mat",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
filename = "font-ini",
marktype = "mkvi",
status = "okay",
comment = "needs occasional checking and upgrading",
},
{
+ filename = "font-sym",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
+ filename = "font-sty",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
+ filename = "font-set",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
+ filename = "font-emp",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
+ filename = "font-col",
+ marktype = "mkvi",
+ status = "okay",
+ },
+ {
filename = "font-pre",
marktype = "mkiv",
status = "okay",
@@ -1275,7 +1323,7 @@ return {
{
filename = "typo-del",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "grph-trf",
@@ -1408,5 +1456,12 @@ return {
status = "okay",
comment = "some parameters might move from export to backend"
},
+ },
+ extra = {
+ {
+ filename = "tabl-xnt",
+ marktype = "mkvi",
+ status = "okay",
+ },
}
}
diff --git a/tex/context/base/status-mkiv.tex b/tex/context/base/status-mkiv.tex
index 4127b35de..110117bbb 100644
--- a/tex/context/base/status-mkiv.tex
+++ b/tex/context/base/status-mkiv.tex
@@ -54,49 +54,54 @@
if coremodules then
- local preloaded = coremodules.preloaded
+ local function tabelize(loaded,what)
- if preloaded then
+ if loaded then
- local nofunknown = 0
- local nofloaded = #preloaded
+ local nofunknown = 0
+ local nofloaded = #loaded
- for i=1,nofloaded do
- preloaded[i].order = i
- end
-
- table.sort(preloaded,function(a,b) return a.filename < b.filename end)
-
- context.starttabulate { "|Tr|Tl|Tl|l|p|" }
- context.NC() -- context.bold("order")
- context.NC() context.bold("file")
- context.NC() context.bold("mark")
- context.NC() context.bold("status")
- context.NC() context.bold("comment")
- context.NC() context.NR()
- for i=1,nofloaded do
- local module = preloaded[i]
- local status = module.status
- context.NC() context(module.order)
- context.NC() context(module.filename)
- context.NC() context(module.marktype)
- if status == "unknown" then
- context.NC() context.bold(status)
- nofunknown = nofunknown + 1
- else
- context.NC() context(status)
+ for i=1,nofloaded do
+ loaded[i].order = i
end
- context.NC() context(module.comment)
+
+ table.sort(loaded,function(a,b) return a.filename < b.filename end)
+
+ context.starttabulate { "|Tr|Tl|Tl|l|p|" }
+ context.NC() -- context.bold("order")
+ context.NC() context.bold("file")
+ context.NC() context.bold("mark")
+ context.NC() context.bold("status")
+ context.NC() context.bold("comment")
context.NC() context.NR()
- end
- context.stoptabulate()
+ for i=1,nofloaded do
+ local module = loaded[i]
+ local status = module.status
+ context.NC() context(module.order)
+ context.NC() context(module.filename)
+ context.NC() context(module.marktype)
+ if status == "unknown" then
+ context.NC() context.bold(status)
+ nofunknown = nofunknown + 1
+ else
+ context.NC() context(status)
+ end
+ context.NC() context(module.comment)
+ context.NC() context.NR()
+ end
+ context.stoptabulate()
+
+ context.blank()
- context.blank()
+ context("Of the %s %s modules (so far) in this list %s have the status unknown",nofloaded,what,nofunknown)
- context("Of the %s core modules (so far) in this list %s have the status unknown",nofloaded,nofunknown)
+ end
end
+ tabelize(coremodules.core, "core")
+ tabelize(coremodules.extra,"extra")
+
end
local namespaces = dofile("status-namespaces.lua")
diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv
index f30fdceec..338e4bc63 100644
--- a/tex/context/base/syst-aux.mkiv
+++ b/tex/context/base/syst-aux.mkiv
@@ -3639,35 +3639,33 @@
%D For special purposes:
-\newcount\fastrecursecounter
-\newcount\lastrecursecounter
-\newcount\steprecursecounter
-
-\unexpanded\def\dofastrecurse#1#2#3#4%
- {\def\fastrecursebody{#4}%
- \fastrecursecounter#1\relax
- \lastrecursecounter#2\relax
- \steprecursecounter#3\relax
- \def\recurselevel{\number\fastrecursecounter}%
- \dodofastrecurse}
+\newcount\fastloopindex
+\newcount\fastloopfinal
+\let\fastloopcs\relax
+
+\unexpanded\def\dofastloopcs#1#2%
+ {\let\fastloopcs#2
+ \fastloopindex\plusone
+ \fastloopfinal#1\relax
+ \dodofastloopcs}
+
+\unexpanded\def\dodofastloopcs
+ {\ifnum\fastloopindex>\fastloopfinal
+ \let\fastloopcs\relax
+ \else
+ \fastloopcs
+ \advance\fastloopindex\plusone
+ \expandafter\dodofastloopcs
+ \fi}
+
+% Helper:
\unexpanded\def\resetrecurselevel{\let\recurselevel\!!zerocount}
-\unexpanded\def\dodofastrecurse
- {\ifnum\fastrecursecounter>\lastrecursecounter
- % \resetrecurselevel % slows down
- \else
- \fastrecursebody
- \advance\fastrecursecounter\steprecursecounter
- \expandafter\dodofastrecurse
- \fi}
+\let\recurselevel\!!zerocount
% \appendtoks \resetrecurselevel \to \everydump
-\everydump\expandafter{\the\everydump\resetrecurselevel}
-
-% %
-
%D \macros
%D {doloopoverlist}
%D
@@ -3852,6 +3850,13 @@
\expandafter\firstoftwoarguments
\fi}
+\newif\ifassignment
+
+% \def\docheckassignmentindeed#1=#2#3\@end@{\if#2@\assignmentfalse\else\assignmenttrue\fi}
+%
+% \def\docheckassignment#1%
+% {\expandafter\docheckassignmentindeed\detokenize{#1}=@@\@end@}
+
% D \macros
% D {convertasciiafter}
% D
@@ -5983,11 +5988,11 @@
%D
%D This macro is first used in the tabulation macros.
-\def\processcontent#1%
+\unexpanded\def\processcontent#1%
{\begingroup\expandafter\doprocesscontent\csname#1\endcsname}
-\def\doprocesscontent#1#2#3%
- {\def\doprocesscontent##1#1%
+\unexpanded\def\doprocesscontent#1#2#3%
+ {\unexpanded\def\doprocesscontent##1#1%
{\endgroup\def#2{##1}#3}%
\doprocesscontent}
@@ -7023,4 +7028,58 @@
\unexpanded\def\signalcharacter{\char\zerocount} % \zwj
+%D Here are some nasty helpers:
+
+\def\constantnumber#1%
+ {\ifcase#1\zerocount
+ \or \plusone
+ \or \plustwo
+ \or \plusthree
+ \or \plusfour
+ \or \plusfive
+ \or \plussix
+ \or \plusseven
+ \or \pluseight
+ \or \plusnine
+ \or \plusten
+ \else \number#1\relax\fi}
+
+\def\constantnumberargument#1%
+ {\ifcase#1\zerocount
+ \or \plusone
+ \or \plustwo
+ \or \plusthree
+ \or \plusfour
+ \or \plusfive
+ \or \plussix
+ \or \plusseven
+ \or \pluseight
+ \or \plusnine
+ \or \plusten
+ \else {\number#1}\fi}
+
+\def\constantdimen#1%
+ {\ifdim#1=\zeropoint
+ \zeropoint
+ \else
+ \the#1\relax
+ \fi}
+
+\def\constantdimenargument#1%
+ {\ifdim#1=\zeropoint
+ \zeropoint
+ \else
+ {\the#1}%
+ \fi}
+
+\def\constantemptyargument#1%
+ {\ifx#1\empty
+ \noexpand\empty
+ \else
+ {#1}%
+ \fi}
+
+%D These can be used when constructing often reused token lists,
+%D as we do with tabulates.
+
\protect \endinput
diff --git a/tex/context/base/tabl-com.mkiv b/tex/context/base/tabl-com.mkiv
index 8a0bb9e0c..e90086368 100644
--- a/tex/context/base/tabl-com.mkiv
+++ b/tex/context/base/tabl-com.mkiv
@@ -15,7 +15,39 @@
\unprotect
+\let\VL\relax
+
\let\NC\relax
+\let\RC\relax
+\let\HC\relax
+\let\EQ\relax
+
+\let\RQ\relax
+\let\HQ\relax
+
+\let\NG\relax
+\let\NN\relax
+\let\ND\relax
\let\NR\relax
+\let\NB\relax
+
+\let\CC\relax
+\let\CL\relax
+\let\CM\relax
+\let\CR\relax
+
+\let\SR\relax
+\let\FR\relax
+\let\MR\relax
+\let\LR\relax
+\let\AR\relax
+
+\let\FL\relax
+\let\ML\relax
+\let\LL\relax
+\let\TL\relax
+\let\BL\relax
+\let\HL\relax
+\let\HR\relax
\protect \endinput
diff --git a/tex/context/base/tabl-tbl.lua b/tex/context/base/tabl-tbl.lua
index 86968721b..c48c5100d 100644
--- a/tex/context/base/tabl-tbl.lua
+++ b/tex/context/base/tabl-tbl.lua
@@ -10,7 +10,7 @@ if not modules then modules = { } end modules ['tabl-tbl'] = {
-- TeX. More will follow.
local tonumber = tonumber
-local gsub, rep, sub = string.gsub, string.rep, string.sub
+local gsub, rep, sub, find = string.gsub, string.rep, string.sub, string.find
local P, C, Cc, Ct, lpegmatch = lpeg.P, lpeg.C, lpeg.Cc, lpeg.Ct, lpeg.match
@@ -21,17 +21,20 @@ local nested = lpeg.patterns.nested
local pattern = Ct((separator * (C(nested) + Cc("")) * C((1-separator)^0))^0)
function commands.presettabulate(preamble)
- -- todo: lpeg but not now
- preamble = gsub(preamble, "%*(%b{})(%b{})", function(n,p)
- return rep(sub(p,2,-2),tonumber(sub(n,2,-2)) or 1)
- end)
+ preamble = gsub(preamble,"~","d") -- let's get rid of ~ mess here
+ if find(preamble,"%*") then
+ -- todo: lpeg but not now
+ preamble = gsub(preamble, "%*(%b{})(%b{})", function(n,p)
+ return rep(sub(p,2,-2),tonumber(sub(n,2,-2)) or 1)
+ end)
+ end
local t = lpegmatch(pattern,preamble)
local m = #t - 2
- settexcount("global","noftabulatecolumns", m/2)
- settexcount("global","tabulatehasfirstrulespec", t[1] == "" and 0 or 1)
- settexcount("global","tabulatehaslastrulespec", t[m+1] == "" and 0 or 1)
+ settexcount("global","c_tabl_tabulate_nofcolumns", m/2)
+ settexcount("global","c_tabl_tabulate_has_rule_spec_first", t[1] == "" and 0 or 1)
+ settexcount("global","c_tabl_tabulate_has_rule_spec_last", t[m+1] == "" and 0 or 1)
for i=1,m,2 do
context.settabulateentry(t[i],t[i+1])
end
- context.setlasttabulateentry(t[m+1])
+ context.settabulatelastentry(t[m+1])
end
diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv
index c07cf10af..145c702d2 100644
--- a/tex/context/base/tabl-tbl.mkiv
+++ b/tex/context/base/tabl-tbl.mkiv
@@ -19,28 +19,17 @@
%D I can probably reimplement this using a \LUATEX\ combination
%D but it does not pay of in development time. If I need something
-%D else I will write it from scratch anyway.
+%D else I will write it from scratch anyway. This module looks
+%D a bit complex which is a consequence of it dealing with paragraphs
+%D being split over pages and that there are several passes over the
+%D data set. We can probably do some cleanup (combine/split).
%D
-%D I never really looked at the preamble code of TaBlE (at that time
-%D I simply didn't look into alignments too much) but there seem to
-%D be some similarities with the following code. So, maybe it's not
-%D too much work to rewrite that package in a more contexty style. If
-%D it makes sense to do that remains to be seen. We might as well
-%D drop it.
-%D
-%D Be careful with changing the hsize calculation in p mode;
-%D the following code works quite well:
-%D
-%D \starttyping
-%D \setupfield [line][location=low,height=1.2\lineheight,width=\hsize]
-%D \definefield [test] [line] [line] []
-%D
-%D \starttabulate[|l|p|]
-%D \NC test \NC \field [test] \NC \NR
-%D \stoptabulate
-%D \stoptyping
+%D Caching the preamble does not save much (compared to other
+%D bits and pieces of \CONTEXT). There are not that many ways to
+%D deal with preambles and this is just one of them. The keys are
+%D somewhat similar to those of the \TABLE\ package.
-% |p2|p3| 2:3 -> spanning
+% |p2|p3| 2:3 -> spanning (maybe)
%
% In-text tabbing environment
%
@@ -72,6 +61,7 @@
% i i<n> skip left of column
% j i<n> skip right of column
% k i<n> skip around column
+% d digits (~)
%
% C [C\L\M\R] {color}
%
@@ -157,414 +147,495 @@
% \NC 500 \NC \NC 20 \NC \NC 100 \NC \NR
% \stoptabulate
-\newtoks \tabulatepreamble
-\newtoks \tabulatebefore
-\newtoks \tabulateafter
-\newtoks \tabulatebmath
-\newtoks \tabulateemath
-\newtoks \tabulatefont
-\newtoks \tabulatesettings
-\newtoks \tabulatedummy
-
-\newcount \nofautotabulate
-\newcount \tabulatecolumns
-\newcount \tabulatecolumn
-
-\newcount \noftabulatecolumns % set by parser
-
-\newcount \tabulateminplines
-\newcount \tabulatemaxplines
-
-\newif \iftracetabulate
-
-\newconditional \tabulatenopbreak
-\newconditional \tabulatefirstflushed
-\newconditional \tabulateequal
-\newconditional \tabulatesplit \settrue\tabulatesplit
-\newconditional \tabulateautomode
-\newconditional \tabulatehandlepbreak \settrue\tabulatehandlepbreak
-
-\newdimen \tabulatepwidth
-\newdimen \tabulatexwidth
-\newdimen \tabulatewidth
-\newdimen \tabulateunit
-\newdimen \tabulatemaxpheight
-
-\newskip \tabulatepreskip
-\newskip \tabulateposskip
-\newskip \firstpretabskip
-\newskip \lastposttabskip
-
-\newbox \tabulatebox
-
-\newtoks \everytabulaterow
-\newtoks \everytabulatepar
-\newtoks \everyaftertabulaterow
-\newtoks \everytabulate
-
-\newconditional \tabulateautorulespacing \settrue\tabulateautorulespacing
-\newcount \tabulatehasfirstrulespec % for the moment a count
-\newcount \tabulatehaslastrulespec % for the moment a count
-\newconditional \tabulatesomeamble
-\newconstant \tabulatepass
-
-\setnewconstant \tabulatesplitlinemode \plusone
-
-\newconstant \tabulatecolorspan
-\newconstant \tabulatelocalcolorspan
-
-\newdimen \defaulttabulatevrulethickness
-\newdimen \defaulttabulatehrulethickness
-\newdimen \tabulatevrulethickness
-\newdimen \tabulatehrulethickness
-\newdimen \tabulatelocalvrulethickness
-\newdimen \tabulatelocalhrulethickness
+\newtoks \t_tabl_tabulate_preamble
+\newtoks \t_tabl_tabulate_before
+\newtoks \t_tabl_tabulate_after
+\newtoks \t_tabl_tabulate_bmath
+\newtoks \t_tabl_tabulate_emath
+\newtoks \t_tabl_tabulate_font
+\newtoks \t_tabl_tabulate_settings
+\newtoks \t_tabl_tabulate_dummy
+\newtoks \t_tabl_tabulate_every_row
+\newtoks \t_tabl_tabulate_every_after_row
+
+\newtoks \t_tabl_tabulate_initializers_first
+\newtoks \t_tabl_tabulate_initializers_second
+
+\newcount \c_tabl_tabulate_nofauto
+\newcount \c_tabl_tabulate_columns
+\newcount \c_tabl_tabulate_column
+\newcount \c_tabl_tabulate_plines_min
+\newcount \c_tabl_tabulate_plines_max
+\newcount \c_tabl_tabulate_max_colorcolumn
+\newcount \c_tabl_tabulate_repeathead
+\newcount \c_tabl_tabulate_noflines
+\newcount \c_tabl_tabulate_totalnoflines
+\newcount \c_tabl_tabulate_minusnoflines
+\newcount \c_tabl_tabulate_align
+
+\newcount \c_tabl_tabulate_nofcolumns % set at the lua end by parser
+\newcount \c_tabl_tabulate_has_rule_spec_first % set at the lua end by parser (for the moment a count)
+\newcount \c_tabl_tabulate_has_rule_spec_last % set at the lua end by parser (for the moment a count)
+
+\newconditional \c_tabl_tabulate_nopbreak
+\newconditional \c_tabl_tabulate_firstflushed
+\newconditional \c_tabl_tabulate_equal
+\newconditional \c_tabl_tabulate_split \settrue\c_tabl_tabulate_split
+\newconditional \c_tabl_tabulate_automode
+\newconditional \c_tabl_tabulate_handlepbreak \settrue\c_tabl_tabulate_handlepbreak
+\newconditional \c_tabl_tabulate_autorulespacing \settrue\c_tabl_tabulate_autorulespacing
+\newconditional \c_tabl_tabulate_someamble
+\newconditional \c_tabl_tabulate_has_colors
+\newconditional \c_tabl_tabulate_tolerant_break
+\newconditional \c_tabl_tabulate_splitoff_whitespace
+\newconditional \c_tabl_tabulate_pwidth_set
+\newconditional \c_tabl_tabulate_reshape
+
+\newdimen \d_tabl_tabulate_width_p
+\newdimen \d_tabl_tabulate_width_w
+\newdimen \d_tabl_tabulate_width
+\newdimen \d_tabl_tabulate_unit
+\newdimen \d_tabl_tabulate_height_p_max
+\newdimen \d_tabl_tabulate_vrulethickness_default
+\newdimen \d_tabl_tabulate_hrulethickness_default
+\newdimen \d_tabl_tabulate_vrulethickness
+\newdimen \d_tabl_tabulate_hrulethickness % not used
+\newdimen \d_tabl_tabulate_vrulethickness_local
+\newdimen \d_tabl_tabulate_hrulethickness_local
+\newdimen \d_tabl_tabulate_indent
+\newdimen \d_tabl_tabulate_splitoff_betweenskip
+\newdimen \d_tabl_tabulate_margin
+
+\newskip \s_tabl_tabulate_pre
+\newskip \s_tabl_tabulate_post
+\newskip \s_tabl_tabulate_first
+\newskip \s_tabl_tabulate_last
+\newskip \s_tabl_tabulate_separator
+
+\newbox \b_tabl_tabulate
+
+\newconstant \c_tabl_tabulate_pass
+\newconstant \c_tabl_tabulate_type
+\newconstant \c_tabl_tabulate_splitlinemode \c_tabl_tabulate_splitlinemode\plusone
+\newconstant \c_tabl_tabulate_colorspan
+\newconstant \c_tabl_tabulate_localcolorspan
+\newconstant \c_tabl_tabulate_modus
+
+\let \m_tabl_tabulate_separator_factor \empty % fraction
+
+\newif \iftracetabulate % will become a tracker
+\newtoks \everytabulatepar % where used ?
+\newtoks \everytabulate % public ?
+
+\unexpanded\def\tolerantTABLEbreaktrue {\settrue \c_tabl_tabulate_tolerant_break} % used in styles !
+\unexpanded\def\handletabulatepbreakfalse{\setfalse\c_tabl_tabulate_handlepbreak } % depricated
+
+\installcorenamespace{tabulatealign}
+\installcorenamespace{tabulatebox}
+\installcorenamespace{tabulatesetup}
+\installcorenamespace{tabulatehook}
+\installcorenamespace{tabulatesplit}
+\installcorenamespace{tabulateseparator}
+\installcorenamespace{tabulatecolor}
+\installcorenamespace{tabulateheader}
+\installcorenamespace{tabulatealigning}
+\installcorenamespace{tabulatepreamble}
+
+\installcorenamespace{tabulatehead}
+\installcorenamespace{tabulatefoot}
+\installcorenamespace{tabulatenext}
+
+\def\b_tabl_tabulate_current#1%
+ {\csname\??tabulatebox\number#1\endcsname} % beware, a synonym
+
+\def\tabl_tabulate_initialize_boxes#1%
+ {\scratchcounter#1\relax
+ \tabl_tabulate_initialize_boxes_step}
-\newskip \tabulateseparatorskip
+\def\tabl_tabulate_initialize_boxes_step
+ {\ifnum\scratchcounter>\zerocount
+ \tabl_tabulate_initialize_box\scratchcounter
+ \advance\scratchcounter\minusone
+ \expandafter\tabl_tabulate_initialize_boxes_step
+ \fi}
-\newcount \maxtabularcolorcolumn
+\def\tabl_tabulate_initialize_box#1% also used elsewhere
+ {\ifcsname\??tabulatebox\number#1\endcsname
+ \tabl_tabulate_initialize_box_yes#1%
+ \else
+ \tabl_tabulate_initialize_box_nop#1%
+ \fi}
-\newif \iftolerantTABLEbreak % used in styles !
+\def\tabl_tabulate_initialize_box_yes#1{\global \setbox\csname\??tabulatebox\number#1\endcsname\emptybox}
+\def\tabl_tabulate_initialize_box_nop#1{\expandafter\newbox\csname\??tabulatebox\number#1\endcsname}
-\newcount \tabulaterepeathead
-\newcount \noftabulatelines
-\newcount \totalnoftabulatelines
-\newcount \minusnoftabulatelines
+\tabl_tabulate_initialize_boxes{16} % not really needed
-\newconstant \tabulatetype
+\let\initializetablebox \tabl_tabulate_initialize_box % used elsewhere, will change
+\let\initializetableboxes\tabl_tabulate_initialize_boxes % used elsewhere, will change
+\let\tablebox \b_tabl_tabulate_current
% 0 = NC column next EQ equal column
% 1 = RC column raw RQ equal column raw
% 2 = HC column hook HQ equal column hook
-% for old times sake:
-
-\def\handletabulatepbreakfalse{\setfalse\tabulatehandlepbreak} % depricated
-
% handy helper
-\def\tabulatenoalign
+\def\tabulatenoalign % public ?
{\noalign
\bgroup
\let\noalign\relax
\let\tabulatenoalign\relax
\let\next=}
-\def\starttabulatenoalign
+\def\starttabulatenoalign % public ?
{\tabulatenoalign\bgroup}
\let\stoptabulatenoalign\egroup
% [|lg{.}|] => \NG 12.34 \NC
-\gdef\handletabulatecharalign#1 % space delimited ! (will be redone in lua)
- {\edef\alignmentclass{\the\tabulatecolumn}%
- \edef\alignmentcharacter{\csname\??tt:a:\the\tabulatecolumn\endcsname}%
- \ifcase\tabulatepass\or
+\def\tabl_tabulate_charalign#1 % space delimited ! (will be redone in lua)
+ {\edef\alignmentclass{\the\c_tabl_tabulate_column}%
+ \edef\alignmentcharacter{\csname\??tabulatealign\the\c_tabl_tabulate_column\endcsname}%
+ \ifcase\c_tabl_tabulate_pass\or
\setfirstpasscharacteralign\checkalignment{#1}%
\fi % force hsize
\setsecondpasscharacteralign\checkalignment{#1}}
-\def\noftabcolumns{16}
-
-\def\tablebox#1%
- {\csname\??tt:b:\number#1\endcsname}
-
-\def\initializetablebox#1% also used elsewhere
- {\ifcsname\??tt:b:\number#1\endcsname
- \global\setbox\csname\??tt:b:\number#1\endcsname\emptybox
- \else
- \expandafter\newbox\csname\??tt:b:\number#1\endcsname
- \fi}
+\def\tabl_tabulate_nobreak_inject_tracer
+ {\red % maybe use the fast color switcher here
+ \hrule\!!height.5\linewidth\!!depth.5\linewidth
+ \par
+ \kern-\linewidth
+ \nobreak}
-\def\initializetableboxes#1%
- {\scratchcounter#1\relax
- \doinitializetableboxes}
-
-\def\doinitializetableboxes
- {\ifnum\scratchcounter>\zerocount
- \initializetablebox\scratchcounter
- \advance\scratchcounter\minusone
- \expandafter\doinitializetableboxes
- \fi}
-
-\initializetableboxes\noftabcolumns
-
-\def\dodotabulatenobreak
+\def\tabl_tabulate_nobreak_inject_indeed
{\nobreak
\iftracetabulate
- \red\hrule\!!height.5\linewidth\!!depth.5\linewidth
- \par
- \kern-\linewidth
- \nobreak
+ \tabl_tabulate_nobreak_inject_tracer
\fi}
-\def\dotabulatenobreak
- {\tabulatenoalign{\dodotabulatenobreak}}
+\def\tabl_tabulate_nobreak_inject
+ {\tabulatenoalign{\tabl_tabulate_nobreak_inject_indeed}}
-\unexpanded\def\notabulatehook
- {}
-
-\unexpanded\def\checktabulatehook
- {\ifnum\tabulatetype<\plustwo
- \glet\tabulatehook\notabulatehook
+\unexpanded\def\tabl_tabulate_hook_check
+ {\ifnum\c_tabl_tabulate_type<\plustwo
+ \glet\tabl_tabulate_hook\tabl_tabulate_hook_nop
\else
- \glet\tabulatehook\dotabulatehook
+ \glet\tabl_tabulate_hook\tabl_tabulate_hook_yes
\fi}
-\unexpanded\def\checktabulatesetups
- {\csname\??tt:s:\the\tabulatecolumn\endcsname}
+\unexpanded\def\tabl_tabulate_setups_check
+ {\csname\??tabulatesetup\the\c_tabl_tabulate_column\endcsname}
-\unexpanded\def\beforetabulateentry{\ignorespaces\tabulatehook}
-\unexpanded\def\aftertabulateentry {\unskip\unskip\ifmmode\else\endgraf\fi}
+\unexpanded\def\tabl_tabulate_entry_before{\ignorespaces\tabl_tabulate_hook}
+\unexpanded\def\tabl_tabulate_entry_after {\unskip\unskip\ifmmode\else\endgraf\fi}
-\unexpanded\def\beginreshapedtabulatepar
- {\dowithnextboxcs\beginreshapedtabulateparfinish\vbox\bgroup}
+\unexpanded\def\tabl_tabulate_shaped_par_begin
+ {\dowithnextboxcs\tabl_tabulate_shaped_par_finish\vbox\bgroup}
-\def\beginreshapedtabulateparfinish
+\def\tabl_tabulate_shaped_par_finish
{\ctxcommand{doreshapeframedbox(\number\nextbox)}%
\ifvmode\unvbox\else\box\fi\nextbox}
-\let\endreshapedtabulatepar\egroup
+\let\tabl_tabulate_shaped_par_end\egroup
\ifdefined\dotagtabulatecell \else \let\dotagtabulatecell \relax \fi
\ifdefined\dotagtabulatesignal \else \let\dotagtabulatesignal\relax \fi
-\unexpanded\def\dochecklocaltabulatecolor#1#2%
+\unexpanded\def\tabl_tabulate_check_local_color_first#1#2%
{\relax
- \ifx\currenttabulatelocalcolor\empty
- \gdef\currenttabulatecolor{#1}%
+ \ifx\m_tabl_tabulate_color_local\empty
+ \gdef\m_tabl_tabulate_color{#1}%
\else
- \global\let\currenttabulatecolor\currenttabulatelocalcolor
- \global\let\currenttabulatelocalcolor\empty
+ \global\let\m_tabl_tabulate_color\m_tabl_tabulate_color_local
+ \global\let\m_tabl_tabulate_color_local\empty
\fi
- \ifcase\tabulatelocalcolorspan
- \global\tabulatecolorspan#2\relax
+ \ifcase\c_tabl_tabulate_localcolorspan
+ \global\c_tabl_tabulate_colorspan#2\relax
\else
- \global\tabulatecolorspan\tabulatelocalcolorspan
- \global\tabulatelocalcolorspan\zerocount
+ \global\c_tabl_tabulate_colorspan\c_tabl_tabulate_localcolorspan
+ \global\c_tabl_tabulate_localcolorspan\zerocount
\fi}
-\unexpanded\def\dochecklocaltabulatevrulecolor#1#2%
+\unexpanded\def\tabl_tabulate_check_local_color_second#1#2%
+ {\relax}
+
+\unexpanded\def\tabl_tabulate_check_local_vrule_thickness#1%
{\relax
- \ifx\currenttabulatelocalvrulecolor\empty
- \gdef\currenttabulatevrulecolor{#1}%
+ \ifcase\d_tabl_tabulate_vrulethickness_local
+ \global\d_tabl_tabulate_vrulethickness#1\relax
\else
- \global\let\currenttabulatevrulecolor\currenttabulatelocalvrulecolor
- \global\let\currenttabulatelocalvrulecolor\empty
- \fi
- \ifcase\tabulatelocalvrulethickness
- \global\tabulatevrulethickness#2\relax
+ \global\d_tabl_tabulate_vrulethickness\d_tabl_tabulate_vrulethickness_local
+ \global\d_tabl_tabulate_vrulethickness_local\zeropoint
+ \fi}
+
+\unexpanded\def\tabl_tabulate_check_local_vrule_color_first#1%
+ {\relax}
+
+\unexpanded\def\tabl_tabulate_check_local_vrule_color_second#1%
+ {\relax
+ \ifx\m_tabl_tabulate_vrule_color_local\empty
+ \gdef\m_tabl_tabulate_vrule_color{#1}%
\else
- \global\tabulatevrulethickness\tabulatelocalvrulethickness
- \global\tabulatelocalvrulethickness\zeropoint
+ \global\let\m_tabl_tabulate_vrule_color\m_tabl_tabulate_vrule_color_local
+ \global\let\m_tabl_tabulate_vrule_color_local\empty
\fi}
-\unexpanded\def\dotabulatepreskip#1%
+\let\tabl_tabulate_check_local_color \gobbletwoarguments
+\let\tabl_tabulate_check_local_vrule_color\gobbleoneargument
+
+\appendtoks
+ \let\tabl_tabulate_check_local_color \tabl_tabulate_check_local_color_first
+ \let\tabl_tabulate_check_local_vrule_color\tabl_tabulate_check_local_vrule_color_first
+\to \t_tabl_tabulate_initializers_first
+
+\appendtoks
+ \let\tabl_tabulate_check_local_color \tabl_tabulate_check_local_color_second
+ \let\tabl_tabulate_check_local_vrule_color\tabl_tabulate_check_local_vrule_color_second
+\to \t_tabl_tabulate_initializers_second
+
+% \unexpanded % we can expand this one
+\def\tabl_tabulate_inject_pre_skip#1%
{\ifdim#1>\zeropoint
\hskip#1\relax
- \else\ifnum\tabulatecolumn=\zerocount
- \ifconditional\tabulateautorulespacing
- \ifcase\tabulatehasfirstrulespec\else
- \hskip\firstpretabskip\relax
+ \else\ifnum\c_tabl_tabulate_column=\zerocount
+ \ifconditional\c_tabl_tabulate_autorulespacing
+ \ifcase\c_tabl_tabulate_has_rule_spec_first\else
+ \hskip\s_tabl_tabulate_first\relax
\fi
\fi
\fi\fi}
-\unexpanded\def\dotabulatepostskip#1%
+% \unexpanded % we can expand this one
+\def\tabl_tabulate_inject_post_skip#1%
{\ifdim#1>\zeropoint
\hskip#1\relax
- \else\ifnum\tabulatecolumns=\noftabulatecolumns
- \ifconditional\tabulateautorulespacing
- \ifcase\tabulatehaslastrulespec\else
- \hskip\lastposttabskip\relax
+ \else\ifnum\c_tabl_tabulate_columns=\c_tabl_tabulate_nofcolumns
+ \ifconditional\c_tabl_tabulate_autorulespacing
+ \ifcase\c_tabl_tabulate_has_rule_spec_last\else
+ \hskip\s_tabl_tabulate_last\relax
\fi
\fi
\fi\fi}
-\def\dodosettabulatepreamble#1#2% only makes sense for many tabulates
- {\normalexpanded{\tabulatepreamble{\the\tabulatepreamble
- \dochecklocaltabulatevrulecolor{\currenttabulatevrulecolor}{\the\tabulatevrulethickness}%
- \dochecklocaltabulatecolor{\currenttabulatecolor}{\number\tabulatecolorspan}%
- \dorightsidetabulatecolor
+\def\tabl_tabulate_set_preamble_step#1#2% only makes sense for many tabulates
+ {\normalexpanded{\t_tabl_tabulate_preamble{\the\t_tabl_tabulate_preamble
+ \tabl_tabulate_check_local_vrule_thickness\constantdimenargument\d_tabl_tabulate_vrulethickness
+ \tabl_tabulate_check_local_vrule_color\constantemptyargument\m_tabl_tabulate_vrule_color
+ \tabl_tabulate_check_local_color\constantemptyargument\m_tabl_tabulate_color\constantnumberargument\c_tabl_tabulate_colorspan
+ \tabl_tabulate_color_side_right
\aligntab
- \dotabulatevrule
- \doleftsidetabulatecolor
- \dotabulatepreskip{\the\tabulatepreskip}%
+ \tabl_tabulate_column_vrule_inject
+ \tabl_tabulate_color_side_left
+ \tabl_tabulate_inject_pre_skip{\the\s_tabl_tabulate_pre}%
\alignmark\alignmark
\aligntab
- \dobothsidetabulatecolor
- \global\tabulatecolorspan\zerocount
- \global\tabulatecolumn\the\tabulatecolumns\relax
- \checktabulatesetups % unexpandable
- \checktabulatehook % unexpandable
- \ifzeropt\tabulatewidth
- \ifcase\tabulatemodus\else
- \noexpand\settrue\noexpand\tabulateautomode
+ \tabl_tabulate_color_side_both
+ \global\c_tabl_tabulate_colorspan\zerocount
+ \global\c_tabl_tabulate_column\constantnumber\c_tabl_tabulate_columns
+ \tabl_tabulate_setups_check % unexpandable
+ \tabl_tabulate_hook_check % unexpandable
+ \ifzeropt\d_tabl_tabulate_width
+ \ifcase\c_tabl_tabulate_modus\else
+ \settrue\c_tabl_tabulate_automode
\fi
\else
- \ifnum\tabulatemodus=\zerocount
+ \ifcase\c_tabl_tabulate_modus
\hbox to
\else
\hsize
\fi
- \the\tabulatewidth
+ \the\d_tabl_tabulate_width
\fi
\bgroup
- \noexpand\bbskip
+ \tabl_tabulate_bbskip
\bgroup % we cannot combine the if because a cell may have only one ##
- \tabulatealign\number\tabulatealign\relax % needed in tag passing
+ \c_tabl_tabulate_align\constantnumber\c_tabl_tabulate_align % needed in tag passing
\noexpand\dostarttagged\noexpand\t!tabulatecell\noexpand\empty
\noexpand\dotagtabulatecell
\noexpand#1%
- \ifcase\tabulatereshape\else
- \beginreshapedtabulatepar
+ \ifconditional\c_tabl_tabulate_reshape
+ \tabl_tabulate_shaped_par_begin
\fi
\dotagtabulatesignal % empty cells .. todo (can be removed as soon as build)
- \noexpand\ifnum\noexpand\tabulatetype=\plusone\noexpand\else
- \the\tabulatebmath % maybe later? can interfere with char 0
- \the\tabulatefont
- \the\tabulatesettings
- \the\tabulatebefore
+ \noexpand\ifnum\noexpand\c_tabl_tabulate_type=\plusone\noexpand\else
+ \the\t_tabl_tabulate_bmath % maybe later? can interfere with char 0
+ \the\t_tabl_tabulate_font
+ \the\t_tabl_tabulate_settings
+ \the\t_tabl_tabulate_before
\noexpand\fi
% grouping needs to be outside macros (or expandable), nice test
% example \NC \string \aligntab \NC which will fail otherwise (mk)
\bgroup
- \beforetabulateentry
+ \tabl_tabulate_entry_before
\alignmark\alignmark
- \aftertabulateentry
+ \tabl_tabulate_entry_after
\egroup
- \noexpand\ifnum\noexpand\tabulatetype=\plusone\noexpand\else
- \the\tabulateafter
- \the\tabulateemath
+ \noexpand\ifnum\noexpand\c_tabl_tabulate_type=\plusone\noexpand\else
+ \the\t_tabl_tabulate_after
+ \the\t_tabl_tabulate_emath
\noexpand\fi
- \ifcase\tabulatereshape\else
- \endreshapedtabulatepar
+ \ifconditional\c_tabl_tabulate_reshape
+ \tabl_tabulate_shaped_par_end
\fi
\noexpand#2%
-% \noexpand\dostoptagged
\egroup
\egroup
\aligntab
-\noexpand\dostoptagged
- \dotabulatepostskip{\the\tabulateposskip}%
+ \noexpand\dostoptagged
+ \tabl_tabulate_inject_post_skip{\the\s_tabl_tabulate_post}%
\alignmark\alignmark
}}%
- \tabulatedummy\expandafter{\the\tabulatedummy\NC}%
- \tabulatepreskip.5\tabulateunit\relax
- \ifnum\tabulatecolumns<\numexpr\noftabulatecolumns-\plusone\relax
- \tabulateposskip\tabulatepreskip
+ \t_tabl_tabulate_dummy\expandafter{\the\t_tabl_tabulate_dummy\NC}%
+ \s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\relax
+ \ifnum\c_tabl_tabulate_columns<\numexpr\c_tabl_tabulate_nofcolumns-\plusone\relax
+ \s_tabl_tabulate_post\s_tabl_tabulate_pre
\else
- \tabulateposskip\zeropoint
+ \s_tabl_tabulate_post\zeropoint
\fi
%\let\gettabulateexit\dogettabulateexit % still needed ?
- \tabulatewidth\zeropoint}
-
-\newcount\tabulatealign
-
-\setvalue{\??tt>\meaning x}{\tabulatealign\zerocount
- \settabulatepreamble} % internal
-\setvalue{\??tt>\meaning l}{\tabulatealign\plusone
- \settabulatepreamble}
-\setvalue{\??tt>\meaning r}{\tabulatealign\plustwo
- \settabulatepreamble}
-\setvalue{\??tt>\meaning c}{\tabulatealign\plusthree
- \settabulatepreamble}
-\setvalue{\??tt>\meaning p}{\gettabulateparagraph}
-\setvalue{\??tt>\meaning s}{\gettabulatesetups}
-\setvalue{\??tt>\meaning w}{\gettabulatewidth}
-\setvalue{\??tt>\meaning f}{\gettabulatefont}
-\setvalue{\??tt>\meaning B}{\tabulatefont{\bf}%
- \settabulatepreamble}
-\setvalue{\??tt>\meaning I}{\tabulatefont{\it}%
- \settabulatepreamble}
-\setvalue{\??tt>\meaning S}{\tabulatefont{\sl}%
- \settabulatepreamble}
-\setvalue{\??tt>\meaning T}{\tabulatefont{\tt}%
- \settabulatepreamble}
-\setvalue{\??tt>\meaning R}{\tabulatefont{\rm}%
- \settabulatepreamble}
-\setvalue{\??tt>\meaning m}{\tabulatebmath{$}\tabulateemath{$}%
- \settabulatepreamble}
-\setvalue{\??tt>\meaning M}{\tabulatebmath{$\displaystyle}\tabulateemath{$}%
- \settabulatepreamble}
-\setvalue{\??tt>\meaning h}{\gettabulatehook}
-\setvalue{\??tt>\meaning b}{\gettabulatebefore}
-\setvalue{\??tt>\meaning a}{\gettabulateafter}
-\setvalue{\??tt>\meaning i}{\gettabulatepreskip}
-\setvalue{\??tt>\meaning j}{\gettabulateposskip}
-\setvalue{\??tt>\meaning k}{\gettabulatepreposskip}
-\setvalue{\??tt>\meaning e}{\tabulatesettings\expandafter{\the\tabulatesettings\global\settrue\tabulateequal}%
- \settabulatepreamble}
-\setvalue{\??tt>\meaning ~}{\tabulatesettings\expandafter{\the\tabulatesettings\fixedspaces}%
- \settabulatepreamble}
-\setvalue{\??tt>\meaning g}{\gettabulatealign}
-\setvalue{\??tt>\meaning .}{\gettabulatealign.}
-\setvalue{\??tt>\meaning ,}{\gettabulatealign,}
-\setvalue{\??tt>\meaning C}{\doparsecolortabulate}
-\setvalue{\??tt>\s!unknown }{\writestatus{error}{unknown preamble key [\meaning\next]}%
- \settabulatepreamble}
-\setvalue{\??tt>\meaning\relax}{}
-
-\def\dosettabulatepreamble
- {\csname\??tt>\ifcsname\??tt>\meaning\next\endcsname\meaning\next\else\s!unknown\fi\endcsname}
-
-\def\gettabulatepreskip#1%
+ \d_tabl_tabulate_width\zeropoint}
+
+\unexpanded\def\installtabulatepreambleoption#1#2%
+ {\setvalue{\??tabulatepreamble\string#1}{#2}}%
+
+\installtabulatepreambleoption{x}{\c_tabl_tabulate_align\zerocount
+ \tabl_tabulate_set_preamble} % internal
+\installtabulatepreambleoption{l}{\c_tabl_tabulate_align\plusone
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{r}{\c_tabl_tabulate_align\plustwo
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{c}{\c_tabl_tabulate_align\plusthree
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{p}{\tabl_tabulate_set_paragraph}
+\installtabulatepreambleoption{s}{\tabl_tabulate_set_setups}
+\installtabulatepreambleoption{w}{\tabl_tabulate_set_width}
+\installtabulatepreambleoption{f}{\tabl_tabulate_set_font}
+\installtabulatepreambleoption{B}{\t_tabl_tabulate_font{\bf}%
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{I}{\t_tabl_tabulate_font{\it}%
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{S}{\t_tabl_tabulate_font{\sl}%
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{T}{\t_tabl_tabulate_font{\tt}%
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{R}{\t_tabl_tabulate_font{\rm}%
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{m}{\t_tabl_tabulate_bmath{$}\t_tabl_tabulate_emath{$}%
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{M}{\t_tabl_tabulate_bmath{$\displaystyle}\t_tabl_tabulate_emath{$}%
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{h}{\tabl_tabulate_set_hook}
+\installtabulatepreambleoption{b}{\tabl_tabulate_set_before}
+\installtabulatepreambleoption{a}{\tabl_tabulate_set_after}
+\installtabulatepreambleoption{i}{\tabl_tabulate_set_preskip}
+\installtabulatepreambleoption{j}{\tabl_tabulate_set_posskip}
+\installtabulatepreambleoption{k}{\tabl_tabulate_set_preposskip}
+\installtabulatepreambleoption{e}{\t_tabl_tabulate_settings\expandafter{\the\t_tabl_tabulate_settings\global\settrue\c_tabl_tabulate_equal}%
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{g}{\tabl_tabulate_set_align}
+\installtabulatepreambleoption{.}{\tabl_tabulate_set_align.}
+\installtabulatepreambleoption{,}{\tabl_tabulate_set_align,}
+\installtabulatepreambleoption{C}{\tabl_tabulate_set_color_span}
+\installtabulatepreambleoption{d}{\t_tabl_tabulate_settings\expandafter{\the\t_tabl_tabulate_settings\fixedspaces}%
+ \tabl_tabulate_set_preamble}
+\installtabulatepreambleoption{ }{\tabl_tabulate_set_preamble}
+
+% We no longer deal with '~' here but map it onto 'd' instead. Of course
+% we could prefix a key with \type {\meaning} instead, which works ok (and
+% is needed in order to pseudo expand \type {\next}, but is ugly at the
+% same time. The 'd' stands for digitspace.
+%
+% \installtabulatepreambleoption{~}{...} % see 'd'
+%
+% Also, as there is always a key, we no longer do some after assigment or
+% future let but just pick up the key.
+
+% \installtabulatepreambleoption \s!unknown %
+% {\writestatus{tabulate}{unknown preamble key [\meaning\next]}%
+% \tabl_tabulate_set_preamble}
+%
+% \def\tabl_tabulate_set_preamble
+% {\afterassignment\dosettabulatepreamble\let\next=}
+%
+% \def\dosettabulatepreamble
+% {\ifx\next\relax \else
+% \csname\??tabulatepreamble
+% \ifcsname\??tabulatepreamble\next\endcsname\next\else\s!unknown\fi
+% \expandafter\endcsname
+% \fi}
+
+\installtabulatepreambleoption\relax
+ {} % finished
+
+\def\tabl_tabulate_set_preamble#1%
+ {\ifcsname\??tabulatepreamble\string#1\endcsname
+ \expandafter\tabl_tabulate_set_preamble_yes
+ \else
+ \expandafter\tabl_tabulate_set_preamble_nop
+ \fi{#1}}
+
+\def\tabl_tabulate_set_preamble_yes#1%
+ {\csname\??tabulatepreamble\string#1\expandafter\endcsname}
+
+\def\tabl_tabulate_set_preamble_nop#1%
+ {\writestatus{tabulate}{unknown preamble key: #1}%
+ \tabl_tabulate_set_preamble}
+
+\def\tabl_tabulate_set_preskip#1%
{\doifnumberelse{#1}
- {\tabulatepreskip#1\tabulateunit\let\next\empty}
- {\tabulatepreskip.5\tabulateunit\def\next{#1}}%
- \@EA\settabulatepreamble\next}
+ {\s_tabl_tabulate_pre#1\d_tabl_tabulate_unit\tabl_tabulate_set_preamble }
+ {\s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\tabl_tabulate_set_preamble#1}}
-\def\gettabulateposskip#1%
+\def\tabl_tabulate_set_posskip#1%
{\doifnumberelse{#1}
- {\tabulateposskip#1\tabulateunit\let\next\empty}
- {\tabulateposskip.5\tabulateunit\def\next{#1}}%
- \@EA\settabulatepreamble\next}
+ {\s_tabl_tabulate_post#1\d_tabl_tabulate_unit\tabl_tabulate_set_preamble }
+ {\s_tabl_tabulate_post.5\d_tabl_tabulate_unit\tabl_tabulate_set_preamble#1}}
-\def\gettabulatepreposskip#1%
+\def\tabl_tabulate_set_preposskip#1%
{\doifnumberelse{#1}
- {\tabulatepreskip#1\tabulateunit\let\next\empty}
- {\tabulatepreskip.5\tabulateunit\def\next{#1}}%
- \tabulateposskip\tabulatepreskip
- \@EA\settabulatepreamble\next}
+ {\s_tabl_tabulate_pre#1\d_tabl_tabulate_unit\s_tabl_tabulate_post\s_tabl_tabulate_pre\tabl_tabulate_set_preamble }
+ {\s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\s_tabl_tabulate_post\s_tabl_tabulate_pre\tabl_tabulate_set_preamble#1}}
-\def\gettabulatesetups#1%
- {\setvalue{\??tt:s:\the\tabulatecolumns}{\setups[#1]}%
- \settabulatepreamble}
+\def\tabl_tabulate_set_setups#1%
+ {\setvalue{\??tabulatesetup\the\c_tabl_tabulate_columns}{\setups[#1]}%
+ \tabl_tabulate_set_preamble}
-\def\gettabulatehook#1%
- {\setvalue{\??tt:h:\the\tabulatecolumns}{#1}%
- \settabulatepreamble}
+\def\tabl_tabulate_set_hook#1%
+ {\setvalue{\??tabulatehook\the\c_tabl_tabulate_columns}{#1}%
+ \tabl_tabulate_set_preamble}
-\def\gettabulatealign#1%
- {\setvalue{\??tt:a:\the\tabulatecolumns}{#1}%
- \settabulatepreamble}
+\def\tabl_tabulate_set_align#1%
+ {\setvalue{\??tabulatealign\the\c_tabl_tabulate_columns}{#1}%
+ \tabl_tabulate_set_preamble}
-\def\gettabulatebefore#1%
- {\tabulatebefore{#1}%
- \settabulatepreamble}
+\def\tabl_tabulate_set_before#1%
+ {\t_tabl_tabulate_before{#1}%
+ \tabl_tabulate_set_preamble}
-\def\gettabulateafter#1%
- {\tabulateafter{#1}%
- \settabulatepreamble}
+\def\tabl_tabulate_set_after#1%
+ {\t_tabl_tabulate_after{#1}%
+ \tabl_tabulate_set_preamble}
-\def\gettabulatefont#1%
- {\tabulatefont{#1}%
- \settabulatepreamble}
+\def\tabl_tabulate_set_font#1%
+ {\t_tabl_tabulate_font{#1}%
+ \tabl_tabulate_set_preamble}
-\def\gettabulatewidth
- {\let\tabulatemodus\zerocount
- \let\tabulatedimen\zerocount
- \doifnextparenthesiselse\dogettabulatewidth\settabulatepreamble}
+\def\tabl_tabulate_set_width
+ {\c_tabl_tabulate_modus\zerocount
+ \setfalse\c_tabl_tabulate_pwidth_set
+ \doifnextparenthesiselse\tabl_tabulate_set_width_indeed\tabl_tabulate_set_preamble}
-\def\gettabulateparagraph
+\def\tabl_tabulate_set_paragraph
{\doifnextparenthesiselse
- {\let\tabulatemodus\plusone
- \let\tabulatedimen\plusone
- \dogettabulatewidth}
- {\let\tabulatemodus\plustwo
- \let\tabulatedimen\zerocount
- \settabulatepreamble}}
+ {\c_tabl_tabulate_modus\plusone
+ \settrue\c_tabl_tabulate_pwidth_set
+ \tabl_tabulate_set_width}
+ {\c_tabl_tabulate_modus\plustwo
+ \setfalse\c_tabl_tabulate_pwidth_set
+ \tabl_tabulate_set_preamble}}
% \startbuffer
% \toplinebox{\framed[width=3cm,height=2cm]{tufte}}
@@ -576,203 +647,204 @@
% \dorecurse{100}{\NC \getbuffer \NC test \par test \par \NC \NR}
% \stoptabulate
-\def\dogettabulatewidth(#1)%
+\def\tabl_tabulate_set_width_indeed(#1)%
{\processallactionsinset % can be made faster
[#1]%
- [ \v!fit=>\let\tabulatemodus\plusthree,
- \v!fixed=>\let\tabulatemodus\plusthree
- \settrue\tabulatenopbreak,
- \v!auto=>\let\tabulatemodus\plusthree
- \let\tabulatereshape\plusone,
- \s!unknown=>\tabulatewidth#1\relax]%
- \ifnum\tabulatedimen=\plusone
- \global\advance\tabulatepwidth\tabulatewidth % accumulated parwidth
+ [ \v!fit=>\c_tabl_tabulate_modus\plusthree,
+ \v!fixed=>\c_tabl_tabulate_modus\plusthree
+ \settrue\c_tabl_tabulate_nopbreak,
+ \v!auto=>\c_tabl_tabulate_modus\plusthree
+ \settrue\c_tabl_tabulate_reshape,
+ \s!unknown=>\d_tabl_tabulate_width#1\relax]%
+ \ifconditional\c_tabl_tabulate_pwidth_set
+ \global\advance\d_tabl_tabulate_width_p\d_tabl_tabulate_width % accumulated parwidth
\fi
- \settabulatepreamble}
-
-\def\settabulatepreamble
- {\afterassignment\dosettabulatepreamble\let\next=}
-
-\def\tabulateraggedright {\ifnum\tabulatetype=\plusone \else\raggedright \fi}
-\def\tabulateraggedcenter{\ifnum\tabulatetype=\plusone \else\raggedcenter\fi}
-\def\tabulateraggedleft {\ifnum\tabulatetype=\plusone \else\raggedleft \fi}
-\def\tabulatenotragged {\ifnum\tabulatetype=\plusone \else\notragged \fi}
-\def\tabulatehss {\ifnum\tabulatetype=\plusone \else\hss \fi} % never change this to a fill
-
-\def\tabulatebskipraggedright {\bskip\tabulateraggedright }
-\def\tabulatebskipraggedleft {\bskip\tabulateraggedleft }
-\def\tabulatebskipraggedcenter{\bskip\tabulateraggedcenter}
-
-\def\tabulatesetpreamblewidthnormal
- {\ifcase\tabulatealign\relax
- \dodosettabulatepreamble\empty \tabulatehss \or
- \dodosettabulatepreamble\empty \tabulatehss \or
- \dodosettabulatepreamble\tabulatehss\empty \or
- \dodosettabulatepreamble\tabulatehss\tabulatehss \fi}
-
-\def\tabulatesetpreamblewidthfixed
- {\ifcase\tabulatealign\relax
- \dodosettabulatepreamble\bskip \eskip \or
- \dodosettabulatepreamble\tabulatebskipraggedright \eskip \or
- \dodosettabulatepreamble\tabulatebskipraggedleft \eskip \or
- \dodosettabulatepreamble\tabulatebskipraggedcenter\eskip \fi}
-
-\def\tabulatesetpreamblewidthauto
- {\global\advance\nofautotabulate\plusone
- \ifcase\tabulatealign\relax
- \dodosettabulatepreamble\bskip \eskip \or
- \dodosettabulatepreamble\tabulatebskipraggedright \eskip \or
- \dodosettabulatepreamble\tabulatebskipraggedleft \eskip \or
- \dodosettabulatepreamble\tabulatebskipraggedcenter\eskip \fi}
-
-\def\tabulatesetpreamblewidthsimple
- {\dodosettabulatepreamble\xbskip\xeskip}
-
-\def\doparsecolortabulate#1#2%
- {\gdef\currenttabulatecolor{#2}%
- \global\tabulatecolorspan\if#1L\plusone\else\if#1M\plustwo\else\if#1R\plusthree\else\zerocount\fi\fi\fi\relax
- \settabulatepreamble}
-
-\def\dotabulatevrulecommand#1%
+ \tabl_tabulate_set_preamble}
+
+\def\tabl_tabulate_set_raggedright {\ifnum\c_tabl_tabulate_type=\plusone \else\raggedright \fi}
+\def\tabl_tabulate_set_raggedcenter{\ifnum\c_tabl_tabulate_type=\plusone \else\raggedcenter\fi}
+\def\tabl_tabulate_set_raggedleft {\ifnum\c_tabl_tabulate_type=\plusone \else\raggedleft \fi}
+\def\tabl_tabulate_set_notragged {\ifnum\c_tabl_tabulate_type=\plusone \else\notragged \fi}
+\def\tabl_tabulate_set_hss {\ifnum\c_tabl_tabulate_type=\plusone \else\hss \fi} % never change this to a fill
+
+\def\tabl_tabulate_bskip_raggedright {\tabl_tabulate_bskip\tabl_tabulate_set_raggedright }
+\def\tabl_tabulate_bskip_raggedleft {\tabl_tabulate_bskip\tabl_tabulate_set_raggedleft }
+\def\tabl_tabulate_bskip_raggedcenter{\tabl_tabulate_bskip\tabl_tabulate_set_raggedcenter}
+
+\def\tabl_tabulate_set_width_normal
+ {\ifcase\c_tabl_tabulate_align\relax
+ \tabl_tabulate_set_preamble_step\empty \tabl_tabulate_set_hss \or
+ \tabl_tabulate_set_preamble_step\empty \tabl_tabulate_set_hss \or
+ \tabl_tabulate_set_preamble_step\tabl_tabulate_set_hss\empty \or
+ \tabl_tabulate_set_preamble_step\tabl_tabulate_set_hss\tabl_tabulate_set_hss \fi}
+
+\def\tabl_tabulate_set_width_fixed
+ {\ifcase\c_tabl_tabulate_align\relax
+ \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip \tabl_tabulate_eskip \or
+ \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedright \tabl_tabulate_eskip \or
+ \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedleft \tabl_tabulate_eskip \or
+ \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedcenter\tabl_tabulate_eskip \fi}
+
+\def\tabl_tabulate_set_width_auto
+ {\global\advance\c_tabl_tabulate_nofauto\plusone
+ \ifcase\c_tabl_tabulate_align\relax
+ \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip \tabl_tabulate_eskip \or
+ \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedright \tabl_tabulate_eskip \or
+ \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedleft \tabl_tabulate_eskip \or
+ \tabl_tabulate_set_preamble_step\tabl_tabulate_bskip_raggedcenter\tabl_tabulate_eskip \fi}
+
+\def\tabl_tabulate_set_width_simple
+ {\tabl_tabulate_set_preamble_step\tabl_tabulate_xbskip\tabl_tabulate_xeskip}
+
+\def\tabl_tabulate_set_color_span#1#2%
+ {\gdef\m_tabl_tabulate_color{#2}%
+ \global\c_tabl_tabulate_colorspan\if#1L\plusone\else\if#1M\plustwo\else\if#1R\plusthree\else\zerocount\fi\fi\fi\relax
+ \tabl_tabulate_set_preamble}
+
+\def\tabl_tabulate_set_vrule_command#1%
{\doifnumberelse{#1}
- {\global\tabulatevrulethickness#1\defaulttabulatevrulethickness}
- {\xdef\currenttabulatevrulecolor{#1}}}
-
-\def\settabulateentry#1#2% rulespec template
- {\tabulatealign\@@tabulatealign
- \let\tabulatemodus\zerocount
- \let\tabulatedimen\zerocount
- \let\tabulatereshape\zerocount
- \tabulatebefore\emptytoks
- \tabulateafter\emptytoks
- \tabulatebmath\emptytoks
- \tabulateemath\emptytoks
- \tabulatefont\emptytoks
- \tabulatesettings\emptytoks
- \global\let\currenttabulatecolor\empty
- \global\let\currenttabulatevrulecolor\empty
- \global\tabulatecolorspan\zerocount
- \global\advance\tabulatecolumns\plusone % == #1
- \expandafter\let\csname\??tt:s:\the\tabulatecolumns\endcsname\donothing
- \edef\currenttabulatetrulespec{#1}%
- \ifx\currenttabulatetrulespec\empty
- \global\tabulatevrulethickness\zeropoint
+ {\global\d_tabl_tabulate_vrulethickness#1\d_tabl_tabulate_vrulethickness_default}
+ {\xdef\m_tabl_tabulate_vrule_color{#1}}}
+
+\def\tabl_tabulate_set_entry#1#2% rulespec template
+ {\c_tabl_tabulate_align\v_tabl_tabulate_align
+ \c_tabl_tabulate_modus\zerocount
+ \setfalse\c_tabl_tabulate_pwidth_set
+ \setfalse\c_tabl_tabulate_reshape
+ \t_tabl_tabulate_before\emptytoks
+ \t_tabl_tabulate_after\emptytoks
+ \t_tabl_tabulate_bmath\emptytoks
+ \t_tabl_tabulate_emath\emptytoks
+ \t_tabl_tabulate_font\emptytoks
+ \t_tabl_tabulate_settings\emptytoks
+ \global\let\m_tabl_tabulate_color\empty
+ \global\let\m_tabl_tabulate_vrule_color\empty
+ \global\c_tabl_tabulate_colorspan\zerocount
+ \global\advance\c_tabl_tabulate_columns\plusone
+ \expandafter\let\csname\??tabulatesetup\the\c_tabl_tabulate_columns\endcsname\donothing % here ?
+ \edef\currenttabulationtrulespec{#1}%
+ \ifx\currenttabulationtrulespec\empty
+ \global\d_tabl_tabulate_vrulethickness\zeropoint
\else
- \global\tabulatevrulethickness\defaulttabulatevrulethickness
- \rawprocesscommalist[#1]\dotabulatevrulecommand
+ \global\d_tabl_tabulate_vrulethickness\d_tabl_tabulate_vrulethickness_default
+ \rawprocesscommalist[#1]\tabl_tabulate_set_vrule_command
\fi
- \settabulatepreamble#2\relax\relax % permits i without n
- \ifcase\tabulatemodus\relax
- \tabulatesetpreamblewidthnormal
+ \tabl_tabulate_set_preamble#2\relax\relax % permits i without n
+ \ifcase\c_tabl_tabulate_modus\relax
+ \tabl_tabulate_set_width_normal
\or % fixed width
- \tabulatesetpreamblewidthfixed
+ \tabl_tabulate_set_width_fixed
\or % auto width
- \tabulatesetpreamblewidthauto
+ \tabl_tabulate_set_width_auto
\or % simple
- \tabulatesetpreamblewidthsimple
+ \tabl_tabulate_set_width_simple
\fi}
-\def\setlasttabulateentry#1% rulespec
- {\global\let\currenttabulatevrulecolor\empty
- \rawprocesscommalist[#1]\dotabulatevrulecommand
- \ifx\currenttabulatetrulespec\empty
- \global\tabulatevrulethickness\zeropoint
+\def\tabl_tabulate_set_last_entry#1% rulespec
+ {\global\let\m_tabl_tabulate_vrule_color\empty
+ \rawprocesscommalist[#1]\tabl_tabulate_set_vrule_command
+ \ifx\currenttabulationtrulespec\empty
+ \global\d_tabl_tabulate_vrulethickness\zeropoint
\else
- \global\tabulatevrulethickness\defaulttabulatevrulethickness
- \rawprocesscommalist[#1]\dotabulatevrulecommand
+ \global\d_tabl_tabulate_vrulethickness\d_tabl_tabulate_vrulethickness_default
+ \rawprocesscommalist[#1]\tabl_tabulate_set_vrule_command
\fi
- \normalexpanded{\tabulatepreamble{\the\tabulatepreamble
- \dochecklocaltabulatevrulecolor{\currenttabulatevrulecolor}{\the\tabulatevrulethickness}%
- \dotabulatevrule}}}
+ \normalexpanded{\t_tabl_tabulate_preamble{\the\t_tabl_tabulate_preamble
+ \tabl_tabulate_check_local_vrule_thickness\constantdimenargument\d_tabl_tabulate_vrulethickness
+ \tabl_tabulate_check_local_vrule_color\constantemptyargument\m_tabl_tabulate_vrule_color
+ \tabl_tabulate_column_vrule_inject}}%
+ }
-\def\donormalizetabulatesplitline
- {\ifcase\tabulatesplitlinemode
+\let\settabulateentry \tabl_tabulate_set_entry % used at the lua end
+\let\settabulatelastentry\tabl_tabulate_set_last_entry % used at the lua end
+
+\def\tabl_tabulate_normalize_splitline
+ {\ifcase\c_tabl_tabulate_splitlinemode
% nothing
\or
- \ht\tabulatebox\strutht
- \dp\tabulatebox\strutdp
+ \ht\b_tabl_tabulate\strutht
+ \dp\b_tabl_tabulate\strutdp
\or
- \ifdim\ht\tabulatebox<\strutht
- \ht\tabulatebox\strutht
+ \ifdim\ht\b_tabl_tabulate<\strutht
+ \ht\b_tabl_tabulate\strutht
\fi
- \ifdim\dp\tabulatebox<\strutdp
- \dp\tabulatebox\strutdp
+ \ifdim\dp\b_tabl_tabulate<\strutdp
+ \dp\b_tabl_tabulate\strutdp
\fi
\fi}
-\def\flushtabulatesplitbox
- {\box\tabulatebox}
-
-\newconditional\splitofftabulatewhitespace
-\newdimen\splitofftabulatebetweenskip
-
-\def\flushtabulatewhitespace
- {\ifdim\splitofftabulatebetweenskip>\zeropoint
- \vskip\splitofftabulatebetweenskip
- \global\splitofftabulatebetweenskip\zeropoint
+\def\tabl_tabulate_whitespace
+ {\ifdim\d_tabl_tabulate_splitoff_betweenskip>\zeropoint
+ \vskip\d_tabl_tabulate_splitoff_betweenskip
+ \global\d_tabl_tabulate_splitoff_betweenskip\zeropoint
\fi}
-\def\checktabulatewhitespace
+\def\tabl_tabulate_check_whitespace
{\setbox\scratchbox\vbox
{\splitdiscards
\unskip
- \ifdim\lastskip>\splitofftabulatebetweenskip
- \global\splitofftabulatebetweenskip\lastskip
+ \ifdim\lastskip>\d_tabl_tabulate_splitoff_betweenskip
+ \global\d_tabl_tabulate_splitoff_betweenskip\lastskip
\fi}}
-\def\splitofftabulatebox
+\def\tabl_tabulate_splitoff_box
{\dontcomplain
- \global\setbox\tabulatebox\vsplit\tablebox\tabulatecolumn to \lineheight % % % global ? % % %
- \setbox\tabulatebox\vbox
- {\unvbox\tabulatebox}%
- \ifconditional\splitofftabulatewhitespace
- \checktabulatewhitespace
+ \global\setbox\b_tabl_tabulate\vsplit\b_tabl_tabulate_current\c_tabl_tabulate_column to \lineheight % % % global ? % % %
+ \setbox\b_tabl_tabulate\vbox
+ {\unvbox\b_tabl_tabulate}%
+ \ifconditional\c_tabl_tabulate_splitoff_whitespace
+ \tabl_tabulate_check_whitespace
\fi
- \setbox\tabulatebox\hbox to \wd\tabulatebox
- {\iftrialtypesetting\else\ifconditional\tabulatehascolors\repeatsettabulatecolor\fi\fi
- \hss\dotabulatehook{\box\tabulatebox}\hss}%
- \donormalizetabulatesplitline
- \flushtabulatesplitbox}
-
-\def\dotabulatehook {\csname\??tt:h:\the\tabulatecolumn\endcsname}
-\def\dotabulatealign{\csname\??tt:a:\the\tabulatecolumn\endcsname}
-
-\def\resettabulatepheight
- {\global\tabulateminplines\plusone
- \ifdim\tabulatemaxpheight>\zeropoint
- \getnoflines\tabulatemaxpheight
- \global\tabulatemaxplines\noflines
+ \setbox\b_tabl_tabulate\hbox to \wd\b_tabl_tabulate
+ {\tabl_tabulate_color_repeat
+ \hss\tabl_tabulate_hook_yes{\box\b_tabl_tabulate}\hss}%
+ \tabl_tabulate_normalize_splitline
+ \box\b_tabl_tabulate}
+
+\unexpanded\def\tabl_tabulate_hook_nop
+ {}
+
+\let\tabl_tabulate_hook\tabl_tabulate_hook_nop
+
+\def\tabl_tabulate_hook_yes {\csname\??tabulatehook \the\c_tabl_tabulate_column\endcsname}
+\def\tabl_tabulate_align_yes{\csname\??tabulatealign\the\c_tabl_tabulate_column\endcsname} % to be used
+
+\def\tabl_tabulate_pheight_reset
+ {\global\c_tabl_tabulate_plines_min\plusone
+ \ifdim\d_tabl_tabulate_height_p_max>\zeropoint
+ \getnoflines\d_tabl_tabulate_height_p_max
+ \global\c_tabl_tabulate_plines_max\noflines
\else
- \global\tabulatemaxplines\zerocount
+ \global\c_tabl_tabulate_plines_max\zerocount
\fi
- \global\tabulatemaxpheight\zeropoint}
+ \global\d_tabl_tabulate_height_p_max\zeropoint}
-\def\settabulatepheight
- {\scratchdimen\ht\tablebox\tabulatecolumn\relax
- \ifdim\scratchdimen>\tabulatemaxpheight
- \global\tabulatemaxpheight\scratchdimen
+\def\tabl_tabulate_pheight_set
+ {\scratchdimen\ht\b_tabl_tabulate_current\c_tabl_tabulate_column\relax
+ \ifdim\scratchdimen>\d_tabl_tabulate_height_p_max
+ \global\d_tabl_tabulate_height_p_max\scratchdimen
\fi}
-\def\dohandletabulatepbreak
- {\ifconditional\tabulatehandlepbreak
- \ifconditional\tabulatenopbreak
- \dotabulatenobreak
- \else\ifnum\tabulatemaxplines>\plusone
- \ifnum\tabulateminplines=\plusone
- \dotabulatenobreak
+\def\tabl_tabulate_pbreak_inject
+ {\ifconditional\c_tabl_tabulate_handlepbreak
+ \ifconditional\c_tabl_tabulate_nopbreak
+ \tabl_tabulate_nobreak_inject
+ \else\ifnum\c_tabl_tabulate_plines_max>\plusone
+ \ifnum\c_tabl_tabulate_plines_min=\plusone
+ \tabl_tabulate_nobreak_inject
\fi
- \global\advance\tabulateminplines\plusone
- \ifnum\tabulateminplines=\tabulatemaxplines\relax
- \dotabulatenobreak
+ \global\advance\c_tabl_tabulate_plines_min\plusone
+ \ifnum\c_tabl_tabulate_plines_min=\c_tabl_tabulate_plines_max\relax
+ \tabl_tabulate_nobreak_inject
\fi
\fi \fi
\fi}
-\def\handletabulatepbreak % overloads previous
+\def\tabl_tabulate_pbreak_check
{\starttabulatenoalign
- \dohandletabulatepbreak
- \ifconditional\splitofftabulatewhitespace
- \flushtabulatewhitespace
+ \tabl_tabulate_pbreak_inject
+ \ifconditional\c_tabl_tabulate_splitoff_whitespace
+ \tabl_tabulate_whitespace
\fi
\stoptabulatenoalign}
@@ -802,407 +874,538 @@
%D
%D \typebuffer {\tracetabulatetrue\getbuffer}
-% \definetabulate
-% \redefinetabulate
-% \starttabulate[preamble]
-% \starttabulate -> \starttabulate[|l|p|]
+%D As we want to be compatible we use an indirect way to
+%D implement the definers. The next examples demonstrate
+%D the difference:
+%D
+%D \starttyping
+%D \definetabulate[test][|l|c|r|]
+%D \definetabulate[test][two][|r|c|l|]
+%D
+%D \definetabulation[more][format={|l|c|r|}]
+%D \definetabulation[more:two][format={|r|c|l|}]
+%D
+%D \starttest
+%D \NC t \NC t \NC t \NC \NR
+%D \NC te \NC te \NC te \NC \NR
+%D \NC tes \NC tes \NC tes \NC \NR
+%D \NC test \NC test \NC test \NC \NR
+%D \stoptest
+%D
+%D \starttest[two]
+%D \NC t \NC t \NC t \NC \NR
+%D \NC te \NC te \NC te \NC \NR
+%D \NC tes \NC tes \NC tes \NC \NR
+%D \NC test \NC test \NC test \NC \NR
+%D \stoptest
+%D \startmore
+%D \NC t \NC t \NC t \NC \NR
+%D \NC te \NC te \NC te \NC \NR
+%D \NC tes \NC tes \NC tes \NC \NR
+%D \NC test \NC test \NC test \NC \NR
+%D \stopmore
+%D
+%D \startmore[two]
+%D \NC t \NC t \NC t \NC \NR
+%D \NC te \NC te \NC te \NC \NR
+%D \NC tes \NC tes \NC tes \NC \NR
+%D \NC test \NC test \NC test \NC \NR
+%D \stopmore
+%D \stoptyping
+
+\installcorenamespace {tabulation}
-% todo: commandhandler
+\installcommandhandler \??tabulation {tabulation} \??tabulation
-\def\definetabulate
- {\dotripleempty\dodefinetabulate}
+\setuptabulation
+ [\c!unit=1em,
+ EQ={:},
+ \c!format={|l|p|},
+ \c!frame=\v!off,
+ %\c!bodyfont=,
+ \c!rule=\v!normal,
+ %\c!rulecolor=,
+ \c!rulethickness=\linewidth,
+ %\c!inner=,
+ \c!before=\blank,
+ \c!after=\blank,
+ \c!distance={\v!depth,\v!medium},
+ \c!align=\v!normal,
+ \c!margin=\!!zeropoint,
+ \c!split=\v!auto,
+ \c!header=\v!yes,
+ %\c!title=,
+ \c!indenting=\v!no]
-\def\dodefinetabulate[#1][#2][#3]%
+\unexpanded\def\definetabulate
+ {\dotripleempty\tabl_tabulate_define}
+
+\def\tabl_tabulate_define[#1][#2][#3]%
{\ifthirdargument
- \ifcsname\??tt#1::\c!unit\endcsname \else
- \copyparameters
- [\??tt#1::][\??tt\v!tabulate::]%
- [\c!frame,\c!distance,\c!unit,\c!before,\c!bodyfont,\c!after,
- \c!inner,\c!indenting,\c!margin,\c!align,\c!header,\c!title,
- \c!rulecolor,\c!rulethickness,\c!split,EQ]%
+ % [tag] [sub] [template]
+ \ifcsname\namedtabulationhash{#1}\s!check\endcsname \else
+ \definetabulation[#1][\c!format={#3},\s!check=]%
\fi
- \copyparameters
- [\??tt#1::#2][\??tt#1::]%
- [\c!frame,\c!distance,\c!unit,\c!before,\c!bodyfont,\c!after,
- \c!inner,\c!indenting,\c!margin,\c!align,\c!header,\c!title,
- \c!rulecolor,\c!rulethickness,\c!split,EQ]%
- \setuvalue{\e!start#1::#2}{\dofinalstarttabulate[#1][#2][#3]}%
- \setuvalue{\e!start#1}{\bgroup\dosubstarttabulate[#1]}%
- \letvalueempty{\??tt#1-\v!header}%
- \letvalueempty{\??tt#1-\v!footer}%
+ \definetabulation[#1:#2][#1][\c!format={#3},\s!check=]%
\else\ifsecondargument
- \definetabulate[#1][][#2]%
+ % [tag] [template]
+ \definetabulation[#1][\c!format={#2},\s!check=]%
\else
- \definetabulate[#1][][|l|p|]%
+ % [tag]
+ \definetabulation[#1][\c!format={|l|p|},\s!check=]%
\fi\fi}
-\let\tabulateheadcontent\empty
-\let\tabulatetailcontent\empty
+\unexpanded\def\setuptabulate
+ {\dotripleempty\tabl_tabulate_setup}
+
+\def\tabl_tabulate_setup[#1][#2][#3]%
+ {\ifthirdargument
+ % [tag] [sub] [settings]
+ \setuptabulation[#1:#2][#3]%
+ \else\ifsecondargument
+ % [tag] [settings]
+ \setuptabulation[#1][#2]%
+ \else
+ % [tag]
+ \setuptabulation[#1]%
+ \fi\fi}
-\def\processtabulateheadcontent
- {\tabulatenoalign{\global\settrue\tabulatesomeamble}%
- \csname\??tt\currenttabulate-\v!header\endcsname
- \tabulatenoalign{\global\setfalse\tabulatesomeamble}}%
+\appendtoks
+ \setuevalue{\e!start\currenttabulation}{\tabl_start_defined[\currenttabulation]}%
+ \letvalue{\??tabulatehead\currenttabulation}\empty
+ \letvalue{\??tabulatefoot\currenttabulation}\empty
+\to \everydefinetabulation
-\def\processtabulatetailcontent
- {\tabulatenoalign{\global\settrue\tabulatesomeamble}%
- \csname\??tt\currenttabulate-\v!footer\endcsname
- \tabulatenoalign{\global\setfalse\tabulatesomeamble}}%
+\let\tabulateparameter\tabulationparameter % will stay for a while
+\def\currenttabulate {\currenttabulation} % will stay for a while
-\def\checkfulltabulatecontent % - needed, else confusion with \c!header
- {\ifcsname\??tt\currenttabulate-\v!header\endcsname
- \let\tabulateheadcontent\processtabulateheadcontent
+% Here begins the implementation.
+
+\let\tabl_tabulate_insert_head\empty
+\let\tabl_tabulate_insert_body\empty
+\let\tabl_tabulate_insert_foot\empty
+
+\def\tabl_tabulate_insert_head_content
+ {\tabulatenoalign{\global\settrue\c_tabl_tabulate_someamble}%
+ \csname\??tabulatehead\currenttabulation\endcsname
+ \tabulatenoalign{\global\setfalse\c_tabl_tabulate_someamble}}%
+
+\def\tabl_tabulate_insert_foot_content
+ {\tabulatenoalign{\global\settrue\c_tabl_tabulate_someamble}%
+ \csname\??tabulatehead\currenttabulation\endcsname
+ \tabulatenoalign{\global\setfalse\c_tabl_tabulate_someamble}}%
+
+\def\tabl_tabulate_check_full_content % - needed, else confusion with \c!header
+ {\ifcsname\??tabulatehead\currenttabulation\endcsname
+ \let\tabl_tabulate_insert_head\tabl_tabulate_insert_head_content
\else
- \let\tabulateheadcontent\empty
+ \let\tabl_tabulate_insert_head\empty
\fi
- \ifcsname\??tt\currenttabulate-\v!footer\endcsname
- \let\tabulatetailcontent\processtabulatetailcontent
+ \ifcsname\??tabulatefoot\currenttabulation\endcsname
+ \let\tabl_tabulate_insert_foot\tabl_tabulate_insert_foot_content
\else
- \let\tabulatetailcontent\empty
+ \let\tabl_tabulate_insert_foot\empty
\fi}
-\def\fulltabulatecontent
- {\tabulateheadcontent
- \tabulatecontent
- \tabulatetailcontent
- \removefunnytabulateline}
+\def\tabl_tabulate_insert_content
+ {\tabl_tabulate_insert_head
+ \tabl_tabulate_insert_body
+ \tabl_tabulate_insert_foot
+ \tabl_tabulate_remove_funny_line}
-\def\removefunnytabulateline
+\def\tabl_tabulate_remove_funny_line
{\ifhmode
\strut\crcr
\tabulatenoalign{\kern-\lineheight}%
\fi}
-\setuvalue{\e!start\v!tabulatehead}%
- {\dosingleempty\dostartstarttabulatehead}
+\setuvalue{\e!start\v!tabulatehead}{\doifnextoptionalelse\tabl_tabulate_start_head_yes\tabl_tabulate_start_head_nop}
+\setuvalue{\e!start\v!tabulatetail}{\doifnextoptionalelse\tabl_tabulate_start_foot_yes\tabl_tabulate_start_foot_nop}
-\def\dostartstarttabulatehead[#1]%
- {\processcontent{\e!stop\v!tabulatehead}\next
- {\letvalue{\??tt\iffirstargument#1\else\v!tabulate\fi::-\v!header}\next}}
+\let\m_tabl_tabulate_data\empty
-\setuvalue{\e!start\v!tabulatetail}%
- {\dosingleempty\dostartstarttabulatetail}
+\def\tabl_tabulate_start_head_yes[#1]%
+ {\processcontent{\e!stop\v!tabulatehead}\m_tabl_tabulate_data{\letvalue{\??tabulatehead#1}\m_tabl_tabulate_data}}
-\def\dostartstarttabulatetail[#1]%
- {\processcontent{\e!stop\v!tabulatetail}\next
- {\letvalue{\??tt\iffirstargument#1\else\v!tabulate\fi::-\v!footer}\next}}
+\def\tabl_tabulate_start_foot_yes[#1]%
+ {\processcontent{\e!stop\v!tabulatetail}\m_tabl_tabulate_data{\letvalue{\??tabulatefoot#1}\m_tabl_tabulate_data}}
-\def\dosubstarttabulate
- {\dodoubleempty\dodosubstarttabulate}
+% \def\tabl_tabulate_start_head_nop{\tabl_tabulate_start_foot_yes[\v!tabulate]}
+% \def\tabl_tabulate_start_foot_nop{\tabl_tabulate_start_head_yes[\v!tabulate]}
-\def\dodosubstarttabulate[#1][#2]%
- {\csname\e!start#1::\ifcsname\e!start#1::#2\endcsname#2\fi\endcsname}
+\def\tabl_tabulate_start_head_nop{\tabl_tabulate_start_foot_yes[]}
+\def\tabl_tabulate_start_foot_nop{\tabl_tabulate_start_head_yes[]}
-\setuvalue{\e!start\v!tabulate}%
- {\bgroup % whole thing
- \dodoubleempty\donormalstarttabulate}
+\unexpanded\def\tabl_start_defined[#1]%
+ {\bgroup
+ \edef\currenttabulationparent{#1}%
+ \let\currenttabulation\currenttabulationparent
+ \doifnextoptionalelse\tabl_start_defined_yes\tabl_start_defined_nop}
-\def\doinhibitnestedtabulate
- {\setuvalue{\e!start\v!tabulate}%
- {\em Nested tabulate is not (yet) supported.\relax
- \expandafter\gobbleuntil\csname\e!stop\v!tabulate\endcsname}}
+\def\tabl_start_defined_yes[#1]%
+ {\edef\currenttabulation{\currenttabulation:#1}%
+ \tabl_tabulate_start_building}
-\appendtoks
- \doinhibitnestedtabulate
-\to \everytabulate
+\def\tabl_start_defined_nop
+ {\tabl_tabulate_start_building}
-\setuvalue{\e!stop\v!tabulate }{}
-\setuvalue{\e!stop\v!tabulatehead}{}
-\setuvalue{\e!stop\v!tabulatetail}{}
+% \definetabulate[\v!tabulate][|l|p|] % we need to get rid of this one
-\gdef\donormalstarttabulate[#1][#2]%
- {\ifsecondargument
- \getparameters[\??tt\v!tabulate::][#2]%
+\unexpanded\setuvalue{\e!start\v!tabulate}%
+ {\bgroup % whole thing
+ \dodoubleempty\tabl_start_regular}
+
+\def\tabl_start_regular[#1][#2]%
+ {%\let\currenttabulationparent\v!tabulate
+ \let\currenttabulationparent\empty
+ \let\currenttabulation\currenttabulationparent
+ \def\p_format{#1}%
+ \ifx\p_format\empty
+ \def\p_format{|l|p|}%
\fi
- \iffirstargument
- \def\next{\dofinalstarttabulate[\v!tabulate][][#1]}%
- \else
- \def\next{\dofinalstarttabulate[\v!tabulate][][|l|p|]}%
+ \lettabulationparameter\c!format\p_format
+ \ifsecondargument
+ \getcurrenttabulationparameters[#2]%
\fi
- \next}
+ \tabl_tabulate_start_building}
-% The much needed hook:
+\letvalue{\e!stop\v!tabulate }\relax
+\letvalue{\e!stop\v!tabulatehead}\relax
+\letvalue{\e!stop\v!tabulatetail}\relax
-% \appendtoks \optimizeverbatimfalse \to \everytabulate
+\unexpanded\def\tabl_tabulate_start_ignore
+ {\em Nested tabulate is not (yet) supported.\relax
+ \expandafter\gobbleuntil\csname\e!stop\v!tabulate\endcsname}
-% Todo: proper inheritance
+\appendtoks
+ \letvalue{\e!start\v!tabulate}\tabl_tabulate_start_ignore % only the main one
+\to \everytabulate
-\def\tabulateparameter#1{\csname\??tt\currenttabulate#1\endcsname}
+\setvalue{\??tabulatesplit\v!yes }{\settrue\c_tabl_tabulate_split}
+\setvalue{\??tabulatesplit\v!repeat}{\settrue\c_tabl_tabulate_split}
+\setvalue{\??tabulatesplit\v!no }{\setfalse\c_tabl_tabulate_split}
+\setvalue{\??tabulatesplit\v!auto }{\ifinsidefloat\ifinsidesplitfloat\else\setfalse\c_tabl_tabulate_split\fi\fi}
-\setvalue{\??tt:\c!split:\v!yes }{\settrue\tabulatesplit}
-\setvalue{\??tt:\c!split:\v!repeat}{\settrue\tabulatesplit}
-\setvalue{\??tt:\c!split:\v!no }{\setfalse\tabulatesplit}
-\setvalue{\??tt:\c!split:\v!auto }{\ifinsidefloat\ifinsidesplitfloat\else\setfalse\tabulatesplit\fi\fi}
+% todo: spacing around tabulate when bodyfont is set
-\def\dofinalstarttabulate[#1][#2][#3]% identifier sub preamble
- {\edef\currenttabulate{#1::#2}%
- \ifinsidefloat \else
+\unexpanded\def\tabl_tabulate_start_building
+ {\ifinsidefloat \else
\whitespace
- \tabulateparameter\c!before
+ \tabulationparameter\c!before
\fi
\bgroup % settings
+ %
\resetcharacteralign
- % todo: spacing around tabulate when bodyfont is set
- % expansion en test needed ?
- \settrue\tabulatesplit
- \csname\??tt:\c!split:\tabulateparameter\c!split\endcsname
- \doifsomething{\tabulateparameter\c!bodyfont}
- {\expanded{\switchtobodyfont[\tabulateparameter\c!bodyfont]}}%
+ %
+ \edef\p_distance {\tabulationparameter\c!distance}%
+ \edef\p_align {\tabulationparameter\c!align}%
+ \edef\p_line {\tabulationparameter\c!rule}%
+ \edef\p_rulecolor {\tabulationparameter\c!rulecolor}%
+ \edef\p_rulethickness{\tabulationparameter\c!rulethickness}%
+ \edef\p_bodyfont {\tabulationparameter\c!bodyfont}
+ \edef\p_indenting {\tabulationparameter\c!indenting}%
+ %
+ \settrue\c_tabl_tabulate_split
+ \csname\??tabulatesplit\tabulationparameter\c!split\endcsname
+ %
+ \d_tabl_tabulate_unit\tabulationparameter\c!unit
+ \d_tabl_tabulate_margin\tabulationparameter\c!margin
+ \let\m_tabl_tabulate_vrule_color_default\p_rulecolor
+ \let\m_tabl_tabulate_hrule_color_default\p_rulecolor
+ \d_tabl_tabulate_vrulethickness_default\p_rulethickness
+ \d_tabl_tabulate_hrulethickness_default\p_rulethickness
+ \ifx\p_bodyfont\empty\else
+ \switchtobodyfont[\p_bodyfont]%
+ \fi
\postponenotes % new, to be tested / will be configurable
- \tabulatepass\plusone
\widowpenalty\zerocount % otherwise lines are not broken
\clubpenalty \zerocount % but overlap in funny ways
\the\everytabulate
- \tabulateparameter\c!inner
- \doifelsevalue{\??tt\currenttabulate\c!indenting}\v!yes
- {\edef\tabulateindent{\the\dimexpr\leftskip+\hangindent+\parindent}}%
- {\edef\tabulateindent{\the\dimexpr\leftskip+\hangindent }}%
- \global\tabulatecolumn\zerocount
- \processcontent{\e!stop#1}\tabulatecontent{\processtabulate[#3]}} % \currenttabulate
+ \tabulationparameter\c!inner
+ \d_tabl_tabulate_indent\dimexpr\leftskip+\hangindent\ifx\p_indenting\v!yes+\parindent\fi\relax
+ \global\c_tabl_tabulate_column\zerocount
+ \processcontent
+ {\e!stop\ifx\currenttabulationparent\empty\v!tabulate\else\currenttabulationparent\fi}
+ \tabl_tabulate_insert_body
+ \tabl_tabulate_process}
\def\tabulateEQ
- {\ifconditional\tabulatefirstflushed\else\tabulateparameter{EQ}\fi
- \global\setfalse\tabulateequal}
+ {\ifconditional\c_tabl_tabulate_firstflushed\else\tabulationparameter{EQ}\fi
+ \global\setfalse\c_tabl_tabulate_equal}
% The next ones will be token registers
-\let\tabulatenormalpos\relax
-\let\tabulateequalpos \relax
+\let\tabulatenormalpos\relax % hooks, todo
+\let\tabulateequalpos \relax % hooks, todo
% color columns
-\glet\previoustabulatecolor \empty
-\glet\currenttabulatecolor \empty
-\glet\currenttabulatelocalcolor \empty
-\glet\currenttabulatevrulecolor \empty
-\glet\currenttabulatelocalvrulecolor\empty
+\let\m_tabl_tabulate_color_previous \empty
+\let\m_tabl_tabulate_color \empty
+\let\m_tabl_tabulate_color_local \empty
+\let\m_tabl_tabulate_vrule_color \empty
+\let\m_tabl_tabulate_vrule_color_local \empty
+\let\m_tabl_tabulate_vrule_color_default\empty % used local
+\let\m_tabl_tabulate_hrule_color_default\empty % used local
\appendtoks
- \glet\previoustabulatecolor \empty
- \glet\currenttabulatecolor \empty
- \glet\currenttabulatelocalcolor \empty
- \glet\currenttabulatevrulecolor \empty
- \glet\currenttabulatelocalvrulecolor\empty
- \global\tabulatelocalvrulethickness \zeropoint
-\to \everytabulaterow
-
-\unexpanded\def\dorightsidetabulatecolor
- {\iftrialtypesetting\else
- \ifx\previoustabulatecolor\empty \else
- \settabulatecolor\previoustabulatecolor
- \glet\previoustabulatecolor\empty
- \fi
+ \glet\m_tabl_tabulate_color_previous \empty
+ \glet\m_tabl_tabulate_color \empty
+ \glet\m_tabl_tabulate_color_local \empty
+ \glet\m_tabl_tabulate_vrule_color \empty
+ \glet\m_tabl_tabulate_vrule_color_local\empty
+ \global\d_tabl_tabulate_vrulethickness_local\zeropoint
+\to \t_tabl_tabulate_every_row
+
+\unexpanded\def\tabl_tabulate_color_side_right_second
+ {\ifx\m_tabl_tabulate_color_previous\empty \else
+ \tabl_tabulate_color_set\m_tabl_tabulate_color_previous
+ \glet\m_tabl_tabulate_color_previous\empty
\fi}
-\unexpanded\def\doleftsidetabulatecolor
- {\iftrialtypesetting\else
- \ifx\currenttabulatecolor\empty \else
- \ifcase\tabulatecolorspan
- \or
- \settabulatecolor\currenttabulatecolor
- \or
- \settabulatecolor\currenttabulatecolor
- \fi
+\unexpanded\def\tabl_tabulate_color_side_left_second
+ {\ifx\m_tabl_tabulate_color\empty \else
+ \ifcase\c_tabl_tabulate_colorspan
+ \or
+ \tabl_tabulate_color_set\m_tabl_tabulate_color
+ \or
+ \tabl_tabulate_color_set\m_tabl_tabulate_color
\fi
\fi}
-\unexpanded\def\dobothsidetabulatecolor
- {\iftrialtypesetting\else
- \ifx\currenttabulatecolor\empty \else
- \settabulatecolor\currenttabulatecolor
- \ifcase\tabulatecolorspan
- %\glet\previoustabulatecolor\empty
- \or
- \glet\previoustabulatecolor\empty
- \or
- \glet\previoustabulatecolor\currenttabulatecolor
- \or
- \glet\previoustabulatecolor\currenttabulatecolor
- \fi
+\unexpanded\def\tabl_tabulate_color_side_both_second
+ {\ifx\m_tabl_tabulate_color\empty \else
+ \tabl_tabulate_color_set\m_tabl_tabulate_color
+ \ifcase\c_tabl_tabulate_colorspan
+ %\glet\m_tabl_tabulate_color_previous\empty
+ \or
+ \glet\m_tabl_tabulate_color_previous\empty
+ \or
+ \glet\m_tabl_tabulate_color_previous\m_tabl_tabulate_color
+ \or
+ \glet\m_tabl_tabulate_color_previous\m_tabl_tabulate_color
\fi
\fi}
-\def\tabulatecolorcolumn#1% overloaded
+\let\tabl_tabulate_color_side_right \relax
+\let\tabl_tabulate_color_side_left \relax
+\let\tabl_tabulate_color_side_both \relax
+
+\appendtoks
+ \let\tabl_tabulate_color_side_right\tabl_tabulate_color_side_right_second
+ \let\tabl_tabulate_color_side_left \tabl_tabulate_color_side_left_second
+ \let\tabl_tabulate_color_side_both \tabl_tabulate_color_side_both_second
+\to \t_tabl_tabulate_initializers_second
+
+\def\tabl_tabulate_set_color_column#1% overloaded
{\unskip
- \doiffastoptionalcheckelse{\tabulatecolorcolumnyes#1}{\tabulatecolorcolumnnop#1}}
+ \doiffastoptionalcheckelse{\tabl_tabulate_set_color_column_yes#1}{\tabl_tabulate_set_color_column_nop#1}}
-\def\tabulatecolorcolumnnop
- {\tabulatenormalcolumn}
+\def\tabl_tabulate_set_color_column_nop
+ {\tabl_tabulate_column_normal}
-\def\tabulatecolorcolumnyes#1[#2]%
- {\xdef\currenttabulatelocalcolor{#2}%
- \tabulatenormalcolumn#1}
+\def\tabl_tabulate_set_color_column_yes#1[#2]%
+ {\xdef\m_tabl_tabulate_color_local{#2}%
+ \tabl_tabulate_column_normal#1}
% normal columns:
-\def\tabulatenormalcolumn#1%
+\def\tabl_tabulate_column_normal#1%
{\unskip
\aligntab
- \ifconditional\tabulateequal\tabulateequalpos\else\tabulatenormalpos\fi
+ \ifconditional\c_tabl_tabulate_equal\tabulateequalpos\else\tabulatenormalpos\fi
\aligntab
- \global\tabulatetype#1%
+ \global\c_tabl_tabulate_type#1%
\aligntab}
% equal columns
-\def\tabulateequalcolumn#1% overloaded
+\def\tabl_tabulate_column_equal#1%
{\unskip
\aligntab
\tabulateequalpos
- \aligntab\global\tabulatetype#1%
+ \aligntab\global\c_tabl_tabulate_type#1%
\aligntab}
% ruled columns
-\def\tabulatevruledcolumn#1%
+\def\tabl_tabulate_column_vruled#1%
{\unskip % 0-n
- \ifnum\tabulatecolumn=\plusone
- \global\tabulatehasfirstrulespec\plusone
- \else\ifnum\tabulatecolumn=\noftabulatecolumns
- \global\tabulatehaslastrulespec\plusone
- \fi\fi
- \global\let\currenttabulatelocalvrulecolor\defaulttabulatevrulecolor
- \global\tabulatelocalvrulethickness\defaulttabulatevrulethickness
- \doiffastoptionalcheckelse{\tabulatevruledcolumnyes#1}{\tabulatevruledcolumnnop#1}}
+% \ifnum\c_tabl_tabulate_column=\plusone
+% \global\c_tabl_tabulate_has_rule_spec_first\plusone
+% \else\ifnum\c_tabl_tabulate_column=\c_tabl_tabulate_nofcolumns
+% \global\c_tabl_tabulate_has_rule_spec_last\plusone
+% \fi\fi
+ \global\let\m_tabl_tabulate_vrule_color_local\m_tabl_tabulate_vrule_color_default
+ \global\d_tabl_tabulate_vrulethickness_local\d_tabl_tabulate_vrulethickness_default
+ \doiffastoptionalcheckelse{\tabl_tabulate_column_vruled_yes#1}{\tabl_tabulate_column_vruled_nop#1}}
+
+\def\tabl_tabulate_column_vruled_nop
+ {\tabl_tabulate_column_normal}
+
+\def\tabl_tabulate_column_vruled_step#1%
+ {\doifnumberelse{#1}
+ {\global\d_tabl_tabulate_vrulethickness_local#1\d_tabl_tabulate_vrulethickness_default}
+ {\xdef\m_tabl_tabulate_vrule_color_local{#1}}}
-\def\tabulatevruledcolumnnop
- {\tabulatenormalcolumn}
+\def\tabl_tabulate_column_vruled_yes#1[#2]%
+ {\rawprocesscommalist[#2]\tabl_tabulate_column_vruled_step
+ \tabl_tabulate_column_normal#1}
-\def\dotabulatevrulelocalcommand#1%
- {\doifnumberelse{#1}
- {\global\tabulatelocalvrulethickness#1\defaulttabulatevrulethickness}
- {\xdef\currenttabulatelocalvrulecolor{#1}}}
-
-\def\tabulatevruledcolumnyes#1[#2]%
- {\rawprocesscommalist[#2]\dotabulatevrulelocalcommand
- \tabulatenormalcolumn#1}
-
-\def\donormaltabulatevrule
- {\vrule\!!width\tabulatevrulethickness\relax}
-
-\def\docoloredtabulatevrule
- {\dousecolorparameter\currenttabulatevrulecolor
- \vrule\!!width\tabulatevrulethickness\relax}
-
-\unexpanded\def\dotabulatevrule
- {\ifcase\tabulatevrulethickness\else
- \iftrialtypesetting
- \donormaltabulatevrule
- \else\ifx\currenttabulatevrulecolor\empty
- \donormaltabulatevrule
+\def\tabl_tabulate_column_vruled_normal
+ {\vrule\!!width\d_tabl_tabulate_vrulethickness\relax}
+
+\def\tabl_tabulate_column_vruled_colored
+ {\dousecolorparameter\m_tabl_tabulate_vrule_color
+ \vrule\!!width\d_tabl_tabulate_vrulethickness\relax}
+
+\unexpanded\def\tabl_tabulate_column_vrule_inject_first
+ {\ifcase\d_tabl_tabulate_vrulethickness\else
+ \tabl_tabulate_column_vruled_normal % could be a skip instead
+ \fi
+ \global\d_tabl_tabulate_vrulethickness\zeropoint} % nils second one
+
+\unexpanded\def\tabl_tabulate_column_vrule_inject_second
+ {\ifcase\d_tabl_tabulate_vrulethickness\else
+ \ifx\m_tabl_tabulate_vrule_color\empty
+ \tabl_tabulate_column_vruled_normal
\else
- \docoloredtabulatevrule
- \fi\fi
+ \tabl_tabulate_column_vruled_colored
+ \fi
\fi
- \global\tabulatevrulethickness\zeropoint} % nils second one
+ \global\d_tabl_tabulate_vrulethickness\zeropoint} % nils second one
+
+\let\tabl_tabulate_column_vrule_inject\relax
+
+\appendtoks
+ \let\tabl_tabulate_column_vrule_inject\tabl_tabulate_column_vrule_inject_first
+\to \t_tabl_tabulate_initializers_first
+
+\appendtoks
+ \let\tabl_tabulate_column_vrule_inject\tabl_tabulate_column_vrule_inject_second
+\to \t_tabl_tabulate_initializers_second
% auto columns
-\def\tabulateautocolumn
- {\tabulatenormalcolumn\zerocount
- \ifnum\tabulatecolumn>\tabulatecolumns\relax
+\def\tabl_tabulate_column_inject_auto
+ {\tabl_tabulate_column_normal\zerocount
+ \ifnum\c_tabl_tabulate_column>\c_tabl_tabulate_columns\relax
\expandafter\NR
\else
\expandafter\ignorespaces % interferes with the more tricky hooks
\fi}
-\def\setquicktabulate#1% see \startlegend \startgiven
- {\let#1\tabulateautocolumn
- \let\\\tabulateautocolumn}
-
-\setvalue{\??tt:rs:\v!blank }{\tabulateseparatorskip\bigskipamount}
-\setvalue{\??tt:rs:\v!depth }{\tabulateseparatorskip\strutdp}
-\setvalue{\??tt:rs:\v!small }{\def\factor{.25}}
-\setvalue{\??tt:rs:\v!medium}{\def\factor{.5}}
-\setvalue{\??tt:rs:\v!big }{}
-\setvalue{\??tt:rs:\v!none }{\tabulateseparatorskip\zeropoint\def\factor{0}}
-\setvalue{\??tt:rs:\v!grid }{\tabulateseparatorskip\zeropoint\def\factor{0}}
-
-\def\dodotabulateruleseparator#1%
- {\ifcsname\??tt:rs:#1\endcsname
- \csname\??tt:rs:#1\endcsname
+\def\setquicktabulate#1% see \startlegend \startgiven (for the moment still public)
+ {\let#1\tabl_tabulate_column_inject_auto
+ \let\\\tabl_tabulate_column_inject_auto} % brrr, will go
+
+\setvalue{\??tabulateseparator\v!blank }{\s_tabl_tabulate_separator\bigskipamount}
+\setvalue{\??tabulateseparator\v!depth }{\s_tabl_tabulate_separator\strutdp}
+\setvalue{\??tabulateseparator\v!small }{\def\m_tabl_tabulate_separator_factor{.25}}
+\setvalue{\??tabulateseparator\v!medium}{\def\m_tabl_tabulate_separator_factor{.5}}
+\setvalue{\??tabulateseparator\v!big }{}
+\setvalue{\??tabulateseparator\v!none }{\s_tabl_tabulate_separator\zeropoint\let\m_tabl_tabulate_separator_factor\zerocount}
+\setvalue{\??tabulateseparator\v!grid }{\s_tabl_tabulate_separator\zeropoint\let\m_tabl_tabulate_separator_factor\zerocount}
+
+\def\tabl_tabulate_column_rule_separator_step#1%
+ {\ifcsname\??tabulateseparator#1\endcsname
+ \csname\??tabulateseparator#1\endcsname
\else
- \tabulateseparatorskip#1\relax
+ \s_tabl_tabulate_separator#1\relax
\fi}
-\def\dotabulateruleseparator % can be sped up (will do when used frequently)
+\def\tabl_tabulate_column_rule_separator_inject % can be sped up (will do when used frequently)
{\bgroup
- \edef\tabulateseparatordistance{\tabulateparameter\c!distance}%
- \tabulateseparatorskip\strutdp
- \ifx\tabulateseparatordistance\empty\else
- \let\factor\!!plusone
- \normalexpanded{\processcommalist[\tabulateparameter\c!distance]}\dodotabulateruleseparator
- \tabulateseparatorskip\factor\tabulateseparatorskip
+ \s_tabl_tabulate_separator\strutdp
+ \ifx\p_distance\empty\else
+ \let\m_tabl_tabulate_separator_factor\plusone
+ \processcommacommand[\p_distance]\tabl_tabulate_column_rule_separator_step
+ \s_tabl_tabulate_separator\m_tabl_tabulate_separator_factor\s_tabl_tabulate_separator
\fi
- \ifconditional\tabulatesomeamble\kern\else\vskip\fi\tabulateseparatorskip % new
+ \ifconditional\c_tabl_tabulate_someamble\kern\else\vskip\fi\s_tabl_tabulate_separator % new
\egroup}
-\def\tabulateignorehrulespec#1%
- {%\global\let\currenttabulatelocalhrulecolor\empty
- %\global\tabulatelocalhrulethickness\defaulttabulatehrulethickness
+\def\tabl_tabulate_hrule_spec_ignore#1%
+ {%\global\let\currenttabulationlocalhrulecolor\empty
+ %\global\d_tabl_tabulate_hrulethickness_local\d_tabl_tabulate_hrulethickness_default
\doiffastoptionalcheckelse#1#1}
-\def\tabulatepickuphrulespec#1%
- {\global\let\currenttabulatelocalhrulecolor\defaulttabulatehrulecolor
- \global\tabulatelocalhrulethickness\defaulttabulatehrulethickness
- \doiffastoptionalcheckelse{\tabulatepresethrule#1}#1}
+\def\tabl_tabulate_hrule_spec_pickup#1%
+ {\global\let\currenttabulationlocalhrulecolor\m_tabl_tabulate_hrule_color_default
+ \global\d_tabl_tabulate_hrulethickness_local\d_tabl_tabulate_hrulethickness_default
+ \doiffastoptionalcheckelse{\tabl_tabulate_hrule_preset#1}#1}
-\def\dotabulatehrulelocalcommand#1%
+\def\tabl_tabulate_hrule_preset_step#1%
{\doifnumberelse{#1}
- {\global\tabulatelocalhrulethickness#1\defaulttabulatehrulethickness}
- {\xdef\currenttabulatelocalhrulecolor{#1}}}
+ {\global\d_tabl_tabulate_hrulethickness_local#1\d_tabl_tabulate_hrulethickness_default}
+ {\xdef\currenttabulationlocalhrulecolor{#1}}}
-\def\tabulatepresethrule#1[#2]%
- {\rawprocesscommalist[#2]\dotabulatehrulelocalcommand
+\def\tabl_tabulate_hrule_preset#1[#2]%
+ {\rawprocesscommalist[#2]\tabl_tabulate_hrule_preset_step
#1}
-\def\donormaltabulatehrule
+\def\tabl_tabulate_hrule_inject_normal
{\hrule
- \!!height.5\tabulatelocalhrulethickness
- \!!depth .5\tabulatelocalhrulethickness
+ \!!height.5\d_tabl_tabulate_hrulethickness_local
+ \!!depth .5\d_tabl_tabulate_hrulethickness_local
\relax}
-\def\docoloredtabulatehrule
- {\dousecolorparameter\currenttabulatelocalhrulecolor
- \donormaltabulatehrule}
+\def\tabl_tabulate_hrule_inject_colored
+ {\dousecolorparameter\currenttabulationlocalhrulecolor
+ \tabl_tabulate_hrule_inject_normal}
-\unexpanded\def\dotabulatehrule
- {\ifcase\tabulatelocalhrulethickness\else
- \iftrialtypesetting % does not happen as we nil the caller
- \donormaltabulatehrule
- \else\ifx\currenttabulatelocalhrulecolor\empty
- \donormaltabulatehrule
- \else
- \docoloredtabulatehrule
- \fi\fi
+\unexpanded\def\tabl_tabulate_hrule_inject_first
+ {\ifcase\d_tabl_tabulate_hrulethickness_local\else
+ \tabl_tabulate_hrule_inject_normal
\fi}
-\def\donormaltabulatehlinerule
- {\leaders \hrule
- \!!height\dimexpr.5\lineheight-\strutdepth
- \!!depth-\dimexpr.5\lineheight-\strutdepth+\tabulatelocalhrulethickness
- \hfill}
-
-\def\docoloredtabulatehlinerule
- {\dousecolorparameter\currenttabulatelocalhrulecolor
- \donormaltabulatehlinerule}
-
-\def\dotabulatelinerule
- {\multispan\totaltabulatecolumns % \multispan is a plain macro
- % for the moment this one
- \strut\hskip\tabulateparameter\c!margin
- % neg values are ok !
- \hskip\tabulateindent\relax % new august 2003
- \ifcase\tabulatelocalhrulethickness\else
- \iftrialtypesetting % does not happen as we nil the caller
- \donormaltabulatehlinerule
- \else\ifx\currenttabulatelocalhrulecolor\empty
- \donormaltabulatehlinerule
+\unexpanded\def\tabl_tabulate_hrule_inject_second
+ {\ifcase\d_tabl_tabulate_hrulethickness_local\else
+ \ifx\currenttabulationlocalhrulecolor\empty
+ \tabl_tabulate_hrule_inject_normal
\else
- \docoloredtabulatehlinerule
- \fi\fi
- \fi
- \cr}
+ \tabl_tabulate_hrule_inject_colored
+ \fi
+ \fi}
+
+\let\tabl_tabulate_hrule_inject\relax
+
+\appendtoks
+ \let\tabl_tabulate_hrule_inject\tabl_tabulate_hrule_inject_first
+\to \t_tabl_tabulate_initializers_first
+
+\appendtoks
+ \let\tabl_tabulate_hrule_inject\tabl_tabulate_hrule_inject_second
+\to \t_tabl_tabulate_initializers_second
+
+% \def\totaltabulatecolumns{0}
+%
+% \def\donormaltabulatehlinerule
+% {\leaders \hrule
+% \!!height\dimexpr.5\lineheight-\strutdepth
+% \!!depth-\dimexpr.5\lineheight-\strutdepth+\d_tabl_tabulate_hrulethickness_local
+% \hfill}
+%
+% \def\docoloredtabulatehlinerule
+% {\dousecolorparameter\currenttabulationlocalhrulecolor
+% \donormaltabulatehlinerule}
+%
+% \def\dotabulatelinerule
+% {\multispan\totaltabulatecolumns % \multispan is a plain macro
+% % for the moment this one
+% \strut\hskip\d_tabl_tabulate_margin
+% % neg values are ok !
+% \hskip\d_tabl_tabulate_indent\relax % new august 2003
+% \ifcase\d_tabl_tabulate_hrulethickness_local\else
+% \iftrialtypesetting % does not happen as we nil the caller
+% \donormaltabulatehlinerule
+% \else\ifx\currenttabulationlocalhrulecolor\empty
+% \donormaltabulatehlinerule
+% \else
+% \docoloredtabulatehlinerule
+% \fi\fi
+% \fi
+% \cr}
%D Color:
@@ -1229,167 +1432,222 @@
% \NC test \NC[yellow] test \NC test \NC \NR
% \stoptabulate
-\unexpanded\def\settabulatecolor#1% we could store the attributes at the cost of a lua call
+\unexpanded\def\tabl_tabulate_color_set#1% we could store the attributes at the cost of a lua call
{\begingroup
- \doinitializeboxbackgrounds
- \global\settrue\tabulatehascolors
- \ifnum\tabulatecolumn>\maxtabularcolorcolumn
- \global\maxtabularcolorcolumn\tabulatecolumn
+ \node_backgrounds_boxes_initialize % name might change
+ \global\settrue\c_tabl_tabulate_has_colors
+ \ifnum\c_tabl_tabulate_column>\c_tabl_tabulate_max_colorcolumn
+ \global\c_tabl_tabulate_max_colorcolumn\c_tabl_tabulate_column
\fi
- \setxvalue{\??tt:c:\the\tabulatecolumn}{#1}%
+ \setxvalue{\??tabulatecolor\the\c_tabl_tabulate_column}{#1}%
\attribute\backgroundattribute\plusone
\dousecolorparameter{#1}\strut\char\zerocount % hack
\endgroup}
-\def\repeatsettabulatecolor
+\def\tabl_tabulate_color_repeat_second % for split off lines
{\begingroup
- \ifcsname\??tt:c:\the\tabulatecolumn\endcsname
+ \ifcsname\??tabulatecolor\the\c_tabl_tabulate_column\endcsname
\attribute\backgroundattribute\plusone
- \expandafter\dousecolorparameter\csname\??tt:c:\the\tabulatecolumn\endcsname\strut\char\zerocount % hack
+ \expandafter\dousecolorparameter\csname\??tabulatecolor\the\c_tabl_tabulate_column\endcsname\strut\char\zerocount % hack
\fi
\endgroup}
-\def\resettabulatecolors
- {\ifcase\maxtabularcolorcolumn\else
- \doresettabulatecolors
+\let\tabl_tabulate_color_repeat\relax
+
+\appendtoks
+ \ifconditional\c_tabl_tabulate_has_colors
+ \let\tabl_tabulate_color_repeat\tabl_tabulate_color_repeat_second
+ \fi
+\to \t_tabl_tabulate_initializers_second
+
+\def\tabl_tabulate_color_reset
+ {\ifcase\c_tabl_tabulate_max_colorcolumn\else
+ \tabl_tabulate_color_reset_indeed
\fi}
-\def\doresettabulatecolors
- {\dorecurse\maxtabularcolorcolumn{\letgvalue{\??tt:c:\recurselevel}\undefined}} % slow
+% \def\tabl_tabulate_color_reset_indeed
+% {\dorecurse\c_tabl_tabulate_max_colorcolumn{\letgvalue{\??tabulatecolor\recurselevel}\undefined}} % slow
+
+\def\tabl_tabulate_color_reset_indeed
+ {\dofastloopcs\c_tabl_tabulate_max_colorcolumn\tabl_tabulate_color_reset_step}
+
+\def\tabl_tabulate_color_reset_step % undefined or empty?
+ {\global\expandafter\let\csname\??tabulatecolor\number\fastloopindex\endcsname\undefined}
\appendtoks
- \resettabulatecolors
-\to \everyaftertabulaterow
+ \tabl_tabulate_color_reset
+\to \t_tabl_tabulate_every_after_row
\appendtoks
- \global\setfalse\tabulatehascolors
+ \global\setfalse\c_tabl_tabulate_has_colors
\to \everytabulate
-%D When set to true, no (less) break optimization is done.
+% \def\tabl_tabulate_register_par_options_indeed
+% {\iftrialtypesetting \else
+% \registerparoptions
+% \ifinsidefloat
+% % that is, an unbreakable one
+% \glet\tabl_tabulate_register_par_options\empty
+% \else
+% % unsafe in crossing pages, at each b...
+% % \glet\tabl_tabulate_register_par_options\empty
+% \fi
+% \fi}
+%
+% \appendtoks
+% \glet\tabl_tabulate_register_par_options\tabl_tabulate_register_par_options_indeed
+% \to \everytabulate
-%D The main processing macro is large but splitting it up
-%D would make things less clear.
+\def\tabl_tabulate_register_par_options_first % maybe track here if needed
+ {}
-\def\doregistertabulateparoptions
- {\iftrialtypesetting \else
- \registerparoptions
- \ifinsidefloat
- % that is, an unbreakable one
- \glet\registertabulateparoptions\empty
- \else
- % unsafe in crossing pages, at each b...
- % \glet\registertabulateparoptions\empty
- \fi
+\def\tabl_tabulate_register_par_options_second
+ {\registerparoptions
+ \ifinsidefloat
+ % that is, an unbreakable one
+ \glet\tabl_tabulate_register_par_options\empty
+ \else
+ % unsafe in crossing pages, at each b...
+ % \glet\tabl_tabulate_register_par_options\empty
\fi}
+\let\tabl_tabulate_register_par_options\relax
+
\appendtoks
- \glet\registertabulateparoptions\doregistertabulateparoptions
-\to \everytabulate
+ \let\tabl_tabulate_register_par_options\tabl_tabulate_register_par_options_first
+\to \t_tabl_tabulate_initializers_first
+
+\appendtoks
+ \let\tabl_tabulate_register_par_options\tabl_tabulate_register_par_options_second
+\to \t_tabl_tabulate_initializers_second
\appendtoks
- \registertabulateparoptions
-\to \everytabulaterow
+ \tabl_tabulate_register_par_options
+\to \t_tabl_tabulate_every_row
-\def\flushtabulateindent
- {\ifnum\tabulatecolumn=\zerocount
- \hbox to \tabulateindent
+\def\tabl_tabulate_flush_indent
+ {\ifnum\c_tabl_tabulate_column=\zerocount
+ \hbox to \d_tabl_tabulate_indent
{% we now have a local hsize, and since we want to
% register positional info (i.e. real hsizes) we
% need to reconstitute the original hsize
- \advance\hsize\tabulateindent
+ \advance\hsize\d_tabl_tabulate_indent
% this is indeed rather messy and took a few hours
% to dis/uncover
- \the\everytabulaterow
+ \the\t_tabl_tabulate_every_row
\hss}%
\fi}
-\def\totaltabulatecolumns{0}
-
-\def\handletabulatedigits{\digits}
+\def\tabl_tabulate_digits{\digits}
%D Beware, we cannot use \type {\unexpanded} on \type {\HL}
%D cum suis, since \TEX's hard coded noalign lookahead fails
%D on it! I mistakenly added this for a while.
-\setvalue{\??tt:\c!align:\v!normal}{0}
-\setvalue{\??tt:\c!align:\v!right }{1}
-\setvalue{\??tt:\c!align:\v!left }{2}
-\setvalue{\??tt:\c!align:\v!middle}{3}
+\setvalue{\??tabulatealigning\v!normal}{0}
+\setvalue{\??tabulatealigning\v!right }{1}
+\setvalue{\??tabulatealigning\v!left }{2}
+\setvalue{\??tabulatealigning\v!middle}{3}
+
+\setvalue{\??tabulateheader\v!repeat}{\plusone}
+\setvalue{\??tabulateheader\v!text }{\plustwo}
-\setvalue{\??tt:\c!header:\v!repeat}{\plusone}
-\setvalue{\??tt:\c!header:\v!text }{\plustwo}
+\unexpanded\def\tabl_tabulate_bskip_first {\setbox\b_tabl_tabulate\vbox\bgroup\glet\tabl_tabulate_hook\tabl_tabulate_hook_nop}
+\unexpanded\def\tabl_tabulate_eskip_first {\par\egroup\glet\tabl_tabulate_hook\tabl_tabulate_hook_yes}
+\unexpanded\def\tabl_tabulate_xbskip_first{\hbox\bgroup\vbox\bgroup\glet\tabl_tabulate_hook\tabl_tabulate_hook_nop}
+\unexpanded\def\tabl_tabulate_xeskip_first{\par\egroup\egroup\glet\tabl_tabulate_hook\tabl_tabulate_hook_yes}
-\def\tabulatebskipone {\setbox\tabulatebox\vbox\bgroup\glet\tabulatehook\notabulatehook}
-\def\tabulateeskipone {\par\egroup\glet\tabulatehook\dotabulatehook}
-\def\tabulatexbskipone{\hbox\bgroup\vbox\bgroup\glet\tabulatehook\notabulatehook}
-\def\tabulatexeskipone{\par\egroup\egroup\glet\tabulatehook\dotabulatehook}
+\let\tabl_tabulate_bbskip\relax
+\let\tabl_tabulate_eeskip\relax
+\let\tabl_tabulate_bskip \relax
+\let\tabl_tabulate_eskip \relax
+\let\tabl_tabulate_xbskip\relax
+\let\tabl_tabulate_xeskip\relax
-\def\tabulatebaselinecorrection
- {\def\dobaselinecorrection % todo: mkiv
- {\vskip-\prevdepth+\strutdp+\strutdp\relax}%
+\appendtoks
+ \let\tabl_tabulate_bbskip\relax
+ %\let\tabl_tabulate_eeskip\relax % adapted by bskip
+ \let\tabl_tabulate_bskip \tabl_tabulate_bskip_first
+ \let\tabl_tabulate_eskip \tabl_tabulate_eskip_first
+ \let\tabl_tabulate_xbskip\tabl_tabulate_xbskip_first
+ \let\tabl_tabulate_xeskip\tabl_tabulate_xeskip_first
+\to \t_tabl_tabulate_initializers_first
+
+\def\tabl_tabulate_baselinecorrection % keep an eye on this one
+ {\def\dobaselinecorrection{\vskip\dimexpr-\prevdepth+\strutdp+\strutdp\relax}% todo: mkiv
\baselinecorrection}
-\unexpanded\def\tabulateVLone{\tabulatevruledcolumn\zerocount}
-\unexpanded\def\tabulateNCone{\tabulatenormalcolumn\zerocount}
-\unexpanded\def\tabulateRCone{\tabulatenormalcolumn\plusone}
-\unexpanded\def\tabulateHCone{\tabulatenormalcolumn\plustwo}
-\unexpanded\def\tabulateEQone{\tabulateequalcolumn \zerocount}
-\unexpanded\def\tabulateRQone{\tabulateequalcolumn \plusone}
-\unexpanded\def\tabulateHQone{\tabulateequalcolumn \plustwo}
-\unexpanded\def\tabulateNGone{\NC\handletabulatecharalign}
-\unexpanded\def\tabulateNNone{\NC\handletabulatedigits} % new, undocumented, test first
-\unexpanded\def\tabulateNDone{\NC\handletabulatedigits} % same, for old times sake
-
-\unexpanded\def\tabulateHRone{\doHR\zerocount}
-
-\unexpanded\def\tabulateCCone{\global\tabulatelocalcolorspan\zerocount\tabulatecolorcolumn\zerocount}
-\unexpanded\def\tabulateCLone{\global\tabulatelocalcolorspan\plusone \tabulatecolorcolumn\zerocount}
-\unexpanded\def\tabulateCMone{\global\tabulatelocalcolorspan\plustwo \tabulatecolorcolumn\zerocount}
-\unexpanded\def\tabulateCRone{\global\tabulatelocalcolorspan\plusthree\tabulatecolorcolumn\zerocount}
-
-% \unexpanded\def\tabulateNRone % next row
-% {\global\advance\noftabulatelines\plusone
-% \global\setfalse\tabulatefirstflushed
-% \global\setfalse\tabulateequal
-% \global\tabulatecolumn\zerocount
-% \resettabulatepheight
-% \unskip\unskip\crcr\flushtabulated
-% \starttabulatenoalign
-% \the\everyaftertabulaterow
-% \checktabulatepenaltiesa
-% \stoptabulatenoalign}
+\unexpanded\def\tabl_tabulate_VL_first{\tabl_tabulate_column_vruled\zerocount}
+\unexpanded\def\tabl_tabulate_NC_first{\tabl_tabulate_column_normal\zerocount}
+\unexpanded\def\tabl_tabulate_RC_first{\tabl_tabulate_column_normal\plusone}
+\unexpanded\def\tabl_tabulate_HC_first{\tabl_tabulate_column_normal\plustwo}
+\unexpanded\def\tabl_tabulate_EQ_first{\tabl_tabulate_column_equal \zerocount}
+\unexpanded\def\tabl_tabulate_RQ_first{\tabl_tabulate_column_equal \plusone}
+\unexpanded\def\tabl_tabulate_HQ_first{\tabl_tabulate_column_equal \plustwo}
+
+\unexpanded\def\tabl_tabulate_NG_first{\NC\tabl_tabulate_charalign}
+\unexpanded\def\tabl_tabulate_NN_first{\NC\tabl_tabulate_digits} % new, undocumented, test first
+\unexpanded\def\tabl_tabulate_ND_first{\NC\tabl_tabulate_digits} % same, for old times sake
+\unexpanded\def\tabl_tabulate_NR_first{\tabl_tabulate_NR_common\tabl_tabulate_check_penalties} % next row
+\unexpanded\def\tabl_tabulate_NB_first{\tabl_tabulate_NR_common\tabl_tabulate_nobreak_inject} % next row no break
+
+\unexpanded\def\tabl_tabulate_CC_first{\global\c_tabl_tabulate_localcolorspan\zerocount\tabl_tabulate_set_color_column\zerocount}
+\unexpanded\def\tabl_tabulate_CL_first{\global\c_tabl_tabulate_localcolorspan\plusone \tabl_tabulate_set_color_column\zerocount}
+\unexpanded\def\tabl_tabulate_CM_first{\global\c_tabl_tabulate_localcolorspan\plustwo \tabl_tabulate_set_color_column\zerocount}
+\unexpanded\def\tabl_tabulate_CR_first{\global\c_tabl_tabulate_localcolorspan\plusthree\tabl_tabulate_set_color_column\zerocount}
+
+\appendtoks
+ \let\VL\tabl_tabulate_VL_first
+ \let\NC\tabl_tabulate_NC_first
+ \let\RC\tabl_tabulate_RC_first
+ \let\HC\tabl_tabulate_HC_first
+ \let\EQ\tabl_tabulate_EQ_first
+ \let\RQ\tabl_tabulate_RQ_first
+ \let\HQ\tabl_tabulate_HQ_first
+ \let\NG\tabl_tabulate_NG_first
+ \let\NN\tabl_tabulate_NN_first
+ \let\ND\tabl_tabulate_ND_first
+ \let\NR\tabl_tabulate_NR_first
+ \let\NB\tabl_tabulate_NB_first
+ \let\CC\tabl_tabulate_CC_first
+ \let\CL\tabl_tabulate_CL_first
+ \let\CM\tabl_tabulate_CM_first
+ \let\CR\tabl_tabulate_CR_first
+\to \t_tabl_tabulate_initializers_first
-\def\tabulateNRcommon#1%
- {\global\advance\noftabulatelines\plusone
- \global\setfalse\tabulatefirstflushed
- \global\setfalse\tabulateequal
- \global\tabulatecolumn\zerocount
- \resettabulatepheight
- \unskip\unskip\crcr\flushtabulated
+\appendtoks
+ \let\SR\NR
+ \let\FR\NR
+ \let\MR\NR
+ \let\LR\NR
+ \let\AR\NR
+\to \t_tabl_tabulate_initializers_first
+
+\unexpanded\def\tabl_tabulate_NR_common#1%
+ {\global\advance\c_tabl_tabulate_noflines\plusone
+ \global\setfalse\c_tabl_tabulate_firstflushed
+ \global\setfalse\c_tabl_tabulate_equal
+ \global\c_tabl_tabulate_column\zerocount
+ \tabl_tabulate_pheight_reset
+ \unskip\unskip\crcr\tabl_tabulate_flush_collected
\starttabulatenoalign
- \the\everyaftertabulaterow
+ \the\t_tabl_tabulate_every_after_row
#1%
\stoptabulatenoalign}
-\unexpanded\def\tabulateNRone % next row
- {\tabulateNRcommon\checktabulatepenaltiesa}
-
-\unexpanded\def\tabulateNBone % next row no break
- {\tabulateNRcommon\dotabulatenobreak}
-
-\def\checktabulatepenaltiesa
- {\iftolerantTABLEbreak\else
- \ifnum\totalnoftabulatelines=\plusone
+\def\tabl_tabulate_check_penalties
+ {\ifconditional\c_tabl_tabulate_tolerant_break\else
+ \ifnum\c_tabl_tabulate_totalnoflines=\plusone
% \allowbreak
\else
- \ifconditional\tabulatesomeamble \ifcase\tabulaterepeathead \else
+ \ifconditional\c_tabl_tabulate_someamble \ifcase\c_tabl_tabulate_repeathead \else
\allowbreak
\fi \fi
- \ifnum\noftabulatelines=\plusone
- \dotabulatenobreak
- \else\ifnum\noftabulatelines=\minusnoftabulatelines
- \ifnum\tabulatemaxplines<\plustwo
- \dotabulatenobreak
+ \ifnum\c_tabl_tabulate_noflines=\plusone
+ \tabl_tabulate_nobreak_inject
+ \else\ifnum\c_tabl_tabulate_noflines=\c_tabl_tabulate_minusnoflines
+ \ifnum\c_tabl_tabulate_plines_max<\plustwo
+ \tabl_tabulate_nobreak_inject
\else
\allowbreak % needed with pbreak prevention
\fi
@@ -1398,66 +1656,85 @@
\fi\fi
\fi
\fi
- \global\setfalse\tabulatefirstflushed}
+ \global\setfalse\c_tabl_tabulate_firstflushed}
-\def\tabulatebbskiptwo
- {\ifvoid\tablebox\tabulatecolumn
- \ifx\flushtabulatedindeed\empty\else
+\unexpanded\def\tabl_tabulate_bbskip_second_split_yes
+ {\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column
+ \ifx\tabl_tabulate_flush_collected_indeed\empty\else
\setbox0\hbox
\fi
\fi}
-\def\tabulatebskiptwoeskip
+\unexpanded\def\tabl_tabulate_eskip_second
{\par\egroup
- \settabulatepheight
- \glet\tabulatehook\dotabulatehook
- \splitofftabulatebox}
+ \tabl_tabulate_pheight_set
+ \glet\tabl_tabulate_hook\tabl_tabulate_hook_yes
+ \tabl_tabulate_splitoff_box}
-\def\tabulatebskiptwo
- {\ifvoid\tablebox\tabulatecolumn
+\unexpanded\def\tabl_tabulate_bskip_second_split_yes
+ {\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column
% first line
- \global\setbox\tablebox\tabulatecolumn\vbox
+ \global\setbox\b_tabl_tabulate_current\c_tabl_tabulate_column\vbox
\bgroup
- \glet\tabulatehook\notabulatehook
- \ifconditional\tabulateautomode\hsize\tabulatewidth\fi
+ \glet\tabl_tabulate_hook\tabl_tabulate_hook_nop
+ \ifconditional\c_tabl_tabulate_automode\hsize\d_tabl_tabulate_width\fi
% \begstrut % interferes with pre-\pars
% evt: \appendtoks\begstrut\to\everypar
\ignorespaces
- \let\eskip\tabulatebskiptwoeskip
+ \let\tabl_tabulate_eskip\tabl_tabulate_eskip_second
\else
% successive lines
- \let\eskip\empty
+ \let\tabl_tabulate_eskip\empty
\dontcomplain
- \glet\tabulatehook\dotabulatehook
- \expandafter\splitofftabulatebox
+ \glet\tabl_tabulate_hook\tabl_tabulate_hook_yes
+ \expandafter\tabl_tabulate_splitoff_box
\fi}
-\def\tabulatexbskiptwo{\bskip}
-\def\tabulatexeskiptwo{\eskip}
+\unexpanded\def\tabl_tabulate_xbskip_second{\tabl_tabulate_bskip}
+\unexpanded\def\tabl_tabulate_xeskip_second{\tabl_tabulate_eskip}
-\def\dotabulateflushtabulatedtwo
- {\glet\flushtabulatedindeed\empty
- \global\tabulatecolumn\zerocount
- \handletabulatepbreak
- \dorecurse\tabulatecolumns % was: \noftabcolumns
- {\ifvoid\tablebox\recurselevel\else
- \gdef\flushtabulatedindeed{\the\tabulatedummy}%
- \fi}%
- \global\settrue\tabulatefirstflushed}
+\unexpanded\def\tabl_tabulate_flush_second_indeed
+ {\glet\tabl_tabulate_flush_collected_indeed\empty
+ \global\c_tabl_tabulate_column\zerocount
+ \tabl_tabulate_pbreak_check
+ \dofastloopcs\c_tabl_tabulate_columns\tabl_tabulate_flush_second_step
+ \global\settrue\c_tabl_tabulate_firstflushed}
-\def\tabulateflushtabulatedtwo
- {\tabulatenoalign{\dotabulateflushtabulatedtwo}%
- \flushtabulatedindeed}
+\unexpanded\def\tabl_tabulate_flush_second_step
+ {\ifvoid\b_tabl_tabulate_current\fastloopindex\else
+ \gdef\tabl_tabulate_flush_collected_indeed{\the\t_tabl_tabulate_dummy}%
+ \fi}
+
+\def\tabl_tabulate_flush_second
+ {\tabulatenoalign{\tabl_tabulate_flush_second_indeed}%
+ \tabl_tabulate_flush_collected_indeed}
-\def\tabulatebskipthree
+\unexpanded\def\tabl_tabulate_bskip_second_split_nop
{\vtop\bgroup
- \ifconditional\tabulateautomode\hsize\tabulatewidth\fi
+ \ifconditional\c_tabl_tabulate_automode\hsize\d_tabl_tabulate_width\fi
% \begstrut % interferes with pre-\pars
% evt: \appendtoks\begstrut\to\everypar
\ignorespaces}
-\def\tabulateeskipthree % vertical strut added august 2003
- {\par\verticalstrut\vskip-\struttotal\egroup}
+\unexpanded\def\tabl_tabulate_eskip_second_split_nop % vertical strut added august 2003
+ {\par\verticalstrut
+ \vskip-\struttotal
+ \egroup}
+
+% \let\tabl_tabulate_eskip \relax % adapted by bskip
+% \let\tabl_tabulate_eeskip\relax % adapted by bskip
+
+\appendtoks
+ \let\tabl_tabulate_xbskip\tabl_tabulate_xbskip_second
+ \let\tabl_tabulate_xeskip\tabl_tabulate_xeskip_second
+ \ifconditional\c_tabl_tabulate_split
+ \let\tabl_tabulate_bskip \tabl_tabulate_bskip_second_split_yes
+ \let\tabl_tabulate_bbskip\tabl_tabulate_bbskip_second_split_yes
+ \else
+ \let\tabl_tabulate_bskip \tabl_tabulate_bskip_second_split_nop
+ \let\tabl_tabulate_eskip \tabl_tabulate_eskip_second_split_nop
+ \fi
+\to \t_tabl_tabulate_initializers_second
% see ***
%
@@ -1466,104 +1743,113 @@
% \starttabulate[||] \dorecurse{100}{\NC Eins \NC \NR \HL} \stoptabulate
% \stoptext
-\def\tabulateXXnone{\starttabulatenoalign\tabulateignorehrulespec\stoptabulatenoalign}
-
-\def\tabulateFLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateFLfive}
-\def\tabulateMLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateMLfive}
-\def\tabulateLLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateLLfive}
-\def\tabulateTLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateTLfive}
-\def\tabulateBLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateBLfive}
-%def\tabulateHLfive{\starttabulatenoalign\tabulatepickuphrulespec\dotabulateHLfive}
+\def\tabl_tabulate_XX_none{\starttabulatenoalign\tabl_tabulate_hrule_spec_ignore\stoptabulatenoalign}
-% we can use one common spec: (saves 4 macros)
-%
-% \def\dotabulatecheckhrulespec#1%
-% {\iftrialtypesetting
-% \expandafter\tabulateignorehrulespec\expandafter\stoptabulatenoalign
-% \else
-% \expandafter\tabulatepickuphrulespec\expandafter\dotabulateFLfive
-% \fi}
+\def\tabl_tabulate_FL_second{\starttabulatenoalign\tabl_tabulate_hrule_spec_pickup\tabl_tabulate_FL_second_indeed}
+\def\tabl_tabulate_ML_second{\starttabulatenoalign\tabl_tabulate_hrule_spec_pickup\tabl_tabulate_ML_second_indeed}
+\def\tabl_tabulate_LL_second{\starttabulatenoalign\tabl_tabulate_hrule_spec_pickup\tabl_tabulate_LL_second_indeed}
+\def\tabl_tabulate_TL_second{\starttabulatenoalign\tabl_tabulate_hrule_spec_pickup\tabl_tabulate_TL_second_indeed}
+\def\tabl_tabulate_BL_second{\starttabulatenoalign\tabl_tabulate_hrule_spec_pickup\tabl_tabulate_BL_second_indeed}
-\unexpanded\def\dotabulateFLfive
+\unexpanded\def\tabl_tabulate_FL_second_indeed
{\ifinsidefloat\else
- \doifemptyvalue{\??tt\currenttabulate\c!before} % no expansion
- {\tabulatebaselinecorrection}%
+ \doifemptyvalue{\??tt\currenttabulation\c!before}\tabl_tabulate_baselinecorrection % no expansion
\fi
- \dotabulatehrule
- \dotabulatenobreak
- \dotabulateruleseparator
+ \tabl_tabulate_hrule_inject
+ \tabl_tabulate_nobreak_inject
+ \tabl_tabulate_column_rule_separator_inject
\prevdepth\strutdp
- \dotabulatenobreak
+ \tabl_tabulate_nobreak_inject
\stoptabulatenoalign}
-\unexpanded\def\dotabulateMLfive
- {\dotabulateruleseparator
- \dotabulatehrule
- \vskip-\tabulateparameter\c!rulethickness
- \dotabulatehrule
+\unexpanded\def\tabl_tabulate_ML_second_indeed
+ {\tabl_tabulate_column_rule_separator_inject
+ \tabl_tabulate_hrule_inject
+ \vskip-\p_rulethickness\relax
+ \tabl_tabulate_hrule_inject
\nobreak
- \dotabulateruleseparator
+ \tabl_tabulate_column_rule_separator_inject
\stoptabulatenoalign}
-\unexpanded\def\dotabulateLLfive
- {\dotabulatenobreak
- \dotabulateruleseparator
- \dotabulatenobreak
- \dotabulatehrule
+\unexpanded\def\tabl_tabulate_LL_second_indeed
+ {\tabl_tabulate_nobreak_inject
+ \tabl_tabulate_column_rule_separator_inject
+ \tabl_tabulate_nobreak_inject
+ \tabl_tabulate_hrule_inject
\ifinsidefloat\else
- \doifemptyvalue{\??tt\currenttabulate\c!after} % no expansion
+ \doifemptyvalue{\??tt\currenttabulation\c!after} % no expansion
{\vskip\strutdp
\verticalstrut
\vskip-\struttotal}%
\fi
\stoptabulatenoalign}
-\unexpanded\def\dotabulateTLfive
- {\dotabulatenobreak
- \dotabulateruleseparator
- \dotabulatenobreak
- \dotabulatehrule
- \dotabulatenobreak
- \dotabulateruleseparator
+\unexpanded\def\tabl_tabulate_TL_second_indeed
+ {\tabl_tabulate_nobreak_inject
+ \tabl_tabulate_column_rule_separator_inject
+ \tabl_tabulate_nobreak_inject
+ \tabl_tabulate_hrule_inject
+ \tabl_tabulate_nobreak_inject
+ \tabl_tabulate_column_rule_separator_inject
%\prevdepth\strutdp % todo, might differ between TL and BL
- \dotabulatenobreak
+ \tabl_tabulate_nobreak_inject
\stoptabulatenoalign}
-\let\dotabulateBLfive\dotabulateTLfive
+\let\tabl_tabulate_BL_second\tabl_tabulate_TL_second
-\def\tabulateHLfive
+\def\tabl_tabulate_HL_second
{\csname
- \ifnum\noftabulatelines=\zerocount F\else
- \ifnum\noftabulatelines=\totalnoftabulatelines L\else
- M\fi\fi
+ \ifnum\c_tabl_tabulate_noflines=\zerocount F\else
+ \ifnum\c_tabl_tabulate_noflines=\c_tabl_tabulate_totalnoflines L\else
+ M\fi\fi
L\endcsname}
-\def\tabulatedoHRfive % horizontal rule line (break untested)
- {\starttabulatenoalign
- \globallet\dotabulateautoline\dotabulatelinerule
- %\ifcase#1\or % todo: check what this does
- \ifnum\noftabulatelines=\zerocount
- \glet\dotabulateautoline\donothing
- \else\ifnum\noftabulatelines=\totalnoftabulatelines
- \glet\dotabulateautoline\donothing
- \fi\fi
- %\fi
- \dotabulatenobreak
- \stoptabulatenoalign
- \dotabulateautoline
- \starttabulatenoalign
- \nobreak
- \ifx\dotabulateautoline\dotabulatelinerule\kern-\lineheight\fi
- \ifnum\noftabulatelines=\totalnoftabulatelines
- \@EA\dotabulatenobreak
- \else
- \@EA\allowbreak
- \fi
- \stoptabulatenoalign
- \dotabulateautoline
- \starttabulatenoalign
- \dotabulatenobreak
- \stoptabulatenoalign}
+\appendtoks
+ \let\FL\tabl_tabulate_XX_none
+ \let\ML\tabl_tabulate_XX_none
+ \let\LL\tabl_tabulate_XX_none
+ \let\TL\tabl_tabulate_XX_none
+ \let\BL\tabl_tabulate_XX_none
+ \let\HL\tabl_tabulate_XX_none
+ \let\HR\tabl_tabulate_XX_none
+\to \t_tabl_tabulate_initializers_first
+
+\appendtoks
+ \let\FL\tabl_tabulate_FL_second
+ \let\ML\tabl_tabulate_ML_second
+ \let\LL\tabl_tabulate_LL_second
+ \let\TL\tabl_tabulate_TL_second
+ \let\BL\tabl_tabulate_BL_second
+ \let\HL\tabl_tabulate_HL_second
+ \let\HR\tabl_tabulate_HL_second
+\to \t_tabl_tabulate_initializers_second
+
+% \def\tabulatedoHRfive % horizontal rule line (break untested)
+% {\starttabulatenoalign
+% \globallet\dotabulateautoline\dotabulatelinerule
+% %\ifcase#1\or % todo: check what this does
+% \ifnum\noftabulatelines=\zerocount
+% \glet\dotabulateautoline\donothing
+% \else\ifnum\noftabulatelines=\totalnoftabulatelines
+% \glet\dotabulateautoline\donothing
+% \fi\fi
+% %\fi
+% \dotabulatenobreak
+% \stoptabulatenoalign
+% \dotabulateautoline
+% \starttabulatenoalign
+% \nobreak
+% \ifx\dotabulateautoline\dotabulatelinerule\kern-\lineheight\fi
+% \ifnum\noftabulatelines=\totalnoftabulatelines
+% \@EA\dotabulatenobreak
+% \else
+% \@EA\allowbreak
+% \fi
+% \stoptabulatenoalign
+% \dotabulateautoline
+% \starttabulatenoalign
+% \dotabulatenobreak
+% \stoptabulatenoalign}
% \dorecurse{10}{
% \starttabulate[|l|]
@@ -1584,7 +1870,7 @@
% \stoptabulate
% }
-% to be redone
+% This needs checking:
\def\tabulaterule {\HR} % a rule with lineheight
\def\tabulateline {\HL} % just a spaced rule
@@ -1599,27 +1885,27 @@
% places where we can use \LUA\ code (for instance in alignment of
% numbers. The repeat parser is replace at the \LUA\ end as well.
-\gdef\processtabulate[#1]% in the process of optimizing
- {\tabulateunit\tabulateparameter\c!unit
- \checkfulltabulatecontent
- \defaulttabulatevrulethickness\tabulateparameter\c!rulethickness
- \defaulttabulatehrulethickness\defaulttabulatevrulethickness
- \edef\defaulttabulatevrulecolor{\tabulateparameter\c!rulecolor}%
- \let\defaulttabulatehrulecolor\defaulttabulatevrulecolor
- \edef\@@tabulatealign{\executeifdefined{\??tt:\c!align:\tabulateparameter\c!align}0}%
- \tabulateposskip.5\tabulateunit
- \tabulatepreskip\zeropoint
- \firstpretabskip\tabulateposskip
- \lastposttabskip\tabulateposskip
- \global\tabulatecolumns\zerocount
- \global\nofautotabulate\zerocount
- \global\noftabulatelines\zerocount
- \totalnoftabulatelines\noftabulatelines
- \minusnoftabulatelines\noftabulatelines
- \global\tabulatepwidth\zeropoint
- \global\tabulatexwidth\zeropoint
- \global\setfalse\tabulateequal
- \resettabulatepheight
+\let\tabl_tabulate_flush_collected \empty
+\let\tabl_tabulate_flush_collected_indeed\empty
+
+\def\tabl_tabulate_process
+ {\c_tabl_tabulate_pass\plusone
+ \tabl_tabulate_check_full_content
+ \edef\v_tabl_tabulate_align{\executeifdefined{\??tabulatealigning\p_align}0}%
+ \s_tabl_tabulate_post.5\d_tabl_tabulate_unit
+ \s_tabl_tabulate_pre\zeropoint
+ \s_tabl_tabulate_first\s_tabl_tabulate_post
+ \s_tabl_tabulate_last\s_tabl_tabulate_post
+ \global\c_tabl_tabulate_columns\zerocount
+ \global\c_tabl_tabulate_nofauto\zerocount
+ \global\c_tabl_tabulate_noflines\zerocount
+ \c_tabl_tabulate_totalnoflines\zerocount
+ \c_tabl_tabulate_minusnoflines\zerocount
+ \global\d_tabl_tabulate_width_p\zeropoint
+ \global\d_tabl_tabulate_width_w\zeropoint
+ \global\setfalse\c_tabl_tabulate_equal
+ \tabl_tabulate_pheight_reset
+ \tabskip\zeropoint
\ifinsidesplitfloat
\donetrue
\else\ifinsidefloat
@@ -1628,138 +1914,106 @@
\donetrue
\fi\fi
\ifdone
- \tabulaterepeathead\executeifdefined{\??tt:\c!header:\tabulateparameter\c!header}\zerocount
+ \c_tabl_tabulate_repeathead\executeifdefined{\??tabulateheader\tabulationparameter\c!header}\zerocount
+ \else
+ \c_tabl_tabulate_repeathead\zerocount
\fi
- \let\VL\tabulateVLone
- \let\NC\tabulateNCone
- \let\RC\tabulateRCone
- \let\HC\tabulateHCone
- \let\EQ\tabulateEQone
- \let\RQ\tabulateRQone
- \let\HQ\tabulateHQone
- \let\NG\tabulateNGone
- \let\NN\tabulateNNone
- \let\ND\tabulateNDone
- \let\NR\tabulateNRone
- \let\NB\tabulateNBone
- \let\CC\tabulateCCone
- \let\CL\tabulateCLone
- \let\CM\tabulateCMone
- \let\CR\tabulateCRone
- \let\SR\NR
- \let\FR\NR
- \let\MR\NR
- \let\LR\NR
- \let\AR\NR
- \let\FL\tabulateXXnone
- \let\ML\tabulateXXnone
- \let\LL\tabulateXXnone
- \let\TL\tabulateXXnone
- \let\BL\tabulateXXnone
- \let\HL\tabulateXXnone
- \let\HR\tabulateXXnone
- \glet\flushtabulated\empty
- \tabskip\zeropoint
- \ifdim\tabulateparameter\c!margin>\zeropoint
- \tabulatepreamble{\aligntab\flushtabulateindent\strut\alignmark\alignmark\tabskip\tabulateparameter\c!margin\strut\aligntab\alignmark\alignmark\tabskip\zeropoint}%
+ %
+ \the\t_tabl_tabulate_initializers_first % collect more here
+ %
+ \glet\tabl_tabulate_flush_collected\empty
+ \ifdim\d_tabl_tabulate_margin>\zeropoint
+ \t_tabl_tabulate_preamble{\aligntab\tabl_tabulate_flush_indent\strut\alignmark\alignmark\tabskip\d_tabl_tabulate_margin\strut\aligntab\alignmark\alignmark\tabskip\zeropoint}%
\else
- \tabulatepreamble{\aligntab\flushtabulateindent\strut\alignmark\alignmark\aligntab\alignmark\alignmark\tabskip\zeropoint}%
+ \t_tabl_tabulate_preamble{\aligntab\tabl_tabulate_flush_indent\strut\alignmark\alignmark\aligntab\alignmark\alignmark\tabskip\zeropoint}%
\fi
- \tabulatewidth\zeropoint
- \ctxcommand{presettabulate(\!!bs\detokenize{#1}\!!es)}%
- \edef\totaltabulatecolumns{\the\numexpr3*\tabulatecolumns+4}%
- \tabulatewidth\zeropoint
- \initializetableboxes\tabulatecolumns
- \tabulatepreamble\expandafter{\the\tabulatepreamble
- \aligntab\alignmark\alignmark\global\advance\tabulatecolumn\plusone
+ \d_tabl_tabulate_width\zeropoint
+ % these counters are set at the lua end
+ \c_tabl_tabulate_nofcolumns \zerocount
+ \c_tabl_tabulate_has_rule_spec_first\zerocount
+ \c_tabl_tabulate_has_rule_spec_last \zerocount
+ \ctxcommand{presettabulate(\!!bs\detokenizedtabulationparameter\c!format\!!es)}%
+ %
+ % \edef\totaltabulatecolumns{\the\numexpr3*\c_tabl_tabulate_columns+\plusfour}%
+ \d_tabl_tabulate_width\zeropoint
+ \tabl_tabulate_initialize_boxes\c_tabl_tabulate_columns
+ \t_tabl_tabulate_preamble\expandafter{\the\t_tabl_tabulate_preamble
+ \aligntab\alignmark\alignmark\global\advance\c_tabl_tabulate_column\plusone
}%
- \tabulatedummy\expandafter{\the\tabulatedummy
- \NC\unskip\unskip\crcr\flushtabulated % no count
+ \t_tabl_tabulate_dummy\expandafter{\the\t_tabl_tabulate_dummy
+ \NC\unskip\unskip\crcr\tabl_tabulate_flush_collected % no count
}%
- \global\tabulatecolumn\zerocount
- \resettabulatepheight
- \let\bbskip\empty
- %\let\eeskip\empty
- \let\bskip \tabulatebskipone
- \let\eskip \tabulateeskipone
- \let\xbskip\tabulatexbskipone
- \let\xeskip\tabulatexeskipone
- \glet\tabulatehook\dotabulatehook
- \doif{\tabulateparameter\c!indenting}\v!no\forgetparindent
+ \global\c_tabl_tabulate_column\zerocount
+ \tabl_tabulate_pheight_reset
+ \glet\tabl_tabulate_hook\tabl_tabulate_hook_yes
+ \ifx\p_indenting\v!no
+ \forgetparindent
+ \fi
\ifinsidefloat
- \let\tabulateindent\!!zeropoint
+ \d_tabl_tabulate_indent\zeropoint
\else
- \setlocalhsize \hsize\localhsize
+ \setlocalhsize
+ \hsize\localhsize
\fi
\dontcomplain
\forgetall % hm, interference with preceding \forgetparindent probably bug, to be solved
\everypar\everytabulatepar
\setbox0\vbox % outside \if because of line counting
{\notesenabledfalse
- \let\tabulateindent\!!zeropoint
+ \d_tabl_tabulate_indent\zeropoint
\settrialtypesetting % very important
- \@EA\halign\@EA{\the\tabulatepreamble\crcr\fulltabulatecontent\crcr}}%
- \ifnum\nofautotabulate>\zerocount
- % so, even if the natural size is larger, in the final
- % run, we force the calculated width
- \tabulatewidth\dimexpr\hsize-\wd0-\tabulatepwidth-\tabulatexwidth\relax
- \ifnum\nofautotabulate>\zerocount
- \divide\tabulatewidth \nofautotabulate\relax
+ \expandafter\halign\expandafter{\the\t_tabl_tabulate_preamble\crcr\tabl_tabulate_insert_content\crcr}}%
+ \ifnum\c_tabl_tabulate_nofauto>\zerocount
+ % so, even if the natural size is larger, in the final run, we force the calculated width
+ \d_tabl_tabulate_width\dimexpr\hsize-\wd0-\d_tabl_tabulate_width_p-\d_tabl_tabulate_width_w\relax
+ \ifnum\c_tabl_tabulate_nofauto>\zerocount
+ \divide\d_tabl_tabulate_width \c_tabl_tabulate_nofauto\relax
\fi
\fi
- \let\xbskip\tabulatexbskiptwo
- \let\xeskip\tabulatexeskiptwo
- \ifconditional\tabulatesplit
+ \ifconditional\c_tabl_tabulate_split
\splittopskip\strutht
- \glet\flushtabulatedindeed\empty
- \let\bbskip\tabulatebbskiptwo
- \let\bskip\tabulatebskiptwo
- \glet\flushtabulated\tabulateflushtabulatedtwo
- \else
- % tabhook op alles ?
- \let\bskip\tabulatebskipthree
- \let\eskip\tabulateeskipthree
+ \glet\tabl_tabulate_flush_collected_indeed\empty
+ \glet\tabl_tabulate_flush_collected\tabl_tabulate_flush_second
+ \fi
+ \c_tabl_tabulate_totalnoflines\c_tabl_tabulate_noflines
+ \c_tabl_tabulate_minusnoflines\numexpr\c_tabl_tabulate_noflines+\minusone\relax
+ \global\c_tabl_tabulate_noflines\zerocount
+ %
+ \c_tabl_tabulate_pass\plustwo % final pass
+ \the\t_tabl_tabulate_initializers_second % collect more here
+ %
+ \ifx\p_line\v!line
+ \let\HL\HR
+ \let\tabulateautoline\tabulateautorule
+ \let\tabulateline\tabulaterule
\fi
- \totalnoftabulatelines\noftabulatelines
- \minusnoftabulatelines\numexpr\noftabulatelines+\minusone\relax
- \global\noftabulatelines\zerocount
- \let\FL\tabulateFLfive
- \let\ML\tabulateMLfive
- \let\LL\tabulateLLfive
- \let\TL\tabulateTLfive
- \let\BL\tabulateBLfive
- \let\HL\tabulateHLfive
- \let\HR\tabulateHRfive
- \doif{\tabulateparameter\c!rule}\v!line
- {\let\HL\HR
- \let\tabulateautoline\tabulateautorule
- \let\tabulateline\tabulaterule}%
- \tabulatepass\plustwo
%
- \ifcase\tabulaterepeathead
+ \ifcase\c_tabl_tabulate_repeathead
\ifinsidesplitfloat
- \global\setbox\tabulatebox\vbox \bgroup
+ \global\setbox\b_tabl_tabulate\vbox \bgroup
\else
- \startframedcontent[\tabulateparameter\c!frame]%
+ \startframedcontent[\tabulationparameter\c!frame]%
\fi
\else
- \global\setbox\tabulatebox\vbox \bgroup
+ \global\setbox\b_tabl_tabulate\vbox \bgroup
\fi
%
\dostarttagged\t!tabulate\empty
\dostarttagged\t!tabulaterow\empty
\everycr\expandafter{\the\everycr\dostoptagged\dostarttagged\t!tabulaterow\empty}%
- \@EA\halign\@EA{\the\tabulatepreamble\crcr\fulltabulatecontent\crcr}%
+ \expandafter\halign\expandafter{\the\t_tabl_tabulate_preamble\crcr\tabl_tabulate_insert_content\crcr}%
\dostoptagged
\dostoptagged
\ifhmode\par\prevdepth\strutdp\fi % nog eens beter, temporary hack
- \doif{\tabulateparameter\c!distance}\v!grid{\vskip-\strutdp}% experimental tm-prikkels
+ \ifx\p_distance\v!grid
+ \vskip-\strutdp % experimental tm-prikkels
+ \fi
%
- \ifcase\tabulaterepeathead
+ \ifcase\c_tabl_tabulate_repeathead
\ifinsidesplitfloat
\egroup % box
\egroup % settings
- \splittabulatebox\tabulatebox
+ \tabl_split_box\b_tabl_tabulate
\else
\stopframedcontent
\egroup
@@ -1767,11 +2021,11 @@
\else
\egroup % box
\egroup % settings
- \splittabulatebox\tabulatebox
+ \tabl_split_box\b_tabl_tabulate
\fi
%
\ifinsidefloat \else
- \tabulateparameter\c!after
+ \tabulationparameter\c!after
\fi
\egroup} % whole thing
@@ -1792,25 +2046,25 @@
% \NC test \NC \input tufte \relax \NC \NR
% \stoptabulate
-\def\splittabulatebox#1% #1 <> 0/2 / derived from the one in core-ntb.tex
+\def\tabl_split_box#1% #1 <> 0/2 / derived from the one in core-ntb.tex
{\ifinsidesplitfloat
- \dosplittabulatebox#1%
+ \tabl_split_box_indeed#1%
\else\ifinsidefloat
\unvbox#1%
\else
- \dosplittabulatebox#1%
+ \tabl_split_box_indeed#1%
\fi\fi}
-\def\dosplittabulatebox#1%
+\def\tabl_split_box_indeed#1%
{\resettsplit
\def\tsplitminimumfreelines{2}%
\def\tsplitminimumfreespace{0pt}%
\setbox\tsplitcontent\box#1%
- \ifcase\tabulaterepeathead\or
+ \ifcase\c_tabl_tabulate_repeathead\or
\setbox\tsplithead\vsplit\tsplitcontent to \lineheight
\setbox\tsplithead\vbox{\unvbox\tsplithead}%
\or
- \setbox\tsplithead\vbox{\hbox{\strut\tabulateparameter\c!title}}%
+ \setbox\tsplithead\vbox{\hbox{\strut\tabulationparameter\c!title}}%
\fi
\handletsplit}
@@ -1837,11 +2091,11 @@
% \NC text \NC text \NC \NR
% \stoptabulate
-\def\TabulateTB
+\def\tabl_tabulate_TB
{\starttabulatenoalign
- \dosingleempty\doTabulateTB}
+ \dosingleempty\tabl_tabulate_TB_indeed}
-\def\doTabulateTB[#1]%
+\def\tabl_tabulate_TB_indeed[#1]%
{\iffirstargument
\blank[#1]
\else
@@ -1851,26 +2105,26 @@
% to be tested:
%
-% \def\TabulateTB
+% \def\tabl_tabulate_TB
% {\starttabulatenoalign
-% \doiffastoptionalcheckelse\doTabulateTByes\doTabulateTBnop}
+% \doiffastoptionalcheckelse\tabl_tabulate_TB_yes\tabl_tabulate_TB_nop}
%
-% \def\doTabulateTByes[#1]%
+% \def\tabl_tabulate_TB_yes[#1]%
% {\blank[#1]
% \stoptabulatenoalign}
%
-% \def\doTabulateTBnop[#1]%
+% \def\tabl_tabulate_TB_nop[#1]%
% {\blank
% \stoptabulatenoalign}
\appendtoks
- \let\TB\TabulateTB
+ \let\TB\tabl_tabulate_TB
\to \everytabulate
%D Some new trickery:
%D
%D \startbuffer
-%D \settrue\splitofftabulatewhitespace
+%D \settrue\c_tabl_tabulate_splitoff_whitespace
%D
%D \starttabulate[|p(2cm)|p(2cm)|p(2cm)|]
%D \NC test 1a \NC test 2a \NC test 3a
@@ -1954,35 +2208,4 @@
% \NC \digits $@@@.@@1,@@$ \NC\NR
% \stoptabulatie
-\unexpanded\def\setuptabulate
- {\dotripleempty\dosetuptabulate}
-
-\def\dosetuptabulate[#1][#2][#3]%
- {\ifthirdargument
- \getparameters[\??tt#1::#2][#3]%
- \else\ifsecondargument
- \getparameters[\??tt#1::][#2]%
- \else
- \getparameters[\??tt\v!tabulate::][#1]%
- \fi\fi}
-
-\setuptabulate
- [\c!unit=1em,
- EQ={:},
- \c!frame=\v!off,
- \c!bodyfont=,
- \c!rule=\v!normal,
- \c!rulecolor=,
- \c!rulethickness=\linewidth,
- \c!inner=,
- \c!before=\blank,
- \c!after=\blank,
- \c!distance={\v!depth,\v!medium},
- \c!align=\v!normal,
- \c!margin=\!!zeropoint,
- \c!split=\v!auto,
- \c!header=\v!yes,
- \c!title=,
- \c!indenting=\v!no]
-
\protect \endinput
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index c5a3e3028..dc872498a 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 01/12/12 11:03:39
+-- merge date : 01/16/12 18:33:15
do -- begin closure to overcome local limits and interference
@@ -5380,7 +5380,7 @@ local otf = fonts.handlers.otf
otf.glists = { "gsub", "gpos" }
-otf.version = 2.735 -- beware: also sync font-mis.lua
+otf.version = 2.736 -- beware: also sync font-mis.lua
otf.cache = containers.define("fonts", "otf", otf.version, true)
local fontdata = fonts.hashes.identifiers
@@ -6360,7 +6360,8 @@ actions["reorganize subtables"] = function(data,filename,raw)
for k=1,#dw do
local gk = dw[k]
local features = gk.features
- if features and supported(features) then
+-- if features and supported(features) then
+ if not features or supported(features) then -- not always features !
local typ = gk.type
local chain = g_directions[typ] or 0
local subtables = gk.subtables
@@ -6388,7 +6389,6 @@ actions["reorganize subtables"] = function(data,filename,raw)
--
local name = gk.name
--
- local features = gk.features
if features then
-- scripts, tag, ismac
local f = { }
@@ -10338,11 +10338,15 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence
if nofchainlookups == 1 then
local chainlookupname = chainlookups[1]
local chainlookup = lookuptable[chainlookupname]
- local cp = chainprocs[chainlookup.type]
- if cp then
- start, done = cp(start,last,kind,chainname,ck,lookuphash,chainlookup,chainlookupname,nil,sequence)
- else
- logprocess("%s: %s is not yet supported",cref(kind,chainname,chainlookupname),chainlookup.type)
+ if chainlookup then
+ local cp = chainprocs[chainlookup.type]
+ if cp then
+ start, done = cp(start,last,kind,chainname,ck,lookuphash,chainlookup,chainlookupname,nil,sequence)
+ else
+ logprocess("%s: %s is not yet supported",cref(kind,chainname,chainlookupname),chainlookup.type)
+ end
+ else -- shouldn't happen
+ logprocess("%s is not yet supported",cref(kind,chainname,chainlookupname))
end
else
local i = 1