summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/math-stc.mkvi
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/math-stc.mkvi')
-rw-r--r--tex/context/base/mkiv/math-stc.mkvi208
1 files changed, 152 insertions, 56 deletions
diff --git a/tex/context/base/mkiv/math-stc.mkvi b/tex/context/base/mkiv/math-stc.mkvi
index 208e756f6..c9d469d61 100644
--- a/tex/context/base/mkiv/math-stc.mkvi
+++ b/tex/context/base/mkiv/math-stc.mkvi
@@ -69,12 +69,20 @@
% currently no italic correction ... problem is that we don't know yet if we have an italic
% below so we we need to postpone
-\def\math_stackers_fallback
- {\hbox to \scratchwidth{\csname\??mathextensiblefallbacks\ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname\number\scratchunicode\fi\endcsname}}
- %{\csname\??mathextensiblefallbacks\ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname\number\scratchunicode\fi\endcsname }
+% \def\math_stackers_fallback
+% {\hbox to \scratchwidth{\csname\??mathextensiblefallbacks\ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname\number\scratchunicode\fi\endcsname}}
+% %{\csname\??mathextensiblefallbacks\ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname\number\scratchunicode\fi\endcsname }
-% \def\math_stackers_regular
-% {\mathstylehbox{\Umathaccent\fam\zerocount\scratchunicode{\hskip\scratchwidth}}}
+\def\math_stackers_fallback
+ {\mathstylehbox to \scratchwidth{\usemathstackerscolorparameter\c!color
+ \hss
+ \hskip\mathstackersparameter\c!topoffset\relax % for manual italic correction
+ \ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname
+ \lastnamedcs
+ \else
+ \Umathchar \fam \zerocount \scratchunicode
+ \fi
+ \hss}}
\def\math_stackers_regular
{\mathstylehbox{\usemathstackerscolorparameter\c!color
@@ -89,7 +97,8 @@
% $\Umathaccent 0 0 "2190{x}$ \par $\Umathaccent 0 0 "27F8{x}$\par
% $\Udelimiterunder 0 "2190{x}$ \par $\Udelimiterunder 0 "27F8{x}$\par
-\setvalue{\??mathextensiblefallbacks}{\hbox{\vrule\!!width\scratchwidth\!!height.1\exheight\!!depth\zeropoint}}
+\setvalue{\??mathextensiblefallbacks}%
+ {\hpack{\vrule\s!width\scratchwidth\s!height.1\mathexheight\s!depth\zeropoint}}
% \def\math_stackers_with_fallback#codepoint%
% {\begingroup
@@ -151,16 +160,13 @@
\c!right=,
\c!mathclass=\s!rel,
\c!alternative=\v!normal,
- \c!mp=math:stacker:\number\scratchunicode,
- \c!mpheight=\exheight,
- \c!mpdepth=\exheight,
- \c!mpoffset=.25\exheight,
- \c!voffset=.25\exheight,
- \c!hoffset=.5\emwidth,
+ \c!voffset=.25\mathexheight,
+ \c!hoffset=\zeropoint,
+ \c!topoffset=\zeropoint, % for manual italic correction
\c!distance=\mathstackersparameter\c!voffset, % distance between symbol and base (can be different from voffset)
- \c!minheight=\exheight,
+ \c!minheight=\mathexheight,
\c!mindepth=\zeropoint,
- \c!minwidth=.5\emwidth,
+ \c!minwidth=.5\mathemwidth,
\c!order=\v!normal,
\c!strut=,
\c!color=, % todo: when I need it
@@ -220,16 +226,46 @@
\letvalue{\??mathstackersalternative\v!normal }\math_stackers_content
\letvalue{\??mathstackersalternative\v!default}\math_stackers_content
+\setupmathstackers
+ [\c!mp=math:stacker:\number\scratchunicode,
+ \c!mpheight=\mathcharht\scratchunicode,
+ \c!mpdepth=\mathchardp\scratchunicode,
+ \c!mpoffset=.25\mathexheight]
+
+% \setvalue{\??mathstackersalternative\v!mp}%
+% {\hbox\bgroup % todo: add code key + tag
+% \d_overlay_width \scratchwidth
+% \d_overlay_height \dimexpr\mathstackersparameter\c!mpheight
+% \d_overlay_depth \dimexpr\mathstackersparameter\c!mpdepth
+% \d_overlay_offset \dimexpr\mathstackersparameter\c!mpoffset
+% \d_overlay_linewidth\linewidth
+% \edef\overlaylinecolor{\mathstackersparameter\c!color}%
+% \edef\p_mp{\mathstackersparameter\c!mp}%
+% \uniqueMPgraphic{\p_mp}%
+% \egroup}
+
\setvalue{\??mathstackersalternative\v!mp}%
- {\hbox\bgroup % todo: add code key + tag
+ {\normalexpanded{\math_stackers_mp_box
+ {\the\dimexpr\mathstackersparameter\c!mpheight}%
+ {\the\dimexpr\mathstackersparameter\c!mpdepth}%
+ {\the\dimexpr\mathstackersparameter\c!mpoffset}%
+ {\the\dimexpr\triggeredmathstyleparameter\Umathfractionrule}%
+ {\the\dimexpr\triggeredmathstyleparameter\Umathaxis}%
+ {\the\mathexheight}%
+ {\the\mathemwidth}%
+ }}
+
+\unexpanded\def\math_stackers_mp_box#1#2#3#4#5#6#7%
+ {\hpack\bgroup % todo: add code key + tag
+ % we can speed up \mathexheight expansion a bit
\d_overlay_width \scratchwidth
- \d_overlay_height \dimexpr\mathstackersparameter\c!mpheight
- \d_overlay_depth \dimexpr\mathstackersparameter\c!mpdepth
- \d_overlay_offset \dimexpr\mathstackersparameter\c!mpoffset
- \d_overlay_linewidth\linewidth
+ \d_overlay_height #1\relax
+ \d_overlay_depth #2\relax
+ \d_overlay_offset #3\relax
+ \d_overlay_linewidth#4\relax
\edef\overlaylinecolor{\mathstackersparameter\c!color}%
\edef\p_mp{\mathstackersparameter\c!mp}%
- \uniqueMPgraphic{\p_mp}%
+ \uniqueMPgraphic{\p_mp}{axis=#5,ex=#6,em=#7}%
\egroup}
\def\math_stackers_check_unicode#codepoint%
@@ -241,7 +277,7 @@
% heads/tails + hoffset
\else\ifx\p_offset\v!min
% heads/tails - hoffset
- \advance\scratchleftoffset-\scratchhoffset
+ \advance\scratchleftoffset -\scratchhoffset
\advance\scratchrightoffset-\scratchhoffset
\else % \v!normal
% hoffset
@@ -288,15 +324,27 @@
\ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
{\edef\p_offset {\mathstackersparameter\c!offset}%
\edef\p_location {\mathstackersparameter\c!location}%
- \edef\p_order {\mathstackersparameter\c!order}%
\edef\p_strut {\mathstackersparameter\c!strut}%
\edef\p_alternative{\mathstackersparameter\c!alternative}%
- \ifx\p_order\v!reverse
- \edef\m_math_stackers_text_top {#bottomtext}%
- \edef\m_math_stackers_text_bottom{#toptext}%
- \else
- \edef\m_math_stackers_text_top {#toptext}%
- \edef\m_math_stackers_text_bottom{#bottomtext}%
+ % \ifx\p_order\v!reverse
+ % \ifsecondargument
+ % \edef\m_math_stackers_text_top {#bottomtext}%
+ % \edef\m_math_stackers_text_bottom{#toptext}%
+ % \else
+ % \edef\m_math_stackers_text_top {#toptext}%
+ % \let\m_math_stackers_text_bottom \empty
+ % \fi
+ % \else
+ % \edef\m_math_stackers_text_top {#toptext}%
+ % \edef\m_math_stackers_text_bottom{#bottomtext}%
+ % \fi
+ \edef\m_math_stackers_text_top {#toptext}%
+ \edef\m_math_stackers_text_bottom{#bottomtext}%
+ \ifsecondargument
+ \edef\p_order{\mathstackersparameter\c!order}%
+ \ifx\p_order\v!reverse
+ \swapmacros\m_math_stackers_text_top\m_math_stackers_text_bottom
+ \fi
\fi
\scratchleftoffset \zeropoint
\scratchrightoffset\zeropoint
@@ -317,13 +365,20 @@
\fi
%
\ifcase#method\relax
- \scratchwidth\wd
- \ifdim\wd\scratchboxone>\wd\scratchboxtwo
- \scratchboxone
- \else
- \scratchboxtwo
- \fi
- \relax
+ % e.g. extensible
+ %\scratchwidth\wd
+ % \ifdim\wd\scratchboxone>\wd\scratchboxtwo
+ % \scratchboxone
+ % \else
+ % \scratchboxtwo
+ % \fi
+ %\relax
+ \scratchwidth\mathcharwd\scratchunicode
+ \ifdim\wd\scratchboxone>\scratchwidth
+ \scratchwidth\wd\scratchboxone
+ \else\ifdim\wd\scratchboxtwo>\scratchwidth
+ \scratchwidth\wd\scratchboxtwo
+ \fi\fi
\else
\ifx\m_math_stackers_text_middle\empty
\setbox\scratchboxthree\emptyhbox
@@ -645,21 +700,50 @@
\unexpanded\def\mathunder {\begingroup\dosingleempty\math_stackers_handle_under }
\unexpanded\def\mathdouble{\begingroup\dodoubleempty\math_stackers_handle_double}
-\def\math_stackers_handle_over[#category]%
- {\math_stackers_direct_double\plusone\zerocount
- {\iffirstargument#category\else\v!top \fi}} % will be defined later on
+\unexpanded\def\definemathover {\dotripleargument \math_stackers_define_over }
+\unexpanded\def\definemathunder {\dotripleargument \math_stackers_define_under }
+\unexpanded\def\definemathdouble{\doquadrupleargument\math_stackers_define_double}
+
+\def\math_stackers_define_over[#category][#command][#topcode]%
+ {\setuvalue{#command}{\math_stackers_handle_direct\plusone\zerocount{#category}{#topcode}{0}}}
-\def\math_stackers_handle_under[#category]%
- {\math_stackers_direct_double\zerocount\plusone
- {\iffirstargument#category\else\v!bottom\fi}} % will be defined later on
+\def\math_stackers_define_under[#category][#command][#bottomcode]%
+ {\setuvalue{#command}{\math_stackers_handle_direct\zerocount\plusone{#category}{#bottomcode}{0}}}
-\def\math_stackers_handle_double[#topcategory][#bottomcategory]%
- {\math_stackers_direct_double\plusone\plusone
- {\iffirstargument #topcategory\else\v!top \fi}%
- {\ifsecondargument#bottomcategory\else\v!bottom\fi}}
+\def\math_stackers_define_double[#category][#command][#topcode][#bottomcode]%
+ {\setuvalue{#command}{\math_stackers_handle_direct\plusone\plusone{#category}{#topcode}{#bottomcode}}}
-\def\math_stackers_direct_double#top#bottom#category#codepoint#text%
- {\math_stackers_make_double#top#bottom{#category}{#codepoint}{0}{#text}%
+\unexpanded\def\mathover {\begingroup\dosingleempty\math_stackers_handle_over }
+\unexpanded\def\mathunder {\begingroup\dosingleempty\math_stackers_handle_under }
+\unexpanded\def\mathdouble{\begingroup\dosingleempty\math_stackers_handle_double}
+
+\def\math_stackers_handle_over[#category]#topcode#text%
+ {\math_stackers_make_double\plusone\zerocount
+ {\iffirstargument#category\else\v!top\fi}%
+ {#topcode}%
+ {0}%
+ {#text}%
+ \endgroup}
+
+\def\math_stackers_handle_under[#category]#bottomcode#text%
+ {\math_stackers_make_double\zerocount\plusone
+ {\iffirstargument#category\else\v!bottom\fi}%
+ {#bottomcode}%
+ {0}%
+ {#text}%
+ \endgroup}
+
+\def\math_stackers_handle_double[#category]#topcode#bottomcode#text%
+ {\math_stackers_make_double\plusone\plusone
+ {\iffirstargument#category\else\v!both\fi}%
+ {#topcode}%
+ {#bottomcode}%
+ {#text}%
+ \endgroup}
+
+\def\math_stackers_handle_direct#top#bottom#category#topcode#bottomcode#text%
+ {\begingroup
+ \math_stackers_make_double#top#bottom{#category}{#topcode}{#bottomcode}{#text}%
\endgroup}
%D A relative new one is a combination of accents and text (as needed in mathml):
@@ -981,10 +1065,10 @@
%D Here come the new ones:
\definemathstackers [\v!none] [\v!mathematics] [\c!hoffset=\zeropoint]
-\definemathstackers [\v!normal] [\v!mathematics] [\c!hoffset=0.5\emwidth] % the default
-\definemathstackers [\v!small] [\v!mathematics] [\c!hoffset=1\emwidth]
-\definemathstackers [\v!medium] [\v!mathematics] [\c!hoffset=1.5\emwidth]
-\definemathstackers [\v!big] [\v!mathematics] [\c!hoffset=2\emwidth]
+\definemathstackers [\v!normal] [\v!mathematics] [\c!hoffset=0.5\mathemwidth] % the default
+\definemathstackers [\v!small] [\v!mathematics] [\c!hoffset=1\mathemwidth]
+\definemathstackers [\v!medium] [\v!mathematics] [\c!hoffset=1.5\mathemwidth]
+\definemathstackers [\v!big] [\v!mathematics] [\c!hoffset=2\mathemwidth]
\definemathextensible [\v!reverse] [xrel] ["002D]
\definemathextensible [\v!reverse] [xequal] ["003D]
@@ -1146,7 +1230,7 @@
[\c!offset=\v!max,
\c!left=\enspace,
\c!right=\enspace,
- \c!hoffset=.5\emwidth]
+ \c!hoffset=.5\mathemwidth]
\definemathextensible [\v!chemistry] [cleftarrow] ["2190]
\definemathextensible [\v!chemistry] [crightarrow] ["2192]
@@ -1197,14 +1281,14 @@
\unexpanded\def\defineextensiblefiller
{\dodoubleargument\math_stackers_define_filler}
-\def\math_stackers_define_filler[#1][#2]%
- {\setuevalue{#1}{\leaders\number#2\hfill}}
+% \def\math_stackers_define_filler[#1][#2]%
+% {\setuevalue{#1}{\leaders\number#2\hfill}}
-%D For the moment:
+%D For the moment (needs checking):
\def\math_stackers_define_filler[#1][#2]%
{\expandafter\let\csname\??mathextensiblefallbacks\number#2\expandafter\endcsname\csname#1\endcsname
- \expandafter\let\csname #1\expandafter\endcsname\csname#1\endcsname}
+ \expandafter\let\csname #1\expandafter\endcsname\csname#1\endcsname} % huh?
\defineextensiblefiller [barfill] ["203E]
\defineextensiblefiller [relfill] ["002D]
@@ -1283,6 +1367,18 @@
\definemathunstacked [\v!wide] [implies] ["27F9] % \mathrel{\;\Longrightarrow\;}
\definemathunstacked [\v!wide] [iff] ["27FA] % \mathrel{\;\Longleftrightarrow\;}
+% New (an example of using \mathexheight):
+
+\definemathstackers
+ [\v!symbol]
+ [\c!voffset=-.3\mathexheight,
+ \c!hoffset=\zeropoint,
+ \c!mathclass=ord,
+ \c!topoffset=.4\mathemwidth, % poor man's italic correction
+ \c!middlecommand=\mathematics]
+
+\definemathover[\v!symbol][interiorset]["2218]
+
\protect \endinput
% \mathrel{\mathop{\hbox to \dimen0{\hss\copy4\hss}}