diff options
Diffstat (limited to 'tex/context/base/enco-ini.mkiv')
-rw-r--r-- | tex/context/base/enco-ini.mkiv | 111 |
1 files changed, 48 insertions, 63 deletions
diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv index 3b0cbc9fc..a942d5110 100644 --- a/tex/context/base/enco-ini.mkiv +++ b/tex/context/base/enco-ini.mkiv @@ -43,32 +43,22 @@ %D \macros %D {defineaccent, definecharacter, definecommand} -\installcorenamespace{accents} +\unexpanded\def\dodefineaccentcommand#1% + {\setevalue{\string#1}{\noexpand\dohandleaccent{\string#1}}} + +\unexpanded\def\dodefineaccent#1#2#3% no spaces, used low level + {\setvalue{\??ac\string#1\string#2\empty}{#3}} \unexpanded\def\defineaccent#1 #2 #3 % - {\enco_define_accent_command{#1}% - \enco_define_accent{#1}{#2}{#3}} - -\unexpanded\def\enco_define_accent_command#1% - {\setevalue{\string#1}{\noexpand\enco_handle_accent{\string#1}}} - -\unexpanded\def\enco_define_accent#1#2#3% no spaces, used low level - {\setvalue{\??accents\string#1\string#2\empty}{#3}} - -\def\enco_handle_accent#1#2% expandable because we want them in the tuc file - {\csname\??accents - \ifcsname\??accents\string#1#2\empty\endcsname - \string#1#2\empty - \else\ifcsname\??accents\string#1\string#2\empty\endcsname - \string#1\string#2\empty - \else - \empty - \fi\fi - \endcsname} - -\let\dohandleaccent \enco_handle_accent % maybe useful -\let\dodefineaccent \enco_define_accent % used at the lua end -\let\dodefineaccentcommand\enco_define_accent_command % used at the lua end + {\dodefineaccentcommand{#1}% + \dodefineaccent{#1}{#2}{#3}} + +\def\dohandleaccent#1#2% + {\ifcsname\??ac\string#1#2\empty\endcsname + \csname\??ac\string#1#2\empty\endcsname + \else\ifcsname\??ac\string#1\string#2\empty\endcsname + \csname\??ac\string#1\string#2\empty\endcsname + \fi\fi} \unexpanded\def\definecharacter#1 #2 % {\doifnumberelse{\string#2} @@ -87,15 +77,15 @@ %D Accent handling (try to avoid this): -\newbox\b_enco_accent +\newbox\accenttestbox % no longer global so we could use \scratchbox \def\buildmathaccent#1% {\mathaccent#1 } \unexpanded\def\buildtextaccent#1#2% we could do all at the lua end {\begingroup % but that's no fun (yet) - \setbox\b_enco_accent\hbox{#1}% - \scratchcounter\cldcontext{nodes.firstcharinbox(\number\b_enco_accent)}\relax + \setbox\accenttestbox\hbox{#1}% + \scratchcounter\cldcontext{nodes.firstcharinbox(\number\accenttestbox)}\relax \ifcase\scratchcounter\else\accent\scratchcounter\fi \relax#2% \endgroup} @@ -115,7 +105,7 @@ \hidewidth \hskip#2\wd0 \hskip-#3\slantperpoint % in plain 1ex * dimenless value - \vbox to .2\exheight{\box0\vss}\hidewidth + \vbox to .2ex{\box0\vss}\hidewidth \crcr}}} \unexpanded\def\buildtextmacron {\bottomaccent{.25ex}{0}{15}{\textmacron}} @@ -138,8 +128,7 @@ \egroup \egroup} -\unexpanded\def\buildtextgrave - {\topaccent{0pt}{0}{15}{\textgrave}} % e.g. +\def\buildtextgrave{\topaccent{0pt}{0}{15}{\textgrave}} % e.g. \unexpanded\def\definemathaccent#1 #2% {\setvalue{#1}{\mathaccent#2 }} @@ -235,7 +224,7 @@ % left-overs (some day in private unicode space, so that we can roundtrip) -\unexpanded\def\textblacksquare {\dontleavehmode\hbox{\vrule\s!width.3\s!em\s!height.4\s!em\s!depth-.1\s!em}} +\unexpanded\def\textblacksquare {\dontleavehmode\hbox{\vrule\!!width.3\s!em\!!height.4\s!em\!!depth-.1\s!em}} \unexpanded\def\schwa {\hbox{\rotate[\c!rotation=180,\c!location=\v!high]{\hbox{e}}}} \unexpanded\def\schwagrave {\buildtextgrave\schwa} @@ -255,28 +244,28 @@ \let\textvisiblespace\normalcontrolspace \unexpanded\def\fastcontrolspace % no glyph resolving after first (use grouped) - {\enco_fast_control_space} + {\dofastcontrolspace} -\def\enco_fast_control_space +\def\dofastcontrolspace {\iffontchar\font\textcontrolspace - \enco_fast_control_space_nop + \nofastfallbackcontrolspace \else - \enco_fast_control_space_yes + \dofastfallbackcontrolspace \fi - \enco_fast_control_space} + \dofastcontrolspace} -\newbox\b_enco_control_space +\newbox\controlspacebox -\def\enco_fast_control_space_nop - {\let\enco_fast_control_space\textcontrolspace} +\def\nofastfallbackcontrolspace + {\let\dofastcontrolspace\textcontrolspace} -\def\enco_fast_control_space_yes - {\setbox\b_enco_control_space\hbox{\space}% - \setbox\b_enco_control_space\hbox to \wd\b_enco_control_space{\hss\fallbackcontrolspace\hss}% - \let\enco_fast_control_space\flushcontrolspacebox} +\def\dofastfallbackcontrolspace + {\setbox\controlspacebox\hbox{\space}% + \setbox\controlspacebox\hbox to \wd\controlspacebox{\hss\fallbackcontrolspace\hss}% + \let\dofastcontrolspace\flushcontrolspacebox} \def\flushcontrolspacebox - {\copy\b_enco_control_space} + {\copy\controlspacebox} % a few defaults (\<whatever>{}), we really need the verbose \empty as it will be % stringified .. anyhow, we define this at the lua end now but keep it here as a @@ -300,39 +289,39 @@ % from enco-mis: -\unexpanded\def\fakepercent - {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25\emwidth/\kern-.2\emwidth\normalsubscript{\scriptscriptstyle0}}} +\def\fakepercent + {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25em/\kern-.2em\normalsubscript{\scriptscriptstyle0}}} -\unexpanded\def\fakeperthousand - {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25\emwidth/\kern-.2\emwidth\normalsubscript{\scriptscriptstyle00}}} +\def\fakeperthousand + {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25em/\kern-.2em\normalsubscript{\scriptscriptstyle00}}} -\unexpanded\def\fakepermine +\def\fakepermine {\dontleavehmode \bgroup \setbox\scratchbox\hbox {\mathematics{+}}% \hbox to \wd\scratchbox {\hss - \mathematics{\normalsuperscript{\scriptscriptstyle-}\kern-.4\emwidth/\kern-.3\emwidth\normalsubscript{\scriptscriptstyle-}}% + \mathematics{\normalsuperscript{\scriptscriptstyle-}\kern-.4em/\kern-.3em\normalsubscript{\scriptscriptstyle-}}% \hss}% \egroup} %D A smaller and bolder variant, more like the math and monospaced ones. -\unexpanded\def\fakeunderscore +\def\fakeunderscore {\relax\ifmmode - \vrule\s!depth .12\fontexheight\mathstylefont\normalmathstyle\s!width \fontinterwordspace\mathstylefont\normalmathstyle\s!height\zeropoint\relax + \vrule\!!depth .12\fontexheight\mathstylefont\normalmathstyle\!!width \fontinterwordspace\mathstylefont\normalmathstyle\!!height\zeropoint\relax \else - \dontleavehmode\hbox{\vrule\s!depth .12\fontexheight\font\s!width \fontinterwordspace\font\s!height\zeropoint}% + \dontleavehmode\hbox{\vrule\!!depth .12\fontexheight\font\!!width \fontinterwordspace\font\!!height\zeropoint}% \fi} -\unexpanded\def\fakeunderscores{\let\_\fakeunderscore} -\unexpanded\def\textunderscores{\let\_\textunderscore} +\def\fakeunderscores{\let\_\fakeunderscore} +\def\textunderscores{\let\_\textunderscore} \textunderscores -\ifdefined\mathunderscore \else \let\mathunderscore\fakeunderscore \fi -\ifdefined\textunderscore \else \let\textunderscore\fakeunderscore \fi +\ifx\mathunderscore\undefined \let\mathunderscore\fakeunderscore \fi +\ifx\textunderscore\undefined \let\textunderscore\fakeunderscore \fi \unexpanded\def\normalunderscore{\ifmmode\mathunderscore\else\textunderscore\fi} @@ -360,7 +349,7 @@ \def\periodsdefault{3} % was 5, but now it's like \unknown \unexpanded\def\periods - {\dosingleempty\enco_periods} + {\dosingleempty\doperiods} % \def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 % {\dontleavehmode @@ -372,7 +361,7 @@ % % better for export: -\unexpanded\def\enco_periods[#1]% todo: also n=,width= or maybe just #1,#2 +\unexpanded\def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 {\dontleavehmode \hbox\bgroup \setbox\scratchbox\hbox to \periodswidth{\hss.\hss}% @@ -388,8 +377,4 @@ % % Hello\fourdots\ World\fourdots \par Hello\fourdots\ World. -\appendtoks - \let\buildtextaccent\secondoftwoarguments -\to \everysimplifycommands - \protect \endinput |