diff options
author | Marius <mariausol@gmail.com> | 2011-12-16 15:20:15 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-12-16 15:20:15 +0200 |
commit | c444fd017ef64c84f0f8660af523009d88d5361c (patch) | |
tree | c3cb2f5b3a351727afee8906f541a163f45d47dc /tex/context/base/font-ini.mkiv | |
parent | 424eae2baf89faf226859b12e649fed94e466b8d (diff) | |
download | context-c444fd017ef64c84f0f8660af523009d88d5361c.tar.gz |
beta 2011.12.16 13:54
Diffstat (limited to 'tex/context/base/font-ini.mkiv')
-rw-r--r-- | tex/context/base/font-ini.mkiv | 151 |
1 files changed, 102 insertions, 49 deletions
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv index 14c845793..e4c63a4c9 100644 --- a/tex/context/base/font-ini.mkiv +++ b/tex/context/base/font-ini.mkiv @@ -14,6 +14,10 @@ % runtime commands will move to modules +% todo: reconsider design sizes ... kick 'm out which removes the size +% code and simplifies things considerably. After all, there will be no +% lm math in sizes. + % todo: (so that we can delay font loading to \starttext % simplification ... we no longer deal with specific mmtfa specifications @@ -518,77 +522,123 @@ \def\mathsizesuffix{\ifcase0\currentmathsize\or\mathtextsuffix\or\mathscriptsuffix\or\mathscriptscriptsuffix\fi} -\def\dodosetmathfamily#1#2% +% Beware: truefontname also does a fallback on defaultfontclass so there +% can be some interference here, which is why we use a different method +% for bold. + +\def\dodosetmathfamily {\ifcsname\fontclass \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse \csname\fontclass \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \else \ifcsname\fontclass \fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue \csname\fontclass \fontbody\c!mm\fontfamily \currentmathsize\endcsname \else - \dodosetmathfamilyx#1#2% - \fi\fi - #1#2\font} + \dodosetmathfamilyx + \fi\fi} -\def\dodosetmathfamilyx#1#2% somehow this fallback does now always work +\def\dodosetmathfamilyx {\ifcsname\defaultfontclass\fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse \csname\defaultfontclass\fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \else \ifcsname\defaultfontclass\fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue \csname\defaultfontclass\fontbody\c!mm\fontfamily \currentmathsize\endcsname \else - \dodosetmathfamilyxx#1#2% + \dodosetmathfamilyxx \fi\fi} -\def\dodosetmathfamilyxx#1#2% +\def\dodosetmathfamilyxx {\ifcsname \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse \csname \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \else \ifcsname \fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue \csname \fontbody\c!mm\fontfamily \currentmathsize\endcsname \else - \nullfont \autofontsizetrue + \font\nullfont \autofontsizetrue \fi\fi} -\def\dosetmathfamily#1#2% - {\let\savedfontbody\fontbody % op hoger plan +\def\dosetmathfamilyindeed#1#2% \currentmathsize etc are also used later on + {\let\savedfontbody\fontbody \let\fontfamily#2% -% % new per 20100817 -% \checkbodyfontenvironment[\scriptscriptface]% pretty slow when many switches -% \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% + \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\dodosetmathfamily\scriptscriptfont#1\font + \let\currentmathsize\!!plustwo \let\fontbody\scriptface \dodosetmathfamily\scriptfont #1\font + \let\currentmathsize\!!plusone \let\fontbody\textface \dodosetmathfamily\textfont #1\font + \ifconditional\optimizemathfontdefinitions + \dosavefontclassmathfamily#1#2% + \fi \let\currentmathsize\empty \let\fontbody\savedfontbody \autofontsizefalse} -% experiment -% +\def\dodosetboldmathfamily#1% + {\ifcsname\fontclass \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse + \csname\fontclass \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname + \else\ifcsname\fontclass \fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue + \csname\fontclass \fontbody\c!mm\fontfamily \currentmathsize\endcsname + \else + \font#1% + \fi\fi} + +\def\dosetboldmathfamilyindeed#1#2#3% + {\let\savedfontclass\defaultfontclass + \let\defaultfontclass\fontclass % else truefontname falls back on the wrong one + \let\savedfontbody\fontbody + \let\fontfamily#2% + \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\dodosetboldmathfamily#3\scriptscriptfont#1\font + \let\currentmathsize\!!plustwo \let\fontbody\scriptface \dodosetboldmathfamily#3\scriptfont #1\font + \let\currentmathsize\!!plusone \let\fontbody\textface \dodosetboldmathfamily#3\textfont #1\font + \ifconditional\optimizemathfontdefinitions + \dosavefontclassmathfamily#1#2% + \fi + \let\currentmathsize\empty + \let\fontbody\savedfontbody + \let\defaultfontclass\savedfontclass + \autofontsizefalse} + % optimized: math fonts are never changed (10K \bfa $x$: 3.2 => 2.5 (baseline 1.0)) +% +% sort of tricky: we cannot reset in \everybeforedefinetypeface as we don't know +% all sizes so we postpone the optimization to the first starttext +% +% pitfall: we should reset 'm when a fontclass name is reused + +\newconditional\optimizemathfontdefinitions \settrue\optimizemathfontdefinitions \def\dosetmathfamily#1#2% fam tag - {\ifcsname\??ff:\fontclass:\textface:\c!mm:#2:\fontsize\endcsname - \csname\??ff:\fontclass:\textface:\c!mm:#2:\fontsize\endcsname + {\ifconditional\optimizemathfontdefinitions + \ifcsname\??ff:\fontclass:\textface:\c!mm:#2:\fontsize\endcsname + \csname\??ff:\fontclass:\textface:\c!mm:#2:\fontsize\endcsname + \else + \dosetmathfamilyindeed#1#2% + \fi \else \dosetmathfamilyindeed#1#2% \fi} -\def\dosetmathfamilyindeed#1#2% - {\let\savedfontbody\fontbody % op hoger plan - \let\fontfamily#2% - \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% - \dosavefontclassmathfamily#1#2% - \let\currentmathsize\empty - \let\fontbody\savedfontbody - \autofontsizefalse} +\def\dosetboldmathfamily#1#2#3% fam tag + {\ifconditional\optimizemathfontdefinitions + \ifcsname\??ff:\fontclass:\textface:\c!mm:#2:\fontsize\endcsname + \csname\??ff:\fontclass:\textface:\c!mm:#2:\fontsize\endcsname + \else + \dosetboldmathfamilyindeed#1#2#3% + \fi + \else + \dosetboldmathfamilyindeed#1#2#3% + \fi} -% tricky: we cannot reset in \everybeforedefinetypeface as we don't know all sizes -% so we postpone the optimization to the first starttext +\unexpanded\def\doresetfontclassmathfamily#1#2#3% + {\global\expandafter\let\csname\??ff:#1:\textface:\c!mm:#2:#3\endcsname\undefined} -\def\dosavefontclassmathfamilyindeed#1#2% +\def\dosavefontclassmathfamilyindeed#1#2% weird double 1-3 .. will be cleaned up {\expandafter\xdef\csname\??ff:\fontclass:\textface:\c!mm:#2:\fontsize\endcsname{% \scriptscriptfont#1\csname*\fontclass\scriptscriptface\c!mm#23\fontsize3*\endcsname \scriptfont #1\csname*\fontclass\scriptface \c!mm#22\fontsize2*\endcsname - \textfont #1\csname*\fontclass\textface \c!mm#21\fontsize1*\endcsname - }} + \textfont #1\csname*\fontclass\textface \c!mm#21\fontsize1*\endcsname}% + \ifcsname\??ff:l:\fontclass\endcsname \else + \expandafter\newtoks\csname\??ff:l:\fontclass\endcsname + \fi + \normalexpanded{\global\csname\??ff:l:\fontclass\endcsname + {\the\csname\??ff:l:\fontclass\endcsname\doresetfontclassmathfamily{\fontclass}{#2}{\fontsize}}}% + } + +\def\resetfontclassmathfamilies#1% + {\ifcsname\??ff:l:#1\endcsname + \the\csname\??ff:l:#1\endcsname + \global\csname\??ff:l:#1\endcsname\emptytoks + \fi} \let\dosavefontclassmathfamily\gobbletwoarguments @@ -647,14 +697,14 @@ \to \mathstrategies \def\completeboldmathstrategyyesbidi - {\dosetmathfamily \mbfamlr\c!mblr - \dosetmathfamily \mbfamrl\c!mbrl + {\dosetboldmathfamily\mbfamlr\c!mblr\mrfamlr + \dosetboldmathfamily\mbfamrl\c!mbrl\mrfamrl \textfont \mbfam \textfont \mbfamlr \scriptfont \mbfam \scriptfont \mbfamlr \scriptscriptfont\mbfam \scriptscriptfont\mbfamlr} \def\completeboldmathstrategyyes - {\dosetmathfamily \mbfam \c!mb + {\dosetboldmathfamily\mbfam\c!mb\mrfam \textfont \mbfamrl\textfont \mbfam \scriptfont \mbfamrl\scriptfont \mbfam \scriptscriptfont\mbfamrl\scriptscriptfont\mbfam @@ -673,16 +723,19 @@ \scriptfont \mbfamlr\scriptfont \mrfamlr \scriptscriptfont\mbfamlr\scriptscriptfont\mrfamlr} +\def\applycompleteboldmathstrategy + {\ifconditional\completeboldmathstrategy + \ifconditional\bidirectionalmathstrategy + \completeboldmathstrategyyesbidi + \else + \completeboldmathstrategyyes + \fi + \else + \completeboldmathstrategynop + \fi} + \appendtoks - \ifconditional\completeboldmathstrategy - \ifconditional\bidirectionalmathstrategy - \completeboldmathstrategyyesbidi - \else - \completeboldmathstrategyyes - \fi - \else - \completeboldmathstrategynop - \fi + \applycompleteboldmathstrategy \to \mathstrategies \appendtoks |