diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/font-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/font-ini.mkiv | 1256 |
1 files changed, 887 insertions, 369 deletions
diff --git a/Master/texmf-dist/tex/context/base/font-ini.mkiv b/Master/texmf-dist/tex/context/base/font-ini.mkiv index c7d515cca36..1c9cdcd321a 100644 --- a/Master/texmf-dist/tex/context/base/font-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/font-ini.mkiv @@ -14,9 +14,12 @@ % runtime commands will move to modules +% todo: (so that we can delay font loading to \starttext + % simplification ... we no longer deal with specific mmtfa specifications -% todo: always fontclass, then less testing +% todo: always fontclass, then less testing +% todo: bodyfontvariable: parent % \definefontfeature[smallcaps][smcp=yes,script=latn] % \definefontfeature[smallcaps][SmallCapitals=yes,script=latn] @@ -55,34 +58,49 @@ \writestatus{loading}{ConTeXt Font Macros / Initialization} \registerctxluafile{font-ini}{1.001} -\registerctxluafile{node-fnt}{1.001} % here +\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-log}{1.001} + \registerctxluafile{font-tfm}{1.001} -\registerctxluafile{font-enh}{1.001} + \registerctxluafile{font-afm}{1.001} -\registerctxluafile{font-cid}{1.001} % cid maps -\registerctxluafile{font-ott}{1.001} % otf tables -\registerctxluafile{font-otf}{1.001} % otf main -\registerctxluafile{font-otd}{1.001} % otf dynamics + \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-ota}{1.001} % otf analyzers +\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} -\registerctxluafile{font-xtx}{1.001} -\registerctxluafile{font-fbk}{1.001} -\registerctxluafile{font-gds}{1.001} +\registerctxluafile{font-ctx}{1.001} % after def as it overloads + \registerctxluafile{font-ext}{1.001} -\registerctxluafile{font-pat}{1.001} +\registerctxluafile{font-fbk}{1.001} \registerctxluafile{font-chk}{1.001} -\registerctxluafile{font-agl}{1.001} + +\registerctxluafile{font-aux}{1.001} \unprotect @@ -160,9 +178,12 @@ % \newtoks \everydefinedfont % not ot be confused with \everydefinefont +\let\thedefinedfont\relax + \def\dodefinedfont[#1]% - {\iffirstargument\definefont[thedefinedfont][#1]\fi % we can speed this one up - \csname thedefinedfont\endcsname + {\featureinheritancemode\featureinheritancefontonly + \iffirstargument\definefont[thedefinedfont][#1]\fi % we can speed this one up + \thedefinedfont \the\everydefinedfont} \unexpanded\def\definedfont @@ -471,11 +492,11 @@ %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. -\chardef\mrfam\zerocount % math regular -\chardef\mbfam\plusone % math bold +\let\mrfam\zerocount % math regular +\let\mbfam\plusone % math bold -\unexpanded\def\mr{\ifmmode\fam\zerocount\else\setcurrentfontalternative\c!mr\fi} % \fam\csname\c!mr fam\endcsname -\unexpanded\def\mb{\ifmmode\fam\plusone \else\setcurrentfontalternative\c!mb\fi} % \fam\csname\c!mb fam\endcsname +\unexpanded\def\mr{\ifmmode\fam\mrfam\else\setcurrentfontalternative\c!mr\fi} +\unexpanded\def\mb{\ifmmode\fam\mbfam\else\setcurrentfontalternative\c!mb\fi} \def\mathtextsuffix {-text} \def\mathscriptsuffix {-script} @@ -515,6 +536,11 @@ \def\dosetmathfamily#1#2% {\let\savedfontbody\fontbody % op hoger plan \let\fontfamily#2% + % new per 20100817 + \checkbodyfontenvironment[\scriptscriptface]% + \checkbodyfontenvironment[\scriptface]% + \checkbodyfontenvironment[\textface]% + % \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\dodosetmathfamily\scriptscriptfont#1% \let\currentmathsize\!!plustwo \let\fontbody\scriptface \dodosetmathfamily\scriptfont #1% \let\currentmathsize\!!plusone \let\fontbody\textface \dodosetmathfamily\textfont #1% @@ -528,29 +554,14 @@ % not official ! -\chardef\boldmathmode\zerocount % might change ... maybe \mathfontsupport 1 (normal) 2 (bold too) +\newconditional\boldmathmode % might change ... maybe \mathfontsupport 1 (normal) 2 (bold too) -\def\enableboldmath {\chardef\boldmathmode\plusone } % todo: \setupbodyfont[boldmath,...] -\def\disableboldmath{\chardef\boldmathmode\zerocount} +\def\enableboldmath {\settrue \boldmathmode} % todo: \setupbodyfont[boldmath,...] +\def\disableboldmath{\setfalse\boldmathmode} \appendtoks - \ifcase\boldmathmode\or\dosetmathfamily\mbfam\c!mb\fi + \ifconditional\boldmathmode\dosetmathfamily\mbfam\c!mb\fi \to \mathstrategies - -% \chardef\msfam\plustwo % math symbol -% -% \def\c!ms{ms} -% -% \unexpanded\def\ms{\ifmmode\fam\plustwo\else\setcurrentfontalternative\c!ms\fi} -% -% \chardef\symbolmathmode\zerocount -% -% \def\enablesymbolmath {\chardef\symbolmathmode\plusone } -% \def\disablesymbolmath{\chardef\symbolmathmode\zerocount} -% -% \appendtoks -% \ifcase\symbolmathmode\or\dosetmathfamily\msfam\c!ms\fi -% \to \mathstrategies %D All used styles, like rm, ss and tt, are saved in a comma %D separated list. Appart from practical limitations one can @@ -614,6 +625,10 @@ \let\relativefontid\empty \fi} +\def\checkrelativefontid % not yet supported as we then need to trigger \rm\tf or so first + {\let\relativefontsize\minusone + \let\relativefontsize\defaultrelativefontsize} + \def\checkrelativefontsize#1% {\edef\relativefontsize {\ifcsname\fontclass#1\s!rscale\endcsname @@ -685,9 +700,24 @@ \let\relativefontid\empty -\def\lowleveldefinefont#1#2% #2 = cs - {% - \ctxlua{fonts.define.command_1("\luaescapestring{#1}")}% the escapestring catches at \somedimen +% 0 = none +% 1 = fontonly +% 2 = classonly +% 3 = fontfirst +% 4 = classfirst + +\setnewconstant\featureinheritancefontnone \zerocount +\setnewconstant\featureinheritancefontonly \plusone +\setnewconstant\featureinheritanceclassonly \plustwo +\setnewconstant\featureinheritancefontfirst \plusthree +\setnewconstant\featureinheritanceclassfirst\plusfour + +\setnewconstant\featureinheritancedefault \featureinheritancefontfirst +\setnewconstant\featureinheritancemode \featureinheritancedefault + +\unexpanded\def\lowleveldefinefont#1#2% #2 = cs + {% we can now set more at the lua end + \ctxlua{fonts.definers.stage_one("\luaescapestring{#1}")}% the escapestring catches at \somedimen % sets \scaledfontmode and \somefontname and \somefontsize \ifcase\scaledfontmode\relax % none, avoid the designsize if possible @@ -707,6 +737,7 @@ % scaled, don't use this one as it's unpredictable \scaledfontsize-\somefontsize\scaledpoint \fi + \relax \scaledfontsize\localrelativefontsize\scaledfontsize \ifautofontsize \scaledfontsize\currentfontbodyscale\scaledfontsize @@ -718,26 +749,32 @@ \fi \updatefontparameters \updatefontclassparameters - \ctxlua{fonts.define.command_2( + \ctxlua{fonts.definers.stage_two( \ifx\fontclass\empty false\else true\fi, "#2", % cs, trailing % is gone "\somefontfile", \number\scaledfontsize, + \number\featureinheritancemode, "\@@fontclassfeatures", "\@@fontfeatures", "\@@fontclassfallbacks", "\@@fontfallbacks", 0\currentmathsize, \number\dimexpr\textface\relax, - "\relativefontid" % experiment + "\relativefontid", % experiment + "\@@fontclassgoodies", % experiment (not yet used) + "\@@fontgoodies" % experiment )}% - \edef\somefontspec{at \somefontsize}% we need the resolved designsize (for fallbacks) +% \edef\somefontspec{at \somefontsize}% we need the resolved designsize (for fallbacks) + \edef\somefontspec{at \number\scaledfontsize sp}% we need the resolved designsize (for fallbacks) \expandafter\let\expandafter\lastrawfontcall\csname#2\endcsname - \the\everydefinefont} + \the\everydefinefont + \featureinheritancemode\featureinheritancedefault} \def\updatefontclassparameters {\edef\@@fontclassfeatures {\ifcsname\fontclass\fontstyle\s!features \endcsname\csname\fontclass\fontstyle\s!features \endcsname\fi}% - \edef\@@fontclassfallbacks{\ifcsname\fontclass\fontstyle\s!fallbacks\endcsname\csname\fontclass\fontstyle\s!fallbacks\endcsname\fi}} + \edef\@@fontclassfallbacks{\ifcsname\fontclass\fontstyle\s!fallbacks\endcsname\csname\fontclass\fontstyle\s!fallbacks\endcsname\fi}% + \edef\@@fontclassgoodies {\ifcsname\fontclass\fontstyle\s!goodies \endcsname\csname\fontclass\fontstyle\s!goodies \endcsname\fi}} % resolve @@ -755,6 +792,13 @@ \ifcsname\??ff #1\endcsname\@EA \@@thefallbacksyes\csname\??ff #1\endcsname\else \let \@@fontfallbacks \empty \fi\fi\fi\fi} +\def\@@thegoodiesyes#1% + {\ifcsname\??ff\fontclass#1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??ff\fontclass#1\s!goodies \endcsname\else + \ifcsname\??ff #1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??ff #1\s!goodies \endcsname\else + \ifcsname\??ff\fontclass #1\endcsname\@EA \@@thegoodiesyes \csname\??ff\fontclass #1\endcsname\else + \ifcsname\??ff #1\endcsname\@EA \@@thegoodiesyes \csname\??ff #1\endcsname\else + \let \@@fontgoodies \empty \fi\fi\fi\fi} + \def\@@thefeaturesnop#1% {\ifcsname\??ff#1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??ff#1\s!features \endcsname\else \ifcsname\??ff #1\endcsname\@EA \@@thefeaturesnop \csname\??ff #1\endcsname\else @@ -765,13 +809,20 @@ \ifcsname\??ff #1\endcsname\@EA \@@thefallbacksnop\csname\??ff #1\endcsname\else \let \@@fontfallbacks \empty \fi\fi} +\def\@@thegoodiesnop#1% + {\ifcsname\??ff#1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??ff#1\s!goodies \endcsname\else + \ifcsname\??ff #1\endcsname\@EA \@@thegoodiesnop \csname\??ff #1\endcsname\else + \let \@@fontgoodies \empty \fi\fi} + \def\updatefontparametersyes {\@@thefeaturesyes \somefontname - \@@thefallbacksyes\somefontname} + \@@thefallbacksyes\somefontname + \@@thegoodiesyes \somefontname} \def\updatefontparametersnop {\@@thefeaturesnop \somefontname - \@@thefallbacksnop\somefontname} + \@@thefallbacksnop\somefontname + \@@thegoodiesnop \somefontname} \def\updatefontparameters {\ifx\fontclass\empty\updatefontparametersnop\else\updatefontparametersyes\fi} @@ -781,6 +832,8 @@ \let\@@fontfallbacks\empty \let\@@fontfeatures \empty +\let\@@fontgoodies \empty + \let\@@hyphenchar \empty % todo, will go to encoding %D This brings down maps processing from 466 to 309 seconds @@ -915,6 +968,8 @@ % We could use an indirect method ... store in 'array' and refer to % slot. +% +% or nicer .. use parent chain \unexpanded\def\definefontsynonym[#1]#2[#3]% {\edef\@@fontname{#1}% @@ -936,11 +991,13 @@ \def\dododefinefontsynonymnop[#1]% {\let\@@ff@@features \undefined \let\@@ff@@fallbacks\undefined + \let\@@ff@@goodies \undefined \expandafter\dogetfontparameternop#1,]=,} \def\dododefinefontsynonymyes[#1]% {\let\@@ff@@features \undefined \let\@@ff@@fallbacks\undefined + \let\@@ff@@goodies \undefined \expandafter\dogetfontparameteryes#1,]=,} \def\dogetfontparameternop#1=#2,% @@ -959,27 +1016,34 @@ \expandafter\dogetfontparameteryes \fi} -% hm, was wrong, class/global reversed +% helpers, some day these will be toks and counts + +\def\fntsetdefname {\global\let\somefontname\defaultfontfile} +\def\fntsetsomename{\gdef\somefontname} % {#1} +\def\fntsetnopsize {\let\somefontsize\empty} +\def\fntsetsomesize{\def\somefontsize} % {#1} -\let\fcglobal\global -\let\fcxdef \xdef -\let\fcglet \glet +% end of helpers \def\nonodefinefontsynonymnop {\@EA\let\csname\??ff\@@fontname\s!features \endcsname\undefined - \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\undefined} + \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\undefined + \@EA\let\csname\??ff\@@fontname\s!goodies \endcsname\undefined} \def\nonodefinefontsynonymyes - {\fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\undefined - \fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\undefined} + {\global\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\undefined + \global\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\undefined + \global\@EA\let\csname\??ff\fontclass\@@fontname\s!goodies \endcsname\undefined} \def\dodododefinefontsynonymnop {\@EA\let\csname\??ff\@@fontname\s!features \endcsname\@@ff@@features - \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks} + \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks + \@EA\let\csname\??ff\@@fontname\s!goodies \endcsname\@@ff@@goodies} \def\dodododefinefontsynonymyes - {\fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\@@ff@@features - \fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks} + {\global\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\@@ff@@features + \global\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks + \global\@EA\let\csname\??ff\fontclass\@@fontname\s!goodies \endcsname\@@ff@@goodies} \let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater @@ -1135,7 +1199,8 @@ \def\newfontidentifier{*\fontclass\lastfontidentifier\fontstyle\fontsize*} \def\dododefinefont#1#2% - {\edef\lastfontidentifier{#1}% + {\featureinheritancemode\featureinheritancefontonly + \edef\lastfontidentifier{#1}% \let\localrelativefontsize\defaultrelativefontsize \let\localabsolutefontsize\fontbody \lowleveldefinefont{#2}\rawfontidentifier @@ -1260,6 +1325,12 @@ %D expands to the current size in terms of \type {a} \unknown %D \type {d}, nothing, or \type {x} \unknown \type {xx}. +%D In the following macros we use \type{\currentxfontsize} to +%D hold the current x||size of the font. This enables us to +%D support for instance \type{\sl} inside a \type{\tx} switch. + +\newconstant\currentxfontsize + \def\xfontsize{\ifcase\currentxfontsize\fontsize\or\c!x\else\c!xx\fi} %D A typical use of this command is in commands that switch @@ -1334,24 +1405,81 @@ \newcount\@@fontdefhack % check if this is still needed +% \def\@@beginfontdef +% {\ifcase\@@fontdefhack +% \let\k!savedtext \k!text \let\k!text \s!text +% \let\k!saveddefault \k!default \let\k!default \s!default +% \fi +% \advance\@@fontdefhack \plusone } + +% \def\@@endfontdef +% {\advance\@@fontdefhack \minusone +% \ifcase\@@fontdefhack +% \let\k!default \k!saveddefault +% \let\k!text \k!savedtext +% \fi} + +%%%%%%%%%%%%%%%%%%%%%%%% + +% The problem is that the key in a getparameters is resolved +% to the underlying interface language (english). But values +% are kept as they are. However, some of the keys in a font +% definition are used as values later on. +% +% The only place where this happens (for historical reason mostly) +% is in the bodyfont definitions and setup, so we can use a limited +% case. +% +% \let \c!big \v!big : expansion time (user) +% \let \c!small \v!small : expansion time (user) +% \let \c!text \s!text : definition time +% % \c!script \s!script : definition time +% % \c!scriptscript \s!scriptscript : definition time +% % \c!em : definition time +% % \c!interlineskip : definition time +% \let \c!default \s!default : definition time +% \let \k!default \s!default : definition time +% +% Doing the k! definitions local will save us 500 has entries. + +\letvalue{\k!prefix!\v!big }\c!big +\letvalue{\k!prefix!\v!small }\c!small +\letvalue{\k!prefix!\v!text }\s!text +\letvalue{\k!prefix!\v!default}\s!default + +\let\normalc!big \c!big +\let\normalc!small \c!small +\let\normalc!text \c!text % should not happen as we expect text +\let\normalc!default \c!default +\let\normalk!default \k!default + +\newtoks\everybeginfontdef +\newtoks\everyendfontdef + +\appendtoks + \let\c!text \s!text + \let\c!default\s!default +\to \everybeginfontdef + +\appendtoks + \let\c!text \normalc!text + \let\c!default\normalc!default +\to \everyendfontdef + \def\@@beginfontdef {\ifcase\@@fontdefhack - \let\k!savedtext \k!text \let\k!text \s!text - \let\k!k!savedtext \k!k!text \let\k!k!text \!!plusone - \let\k!saveddefault \k!default \let\k!default \s!default - \let\k!k!saveddefault\k!k!default \let\k!k!default \!!plusone + \the\everybeginfontdef \fi - \advance\@@fontdefhack \plusone } + \advance\@@fontdefhack\plusone} \def\@@endfontdef {\advance\@@fontdefhack \minusone \ifcase\@@fontdefhack - \let\k!k!default\k!k!saveddefault - \let\k!default \k!saveddefault - \let\k!k!text \k!k!savedtext - \let\k!text \k!savedtext + \the\everyendfontdef \fi} +%%%%%%%%%%%%%%%%%%%%%%%% + \unexpanded\def\definebodyfontenvironment {\dotripleempty\dodefinebodyfontenvironment} @@ -1360,7 +1488,7 @@ \@@beginfontdef \doifelse{#2}\s!default {\getparameters[\??ft\s!default][#3]} - {\normalizebodyfontsize#2\to\tempbodyfontsize + {\edef\tempbodyfontsize{\thenormalizedbodyfontsize{#2}}% \addtocommalist\tempbodyfontsize\bodyfontenvironmentlist \@EA\dododefinebodyfontenvironment\@EA[\tempbodyfontsize][#1][#3]}% \@@endfontdef @@ -1375,13 +1503,15 @@ \fi} \def\dododefinebodyfontenvironment[#1][#2][#3]% size class settings - {\@@beginfontdef % \s!text goes wrong in testing because the 12pt alternative will called when typesetting the test (or so) + {%\@@beginfontdef % \s!text goes wrong in testing because the 12pt alternative will called when typesetting the test (or so) \ifcsname\??ft#2#1\c!em\endcsname % we test for em as we assume it to be set \else + % speeding this up saves 0.01 sec on a run (tested 20100817) + % but some day we will clean this up anyway \def\docommand##1% {\scratchdimen\csname\??ft\s!default##1\endcsname\dimexpr#1\relax - \normalizebodyfontsize\scratchdimen\to\tempbodyfontsize + \edef\tempbodyfontsize{\thenormalizedbodyfontsize\scratchdimen}% \letvalue{\??ft#2#1##1}\tempbodyfontsize}% \processcommacommand[\fontrelativesizelist]\docommand \copyparameters @@ -1389,20 +1519,20 @@ [\c!interlinespace,\c!em]% \fi \getparameters[\??ft#2#1][#3]% - \@@endfontdef + %\@@endfontdef % new code, see remark - \ifloadingfonts - % only runtime - \else\ifcsname\@size@#1\endcsname - % only once - \else - % prevent loop (hence \empty) - \letvalue{\@size@#1}\empty - \pushmacro\fontclass % new per 26102009 - \edef\fontclass{#2}% % new per 26102009 - \defineunknownfont{#1}% - \popmacro\fontclass % new per 26102009 - \fi\fi + \ifproductionrun + \ifcsname\@size@#1\endcsname + % only once + \else + % prevent loop (hence \empty) + \letvalueempty{\@size@#1}% + \pushmacro\fontclass % new per 26102009 + \edef\fontclass{#2}% % new per 26102009 + \defineunknownfont{#1}% + \popmacro\fontclass % new per 26102009 + \fi + \fi % so far \setvalue{\@size@#1}{\docompletefontswitch[#1]}} @@ -1426,15 +1556,44 @@ %D So, apart from an occasional switch, one should define an %D environment at the outer level. -\def\checkbodyfontenvironment[#1]% - {\definebodyfontenvironment[\fontclass][#1][]} +% \def\checkbodyfontenvironment[#1]% +% {\definebodyfontenvironment[\fontclass][#1][]} +% +% \def\checkbodyfontenvironment[#1]% +% {\ifcsname\??ft\fontclass#1\c!em\endcsname +% % we test for em as we assume it to be set +% \else +% \definebodyfontenvironment[\fontclass][#1][]% +% \fi} +% +% will be adapted with parent chain: \def\checkbodyfontenvironment[#1]% - {\ifcsname\??ft\fontclass#1\c!em\endcsname - % we test for em as we assume it to be set - \else - \definebodyfontenvironment[\fontclass][#1][]% - \fi} + {\ifcsname\??ft #1\c!em\endcsname\else\docheckbodyfontenvironment\empty {#1}\fi + \ifcsname\??ft\fontclass#1\c!em\endcsname\else\docheckbodyfontenvironment\fontclass{#1}\fi} + +\def\docheckbodyfontenvironment#1#2% class size (simplified version of definebodyfontenvironment) + {\@@beginfontdef + \edef\tempbodyfontsize{\thenormalizedbodyfontsize{#2}}% + \addtocommalist\tempbodyfontsize\bodyfontenvironmentlist + \def\docommand##1% text script scriptscript x xx big small + {\setevalue{\??ft#1\tempbodyfontsize##1}% + {\thenormalizedbodyfontsize{\csname\??ft\s!default##1\endcsname\dimexpr\tempbodyfontsize\relax}}}% + \processcommacommand[\fontrelativesizelist]\docommand + \copyparameters % can inherit + [\??ft#1\tempbodyfontsize][\??ft\s!default] + [\c!interlinespace,\c!em]% +% \ifproductionrun + \ifcsname\@size@\tempbodyfontsize\endcsname \else + \letvalueempty{\@size@\tempbodyfontsize}% prevent loop + \pushmacro\fontclass + \edef\fontclass{#1}% + \normalexpanded{\defineunknownfont{\tempbodyfontsize}}% we can also inherit here + \popmacro\fontclass + \fi +% \fi + \setevalue{\@size@#1}{\noexpand\docompletefontswitch[#1]}% + \@@endfontdef} % this one already catches both define/setup @@ -1442,6 +1601,16 @@ %D Just a couple of interface macros: +% todo: +% +% \letvalueempty{\??ft\s!empty} +% +% \def\currentbodyfontvariable#1% +% {\csname\??ft +% \ifcsname\??ft\fontclass#1\endcsname\fontclass#1\else +% \ifcsname\??ft #1\endcsname #1\else \s!empty \fi +% \fi} + \def\bodyfontvariable#1% {\??ft\ifcsname\??ft\fontclass#1\endcsname\fontclass\fi#1} @@ -1580,7 +1749,7 @@ \let\relativefontsize\defaultrelativefontsize} \def\dododefinebodyfont#1#2#3% style defs body - {\checkbodyfontenvironment[#3]% just to be sure. + {\checkbodyfontenvironment[#3]% just to be sure; can probably be omited now \processcommalist[#2]{\dodododefinebodyfont{#1}{#3}}} \def\dodododefinebodyfont#1#2#3% style body def @@ -1616,8 +1785,8 @@ \def\dodefinebodyfontyesxx#1#2[#3#4#5=#6]% style body def {\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5] - \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#5*\endcsname\undefined - \unexpanded\@EA\fcxdef\csname\fontclass#2#1#3#4#5\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#5}{\normalunexpanded{#6}}}} + \global\@EA\let\csname*\fontclass#2#1#3#4#5*\endcsname\undefined + \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#5\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#5}{\normalunexpanded{#6}}}} \def\dodefinebodyfontnopmm#1#2[#3#4#5=#6]% style body def {\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5] @@ -1630,12 +1799,12 @@ \def\dodefinebodyfontyesmm#1#2[#3#4#5=#6]% style body def {\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5] - \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#51*\endcsname\undefined - \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#52*\endcsname\undefined - \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#53*\endcsname\undefined - \unexpanded\@EA\fcxdef\csname\fontclass#2#1#3#4#51\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#51}{\normalunexpanded{#6}}}% - \unexpanded\@EA\fcxdef\csname\fontclass#2#1#3#4#52\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#52}{\normalunexpanded{#6}}}% - \unexpanded\@EA\fcxdef\csname\fontclass#2#1#3#4#53\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#53}{\normalunexpanded{#6}}}} + \global\@EA\let\csname*\fontclass#2#1#3#4#51*\endcsname\undefined + \global\@EA\let\csname*\fontclass#2#1#3#4#52*\endcsname\undefined + \global\@EA\let\csname*\fontclass#2#1#3#4#53*\endcsname\undefined + \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#51\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#51}{\normalunexpanded{#6}}}% + \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#52\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#52}{\normalunexpanded{#6}}}% + \unexpanded\@EA\xdef\csname\fontclass#2#1#3#4#53\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#53}{\normalunexpanded{#6}}}} \def\checkbodyfont#1% tests for ttsl mmbf {\edef\c!!mm{#1}% @@ -1647,24 +1816,49 @@ % some day we can do an auto-fam if needed -\def\checkmathbodyfont#1#2#3% style alt size / gdef % #3 can be empty - {%\message{!m #1 #2 #3!}% - % #1 #2 #3 = signal - %setugvalue {#2}{\setcurrentfontalternative {#2}}% \mr \mb - \setugvalue {#1}{\setcurrentfontstyle {#1}}}% \mm - -\def\checktextbodyfont#1#2#3% style alt size / gdef % #3 can be empty - {%\message{!t #1 #2 #3!}% - \setugvalue {#1#3}{\setcurrentfontstylesize {#1}{#3}}% \rma - \setugvalue {#2#3}{\setcurrentfontalternativesize {#2}{#3}}% \sla - \setugvalue {#1#2#3}{\setcurrentfontstylealternativesize{#1}{#2}{#3}}% \rmsla - \setugvalue {#1}{\setcurrentfontstyle {#1}}% \rm - \setugvalue {#2}{\setcurrentfontalternative {#2}}% \sl - \setugvalue {#1\c!x}{\setcurrentfontxstylealternative {#1}}% \rmx - \setugvalue{#1\c!xx}{\setcurrentfontxxstylealternative {#1}}% \rmxx - \setugvalue {#2\c!x}{\setcurrentfontxalternative {#2}}% \slx - \setugvalue{#2\c!xx}{\setcurrentfontxxalternative {#2}}% \slxx - \setugvalue {#1#2}{\setcurrentfontstylealternative {#1}{#2}}}% \rmsl +% \def\checkmathbodyfont#1#2#3% style alt size / gdef % #3 can be empty (checking needed as \bf is already defined) +% {%\message{!m #1 #2 #3!}% #1 #2 #3 = signal +% %ifcsname #2\endcsname\else\setugvalue {#2}{\setcurrentfontalternative {#2}}\fi % \mr \mb +% \ifcsname #1\endcsname\else\setugvalue {#1}{\setcurrentfontstyle {#1}}\fi} % \mm + +% \def\checktextbodyfont#1#2#3% style alt size / gdef % #3 can be empty (checking needed as \bf is already defined) +% {%\message{!t #1 #2 #3!}% +% \ifcsname #1#3\endcsname\else\setugvalue {#1#3}{\setcurrentfontstylesize {#1}{#3}}\fi % \rma +% \ifcsname #2#3\endcsname\else\setugvalue {#2#3}{\setcurrentfontalternativesize {#2}{#3}}\fi % \sla +% \ifcsname #1#2#3\endcsname\else\setugvalue {#1#2#3}{\setcurrentfontstylealternativesize{#1}{#2}{#3}}\fi % \rmsla +% \ifcsname #1\endcsname\else\setugvalue {#1}{\setcurrentfontstyle {#1}}\fi % \rm +% \ifcsname #2\endcsname\else\setugvalue {#2}{\setcurrentfontalternative {#2}}\fi % \sl +% \ifcsname #1\c!x\endcsname\else\setugvalue {#1\c!x}{\setcurrentfontxstylealternative {#1}}\fi % \rmx +% \ifcsname#1\c!xx\endcsname\else\setugvalue{#1\c!xx}{\setcurrentfontxxstylealternative {#1}}\fi % \rmxx +% \ifcsname #2\c!x\endcsname\else\setugvalue {#2\c!x}{\setcurrentfontxalternative {#2}}\fi % \slx +% \ifcsname#2\c!xx\endcsname\else\setugvalue{#2\c!xx}{\setcurrentfontxxalternative {#2}}\fi % \slxx +% \ifcsname #1#2\endcsname\else\setugvalue {#1#2}{\setcurrentfontstylealternative {#1}{#2}}\fi} % \rmsl + +\def\checkmathbodyfont#1#2#3% style alt size / gdef % #3 can be empty (checking needed as \bf is already defined) + {%\message{!m #1 #2 #3!}% #1 #2 #3 = signal + %setugvalue {#2}{\setcurrentfontalternative {#2}}% % \mr \mb + \setugvalue {#1}{\setcurrentfontstyle {#1}}} % \mm + +\def\checktextbodyfont#1#2#3% style alt size / gdef % #3 can be empty (checking needed as \bf is already defined) + {%\message{!t #1 #2 #3!}% % beware, some can be defined already + \setugvalue {#1#3}{\setcurrentfontstylesize {#1}{#3}}% % \rma + \setugvalue {#2#3}{\setcurrentfontalternativesize {#2}{#3}}% % \sla + \setugvalue {#1#2#3}{\setcurrentfontstylealternativesize{#1}{#2}{#3}}% % \rmsla + \ifcsname\s!normal#1\endcsname % text/math check + \expandafter\let\csname#1\expandafter\endcsname\csname\s!normal#1\endcsname + \else + \setugvalue {#1}{\setcurrentfontstyle {#1}}% % \rm + \fi + \ifcsname\s!normal#2\endcsname % text/math check + \expandafter\let\csname#2\expandafter\endcsname\csname\s!normal#2\endcsname + \else + \setugvalue {#2}{\setcurrentfontalternative {#2}}% % \sl + \fi + \setugvalue {#1\c!x}{\setcurrentfontxstylealternative {#1}}% % \rmx + \setugvalue{#1\c!xx}{\setcurrentfontxxstylealternative {#1}}% % \rmxx + \setugvalue {#2\c!x}{\setcurrentfontxalternative {#2}}% % \slx + \setugvalue{#2\c!xx}{\setcurrentfontxxalternative {#2}}% % \slxx + \setugvalue {#1#2}{\setcurrentfontstylealternative {#1}{#2}}} % \rmsl \def\dodefinedefaultbodyfont[#1][#2][#3]% sizes styles identifier {\def\dododefinedefaultbodyfont##1% @@ -1688,7 +1882,7 @@ \def\dodefineunknownfont#1#2% {\ifcsname\??ft\s!default#2\endcsname \donetrue - \normalizebodyfontsize\csname\??ft\s!default#2\endcsname\dimexpr#1\relax\to\tempbodyfontsize + \edef\tempbodyfontsize{\thenormalizedbodyfontsize{\csname\??ft\s!default#2\endcsname\dimexpr#1\relax}}% \letvalue{\??ft#1#2}\tempbodyfontsize \fi} @@ -1705,9 +1899,10 @@ \defineunknownfont{\csname\??ft#1#2\endcsname}% \fi} +\let\c!savedtext\c!text + \unexpanded\def\defineunknownfont#1% - {\let\c!savedtext\c!text - \let\c!text\s!text + {\let\c!text\s!text \donefalse \processcommacommand[\fontrelativesizelist]{\dodefineunknownfont{#1}}% \let\c!text\c!savedtext @@ -1791,7 +1986,7 @@ %D often not the way users specify the bodyfont size. Therefore %D we also store the normalized value. -\chardef\fontdigits=2 % was 1 +\setnewconstant\fontdigits\plustwo % was 1 % \def\normalizebodyfontsize#1\to#2% % {\@EA\@EA\@EA\donormalizedbodyfontsize\@EA\WITHOUTPT\the\dimexpr#1+\ifcase\fontdigits.5\or.05\or.005\fi\points\relax000\to#2} @@ -1807,14 +2002,14 @@ % \s!pt}} \def\normalizebodyfontsize#1\to#2% - {\edef#2{\ctxlua{fonts.nbfs(\number\dimexpr#1\relax,\number\fontdigits)}}} + {\edef#2{\ctxcommand{nbfs(\number\dimexpr#1\relax,\number\fontdigits)}}} \def\thenormalizedbodyfontsize#1% - {\ctxlua{fonts.nbfs(\number\dimexpr#1\relax,\number\fontdigits)}} + {\ctxcommand{nbfs(\number\dimexpr#1\relax,\number\fontdigits)}} -\normalizebodyfontsize\bodyfontsize\to\normalizedglobalbodyfontsize -\normalizebodyfontsize\bodyfontsize\to\normalizedlocalbodyfontsize -\normalizebodyfontsize\bodyfontsize\to\normalizedbodyfontsize +\edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize} +\edef\normalizedlocalbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize} +\edef\normalizedbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize} %D \macros %D {fontstyle,fontalternative,fontsize} @@ -1850,7 +2045,7 @@ \def\doswitchpoints[#1]% {\normalexpanded{\dodoswitchpoints{#1}}} -\unexpanded \def\dodoswitchpoints#1% +\unexpanded\def\dodoswitchpoints#1% {\ifcsname\@size@#1\endcsname \else \defineunknownfont{#1}% \fi% @@ -1858,14 +2053,14 @@ \ifcsname\@size@#1\endcsname \csname\@size@#1\endcsname \localbodyfontsize#1\relax - \normalizebodyfontsize\localbodyfontsize\to\normalizedbodyfontsize % \edef\fontbody{\fontbody}% to be tested but we can clean up mkiv further + \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\localbodyfontsize}% \checkbodyfontenvironment[\normalizedbodyfontsize]% \else \showmessage\m!fonts4{#1}% \fi} -\unexpanded \def\doswitchstyle[#1]% +\unexpanded\def\doswitchstyle[#1]% {\ifcsname\@style@#1\endcsname \csname\@style@#1\endcsname \edef\fontstyle{#1}% @@ -1914,11 +2109,8 @@ %D we start typesetting. %D %D Therefore we have to signal the font switching macros that -%D we are preloading fonts. As long as the next boolean is, -%D true, no loading is done. - -\newif\ifloadingfonts \loadingfontstrue - +%D we are preloading fonts. +%D %D \macros %D {preloadfonts} %D @@ -1926,29 +2118,115 @@ %D sequence of a session. After the loading job is done, the %D macro relaxes itself and reset the signal. -% \appendtoks -% \to \everysetupdocument +% \fontdimen1\nullfont 0\scaledpoint +% \fontdimen2\nullfont 256377\scaledpoint +% \fontdimen3\nullfont 128188\scaledpoint +% \fontdimen4\nullfont 85459\scaledpoint +% \fontdimen5\nullfont 338952\scaledpoint +% \fontdimen6\nullfont 786432\scaledpoint +% \fontdimen7\nullfont 85459\scaledpoint + +\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\resetnullfont % this is needed because some macro packages (tikz) misuse \nullfont + {\dorecurse7{\fontdimen\recurselevel\nullfont\zeropoint}% + \ctxlua{fonts.definers.resetnullfont()}% in luatex 0.70 this will also do the previous + \globallet\resetnullfont\relax} + +\def\preloaddefaultfonts + {\resetpreloadfonts + \setupbodyfont[modern,\fontstyle,\fontbody]% + \showmessage\m!fonts6{fallback modern \fontstyle\normalspace\normalizedbodyfontsize}} + +\def\preloaddefaultfontsmm + {\writestatus\m!fonts{preloading latin modern fonts (math)}% + \definetypeface[\fontclass][\c!mm][\s!math][modern][\s!default]% + \showmessage\m!fonts6{fallback modern mm \normalizedbodyfontsize}} + +\def\preloaddefaultfontstt + {\writestatus\m!fonts{preloading latin modern fonts (mono)}% + \definetypeface[\fontclass][\c!tt][\s!mono][modern][\s!default]% + \showmessage\m!fonts6{fallback modern tt \normalizedbodyfontsize}} + +\def\resetpreloadfonts + {\glet\preloaddefaultfonts \relax + %\glet\preloaddefaultfontstt \relax + %\glet\preloaddefaultfontsmm \relax + \glet\zerostagepreloadfonts \relax + \glet\firststagepreloadfonts \relax + \glet\secondstagepreloadfonts\relax + %\glet\thirdstagepreloadfonts \relax + \glet\fourthstagepreloadfonts\relax + \global\everyhbox\emptytoks + \global\everyvbox\emptytoks + \resetnullfont} + +\def\resetcheckedfonts + {\glet\preloaddefaultfontstt \relax + \glet\preloaddefaultfontsmm \relax + \glet\thirdstagepreloadfonts \relax} + +\def\dozerostagepreloadfonts + {\definedfont[\s!file:lmmono10-regular sa 1]} + +\def\zerostagepreloadfonts + {\writestatus\m!fonts{beware: no fonts are loaded yet, using 'lm mono' in box}% + \glet\zerostagepreloadfonts\dozerostagepreloadfonts + \zerostagepreloadfonts} -\newconditional\fontsareloaded +\appendtoks + \everyhbox{\zerostagepreloadfonts} + \everyvbox{\zerostagepreloadfonts} +\to \everydump -\def\preloadfonts % never called, needs a clean up - {\global\loadingfontsfalse - \ifconditional\fontsareloaded \else - \doifmodeelse {*nofonts} - {\writestatus\m!fonts{latin modern fonts are not preloaded}} - {\writestatus\m!fonts{preloading latin modern fonts}% - \usetypescript[modern]% - \setuptypeface[modern]% - \showmessage\m!fonts6{\normalizedbodyfontsize\normalspace\fontstyle}}% - \fi - \global\let\preloadfonts\relax} +\def\firststagepreloadfonts % see core-def.mkiv + {\doifmodeelse{*nofonts} + {\writestatus\m!fonts{latin modern fonts are not preloaded}} + {\preloaddefaultfonts + \writestatus\m!fonts{preloading latin modern fonts (first stage)}}} -% maybe add this to \everystarttext -% -% \ifconditional\fontsareloaded\else -% \usetypescript[modern]% -% \setuptypeface[modern]% -% \fi +\def\secondstagepreloadfonts % see core-def.mkiv + {\writestatus\m!fonts{preloading latin modern fonts (second stage)}% + \preloaddefaultfonts} + +\def\thirdstagepreloadfonts % always + {\ifx\fontclass\empty + \writestatus\m!fonts{preloading latin modern fonts (third stage)}% + \preloaddefaultfonts + \else + \resetpreloadfonts + \pushmacro\fontstyle + \ifcsname\fontclass\c!mm\s!features\endcsname \else + \preloaddefaultfontsmm + \fi + \ifcsname\fontclass\c!tt\s!features\endcsname \else + \preloaddefaultfontstt + \fi + \popmacro\fontstyle + \resetcheckedfonts % reset third, mm and tt + \setupbodyfont[\fontstyle]% + \fi} + +\def\fourthstagepreloadfonts + {\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 + \resetpreloadfonts + \endgroup} %D Here comes the main font switching macros. These macros %D handle changes in size as well as returning to the global @@ -1957,25 +2235,24 @@ \def\dosetfont#1#2% #1 = set/switch state {\doifelse{#2}\v!global {\restoreglobalbodyfont} - {\processcommacommand[#2]{\dodosetfont{#1}}% ##1 get also passed - \ifloadingfonts\else - \global\settrue\fontsareloaded + {\processcommacommand[#2]{\dodocheckfontsize}% + \processcommacommand[#2]{\dodosetfont{#1}}% + \ifproductionrun + \thirdstagepreloadfonts \doswitchpoints[\normalizedbodyfontsize]% \doswitchstyle[\fontstyle]% \ifx\defaultfontclass\empty \let\defaultfontclass\fontclass \fi \fi}% - \chardef\currentxfontsize\zerocount} + \currentxfontsize\zerocount} + +\def\dodocheckfontsize#1% + {\doifnumberelse{#1}{\checkbodyfontenvironment[#1]}\donothing} \def\dodosetfont#1#2% #1 = set/switch state | check fo rempty, else space {\doifsomething{#2}{\dododosetfont{#1}{#2}{\showmessage\m!fonts4{#2}}}} -% % % this can be retrofitted in mkii code % % % - -% \def\normalizebodyfontsize#1\to#2% -% {\@EA\@EA\@EA\donormalizedbodyfontsize\@EA\WITHOUTPT\the\dimexpr#1+\ifcase\fontdigits.5\or.05\or.005\fi\points\relax000\to#2} - \def\dododosetfont#1#2#3% #1 = set/switch state ! ! ! !could also be used for mkii {\doifnumberelse{#2}\dodododosetfont\redododosetfont{#1}{#2}{#3}} @@ -2009,7 +2286,7 @@ \fi\fi} \def\dodododosetfont#1#2#3% #1 = set/switch state - {\normalizebodyfontsize#2\to\normalizedsetfont + {\edef\normalizedsetfont{\thenormalizedbodyfontsize{#2}}% \ifcsname\@size@\normalizedsetfont\endcsname \else \defineunknownfont{#2}% \fi @@ -2020,14 +2297,6 @@ #3\dosetsubstitutefont{#1}{#2}% \fi} -% % % - -%D In the previous macros we use \type{\currentxfontsize} to -%D hold the current x||size of the font. This enables us to -%D support for instance \type{\sl} inside a \type{\tx} switch. - -\chardef\currentxfontsize=0 - %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 @@ -2076,25 +2345,14 @@ \trycurrentfontclass{#1}% \fi\fi\fi} -\def\savefontclassparameters#1#2#3#4% #1=rm|ss|.. rscale features fallbacks +\def\savefontclassparameters#1#2#3#4#5% #1=rm|ss|.. rscale features fallbacks goodies {\setxvalue{\fontclass#1\s!rscale }{#2}% \setxvalue{\fontclass#1\s!features }{#3}% - \setxvalue{\fontclass#1\s!fallbacks}{#4}} + \setxvalue{\fontclass#1\s!fallbacks}{#4}% + \setxvalue{\fontclass#1\s!goodies }{#5}} \settrue\autotypescripts -% \def\trycurrentfontclass#1% -% {\ifconditional\autotypescripts -% \usetypescript[#1]% -% \ifcsname\@fontclass@#1\endcsname -% \edef\fontclass{#1}% -% \else -% \letvalue{\@no@fontclass@#1}\empty -% \fi -% \else -% \letvalue{\@no@fontclass@#1}\empty -% \fi} - \def\trycurrentfontclass#1% {\ifconditional\autotypescripts % try to load typescript #1 @@ -2110,12 +2368,12 @@ \edef\fontclass{#1}% \else % todo: message - \letvalue{\@no@fontclass@#1}\empty + \letvalueempty{\@no@fontclass@#1}% \fi \fi \else % todo: message - \letvalue{\@no@fontclass@#1}\empty + \letvalueempty{\@no@fontclass@#1}% \fi} \let\defaultfontstyle \c!rm @@ -2131,7 +2389,7 @@ % 0=never 1=everymath 2=always -\chardef\synchronizebigmathflag=1 +\setnewconstant\synchronizebigmathflag\plusone \appendtoks \ifcase\synchronizebigmathflag @@ -2143,9 +2401,9 @@ \fi \to \everymathematics -\def\nobigmath {\chardef\synchronizebigmathflag\zerocount} -\def\autobigmath{\chardef\synchronizebigmathflag\plusone\synchronizebigmath} -\def\bigmath {\chardef\synchronizebigmathflag\plustwo\synchronizebigmath} +\def\nobigmath {\synchronizebigmathflag\zerocount} +\def\autobigmath{\synchronizebigmathflag\plusone\synchronizebigmath} +\def\bigmath {\synchronizebigmathflag\plustwo\synchronizebigmath} \let\bigmathfontsize\empty @@ -2386,7 +2644,7 @@ %D used. Here we also set \type{\currentxfontsize}. \def\dosetcurrentfontxxxalternative#1#2#3#4% - {\chardef\currentxfontsize#2\relax + {\currentxfontsize#2\relax \ifmmode #4% \else\ifcsname\bodyfontvariable{\normalizedbodyfontsize#3}\endcsname @@ -2404,7 +2662,7 @@ \def\checknestedxfontsize % option {\ifcase\currentxfontsize\else\ifx\fontsize\empty\else - \chardef\currentxfontsize\zeropoint + \currentxfontsize\zerocount \let\fontsize\empty \let\tx\normaltx \let\txx\normaltxx @@ -2506,7 +2764,7 @@ {\bodyfontsize#1\relax \dimensiontocount\bodyfontsize\bodyfontpoints % rounded, still used in m-chart \edef\bodyfontfactor{\withoutpt\the\bodyfontsize}% - \normalizebodyfontsize\bodyfontsize\to\normalizedbodyfontsize + \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}% \dosetbodyfontface \textface \s!text \dosetbodyfontface \scriptface \s!script \dosetbodyfontface \scriptscriptface \s!scriptscript} @@ -2545,8 +2803,6 @@ % \newtoks \everysetupbodyfont % \newtoks \everyswitchtobodyfont -\chardef\bodyfontsetstate=0 - \definecomplexorsimple\setupbodyfont \def\simplesetupbodyfont @@ -2557,9 +2813,9 @@ {\doifsomething{#1} {\dosetfont1{#1}% \globalbodyfontsize\localbodyfontsize - \normalizebodyfontsize\globalbodyfontsize\to\normalizedglobalbodyfontsize + \edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\globalbodyfontsize}% \let\globalfontstyle\fontstyle - \ifloadingfonts\else + \ifproductionrun \the\everybodyfont \the\everyglobalbodyfont \saveinterlinespace @@ -2602,10 +2858,6 @@ % \installfontfeature[otf][tlig] % \installfontfeature[otf][trep] -%D tricky but ok: - -\appendtoks\ctxlua{fonts.tfm.cleanup()}\to\everyshipout - %D Todo: % \def\os{\groupedcommand{\setfontfeature{oldstyle}}{}} @@ -2617,52 +2869,94 @@ \def\dodefinefontfeature[#1][#2][#3]% {\global\expandafter\chardef\csname\??fq=#1\endcsname % beware () needed as we get two values returned - \ctxlua{tex.write((fonts.define.specify.preset_context("#1","#2","#3")))}\relax} + \ctxsprint{((fonts.specifiers.presetcontext("#1","#2","#3")))}\relax} + +\definefontfeature % experiment, this might move to the lua code + [always] + [mode=auto, + kern=yes, + mark=yes, + mkmk=yes, + curs=yes] \definefontfeature [default] - [%mode=node, - liga=yes,kern=yes,tlig=yes,trep=yes] % texligatures=yes,texquotes=yes + [always] + [liga=yes, + tlig=yes, + trep=yes] % texligatures=yes,texquotes=yes \definefontfeature [smallcaps] - [%mode=node,liga=yes, - smcp=yes,kern=yes,tlig=yes,trep=yes] % texligatures=yes,texquotes=yes + [always] + [smcp=yes, + tlig=yes, + trep=yes] % texligatures=yes,texquotes=yes \definefontfeature [oldstyle] - [%mode=node, - onum=yes,liga=yes,kern=yes,tlig=yes,trep=yes] % texligatures=yes,texquotes=yes + [always] + [onum=yes, + liga=yes, + tlig=yes, + trep=yes] % texligatures=yes,texquotes=yes \definefontfeature % == default unless redefined [ligatures] - [%mode=node, - liga=yes,kern=yes,tlig=yes,trep=yes] + [always] + [liga=yes, + tlig=yes, + trep=yes] \definefontfeature % can be used for type1 fonts [complete] - [liga=yes,kern=yes,compose=yes,tlig=yes,trep=yes] + [always] + [compose=yes, + liga=yes, + tlig=yes, + trep=yes] \definefontfeature + [none] + [mode=none, + features=no] + +\definefontfeature % might move [arabic] [mode=node,language=dflt,script=arab,ccmp=yes, init=yes,medi=yes,fina=yes,isol=yes, liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes, mark=yes,mkmk=yes,kern=yes,curs=yes] -\definefontfeature - [none] - [mode=none,features=no] +\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] + +% symbols: \definefontfeature - [virtualmath] - [mode=base,liga=yes,kern=yes,tlig=yes,trep=yes] + [dingbats] + [mode=base, + goodies=dingbats, + unicoding=yes] -% for the moment here, this will change but we need it for mk.tex +% math: -\definefontfeature[math-text] [virtualmath][ssty=no] -\definefontfeature[math-script] [virtualmath][ssty=1,mathsize=yes] -\definefontfeature[math-scriptscript][virtualmath][ssty=2,mathsize=yes] +\definefontfeature + [virtualmath] + [mode=base, + liga=yes, + kern=yes, + tlig=yes, + trep=yes, + language=dflt, + script=math] + +\definefontfeature[math-text] [virtualmath][mathalternates=yes,ssty=no] +\definefontfeature[math-script] [virtualmath][mathalternates=yes,ssty=1,mathsize=yes] +\definefontfeature[math-scriptscript][virtualmath][mathalternates=yes,ssty=2,mathsize=yes] \definefontfeature [math-nostack-text] [math-text] [nostackmath=yes] \definefontfeature [math-nostack-script] [math-script] [nostackmath=yes] @@ -2674,13 +2968,21 @@ %D Also new, handy for manuals: -\unexpanded\def\fontchar#1{\ctxlua{fonts.char("#1")}} - -\let\otfchar\fontchar % will disappear, for compatibility only -\let\afmchar\fontchar % will disappear, for compatibility only +\unexpanded\def\fontchar#1{\ctxcommand{fontchar("#1")}} %D: We cannot yet inherit because no colors are predefined. +\definecolor[trace:0][s=.6] +\definecolor[trace:1][r=.6] +\definecolor[trace:2][g=.6] +\definecolor[trace:3][b=.6] +\definecolor[trace:4][r=.6,g=.6] +\definecolor[trace:5][r=.6,b=.6] +\definecolor[trace:6][g=.6,b=.6] +\definecolor[trace:7][r=.8,g=.4] +\definecolor[trace:8][r=.8,b=.4] +\definecolor[trace:9][g=.4,b=.8] + \definecolor[font:init][r=.75] \definecolor[font:medi][g=.75] \definecolor[font:fina][b=.75] @@ -2702,7 +3004,7 @@ {\dodoubleargument\dofontfeatureslist} \def\dofontfeatureslist[#1][#2]% todo: arg voor type - {\ctxlua{tex.sprint(tex.ctxcatcodes,fonts.define.specify.context_tostring("#1","otf","\luaescapestring{#2}","yes","no",true,{"number"}))}} + {\ctxsprint{fonts.specifiers.contexttostring("#1","otf","\luaescapestring{#2}","yes","no",true,{"number"})}} \attribute\zerocount\zerocount % first in list, so fast match @@ -2723,14 +3025,24 @@ % % \typebuffer \getbuffer -\def\featureattribute#1{\ctxlua{tex.sprint(fonts.define.specify.context_number("#1"))}} -\def\setfontfeature #1{\edef\currentfeature{#1}\attribute\zerocount\featureattribute{#1}\relax} -\def\resetfontfeature#1{\let\currentfeature\empty\attribute\zerocount\zerocount} % initial value +% \unexpanded\def\featureattribute#1{\ctxsprint{fonts.specifiers.contextnumber("#1"))}} +% \unexpanded\def\setfontfeature #1{\edef\currentfeature{#1}\attribute\zerocount\featureattribute{#1}\relax} +% \unexpanded\def\resetfontfeature#1{\let\currentfeature\empty\attribute\zerocount\zerocount} % initial value -\def\addfontfeaturetoset #1{\ctxlua{fonts.withset("#1", 1)}} % merge -\def\subtractfontfeaturefromset #1{\ctxlua{fonts.withset("#1",-1)}} % merge -\def\addfontfeaturetofont #1{\ctxlua{fonts.withfnt("#1", 2)}} % overload -\def\subtractfontfeaturefromfont#1{\ctxlua{fonts.withfnt("#1",-2)}} % overload +% \def\addfontfeaturetoset #1{\ctxlua{fonts.withset("#1", 1)}} % merge +% \def\subtractfontfeaturefromset #1{\ctxlua{fonts.withset("#1",-1)}} % merge +% \def\addfontfeaturetofont #1{\ctxlua{fonts.withfnt("#1", 2)}} % overload +% \def\subtractfontfeaturefromfont#1{\ctxlua{fonts.withfnt("#1",-2)}} % overload + +\unexpanded\def\featureattribute#1{\ctxcommand{featureattribute("#1")}} +\unexpanded\def\setfontfeature #1{\ctxcommand{setfontfeature("#1")}\edef\currentfeature{#1}} +\unexpanded\def\resetfontfeature#1{\ctxcommand{resetfontfeature()}\let\currentfeature\empty} % initial value +\unexpanded\def\resetfontfeature#1{\attribute\zerocount\zerocount\let\currentfeature\empty} % initial value + +\unexpanded\def\addfontfeaturetoset #1{\ctxcommand{addfs("#1")}} % merge +\unexpanded\def\subtractfontfeaturefromset #1{\ctxcommand{subfs("#1")}} % merge +\unexpanded\def\addfontfeaturetofont #1{\ctxcommand{addff("#1")}} % overload +\unexpanded\def\subtractfontfeaturefromfont#1{\ctxcommand{subff("#1")}} % overload \let\setff\setfontfeature \let\addfs\addfontfeaturetoset @@ -2842,7 +3154,7 @@ \def\fullrestoreglobalbodyfont {\let\fontsize\defaultfontsize \let\fontbody\defaultfontbody - \chardef\currentxfontsize\zerocount + \currentxfontsize\zerocount \let\fontclass\globalfontclass \doswitchpoints[\normalizedglobalbodyfontsize]% \doswitchstyle[\globalfontstyle]% @@ -2855,7 +3167,7 @@ \def\partialrestoreglobalbodyfont {\let\fontsize\defaultfontsize \let\fontbody\defaultfontbody - \chardef\currentxfontsize\zerocount + \currentxfontsize\zerocount \redoconvertfont \tf \the\everybodyfont % indeed needed @@ -2939,17 +3251,44 @@ %D text and headings, which is accomplished by assigning both %D arguments. +% \def\dodefinealternativestyle[#1][#2][#3]% +% {\def\docommand##1% +% {\ifcsname##1\endcsname\else\setuvalue{##1}{\groupedcommand{#2}{}}\fi +% \setvalue{\@letter@ ##1}{#2}% +% \setvalue{\@noletter@##1}{#3}}% +% \processcommalist[#1]\docommand} + +\setnewconstant \currentalternativestyleindex \plusone + +\def\dododefinealternativestyle#1#2#3% + {\ifcsname#3\endcsname + % no redefinition + \else + \setuvalue{#3}{\groupedcommand{#1}{}}% + \fi + \setvalue{\??ft:as:#3}{\doapplyalternativestyle{#1}{#2}}}% + \def\dodefinealternativestyle[#1][#2][#3]% - {\def\docommand##1% - {\ifcsname##1\endcsname\else\setuvalue{##1}{\groupedcommand{#2}{}}\fi - \setvalue{\@letter@ ##1}{#2}% - \setvalue{\@noletter@##1}{#3}}% - \processcommalist[#1]\docommand} + {\processcommalist[#1]{\dododefinealternativestyle{#2}{#3}}} % also gets {##1} + +\def\applyalternativestyle#1% + {\ifcsname\??ft:as:#1\endcsname\csname\??ft:as:#1\expandafter\endcsname\fi} + +\def\doapplyalternativestyle + {\ifcase\currentalternativestyleindex + \expandafter\gobbletwoarguments + \or + \expandafter\firstoftwoarguments + \or + \expandafter\secondoftwoarguments + \else + \expandafter\firstoftwoarguments + \fi} \unexpanded\def\definealternativestyle {\dotripleempty\dodefinealternativestyle} -\unexpanded\def\definestyle{\definealternativestyle} +\unexpanded\def\definestyle{\definealternativestyle} % later redefined %D Maybe too geneneric, but probably ok is the following. (Maybe one %D day we will use a dedicated grouped command for styles.) @@ -3005,51 +3344,74 @@ %D conversion by saying \type{\redoconvertfont}. % subtle ... \expandafter is needed else problems with lookahead caps - -\def\@@dodoconvertfont{\csname\@letter@ \p!defined\expandafter\endcsname\gobbleoneargument} -\def\@@donoconvertfont{\csname\@noletter@\p!defined\endcsname} -\def\@@redoconvertfont{\csname \p!defined\expandafter\endcsname\gobbleoneargument} - +% +% this will be cleaned up +% % beware: p!defined can contain crap like \edef crap {...} and such -% so we need to pass #1 as well - -\unexpanded\def\dodoconvertfont#1% #2% we need the protection - {\edef\p!defined{#1}% - \ifx\p!defined\empty\else - \@EA\dododoconvertfont - \fi{#1}} - -\def\dododoconvertfont % #1 - {\ifcsname\@letter@\detokenize\@EA{\p!defined}\endcsname - \@EA\@@dodoconvertfont - \else\ifcsname\detokenize\@EA{\p!defined}\endcsname - \@EAEAEA\@@redoconvertfont - \else - \@EAEAEA\firstofoneargument - \fi\fi} % {#1} +% so we need to pass #1 as well .. no longer needed in luatex -\let\doconvertfont\dodoconvertfont +% \def\@@dodoconvertfont{\csname\@letter@ \p!defined\expandafter\endcsname\gobbleoneargument} +% \def\@@donoconvertfont{\csname\@noletter@\p!defined\endcsname} +% \def\@@redoconvertfont{\csname \p!defined\expandafter\endcsname\gobbleoneargument} +% +% \unexpanded\def\dodoconvertfont#1% #2% we need the protection +% {\edef\p!defined{#1}% +% \ifx\p!defined\empty\else +% \@EA\dododoconvertfont +% \fi{#1}} +% +% \def\dododoconvertfont % #1 (detokenize no longer needed in luatex) +% {\ifcsname\@letter@\detokenize\@EA{\p!defined}\endcsname +% \@EA\@@dodoconvertfont +% \else\ifcsname\detokenize\@EA{\p!defined}\endcsname +% \@EAEAEA\@@redoconvertfont +% \else +% \@EAEAEA\firstofoneargument +% \fi\fi} % {#1} +% +% \let\doconvertfont\dodoconvertfont +% +% \unexpanded\def\noconvertfont#1% #2% +% {\edef\p!defined{#1}% +% \ifx\p!defined\empty +% \else +% \@EA\nononoconvertfont +% \fi} +% +% \def\nononoconvertfont +% {\ifcsname\@noletter@\detokenize\@EA{\p!defined}\endcsname +% \@EA\@@donoconvertfont +% \fi} +% +% %D Extras: +% +% \unexpanded\def\dontconvertfont{\let\doconvertfont\noconvertfont} +% \unexpanded\def\redoconvertfont{\let\doconvertfont\dodoconvertfont} -\unexpanded\def\noconvertfont#1% #2% - {\edef\p!defined{#1}% - \ifx\p!defined\empty - \else - \@EA\nononoconvertfont - \fi} +%D These commands are not grouped! Grouping is most probably +%D done by the calling macro's and would lead to unnecessary +%D overhead. -\def\nononoconvertfont - {\ifcsname\@noletter@\detokenize\@EA{\p!defined}\endcsname - \@EA\@@donoconvertfont +\unexpanded\def\doconvertfont#1% #2% we need the protection + {\edef\currentconvertfont{#1}% + \ifx\currentconvertfont\empty \else + \@EA\dodoconvertfont \fi} -%D Extras: +\def\dodoconvertfont + {\edef\dtcurrentconvertfont{\detokenize\@EA{\currentconvertfont}}% + \ifcsname\??ft:as:\dtcurrentconvertfont\endcsname + \csname\??ft:as:\dtcurrentconvertfont\expandafter\endcsname + \else\ifcsname\dtcurrentconvertfont\endcsname + \csname\dtcurrentconvertfont\expandafter\endcsname + \else + \@EAEAEA\currentconvertfont + \fi\fi} -\unexpanded\def\dontconvertfont{\let\doconvertfont\noconvertfont} -\unexpanded\def\redoconvertfont{\let\doconvertfont\dodoconvertfont} +%D Low level switches (downward compatible): -%D These commands are not grouped! Grouping is most probably -%D done by the calling macro's and would lead to unnecessary -%D overhead. +\unexpanded\def\dontconvertfont{\currentalternativestyleindex\plustwo} +\unexpanded\def\redoconvertfont{\currentalternativestyleindex\plusone} %D \macros %D {em,emphasistypeface,emphasisboldface} @@ -3093,12 +3455,38 @@ \getvalue\emphasizedtypeface \fi\fi\fi} -\def\emphasistypeface{\doemphasistypeface\sl\it} -\def\emphasisboldface{\doemphasistypeface\bs\bi} +\unexpanded\def\emphasistypeface{\doemphasistypeface\sl\it} +\unexpanded\def\emphasisboldface{\doemphasistypeface\bs\bi} + +\unexpanded\def\normalboldface + {\relax\ifx\fontalternative\c!it \bi + \else \ifx\fontalternative\c!sl \bs + \else \bf \fi\fi} + +\unexpanded\def\normaltypeface + {\relax + \ifx\fontalternative\c!bi \it \else + \ifx\fontalternative\c!bs \sl \else + \tf \fi\fi} + +\unexpanded\def\swaptypeface + {\relax + \ifx\fontalternative\c!it \tf \else + \ifx\fontalternative\c!sl \tf \else + \ifx\fontalternative\c!bf \emphasisboldface \else + \ifx\fontalternative\c!bs \bf \else + \ifx\fontalternative\c!bi \bf \else + \emphasistypeface \fi\fi\fi\fi\fi} + +\let\typeface\normaltypeface +\let\boldface\normalboldface +\let\swapface\swaptypeface %D To be set with the default body font environment: \type %D {em} being \type {slanted} or \type {italic}. +% maybe a \csname...\fontalternative\endcsname + \newconditional\emneeded \newtoks\everyemphasized @@ -3125,8 +3513,7 @@ \emphasistypeface \fi\fi\fi\fi\fi \the\everyemphasized - \ifconditional\emneeded\relax - \else + \ifconditional\emneeded\else \expandafter\aftergroup \fi \emphasiscorrection} @@ -3137,7 +3524,7 @@ % \setupbodyfontenvironment [default] [em={\italic\color[red]}] %D The next feature was not present in previous versions. It -%D takes care of \type {\em \bf ...} sitiations. +%D takes care of \type {\em \bf ...} situations. \def\setemphasisboldface {\let\savedemphasisboldface\bf @@ -3161,10 +3548,10 @@ \let\italiccorrection=\/ % tex primitive -\def\emphasiscorrection - {\ifhmode - \expandafter\emphasislook - \fi} +\def\emphasiscorrection % not in raw alignment groups, else omit problem + {\ifhmode\ifnum\currentgrouptype=\@@aligngroup\else + \expandafter\expandafter\expandafter\emphasislook + \fi\fi} \def\emphasislook {\begingroup @@ -3284,7 +3671,7 @@ %D The implementation is rather straightforward in using %D \type{\halign}. -\fetchruntimecommand \showbodyfont {\f!fontprefix\s!run.mkiv} +\fetchruntimecommand \showbodyfont {\f!fontprefix\s!run} %D \macros %D {showfontstrip, testminimalbaseline, showminimalbaseline} @@ -3295,9 +3682,9 @@ %D %D \showfontstrip \blank \showminimalbaseline -\fetchruntimecommand \showfontstrip {\f!fontprefix\s!run.mkiv} -\fetchruntimecommand \testminimalbaseline {\f!fontprefix\s!run.mkiv} -\fetchruntimecommand \showminimalbaseline {\f!fontprefix\s!run.mkiv} +\fetchruntimecommand \showfontstrip {\f!fontprefix\s!run} +\fetchruntimecommand \testminimalbaseline {\f!fontprefix\s!run} +\fetchruntimecommand \showminimalbaseline {\f!fontprefix\s!run} %D \macros %D {showkerning} @@ -3306,7 +3693,7 @@ %D %D \showkerning{Can you guess what kerning is?} -\fetchruntimecommand \showkerning {\f!fontprefix\s!run.mkiv} +\fetchruntimecommand \showkerning {\f!fontprefix\s!run} %D \macros %D {showbodyfontenvironment} @@ -3319,7 +3706,7 @@ %D %D \showsetup{showbodyfontenvironment} -\fetchruntimecommand \showbodyfontenvironment {\f!fontprefix\s!run.mkiv} +\fetchruntimecommand \showbodyfontenvironment {\f!fontprefix\s!run} %D \macros %D {showfont,showfontstyle,showligatures} @@ -3335,11 +3722,11 @@ % to be internationalized -\fetchruntimecommand \showfont {\f!fontprefix\s!run.mkiv} -\fetchruntimecommand \showfontstyle {\f!fontprefix\s!run.mkiv} -\fetchruntimecommand \showligature {\f!fontprefix\s!run.mkiv} -\fetchruntimecommand \showligatures {\f!fontprefix\s!run.mkiv} -\fetchruntimecommand \showcharratio {\f!fontprefix\s!run.mkiv} +\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} @@ -3437,36 +3824,90 @@ \let\thedefinedfont\relax -\def\symbolicsizedfont#1#2#3% - {\scaledfontsize#1% - \scaledfontsize#2\scaledfontsize - \font\thedefinedfont=\truefontname{\glyphfontfile{#3}} at \currentfontbodyscale\scaledfontsize\relax - \thedefinedfont} +% \def\symbolicsizedfont#1#2#3% +% {\scaledfontsize#1% +% \scaledfontsize#2\scaledfontsize +% \font\thedefinedfont=\truefontname{\glyphfontfile{#3}} at \currentfontbodyscale\scaledfontsize\relax +% \thedefinedfont} +% +% \def\symbolicscaledfont +% {\symbolicsizedfont\fontbody} +% +% \unexpanded\def\symbolicfont +% {\symbolicsizedfont\fontbody\plusone} +% +% \unexpanded\def\getglyph#1#2% slow, faster, much faster +% %{{\definefont[\s!dummy][\glyphfontfile{#1} sa \currentfontscale]\dummy#2}} +% %{{\definefont[\s!dummy][\glyphfontfile{#1} sa *]\dummy#2}} +% %{{\symbolicfont{#1}#2}} +% {{\symbolicfont{#1}\doifnumberelse{#2}\char\donothing#2}} +% +% \unexpanded\def\getscaledglyph#1#2#3% +% {{\symbolicscaledfont{#1}{#2}\doifnumberelse{#3}\char\donothing#3}} +% +% \unexpanded\def\getrawglyph#1#2% for simple symbols +% {{\scaledfontsize\fontbody +% \font\thedefinedfont=#1 at \currentfontbodyscale\scaledfontsize\relax +% \thedefinedfont\doifnumberelse{#2}\char\donothing#2}} +% +% \unexpanded\def\getfontchar#1#2% +% {{\symbolicfont{#1}\fontchar{#2}}} + +\def\setscaledstyledsymbolicfont#1#2#3% quite a slowdown, glyphfontfile + {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#3}} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}% + \ifcsname\??ss->\askedsymbolfont\endcsname + \csname\??ss->\askedsymbolfont\endcsname + \else + \dodefinesymbolicfont + \fi} + +\def\setscaleddirectsymbolicfont#1#2#3% quite a slowdown, glyphfontfile + {\edef\askedsymbolfont{\truefontname{#3} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}% + \ifcsname\??ss->\askedsymbolfont\endcsname + \csname\??ss->\askedsymbolfont\endcsname + \else + \dodefinesymbolicfont + \fi} + +\def\setstyledsymbolicfont#1% quite a slowdown, glyphfontfile + {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#1}} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}% + \ifcsname\??ss->\askedsymbolfont\endcsname + \csname\??ss->\askedsymbolfont\endcsname + \else + \dodefinesymbolicfont + \fi} -\def\symbolicscaledfont - {\symbolicsizedfont\fontbody} +\def\setdirectsymbolicfont#1% + {\edef\askedsymbolfont{\truefontname{#1} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}% + \ifcsname\??ss->\askedsymbolfont\endcsname + \csname\??ss->\askedsymbolfont\endcsname + \else + \dodefinesymbolicfont + \fi} -\unexpanded\def\symbolicfont - {\symbolicsizedfont\fontbody\plusone} +\def\dodefinesymbolicfont + {\definefont[currentsymbolfont][\askedsymbolfont]% + \currentsymbolfont + \global\expandafter\let\csname\??ss->\askedsymbolfont\endcsname\lastrawfontcall} -\unexpanded\def\getglyph#1#2% slow, faster, much faster - %{{\definefont[\s!dummy][\glyphfontfile{#1} sa \currentfontscale]\dummy#2}} - %{{\definefont[\s!dummy][\glyphfontfile{#1} sa *]\dummy#2}} - %{{\symbolicfont{#1}#2}} - {{\symbolicfont{#1}\doifnumberelse{#2}\char\donothing#2}} +\unexpanded\def\getnamedglyphstyled#1#2{{\setstyledsymbolicfont{#1}\ctxcommand{fontchar("#2")}}} +\unexpanded\def\getnamedglyphdirect#1#2{{\setdirectsymbolicfont{#1}\ctxcommand{fontchar("#2")}}} +\unexpanded\def\getglyphstyled #1#2{{\setstyledsymbolicfont{#1}\doifnumberelse{#2}\char\donothing#2}} +\unexpanded\def\getglyphdirect #1#2{{\setdirectsymbolicfont{#1}\doifnumberelse{#2}\char\donothing#2}} +\unexpanded\def\getscaledglyph #1#2#3{{\setscaledstyledsymbolicfont{#1}{#2}\doifnumberelse{#3}\char\donothing#3}} -\unexpanded\def\getscaledglyph#1#2#3% - {{\symbolicscaledfont{#1}{#2}\doifnumberelse{#3}\char\donothing#3}} +\let\getglyph \getglyphstyled % old +\let\getrawglyph \getglyphdirect % old +\let\symbolicsizedfont\setscaledstyledsymbolicfont % old +\let\symbolicfont \setstyledsymbolicfont % old -\unexpanded\def\getrawglyph#1#2% for simple symbols - {{\scaledfontsize\fontbody - \font\thedefinedfont=#1 at \currentfontbodyscale\scaledfontsize\relax - \thedefinedfont\doifnumberelse{#2}\char\donothing#2}} +\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 \starttypings %D \definefontsynonym [EuroSans] [eurose] %D \definefontsynonym [EuroSansBold] [euroseb] %D \definefontsynonym [EuroSansItalic] [eurosei] @@ -3693,24 +4134,43 @@ \definefontsize[\c!a] \definefontsize[\c!b] \definefontsize[\c!c] \definefontsize[\c!d] -\definealternativestyle [\v!mediaeval] [\os] [] -\definealternativestyle [\v!normal] [\tf] [] -\definealternativestyle [\v!bold] [\bf] [] -\definealternativestyle [\v!type] [\tt] [] -\definealternativestyle [\v!mono] [\tt] [] -\definealternativestyle [\v!slanted] [\sl] [] -\definealternativestyle [\v!italic] [\it] [] -\definealternativestyle [\v!boldslanted,\v!slantedbold] [\bs] [] -\definealternativestyle [\v!bolditalic,\v!italicbold] [\bi] [] -\definealternativestyle [\v!small,\v!smallnormal] [\tfx] [] -\definealternativestyle [\v!smallbold] [\bfx] [] -\definealternativestyle [\v!smalltype] [\ttx] [] -\definealternativestyle [\v!smallslanted] [\slx] [] -\definealternativestyle [\v!smallboldslanted,\v!smallslantedbold] [\bsx] [] -\definealternativestyle [\v!smallbolditalic,\v!smallitalicbold] [\bix] [] - -\definealternativestyle [\v!sans,\v!sansserif] [\ss] [] -\definealternativestyle [\v!sansbold] [\ss\bf] [] +\definealternativestyle [\v!mediaeval] [\os] [] +\definealternativestyle [\v!normal] [\tf] [] +\definealternativestyle [\v!bold] [\bf] [] +\definealternativestyle [\v!type] [\tt] [] +\definealternativestyle [\v!mono] [\tt] [] +\definealternativestyle [\v!slanted] [\sl] [] +\definealternativestyle [\v!italic] [\it] [] +\definealternativestyle [\v!boldslanted,\v!slantedbold] [\bs] [] +\definealternativestyle [\v!bolditalic,\v!italicbold] [\bi] [] + +% \definealternativestyle [\v!small,\v!smallnormal] [\tfx] [] +% \definealternativestyle [\v!smallbold] [\bfx] [] +% \definealternativestyle [\v!smalltype] [\ttx] [] +% \definealternativestyle [\v!smallslanted] [\slx] [] +% \definealternativestyle [\v!smallboldslanted,\v!smallslantedbold] [\bsx] [] +% \definealternativestyle [\v!smallbolditalic,\v!smallitalicbold] [\bix] [] + +\definealternativestyle [\v!small,\v!smallnormal] [\setsmallbodyfont\tf] [] +\definealternativestyle [\v!smallbold] [\setsmallbodyfont\bf] [] +\definealternativestyle [\v!smalltype] [\setsmallbodyfont\tt] [] +\definealternativestyle [\v!smallslanted] [\setsmallbodyfont\sl] [] +\definealternativestyle [\v!smallboldslanted,\v!smallslantedbold] [\setsmallbodyfont\bs] [] +\definealternativestyle [\v!smallbolditalic,\v!smallitalicbold] [\setsmallbodyfont\bi] [] + +\definealternativestyle [\v!bigger] [\setbigbodyfont \tf] [] +\definealternativestyle [\v!smaller] [\setsmallbodyfont\tf] [] + +\definealternativestyle [\v!sans,\v!sansserif] [\ss] [] +\definealternativestyle [\v!sansbold] [\ss\bf] [] + +%D We can go on and on and on: +%D +%D \starttyping +%D \setupbodyfontenvironment[default][p=0.8,q=0.6] +%D \definefontsize[p] +%D \definefontsize[q] +%D \stoptyping %D Slow but handy: @@ -3774,15 +4234,83 @@ %D New commands (not yet interfaced): -\def\style[#1]% for inline usage, like \color - {\groupedcommand{\ifcsname#1\endcsname\csname#1\endcsname\else\definedfont[#1]\fi}{}} +% \def\style[#1]% for inline usage, like \color +% {\groupedcommand{\ifcsname#1\endcsname\csname#1\endcsname\else\definedfont[#1]\fi}{}} +% +% \unexpanded\def\startstyle[#1]% +% {\begingroup +% \ifcsname#1\endcsname\csname#1\endcsname\else\definedfont[#1]\fi} +% +% \unexpanded\def\stopstyle +% {\endgroup} + +% definitions + +\def\definestyle + {\dotripleargument\dodefinestyle} + +\def\dodefinestyle[#1][#2][#3]% + {\doifassignmentelse{#2}\dododefinestyle\definealternativestyle[#1][#2][#3]} + +\def\dododefinestyle[#1][#2][#3]% no commalist and for the moment #3 is ignored + {\getparameters[\??cf:#1][\c!style=,\c!color=,#2]% + \setuvalue{\e!start#1}{\begingroup\dostartattributes{\??cf:#1}\c!style\c!color}% + \setuvalue{\e!stop #1}{\dostopattributes\endgroup}% + \setuvalue {#1}{\groupedcommand{\dostartattributes{\??cf:#1}\c!style\c!color}\dostopattributes}} + +\def\setupstyle + {\dotripleargument\dosetupstyle} + +\def\dosetupstyle[#1][#2][#3]% no commalist and for the moment #3 is ignored + {\ifcsname\??cf:#1\c!style\endcsname + \getparameters[\??cf:#1][#2]% + \else + \getparameters[\??cf:#1][\c!style=,\c!color=,#2]% so we define but without commands (todo for all define related things) + \fi} + +% commands + +\unexpanded\def\style[#1]% + {\csname\ifcsname#1\endcsname n\else\ifcsname\??cf:#1\c!style\endcsname c\else d\fi\fi ostyle\endcsname{#1}} + +\def\nostyle#1{\csname#1\endcsname} +\def\costyle#1{\groupedcommand{\dostartattributes{\??cf:#1}\c!style\c!color}\dostopattributes} +\def\dostyle#1{\doifassignmentelse{#1}\dostyleassignment\dostyledirect{#1}} + +\def\dostyleassignment#1% + {\groupedcommand + {\getparameters[\??cf][\c!style=,\c!color=,#1]% + \dostartattributes\??cf\c!style\c!color} + {\dostopattributes}} + +\def\dostyledirect#1% + {\groupedcommand + {\definedfont[#1]} + {}} + +% environments \unexpanded\def\startstyle[#1]% {\begingroup - \ifcsname#1\endcsname\csname#1\endcsname\else\definedfont[#1]\fi} + \csname\ifcsname#1\endcsname n\else\ifcsname\??cf:#1\c!style\endcsname c\else d\fi\fi ostyless\endcsname{#1}} \unexpanded\def\stopstyle - {\endgroup} + {\dostopstyle + \endgroup + \autoinsertnextspace} % will be configurable, maybe also in \definestartstop + +\def\nostyless#1{\let\dostopstyle\donothing\csname#1\endcsname} +\def\costyless#1{\let\dostopstyle\dostopattributes\dostartattributes{\??cf:#1}\c!style\c!color} +\def\dostyless#1{\doifassignmentelse{#1}\dostylessassignment\dostylessdirect{#1}} + +\def\dostylessassignment#1% + {\let\dostopstyle\dostopattributes + \getparameters[\??cf][\c!style,\c!color=,#1]% + \dostartattributes\??cf\c!style\c!color} + +\def\dostylessdirect#1% + {\let\dostopstyle\donothing + \definedfont[#1]\relax} %D Still experimental (might even go away). @@ -3820,7 +4348,7 @@ \else\ifthirdargument \setvalue{\??sx#1::#2}{#3}% \else\ifsecondargument - \letvalue{\??sx#1::#2}\empty + \letvalueempty{\??sx#1::#2}% \fi\fi\fi} \unexpanded\def\styleinstance[#1]% will be made faster @@ -3847,8 +4375,8 @@ %D goodies: -\def\showchardata#1{\ctxlua{fonts.show_char_data("#1")}} -\def\showfontdata {\ctxlua{fonts.show_font_parameters()}} +\unexpanded\def\showchardata#1{\ctxcommand{showchardata("#1")}} +\unexpanded\def\showfontdata {\ctxcommand{showfontparameters()}} %D some low level helpers %D @@ -3869,28 +4397,18 @@ % we can also move the lookups to the fonts.namespace (of commands) -\def\dolookupfontbyspec #1{\ctxlua{fonts.names.lookup("#1")}} -\def\dolookupnoffound {\ctxlua{tex.write(fonts.names.noflookups())}} -\def\dolookupgetkeyofindex#1#2{\ctxlua{tex.write(fonts.names.getlookupkey("#1",#2))}} -\def\dolookupgetkey #1{\ctxlua{tex.write(fonts.names.getlookupkey("#1"))}} -\def\cleanfontname #1{\ctxlua{fonts.cleanname("#1")}} - -\protect \endinput - -% \startluacode -% function commands.doifelsecurrentfonthasfeature(name) -% local f = fonts.ids[font.current()] -% f = f and f.shared -% f = f and f.otfdata -% f = f and f.luatex -% f = f and f.features -% commands.doifelse(f and (f.gpos[name] or f.gsub[name])) -% end -% \stopluacode - -% \def\doifelsecurrentfonthasfeature#1% -% {\ctxlua{commands.doifelsecurrentfonthasfeature("#1")}} +\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#1% + {\ctxcommand{doifelsecurrentfonthasfeature("#1")}} + +\protect \endinput + |