diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/enco-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/enco-ini.mkiv | 238 |
1 files changed, 173 insertions, 65 deletions
diff --git a/Master/texmf-dist/tex/context/base/enco-ini.mkiv b/Master/texmf-dist/tex/context/base/enco-ini.mkiv index ab3aa488da1..b2e7efd3e5e 100644 --- a/Master/texmf-dist/tex/context/base/enco-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/enco-ini.mkiv @@ -66,12 +66,16 @@ \fi\fi \endcsname} +\unexpanded\def\enco_define_command#1#2% + {\setuvalue{\string#1}{#2}} + \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 +\let\dodefinecommand \enco_define_command % used at the lua end \unexpanded\def\definecharacter#1 #2 % - {\doifnumberelse{\string#2} + {\doifelsenumber{\string#2} {\setevalue{\string#1}{\utfchar{#2}}} % or {\expandafter\chardef\csname#1\endcsname#2\relax} {\setuvalue{\string#1}{#2}}} @@ -106,7 +110,7 @@ \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}% - \ctxcommand{buildtextaccent(\number\b_enco_accent)}#2% + \clf_buildtextaccent\b_enco_accent#2% \endgroup} \unexpanded\def\bottomaccent#1#2#3#4#5% down right slantcorrection accent char @@ -208,11 +212,42 @@ \def\pound {£} \def\sterling{£} \def\promille {‰} \def\permille{‰} -% tex specific (obsolete) +% tex specific + +\ifdefined\textpercent + \let\percent \textpercent + \let\procent \textpercent + \let\ampersand \textampersand + \let\dollar \textdollar + \let\hash \texthash +\else + \def\percent {\textpercent} + \def\procent {\textpercent} + \def\ampersand {\textampersand} + \def\dollar {\textdollar} + \def\hash {\texthash} +\fi + +% from enco-mis: + +\unexpanded\def\fakepercent + {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25\emwidth/\kern-.2\emwidth\normalsubscript{\scriptscriptstyle0}}} + +\unexpanded\def\fakeperthousand + {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25\emwidth/\kern-.2\emwidth\normalsubscript{\scriptscriptstyle00}}} + +\unexpanded\def\fakepermine + {\dontleavehmode + \bgroup + \setbox\scratchbox\hbox + {\mathematics{+}}% + \hbox to \wd\scratchbox + {\hss + \mathematics{\normalsuperscript{\scriptscriptstyle-}\kern-.4\emwidth/\kern-.3\emwidth\normalsubscript{\scriptscriptstyle-}}% + \hss}% + \egroup} -\def\procent {\percent} -\def\dollar {\textdollar} -\def\permine {\fakepermine} +\def\permine{\fakepermine} % some more @@ -250,9 +285,27 @@ \chardef\textcontrolspace"2423 -\unexpanded\def\fallbackcontrolspace - %{\getglyph{ComputerModernMono}\textcontrolspace} - {\getglyph{LMTypewriter-Regular}\textcontrolspace} +\installcorenamespace{controlspace} + +% \unexpanded\def\fallbackcontrolspace % beware: non-matching widths +% {\hbox to \interwordspace{\hss\getglyph{LMTypewriter-Regular}\textcontrolspace\hss}% + +\unexpanded\def\fallbackcontrolspace % beware, current font, we also need to honor color + {\hbox to \interwordspace \bgroup + \hss + \ifcsname\??controlspace\number\interwordspace\endcsname + \csname\??controlspace\number\interwordspace\endcsname + \else + \enco_fast_control_space_define % only regular + \fi + \textcontrolspace + \hss + \egroup} + +\unexpanded\def\enco_fast_control_space_define + {\scratchdimen\interwordspace + \definedfont[LMTypewriter-Regular at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody]% see font-sym.mkiv + \expandafter\glet\csname\??controlspace\number\scratchdimen\endcsname\lastrawfontcall} \unexpanded\def\normalcontrolspace {\iffontchar\font\textcontrolspace @@ -263,29 +316,35 @@ \let\textvisiblespace\normalcontrolspace -\unexpanded\def\fastcontrolspace % no glyph resolving after first (use grouped) - {\enco_fast_control_space} - -\def\enco_fast_control_space +\unexpanded\def\optionalcontrolspace {\iffontchar\font\textcontrolspace - \enco_fast_control_space_nop + \textcontrolspace \else - \enco_fast_control_space_yes - \fi - \enco_fast_control_space} - -\newbox\b_enco_control_space - -\def\enco_fast_control_space_nop - {\let\enco_fast_control_space\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} + \asciispacechar % used for export ! + \fi} -\def\flushcontrolspacebox - {\copy\b_enco_control_space} +% \unexpanded\def\fastcontrolspace % no glyph resolving after first (use grouped) +% {\enco_fast_control_space} +% +% \def\enco_fast_control_space +% {\iffontchar\font\textcontrolspace +% \enco_fast_control_space_nop +% \else +% \enco_fast_control_space_yes +% \fi +% \enco_fast_control_space} +% +% \newbox\b_enco_control_space +% +% \def\enco_fast_control_space_nop +% {\let\enco_fast_control_space\textcontrolspace} +% +% \def\enco_fast_control_space_yes +% {\setbox\b_enco_control_space\fallbackcontrolspace +% \let\enco_fast_control_space\flushcontrolspacebox} +% +% \def\flushcontrolspacebox +% {\copy\b_enco_control_space} % 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 @@ -305,26 +364,7 @@ % \defineaccent u {\empty} {\textbreve} % \defineaccent v {\empty} {\textcaron} -\ctxlua{characters.tex.defineaccents()} - -% from enco-mis: - -\unexpanded\def\fakepercent - {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25\emwidth/\kern-.2\emwidth\normalsubscript{\scriptscriptstyle0}}} - -\unexpanded\def\fakeperthousand - {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25\emwidth/\kern-.2\emwidth\normalsubscript{\scriptscriptstyle00}}} - -\unexpanded\def\fakepermine - {\dontleavehmode - \bgroup - \setbox\scratchbox\hbox - {\mathematics{+}}% - \hbox to \wd\scratchbox - {\hss - \mathematics{\normalsuperscript{\scriptscriptstyle-}\kern-.4\emwidth/\kern-.3\emwidth\normalsubscript{\scriptscriptstyle-}}% - \hss}% - \egroup} +\clf_defineaccents % one time %D A smaller and bolder variant, more like the math and monospaced ones. @@ -365,37 +405,105 @@ \unexpanded\def\inch {\mathematics{\prime\prime}} % was: \hbox{\rm\char125\relax} \unexpanded\def\fraction#1#2{\mathematics{#1\over#2}} -\def\periodswidth {.5em} -\def\periodsdefault{3} % was 5, but now it's like \unknown - -\unexpanded\def\periods - {\dosingleempty\enco_periods} - +% \def\periodswidth {.5em} +% \def\periodsdefault{3} % was 5, but now it's like \unknown +% +% \unexpanded\def\periods +% {\dosingleempty\enco_periods} +% % \def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 % {\dontleavehmode % \begingroup % \scratchdimen\periodswidth % \hbox to \iffirstargument#1\else\periodsdefault\fi \scratchdimen -% {\leaders\hbox to \scratchdimen{\hss.\hss}\hss}% +% {\leaders\hbox to \scratchdimen{\hss\periodsymbol\hss}\hss}% % \endgroup} % % better for export: +% +% \unexpanded\def\enco_periods[#1]% todo: also n=,width= or maybe just #1,#2 +% {\dontleavehmode +% \hbox\bgroup +% \setbox\scratchbox\hbox to \periodswidth{\hss\periodsymbol\hss}% +% \dorecurse{\iffirstargument#1\else\periodsdefault\fi}{\copy\scratchbox}% +% \egroup} +% +% \unexpanded\def\unknown +% {\periods\relax} % relax prevents lookahead for [] +% +% per request: + +%D \startbuffer +%D \startlines +%D x\periods x +%D x\periods[10]x +%D x\periods[n=10,symbol={,}]x +%D x\periods[n=4,symbol={!!},width=1em]x +%D x\periods[n=4,symbol={!!},width=fit]x +%D x\periods[n=4,symbol={!!},width=fit,distance=1em]x +%D x\unknown x +%D \stoplines +%D \stopbuffer +%D +%D \typbuffer \getbuffer + +\def\periodswidth {.5\emwidth} % downward compatible +\def\periodsdefault{3} % downward compatible + +\installcorenamespace {periods} + +\installsetuponlycommandhandler \??periods {periods} + +\setupperiods + [\c!n=\periodsdefault, + \c!width=\periodswidth, % can also be \v!fit + \c!distance=.25\emwidth, + \c!symbol=.] -\unexpanded\def\enco_periods[#1]% todo: also n=,width= or maybe just #1,#2 +\unexpanded\def\periods {\dontleavehmode \hbox\bgroup - \setbox\scratchbox\hbox to \periodswidth{\hss.\hss}% - \dorecurse{\iffirstargument#1\else\periodsdefault\fi}{\copy\scratchbox}% + \doifelsenextoptional\enco_periods_yes\enco_periods_nop} + +\unexpanded\def\enco_periods_yes[#1]% + {\doifelseassignment{#1} + {\setupcurrentperiods[#1]% + \scratchcounter\periodsparameter\c!n} + {\doifelsenothing{#1} + {\scratchcounter\periodsparameter\c!n}% + {\scratchcounter#1}}% + \enco_periods_finish} + +\unexpanded\def\enco_periods_nop + {\scratchcounter\periodsparameter\c!n + \enco_periods_finish} + +\unexpanded\def\enco_periods_finish + {\edef\p_width{\periodsparameter\c!width}% + \ifx\p_width\v!fit + \enco_periods_finish_fit + \else + \enco_periods_finish_width + \fi \egroup} +\unexpanded\def\enco_periods_finish_width + {\setbox\scratchbox\hbox to \p_width + {\hss\periodsparameter\c!symbol\hss}% + \dorecurse\scratchcounter{\copy\scratchbox}} + +\unexpanded\def\enco_periods_finish_fit + {\edef\p_symbol{\periodsparameter\c!symbol}% + \scratchdistance\periodsparameter\c!distance + \hskip\scratchdistance + \dorecurse\scratchcounter{\p_symbol\hskip\scratchdistance}} + \unexpanded\def\unknown - {\periods\relax} % relax prevents lookahead for [] + {\dontleavehmode + \hbox\bgroup + \enco_periods_nop} -% Example by Wolfgang Schuster on the context list: -% -% \unexpanded\def\fourdots{{\def\periodswidth{.3em}\periods[4]}} -% -% Hello\fourdots\ World\fourdots \par Hello\fourdots\ World. +%D Left-overs: \appendtoks \let\buildtextaccent\secondoftwoarguments |