diff options
author | Hans Hagen <pragma@wxs.nl> | 2009-05-28 11:23:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2009-05-28 11:23:00 +0200 |
commit | 1d3090326210c6e6f7ec5432799ded25b75bba46 (patch) | |
tree | c5921203789ec669e6bccaba4bd56f9c072dc56b /tex/context/base/font-ini.mkiv | |
parent | 94d83f84758766511c5e324721e39fea6ab71dae (diff) | |
download | context-1d3090326210c6e6f7ec5432799ded25b75bba46.tar.gz |
beta 2009.05.28 11:23
Diffstat (limited to 'tex/context/base/font-ini.mkiv')
-rw-r--r-- | tex/context/base/font-ini.mkiv | 2513 |
1 files changed, 853 insertions, 1660 deletions
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv index 3e2e57145..4d0d92fc5 100644 --- a/tex/context/base/font-ini.mkiv +++ b/tex/context/base/font-ini.mkiv @@ -12,26 +12,64 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +% simplification ... we no longer deal with specific mmtfa specifications -% \rm\bf --> \song -% \rm\it --> \kai -% \ss\it --> \kai -% \tt\bf --> \hei +% todo: always fontclass, then less testing -\writestatus{loading}{Context Font Macros (ini)} +% \starttext +% \definefontfeature[basekerned][default][mode=base] +% \definefontfeature[nodekerned][default][mode=node] +% \definefontfeature[nonekerned][default][mode=base,kern=no] +% \setupcolors[state=start] +% \startoverlay +% {\vbox{\red \definedfont[Serif*nonekerned at 12pt]\input tufte }} +% {\vbox{\blue \definedfont[Serif*basekerned at 12pt]\input tufte }} +% {\vbox{\green\definedfont[Serif*nodekerned at 12pt]\input tufte }} +% \stopoverlay +% \stoptext + +% \enabletrackers[otf.kerns] +% +% \definefontfeature[withkern][default][mode=node] +% \definefontfeature[nokern] [default][mode=node,kern=no] +% \definefontfeature[single] [default][mode=node,cpsp=yes] +% \definefontfeature[simple] [default][mode=node,cpsp=yes,kern=no] +% +% {\definedfont[Serif*default] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} +% {\definedfont[Serif*nokern] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} +% {\definedfont[Serif*single] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} +% {\definedfont[Serif*simple] [FGFGFGFGFGFGFGFGFGFGFGFGFG ABCDEFGHIJKLMNOPQRSTUVWXYZ] \par} + +% figure out why \fontbody is not expanded + +\writestatus{loading}{ConTeXt Font Macros / Initialization} \registerctxluafile{font-ini}{1.001} +\registerctxluafile{node-fnt}{1.001} % here \registerctxluafile{font-enc}{1.001} \registerctxluafile{font-map}{1.001} \registerctxluafile{font-syn}{1.001} +\registerctxluafile{font-log}{1.001} \registerctxluafile{font-tfm}{1.001} \registerctxluafile{font-afm}{1.001} -\registerctxluafile{font-otf}{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-otb}{1.001} % otf main base +\registerctxluafile{font-otn}{1.001} % otf main node +\registerctxluafile{font-ota}{1.001} % otf analyzers +\registerctxluafile{font-otp}{1.001} % otf pack +\registerctxluafile{font-otc}{1.001} % otf context \registerctxluafile{font-vf} {1.001} \registerctxluafile{font-def}{1.001} +\registerctxluafile{font-ctx}{1.001} +\registerctxluafile{font-xtx}{1.001} \registerctxluafile{font-fbk}{1.001} \registerctxluafile{font-ext}{1.001} \registerctxluafile{font-pat}{1.001} +\registerctxluafile{font-chk}{1.001} \unprotect @@ -107,10 +145,10 @@ %D %D A couple of relatively new macros: -\newevery \everydefinedfont \relax % not ot be confused with \everydefinefont +% \newtoks \everydefinedfont % not ot be confused with \everydefinefont \def\dodefinedfont[#1]% - {\iffirstargument\definefont[thedefinedfont][#1]\fi + {\iffirstargument\definefont[thedefinedfont][#1]\fi % we can speed this one up \csname thedefinedfont\endcsname \the\everydefinedfont} @@ -132,158 +170,10 @@ \egroup\expandafter\secondoftwoarguments \fi} -%%% message 14 added - -\startmessages dutch library: fonts - title: korps - 1: codering -- - 2: variant -- wordt geladen - 3: onbekende variant -- - 4: korps -- is niet gedefinieerd - 5: stijl -- is niet gedefinieerd - 6: -- wordt geladen - 7: onbekend formaat -- - 8: stijl -- gedefinieerd -% 9: mapping -- is geladen - 10: onbekende font file -- - 14: korps -- is gedefinieerd (kan beter globaal plaatsvinden) -\stopmessages - -\startmessages english library: fonts - title: bodyfont - 1: coding -- - 2: variant -- is loaded - 3: unknown variant -- - 4: bodyfont -- is not defined - 5: style -- is not defined - 6: -- is loaded - 7: unknown format -- - 8: style -- defined -% 9: mapping -- is loaded - 10: unknown font file -- - 14: bodyfont -- is defined (can better be done global) -\stopmessages - -\startmessages german library: fonts - title: Fliesstext - 1: Kodierung -- - 2: Variante -- ist geladen - 3: Unbekannte Variante -- - 4: Fliesstext -- ist nicht definiert - 5: Stil -- ist nicht definiert - 6: -- ist geladen - 7: unbekanntes Format -- - 8: Stil -- definiert -% 9: Map -- ist geladen - 10: unbekanntes Font -- - 14: Fliesstext -- wurde definiert (besser waere globale Definition) -\stopmessages - -\startmessages czech library: fonts - title: zakladnifont - 1: kodovani -- - 2: varianta -- je nactena - 3: neznama varianta -- - 4: zakladni font -- neni definovan - 5: styl -- neni definovan - 6: -- je nacten - 7: neznamy format -- - 8: styl -- definovan -% 9: mapovani -- je nacteno - 10: neznamy font -- - 14: bodyfont -- is defined (can better be done global) -\stopmessages - -\startmessages italian library: fonts - title: font del corpo - 1: codifica -- - 2: variante -- caricata - 3: variante sconosciuta -- - 4: corpo del testo -- non definito - 5: stile -- non definito - 6: -- caricato - 7: formato sconosciuto -- - 8: stile -- definito -% 9: mappatura -- caricata - 10: file di font sconosciuto -- - 14: corpo del testo -- definito (sarebbe meglio globale) -\stopmessages - -\startmessages norwegian library: fonts - title: hovedfont - 1: koding -- - 2: variant -- er lest inn - 3: ukjent variant -- - 4: hovedfont -- er ikke definert - 5: stil -- er ikke definert - 6: -- er lest inn - 7: ukjent format -- - 8: stil -- definert -% 9: avbildning -- er lest inn - 10: ukjent fontfil -- - 14: bodyfont -- is defined (can better be done global) -\stopmessages - -\startmessages romanian library: fonts - title: corp de litere - 1: codificarea -- - 2: varianta -- este incarcata - 3: varianta necunoscuta -- - 4: corpul de litere -- nu este definit - 5: stilul -- nu este definit - 6: -- este incarcat - 7: format necunoscut -- - 8: stilul -- definit -% 9: maparea -- este incarcat - 10: fisier font necunoscut -- - 14: bodyfont -- is defined (can better be done global) -\stopmessages - -\startmessages french library: fonts - title: corps de texte - 1: encodage -- - 2: la variante -- est chargée - 3: variante -- inconnue - 4: policecorps -- n'est pas définie - 5: le style -- n'est pas défini - 6: -- est chargé - 7: format -- inconnu - 8: style -- défini -% 9: mapping -- is loaded - 10: fichier de police -- inconnu - 14: policecorps -- est défini (une définition globale pourrait être plus adéquat) -\stopmessages - -%D This module is one of the oldest modules of \CONTEXT. The -%D macros below evolved out of the \PLAIN\ \TEX\ macros and -%D therefore use a similar naming scheme (\type{\rm}, -%D \type{\bf}, etc). This module grew out of our needs. We -%D started with the \PLAIN\ \TEX\ definitions, generalized the -%D underlaying macros, and extended those to a level at which -%D probably no one will ever recognize them. -%D -%D In 2001 we ran into a couple of projects where more than -%D one combined set of fonts was involved in a document. To -%D make definitions more readable, as well as to overcome the -%D problem of ever growing file name lists, and also because -%D we needed to scale fonts relative to each other, the low -%D level implementation was partly rewritten. Global -%D font assignments, relative scaling, font classes and alike -%D were added then. At the same time some macros were made a -%D bit more readable, and math support was extended to the -%D larger sizes. -%D -%D One important characteristic of the font mechanism presented -%D here is the postponing of font loading. This makes it -%D possible to distribute \type{fmt} files without bothering -%D about the specific breed of \type{tfm} files. -%D -%D Another feature implemented here is the massive switching -%D from roman to {\ss sans serif}, {\tt teletype} or else. This -%D means one doesn't have to take care of all kind of relations -%D between fonts. -%D -%D \page[bigpreference] +%D For more detailed (and historic information) we refer to the file +%D \type {font-ini.mkii}. Here we have a much simplified lower level +%D implementation due to a different approach to math. Also the chapter +%D on fonts in the reference manual explains a lot. %D \macros %D {rm,ss,tt,hw,cg} @@ -314,56 +204,6 @@ %D \stoptable %D \stoplinecorrection %D -%D Anyone who feels the need, can define additional ones, like -%D -%D \startlinecorrection -%D \starttable[|l||] -%D \HL -%D \NC faxfont \NC \type{\ff} \NC\FR -%D \NC blackboard \NC \type{\bb} \NC\LR -%D \HL -%D \stoptable -%D \stoplinecorrection -%D -%D Or even -%D -%D \startlinecorrection -%D \starttable[|l||] -%D \HL -%D \NC hebrew \NC \type{\hb} \NC\SR -%D \HL -%D \stoptable -%D \stoplinecorrection -%D -%D Styles are grouped in font sets. At the moment there are -%D three main sets defined: -%D -%D \startlinecorrection -%D \starttable[|l|l||] -%D \HL -%D \NC Computer Modern Roman \NC Knuth \NC \type{cmr} \NC\FR -%D \NC Lucida Bright \NC Bigelow \& Holmes \NC \type{lbr} \NC\MR -%D \NC Standard Postscript Fonts \NC Adobe \NC \type{pos} \NC\LR -%D \HL -%D \stoptable -%D \stoplinecorrection -%D -%D There are also some Computer Modern Roman alternatives: -%D -%D \startlinecorrection -%D \starttable[|l|l||] -%D \HL -%D \NC Computer Modern Roman \NC Knuth \& Sauter \NC \type{sau} \NC\FR -%D \NC Euler fonts \NC Zapf \NC \type{eul} \NC\MR -%D \NC Computer Modern Concrete \NC Knuth \& Zapf \NC \type{con} \NC\LR -%D \HL -%D \stoptable -%D \stoplinecorrection -%D -%D All these definitions are ordered in files with names like -%D \type{font-cmr} and \type{font-pos}, where the last three -%D characters specify the name as known to \CONTEXT. -%D %D Within such a font set (\type{cmr}) and style (\type{\rm}) %D we can define a number of text font alternatives: %D @@ -380,43 +220,6 @@ %D \HL %D \stoptable %D \stoplinecorrection - -%D For old stylish Frans Goddijn we have: -%D -%D \startlinecorrection -%D \starttable[|l||] -%D \HL -%D \NC oldstyle \NC \type{\os} \NC\SR -%D \HL -%D \stoptable -%D \stoplinecorrection -%D -%D The availability of these alternatives depends on the -%D completeness of a font family and of course the definitions -%D in the font files. -%D -%D But let's not forget math. In addition to the previous \TEX\ -%D families (the mysterious \type{\fam}'s) we've got some more: -%D -%D \startlinecorrection -%D \starttable[|l||] -%D \HL -%D \NC Math Roman \NC \type{\mr} \NC\FR -%D \NC Math Italic \NC \type{\mi} \NC\MR -%D \NC Math Symbol \NC \type{\sy} \NC\MR -%D \NC Math Extra \NC \type{\ex} \NC\MR -%D \NC Math A \NC \type{\ma} \NC\MR -%D \NC Math B \NC \type{\mb} \NC\MR -%D \NC Math C \NC \type{\mc} \NC\LR -%D \HL -%D \stoptable -%D \stoplinecorrection -%D -%D Users can call for specific fonts in many ways. Switches to -%D other typefaces, like the switch from normal to bold, are as -%D intuitive as possible, which means that all dependant fonts -%D also switch. One can imagine that this takes quite some -%D processing time. %D %D Internally fonts are stored as combination of size, style %D and alternative, e.g. \type{12pt}+\type{\ss}+\type{\bf}. @@ -514,7 +317,7 @@ %D And compare $\rm \scriptstyle THIS$ with the slightly larger %D \cap{THIS}: \ruledhbox{$\rm \scriptstyle scriptstyle: THIS$} %D or \ruledhbox{\cap{x style: THIS}} makes a big difference. - +%D %D The \type{x..d} sizes should be used grouped. If you %D don't group them, i.e. call them in a row, \CONTEXT\ will %D not be able to sort out your intention (\type {x} inside @@ -592,282 +395,8 @@ %D \NC \NR %D \HL %D \stoptabulate - -%D \macros -%D {mf} -%D -%D Math fonts are a species in their own. They are tightly -%D hooked into smaller and even smaller ones of similar breed -%D to form a tight family. Let's first see how these are -%D related: -%D -%D \startbuffer -%D $\tf x^2+\bf x^2+\sl x^2+\it x^2+\bs x^2+ \bi x^2 =\rm 6x^2$ -%D $\tf x^2+\bf x^2+\sl x^2+\it x^2+\bs x^2+{\bi x^2}=\rm 6x^2$ -%D $\tf x^2+\bf x^2+\sl x^2+\it x^2+\bs x^2+ \bi x^2 =\tf 6x^2$ -%D $\tf x^2+\bf x^2+\sl x^2+\it x^2+\bs x^2+{\bi x^2}=\tf 6x^2$ -%D $\tf x^2+\bf x^2+\sl x^2+\it x^2+\bs x^2+ \bi x^2 =\bf 6x^2$ -%D $\tf x^2+\bf x^2+\sl x^2+\it x^2+\bs x^2+{\bi x^2}=\bf 6x^2$ -%D $\tf x^2+\bf x^2+\sl x^2+\it x^2+\bs x^2+ \bi x^2 =\sl 6x^2$ -%D $\tf x^2+\bf x^2+\sl x^2+\it x^2+\bs x^2+{\bi x^2}=\sl 6x^2$ -%D \stopbuffer -%D -%D \typebuffer -%D -%D Gives both an expected and unexpected result: -%D -%D \startvoorbeeld -%D \startlines -%D \getbuffer -%D \stoplines -%D \stopvoorbeeld -%D -%D We see here that the character shapes change accordingly to -%D the current family, but that the symbols are always typeset -%D in the font assigned to \type{\fam0}. -%D -%D \startbuffer -%D $\tf\mf x^2 + x^2 + x^2 + x^2 + x^2 + x^2 = 6x^2$ -%D $\bf\mf x^2 + x^2 + x^2 + x^2 + x^2 + x^2 = 6x^2$ -%D $\sl\mf x^2 + x^2 + x^2 + x^2 + x^2 + x^2 = 6x^2$ -%D $\bs\mf x^2 + x^2 + x^2 + x^2 + x^2 + x^2 = 6x^2$ -%D $\it\mf x^2 + x^2 + x^2 + x^2 + x^2 + x^2 = 6x^2$ -%D $\bi\mf x^2 + x^2 + x^2 + x^2 + x^2 + x^2 = 6x^2$ -%D \stopbuffer -%D -%D \startvoorbeeld -%D \startlines -%D \getbuffer -%D \stoplines -%D \stopvoorbeeld %D -%D In this example we see a new command \type{\mf} surface -%D which means as much as {\em math font}. This commands -%D reactivates the last font alternative and therefore equals -%D \type{\bf}, \type{\sl} etc. but by default it equals -%D \type{\tf}: - -\unexpanded\def\mf - {\dodosetmathfont\fontalternative - \csname\fontalternative\endcsname} - -%D The previous example was typeset saying: -%D -%D \typebuffer -%D -%D Beware: the exact location of \type{\mf} is not that -%D important, we could as well has said -%D -%D \startbuffer -%D $\bf x^2 + x^2 + x^2 + x^2 + x^2 + x^2 = \mf 6x^2$ -%D \stopbuffer -%D -%D \typebuffer -%D -%D This is due to the way \TEX\ handles fonts in math mode. -%D -%D Of course we'll have to redefine \type{\mf} every time we -%D change the current \type{\fam}. - -%D \macros -%D {mbox,enablembox,mathop} -%D -%D Now how can we put this to use? Will the next sequence -%D give the desired result? -%D -%D \startbuffer -%D $\bf x^2 + \hbox{\mf whatever} + \sin(2x)$ -%D \stopbuffer -%D -%D \typebuffer -%D -%D It won't! -%D -%D \startvoorbeeld -%D \let\mathop=\normalmathop \getbuffer -%D \stopvoorbeeld -%D -%D The reason for this is that \type{\sin} is defined as: -%D -%D \starttyping -%D \def\sin{\mathop{\rm sin}\nolimits} -%D \stoptyping -%D -%D We can fix this by defining - -\let\normalmathop\mathop - -\unexpanded\def\mathop - {\normalmathop - \bgroup - \let\rm\mf - \let\next=} - -%D We can fix arbitrary horizontal boxes by redefining the -%D \TEX\ primitive \type{\hbox}: -%D -%D \starttyping -%D \let\normalhbox=\hbox -%D -%D \def\hbox{\ifmmode\mbox\else\normalhbox\fi} -%D \stoptyping -%D -%D with -%D -%D \starttyping -%D \def\mbox#1#% -%D {\normalhbox#1\bgroup\mf\let\next=} -%D \stoptyping -%D -%D or more robust, that is, also accepting \type{\hbox\bgroup}: -%D -%D \starttyping -%D \def\mbox% -%D {\normalhbox\bgroup\mf -%D \dowithnextbox{\flushnextbox\egroup}% -%D \normalhbox} -%D \stoptyping -%D -%D And now: -%D -%D \startbuffer -%D $\bf x^2 + \hbox{whatever} + \sin(2x)$ -%D \stopbuffer -%D -%D \typebuffer -%D -%D Indeed gives: -%D -%D \startvoorbeeld -%D \enablembox\getbuffer -%D \stopvoorbeeld -%D -%D But, do we want this kind of trickery to be activated? No, -%D simply because we cannot be sure of incompatibilities, -%D although for instance unboxing goes ok. Therefore we -%D introduce: - -% best can go to math-ini and make \mf a hook then - -% better use \dowithnextboxcontent - -\def\normalmbox - {\normalhbox\bgroup\mf - \dowithnextbox{\flushnextbox\egroup}\normalhbox} - -% to test: -% -% \def\normalmbox -% {\dowithnextboxcontent\mf\flushnextbox\normalhbox} - -\def\mbox - {\ifmmode\normalmbox\else\normalhbox\fi} - -\def\enablembox - {\appendtoks - \ifx\normalhbox\undefined\let\normalhbox\hbox\fi - \let\hbox\mbox - \to\everymathematics} - -%D So in fact one can enable this feature if needed. I would say: -%D go along, but use grouping if needed! - -%D \macros -%D {mrfam,mifam,syfam,exfam, -%D bsfam,bifam,scfam,tffam, -%D mafam,mbfam,msfam} -%D -%D After this short mathematical excursion, we enter the world -%D of fonts and fontswitching. We start with something very -%D \TEX: \type{\fam} specified font families. \TEX\ uses -%D families for managing fonts in math mode. Such a family has -%D three members: text, script and scriptscript: $x^{y^z}$. In -%D \CONTEXT\ we take a bit different approach than \PLAIN\ -%D \TEX\ does. \PLAIN\ \TEX\ needs at least four families for -%D typesetting math. We use those but give them symbolic names. - -\chardef\mrfam = 0 % (Plain TeX) Math Roman -\chardef\mifam = 1 % (Plain TeX) Math Italic -\chardef\syfam = 2 % (Plain TeX) Math Symbol -\chardef\exfam = 3 % (Plain TeX) Math Extra - -%D \PLAIN\ \TEX\ also defines families for {\it italic}, {\sl -%D slanted} and {\bf bold} typefaces, so we don't have to -%D define them here. - -\ifx\itfam\undefined - -\chardef\itfam = 4 % (Plain TeX) Italic -\chardef\slfam = 5 % (Plain TeX) Slanted -\chardef\bffam = 6 % (Plain TeX) Boldface - -\fi - -%D Family~7 in \PLAIN\ \TEX\ is not used in \CONTEXT, because -%D we do massive switches from roman to sans serif, teletype or -%D other faces. - -\ifx\ttfam\undefined - \chardef\ttfam = 7 % (Plain TeX) can be reused! -\fi - -%D We define ourselves some more families for {\bs bold -%D slanted}, {\bi bold italic} and {\sc Small Caps}, so -%D we can use them in math mode too. Instead of separate -%D families for {\ss sans serif} and \type{teletype} we use the -%D more general \type{\tffam}, which stands for typeface. - -\chardef\bsfam = 8 % (ConTeXt) BoldSlanted -\chardef\bifam = 9 % (ConTeXt) BoldItalic -\chardef\scfam = 10 % (ConTeXt) SmallCaps -\chardef\tffam = 11 % (ConTeXt) TypeFace - -%D Because Taco needs a few more math families, we reuse -%D family~7 for all those typefaces that have no related -%D family, and therefore are grouped into one. - -\chardef\nnfam = 7 % (ReUsed) NoName - -%D Normally \type{\mrfam} equals \type{\tffam}, but a more -%D distinctive alternatives are possible, for instance the -%D Euler and Concrete Typefaces. -%D -%D After having defined all those in nature non||mathematical -%D families, we define ourselves some real math ones. These are -%D needed for the \AMS\ Symbol Fonts and Extended Lucida -%D Bright. - -\chardef\mafam = 12 % (ConTeXt) Math A Fam (AmsTeX A) -\chardef\mbfam = 13 % (ConTeXt) Math B Fam (AmsTeX B) -\chardef\mcfam = 14 % (ConTeXt) Math C Fam (MathTime) -\chardef\mdfam = 15 % (ConTeXt) Math D Fam (MathTime) - -%D Because there are 16~families and because \type{\ttfam} -%D is reused, at the moment we have no so many families -%D left. By default, we map any newly defined family on the -%D last one (F). - -\def\newfam#1{\chardef#1=15 } - -%D This hack is also needed because in \ETEX\ we are going -%D to reuse the \type {\newfam} allocation counter. - -%D To ease the support of font packages, we als define -%D shortcuts to these familynames. This is necessary because -%D the family names are in fact \type{\chardef}'s, which means -%D that we're dealing with numbers (one can check this by -%D applying \type{\showthe} and \type{\show}). In the -%D specification of math symbols however we need hexadecimal -%D numbers, so we have to convert the \type{\fam}'s value. - -\edef\hexmrfam {\hexnumber\mrfam} \edef\hexbsfam {\hexnumber\bsfam} -\edef\hexmifam {\hexnumber\mifam} \edef\hexbifam {\hexnumber\bifam} -\edef\hexsyfam {\hexnumber\syfam} \edef\hexscfam {\hexnumber\scfam} -\edef\hexexfam {\hexnumber\exfam} \edef\hextffam {\hexnumber\tffam} -\edef\hexitfam {\hexnumber\itfam} \edef\hexmafam {\hexnumber\mafam} -\edef\hexslfam {\hexnumber\slfam} \edef\hexmbfam {\hexnumber\mbfam} -\edef\hexbffam {\hexnumber\bffam} \edef\hexmcfam {\hexnumber\mcfam} -\edef\hexnnfam {\hexnumber\nnfam} \edef\hexmdfam {\hexnumber\mdfam} +%D Remark: math support has changed a bit. %D \macros %D {uchar} @@ -886,244 +415,122 @@ \def\@shortstyle@ {@f@sh@} % short style prefix (rm etc) \def\@letter@ {@f@le@} % first alternative typeface \def\@noletter@ {@f@no@} % second alternative typeface +\def\@fontclass@ {@f@cl@} % fontclass + +%D \macros +%D {fontclass, defaultfontclass} +%D +%D The fontclass model was introduced a while after we implement +%D the basic font model and at that time we still defaulted to +%D no model at all. Nowadays we default to the \type {modern} +%D fontclass. + +\let\fontclass \empty +\let\defaultfontclass\empty -%D The families can be grouped into math specific ones and -%D more text related families, although text ones can be -%D mapped onto the math ones to get for instance bold math. +%D \macros +%D {textonly} %D -%D Both groups of families are handles by a couple of token -%D list tagged as strategies. This implementation makes -%D implementing extensions more comfortable. +%D Traditionally math has a big impact on font definitions, mainly +%D because we need to define alphabet variants using families and +%D fonts. This means that one can easily get 10 fonts loaded per +%D math size. In \MKIV\ we use a different approach: one family +%D which has either a virtual font made of traditional fonts, or +%D an \OPENTYPE\ font that has it all. +%D +%D We currently use only one math family but in the future we +%D might consider using a second one for bold math. For the +%D moment we keep the \MKII\ method of using a token register +%D for definitions but we already dropped the text and symbols +%D ones since they now live in the same family. -\newtoks \textstrategies \newtoks \mathstrategies -\newtoks \symbstrategies \newif\ifsynchronizemathfonts \synchronizemathfontstrue -\def\synchronizetext % stylish text in mmode - {\ifsynchronizemathfonts\the\textstrategies\fi} % \if...\fam\minusone\fi} - \def\synchronizemath % math stuff in mmode - {\ifsynchronizemathfonts\the\mathstrategies\fi} % \if...\fam\minusone\fi} + {\ifsynchronizemathfonts\the\mathstrategies\fi} -\def\synchronizesymb % stylish math stuff in mmode - {\ifsynchronizemathfonts\the\symbstrategies\fi} % \if...\fam\minusone\fi} +\def\textonly{\synchronizemathfontsfalse} % document this -%D By not setting the family we can append a font switch to \type -%D {\everymath}. On the other hand, one never knows in what family -%D state the strategies brought us. -%D -%D \starttyping -%D {\bfa $\the\fam$} {\bfa \everymath{} $\the\fam$} -%D \stoptyping +%D The main math font definer. We have removed some optimized +%D code simply because we now always have a fontclass. We could +%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. -%D \macros -%D {textonly} -%D -%D We can inhibit this slow||downer with: +\chardef\mrfam\zerocount % math regular +\chardef\mbfam\zerocount % math bold -\def\textonly{\synchronizemathfontsfalse} % document this +\def\mathtextsuffix {-text} +\def\mathscriptsuffix {-script} +\def\mathscriptscriptsuffix{-scriptscript} -\appendtoks - \dosettextfamily\c!tf - \dosettextfamily\c!bf - \dosettextfamily\c!sl - \dosettextfamily\c!it - \dosettextfamily\c!bs - \dosettextfamily\c!bi - \dosettextfamily\c!sc -\to \textstrategies - -\def\dosettextfamily#1% better pass fontbody to dodoset - {\let\savedfontbody\fontbody - \let\fontfamily#1% - \let\fontbody\scriptscriptface\dodosettextfamily\scriptscriptfont - \let\fontbody\scriptface \dodosettextfamily \scriptfont - \let\fontbody\textface \dodosettextfamily \textfont - \let\fontbody\savedfontbody} - -% \def\s!nullfont{nullfont} - -\def\dodosettextfamily - {\ifx\fontclass\empty - \@EA\dodosettextfamilyA - \else - \@EA\dodosettextfamilyB - \fi} +% \let\mathsizesuffix\empty -\def\dodosettextfamilyA#1% - {\ifcsname \fontbody\c!mm\fontfamily\fontsize\endcsname \autofontsizefalse - \csname \fontbody\c!mm\fontfamily\fontsize\endcsname \else - \ifcsname \fontbody\c!mm\fontfamily\endcsname \autofontsizetrue - \csname \fontbody\c!mm\fontfamily\endcsname \else - \ifcsname \fontbody\c!rm\fontfamily\fontsize\endcsname \autofontsizefalse - \csname \fontbody\c!rm\fontfamily\fontsize\endcsname \else - \ifcsname \fontbody\c!rm\fontfamily\endcsname \autofontsizetrue - \csname \fontbody\c!rm\fontfamily\endcsname \else - \nullfont \autofontsizetrue - \fi\fi\fi\fi - #1\csname\fontfamily\s!fam\endcsname\font} - -\def\dodosettextfamilyB#1% - {\ifcsname\fontclass\fontbody\c!mm\fontfamily\fontsize\endcsname \autofontsizefalse - \csname\fontclass\fontbody\c!mm\fontfamily\fontsize\endcsname \else - \ifcsname\fontclass\fontbody\c!mm\fontfamily\endcsname \autofontsizetrue - \csname\fontclass\fontbody\c!mm\fontfamily\endcsname \else - \ifcsname\fontclass\fontbody\c!rm\fontfamily\fontsize\endcsname \autofontsizefalse - \csname\fontclass\fontbody\c!rm\fontfamily\fontsize\endcsname \else - \ifcsname\fontclass\fontbody\c!rm\fontfamily\endcsname \autofontsizetrue - \csname\fontclass\fontbody\c!rm\fontfamily\endcsname \else - \dodosettextfamilyA#1% - \fi\fi\fi\fi - #1\csname\fontfamily\s!fam\endcsname\font} - -\def\mrfallback{\c!rm\c!tf} +\chardef\currentmathsize\zerocount -\appendtoks - \dosetmathfamily\mrfam\textface\scriptface\scriptscriptface\c!mr\mrfallback - \dosetmathfamily\mifam\textface\scriptface\scriptscriptface\c!mi\empty - \dosetmathfamily\syfam\textface\scriptface\scriptscriptface\c!sy\empty - \dosetmathfamily\exfam\textface\textface \textface \c!ex\empty - \dosetmathfamily\mafam\textface\scriptface\scriptscriptface\c!ma\empty - \dosetmathfamily\mbfam\textface\scriptface\scriptscriptface\c!mb\empty - \dosetmathfamily\mcfam\textface\scriptface\scriptscriptface\c!mc\empty -% \dosetmathfamily\mdfam\textface\scriptface\scriptscriptface\c!md\empty - \dosetmathfamily\nnfam\textface\scriptface\scriptscriptface\c!nn\empty -\to \mathstrategies +\def\mathsizesuffix{\ifcase\currentmathsize\or\mathtextsuffix\or\mathscriptscriptsuffix\or\mathscriptsuffix\fi} -\appendtoks - \dosetskewchar\mifam\defaultskewcharmi % implemented later on - \dosetskewchar\syfam\defaultskewcharsy % implemented later on -\to \mathstrategies +\def\dodosetmathfamily#1#2% + {\ifcsname\fontclass \fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \autofontsizefalse + \csname\fontclass \fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \else + \ifcsname\fontclass \fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \autofontsizetrue + \csname\fontclass \fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \else + \dodosetmathfamilyx#1#2% + \fi\fi + #1#2\font} -\def\dosetmathfamily#1#2#3#4#5#6% - {\let\savedfontbody\fontbody % op hoger plan - \let\fontfamily#5% - \let\backfamily#6% - \let\fontbody #4\dodosetmathfamily\scriptscriptfont#1% - \let\fontbody #3\dodosetmathfamily \scriptfont#1% - \let\fontbody #2\dodosetmathfamily \textfont#1% - \let\fontbody\savedfontbody} - -\def\dodosetmathfamily - {\ifx\fontclass\empty - \@EA\dodosetmathfamilyA - \else - \@EA\dodosetmathfamilyB - \fi} +\def\dodosetmathfamilyx#1#2% + {\ifcsname\defaultfontclass\fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \autofontsizefalse + \csname\defaultfontclass\fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \else + \ifcsname\defaultfontclass\fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \autofontsizetrue + \csname\defaultfontclass\fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \else + \dodosetmathfamilyxx#1#2% + \fi\fi} -\def\dodosetmathfamilyA#1#2% - {\ifcsname \fontbody\c!mm\fontfamily\fontsize\endcsname \autofontsizefalse - \csname \fontbody\c!mm\fontfamily\fontsize\endcsname \else - \ifcsname \fontbody\c!mm\fontfamily \endcsname \autofontsizetrue - \csname \fontbody\c!mm\fontfamily \endcsname \else - \ifcsname \fontbody \backfamily\fontsize\endcsname \autofontsizefalse - \csname \fontbody \backfamily\fontsize\endcsname \else - \ifcsname \fontbody \backfamily \endcsname \autofontsizetrue - \csname \fontbody \backfamily \endcsname \else - \nullfont \autofontsizetrue - \fi\fi\fi\fi - #1#2\font} +\def\dodosetmathfamilyxx#1#2% + {\ifcsname \fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \autofontsizefalse + \csname \fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \else + \ifcsname \fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \autofontsizetrue + \csname \fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \else + \nullfont \autofontsizetrue + \fi\fi} -\def\dodosetmathfamilyB#1#2% - {\ifcsname\fontclass\fontbody\c!mm\fontfamily\fontsize\endcsname \autofontsizefalse - \csname\fontclass\fontbody\c!mm\fontfamily\fontsize\endcsname \else - \ifcsname\fontclass\fontbody\c!mm\fontfamily \endcsname \autofontsizetrue - \csname\fontclass\fontbody\c!mm\fontfamily \endcsname \else - \ifcsname\fontclass\fontbody \backfamily\fontsize\endcsname \autofontsizefalse - \csname\fontclass\fontbody \backfamily\fontsize\endcsname \else - \ifcsname\fontclass\fontbody \backfamily \endcsname \autofontsizetrue - \csname\fontclass\fontbody \backfamily \endcsname \else - \dodosetmathfamilyA#1#2% - \fi\fi\fi\fi - #1#2\font} +\def\dosetmathfamily#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% + \let\currentmathsize\zerocount + \let\fontbody\savedfontbody + \autofontsizefalse} \appendtoks - \dosetsymbfamily\mrfam\textface\scriptface\scriptscriptface\c!mr - \dosetsymbfamily\mifam\textface\scriptface\scriptscriptface\c!mi - \dosetsymbfamily\syfam\textface\scriptface\scriptscriptface\c!sy - \dosetsymbfamily\exfam\textface\textface \textface \c!ex - \dosetsymbfamily\mafam\textface\scriptface\scriptscriptface\c!ma - \dosetsymbfamily\mbfam\textface\scriptface\scriptscriptface\c!mb - \dosetsymbfamily\mcfam\textface\scriptface\scriptscriptface\c!mc -% \dosetsymbfamily\mdfam\textface\scriptface\scriptscriptface\c!md % also ? -\to \symbstrategies - -\def\dosetsymbfamily#1#2#3#4#5% - {\let\savedfontbody\fontbody - \let\fontfamily#5% - \let\fontbody #4\dodosetsymbfamily\scriptscriptfont#1% - \let\fontbody #3\dodosetsymbfamily \scriptfont#1% - \let\fontbody #2\dodosetsymbfamily \textfont#1% - \let\fontbody\savedfontbody} - -\def\dodosetsymbfamily#1#2% - {\ifcsname\fontclass\fontbody\c!mm\fontfamily\fontalternative\fontsize\endcsname - \csname\fontclass\fontbody\c!mm\fontfamily\fontalternative\fontsize\endcsname - #1#2\font - \else\ifcsname\fontbody\c!mm\fontfamily\fontalternative\fontsize\endcsname - \csname\fontbody\c!mm\fontfamily\fontalternative\fontsize\endcsname - #1#2\font - \fi\fi} + \dosetmathfamily\mrfam\c!mr + %\dosetmathfamily\mbfam\c!mb % some day, only when defined, else equivalent to 0 +\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 %D define as many styles as needed. -\let\stylelist=\empty +\def\fontrelativesizelist{\s!text,\s!script,\s!scriptscript,\c!x,\c!xx,\c!big,\c!small} -\def\fontsizelist{\s!text,\s!script,\s!scriptscript,\c!x,\c!xx,\c!big,\c!small} - -%D \macros -%D {magfactor,magfactorhalf} -%D %D There are several ways to specify a font. Three of them are %D pure \TeX\ ones, the fourth one is new: %D %D \starttyping %D \font\name=cmr12 %D \font\name=cmr12 at 10pt -%D \font\name=cmr12 scaled \magstep2 +%D \font\name=cmr12 scaled 2 %D \font\name=cmr12 sa 1.440 %D \stoptyping %D %D The non||\TEX\ alternative \type{sa} stands for {\em scaled %D at}. This means as much as: scale the bodyfontsize with this -%D factor. The value 1.440 in this example is derived -%D from the \type{\magstep}'s as mentioned in -%D \in{table}[tab:magstep]. We therefore introduce -%D \type{\magfactor} as an alternative for \type{\magstep}. -%D -%D \placetable[here][tab:magstep] -%D {Factors to be used with \type{sa.}} -%D \starttable[|c|c|c|] -%D \HL -%D \NC \bf magstep \NC \bf equivalent \NC \bf factor \NC\SR -%D \HL -%D \NC 1 \NC \type{\magfactor1} \NC 1.200 \NC\FR -%D \NC 2 \NC \type{\magfactor2} \NC 1.440 \NC\MR -%D \NC 3 \NC \type{\magfactor3} \NC 1.728 \NC\MR -%D \NC 4 \NC \type{\magfactor4} \NC 2.074 \NC\MR -%D \NC 5 \NC \type{\magfactor5} \NC 2.488 \NC\LR -%D \HL -%D \stoptable - -\def\magstep#1% \relax removed, otherwise space after it sticks, else added - {\ifcase#1 \@m\or1200\or1440\or1728\or2074\or2488\or\@m\fi} - -\def\magstephalf - {1095} - -\def\magfactor#1% - {\ifcase#1 1.000\or1.200\or1.440\or1.728\or2.074\or2.488\or1\fi} - -\def\magfactorhalf - {1.095} - -%D These macros enable the use of definitions like \type{sa -%D \magfactor3} which saves us both (mis|)|calculations and -%D potential mistypings. +%D factor. The scaled option is not that useful as one needs to +%D know the design size. %D %D Because \type {sa} (scaled at) and \type {mo} (mapped on) %D are not low level \TEX\ supported alternatives, we have to @@ -1146,9 +553,25 @@ {\edef\relativefontsize {\ifcsname\fontclass#1\s!rscale\endcsname \csname\fontclass#1\s!rscale\endcsname + \else\ifcsname\defaultfontclass#1\s!rscale\endcsname + \csname\defaultfontclass#1\s!rscale\endcsname \else \defaultrelativefontsize - \fi}} + \fi\fi}} + +% \letvalue{\s!default\s!rscale}\defaultrelativefontsize +% +% \def\checkrelativefontsize#1% +% {\edef\relativefontsize +% {\csname +% \ifcsname\fontclass#1\s!rscale\endcsname +% \fontclass#1% +% \else\ifcsname\defaultfontclass#1\s!rscale\endcsname +% \defaultfontclass#1% +% \else +% \s!default +% \fi\fi +% \s!rscale\endcsname}} %D We also save: @@ -1159,6 +582,38 @@ {\executeifdefined{\fontclass\c!mm\s!text}\empty} %D Scaling macros: +%D +%D This system is somewhat complicated by two (possible conflicting) +%D demands: +%D +%D \startitemize +%D \item We support wildcards like \type {sa *} which will adapt +%D to the current size. This is also the default specification. +%D \item We support named scales like \type {sa d}; beware: \type +%D {x} and \type {xx} are valid scales but they are not alway +%D the same as the ones used in for instance \type {\bfx} because +%D there the sized come from the bodyfont environment. In the +%D future there maybe a switch that also honors the environment +%D in named scales. +%D \stopitemize + +%D Keep in mind that the smaller sizes are just for text super and +%D subscripts while larger sizes can be used in titles where for +%D instance math follows the size. + +% b:x{\definedfont[SerifBold sa b]x}{\bfb x $x^x$}\par +% 1:x{\definedfont[SerifBold sa 1]x}{\bf x $x^x$}\par +% x:x{\definedfont[SerifBold sa x]x}{\bfx x $x^x$}\par +% xx:x{\definedfont[SerifBold sa xx]x}{\bfxx x $x^x$}\par +% +% *:x{\definedfont[Serif sa *]x}\par +% 1:x{\definedfont[Serif sa 1]x}\par +% 2:x{\definedfont[Serif sa 2]x}\par +% 3:x{\definedfont[Serif sa 3]x}\par +% 4:x{\definedfont[Serif sa 4]x}\par +% 5:x{\definedfont[Serif sa 5]x}\par +% +% {\definedfont[cmbx10 at 10pt]x\definedfont[cmbx8 at 10pt]x} \def\safontscale{\number\dimexpr\localabsolutefontsize\relax} \def\mofontscale{\number\dimexpr\setmappedfontsize\localabsolutefontsize\relax} @@ -1171,29 +626,39 @@ \newdimen\scaledfontsize \newtoks\everydefinefont +\def\currentfontbodysize + {\ifcsname\??ft\s!default\somefontsize\endcsname + \csname\??ft\s!default\somefontsize\endcsname + \else + \somefontsize + \fi} + \def\lowleveldefinefont#1#2% #2 = cs - {\ctxlua{fonts.define.command_1("\luaescapestring{#1}")}% the escapestring catches at \somedimen + {% + \ctxlua{fonts.define.command_1("\luaescapestring{#1}")}% the escapestring catches at \somedimen % sets \scaledfontmode and \somefontname and \somefontsize \ifcase\scaledfontmode\relax - % none + % none, avoid the designsize if possible \scaledfontsize-1000\scaledpoint \or % at \scaledfontsize\somefontsize \or % sa - \scaledfontsize\localabsolutefontsize - \scaledfontsize\ifcsname\??ft\s!default\somefontsize\endcsname\csname\??ft\s!default\somefontsize\endcsname\else\somefontsize\fi\scaledfontsize + \scaledfontsize\localabsolutefontsize\relax + \scaledfontsize\currentfontbodysize\scaledfontsize \or % mo \scaledfontsize\setmappedfontsize\localabsolutefontsize - \scaledfontsize\ifcsname\??ft\s!default\somefontsize\endcsname\csname\??ft\s!default\somefontsize\endcsname\else\somefontsize\fi\scaledfontsize + \scaledfontsize\currentfontbodysize\scaledfontsize \or - % scaled + % scaled, don't use this one as it's unpredictable \scaledfontsize-\somefontsize\scaledpoint \fi \scaledfontsize\localrelativefontsize\scaledfontsize - \ifautofontsize\scaledfontsize\currentfontbodyscale\scaledfontsize\fi + \ifautofontsize + \scaledfontsize\currentfontbodyscale\scaledfontsize + \fi \edef\somefontspec{at \number\scaledfontsize sp}% \edef\somefontfile{\truefontname\somefontname}% \ifx\somefontfile\s!unknown @@ -1209,7 +674,9 @@ "\@@fontclassfeatures", "\@@fontfeatures", "\@@fontclassfallbacks", - "\@@fontfallbacks" + "\@@fontfallbacks", + \number\currentmathsize, + \number\dimexpr\textface\relax )}% \edef\somefontspec{at \somefontsize}% we need the resolved designsize (for fallbacks) \expandafter\let\expandafter\lastrawfontcall\csname#2\endcsname @@ -1219,12 +686,48 @@ {\edef\@@fontclassfeatures {\ifcsname\fontclass\s!features \endcsname\csname\fontclass\s!features \endcsname\fi}% \edef\@@fontclassfallbacks{\ifcsname\fontclass\s!fallbacks\endcsname\csname\fontclass\s!fallbacks\endcsname\fi}} +% resolve + +\def\@@thefeaturesyes#1% + {\ifcsname\??ff\fontclass#1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??ff\fontclass#1\s!features \endcsname\else + \ifcsname\??ff #1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??ff #1\s!features \endcsname\else + \ifcsname\??ff\fontclass #1\endcsname\@EA \@@thefeaturesyes \csname\??ff\fontclass #1\endcsname\else + \ifcsname\??ff #1\endcsname\@EA \@@thefeaturesyes \csname\??ff #1\endcsname\else + \let \@@fontfeatures \empty \fi\fi\fi\fi} + +\def\@@thefallbacksyes#1% + {\ifcsname\??ff\fontclass#1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??ff\fontclass#1\s!fallbacks\endcsname\else + \ifcsname\??ff #1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??ff #1\s!fallbacks\endcsname\else + \ifcsname\??ff\fontclass #1\endcsname\@EA \@@thefallbacksyes\csname\??ff\fontclass #1\endcsname\else + \ifcsname\??ff #1\endcsname\@EA \@@thefallbacksyes\csname\??ff #1\endcsname\else + \let \@@fontfallbacks \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 + \let \@@fontfeatures \empty \fi\fi} + +\def\@@thefallbacksnop#1% + {\ifcsname\??ff#1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??ff#1\s!fallbacks\endcsname\else + \ifcsname\??ff #1\endcsname\@EA \@@thefallbacksnop\csname\??ff #1\endcsname\else + \let \@@fontfallbacks \empty \fi\fi} + +\def\updatefontparametersyes + {\@@thefeaturesyes \somefontname + \@@thefallbacksyes\somefontname} + +\def\updatefontparametersnop + {\@@thefeaturesnop \somefontname + \@@thefallbacksnop\somefontname} + +\def\updatefontparameters + {\ifx\fontclass\empty\updatefontparametersnop\else\updatefontparametersyes\fi} + \let\@@fontclassfeatures \empty \let\@@fontclassfallbacks\empty \let\@@fontfallbacks\empty \let\@@fontfeatures \empty -\let\@@skewchar \empty \let\@@hyphenchar \empty % todo, will go to encoding %D This brings down maps processing from 466 to 309 seconds @@ -1334,14 +837,6 @@ %D We also accept \type{sa a}||\type{sa d} as specification. -%D The duplicate font definition, using the ever the same dummy -%D font name, results in less fuzzy error messages. In the log -%D file, for instance when overfull boxes are reported, the -%D simple keyword `font' replaces the \TEX\ ordinated name. The -%D latter can be too misleading, due to the fact that \TEX\ has -%D a rather optimized font memory management. Thanks to Taco -%D for helping me sort this out. - %D \macros %D {definefontsynonym, doifelsefontsynonym, %D expandfontsynonym, truefontname, truefontdata} @@ -1366,47 +861,64 @@ \def\definefontsynonym[#1]#2[#3]% {\edef\@@fontname{#1}% \edef\@@fontfile{#3}% - \doifnextcharelse[\dodefinefontsynonym\nodefinefontsynonym} - -\def\nodefinefontsynonym - {\@EA\let\csname\??ff\fontclass\@@fontname\endcsname\@@fontfile} - -\def\dodefinefontsynonym[#1]% - {\edef\@@fontdata{#1}% - \ifx\@@fontdata\empty - \nodefinefontsynonym + \ifx\fontclass\empty + \expandafter\dodefinefontsynonymnop \else - \ifx\fontclass\empty - \getfontparameters - \else - \getglobalfontparameters - \fi - \ifcsname\??ff\@@fontfile\s!features\endcsname - \@EA\edef\csname\??ff\fontclass\@@fontname\endcsname{\@@fontfile*\csname\??ff\@@fontfile\s!features\endcsname}% - \@EA\let\csname\??ff\@@fontfile\s!features\endcsname\undefined - \else - \nodefinefontsynonym - \fi + \expandafter\dodefinefontsynonymyes \fi} -\def\getfontparameters - {\expandafter\dogetfontparameter\@@fontdata,]=,} +\def\dodefinefontsynonymnop + {\@EA\let\csname\??ff\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion + \doifnextoptionalelse\dododefinefontsynonymnop\nonodefinefontsynonymnop} + +\def\dodefinefontsynonymyes + {\@EA\let\csname\??ff\fontclass\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion + \doifnextoptionalelse\dododefinefontsynonymyes\nonodefinefontsynonymyes} + +\def\dododefinefontsynonymnop[#1]% + {\let\@@ff@@features \undefined + \let\@@ff@@fallbacks\undefined + \expandafter\dogetfontparameternop#1,]=,} -\def\getglobalfontparameters - {\expandafter\dogetglobalfontparameter\@@fontdata,]=,} +\def\dododefinefontsynonymyes[#1]% + {\let\@@ff@@features \undefined + \let\@@ff@@fallbacks\undefined + \expandafter\dogetfontparameteryes#1,]=,} -\def\dogetfontparameter#1=#2,% - {\if]#1\else - \expandafter\def\csname\??ff\@@fontfile#1\endcsname{#2}% - \expandafter\dogetfontparameter +\def\dogetfontparameternop#1=#2,% + {\if]#1% + \dodododefinefontsynonymnop + \else + \expandafter\def\csname @@ff@@#1\endcsname{#2}% + \expandafter\dogetfontparameternop \fi} -\def\dogetglobalfontparameter#1=#2,% - {\if]#1\else - \expandafter\gdef\csname\??ff\@@fontfile#1\endcsname{#2}% - \expandafter\dogetglobalfontparameter +\def\dogetfontparameteryes#1=#2,% + {\if]#1% + \dodododefinefontsynonymyes + \else + \expandafter\def\csname @@ff@@#1\endcsname{#2}% + \expandafter\dogetfontparameteryes \fi} +% hm, was wrong, class/global reversed + +\def\nonodefinefontsynonymnop + {\@EA\let\csname\??ff\@@fontname\s!features \endcsname\undefined + \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\undefined} + +\def\nonodefinefontsynonymyes + {\global\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\undefined + \global\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\undefined} + +\def\dodododefinefontsynonymnop + {\@EA\let\csname\??ff\@@fontname\s!features \endcsname\@@ff@@features + \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks} + +\def\dodododefinefontsynonymyes + {\global\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\@@ff@@features + \global\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks} + \let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater \def\setupfontsynonym @@ -1423,20 +935,51 @@ \fi \fi} -\def\truefontdata#1#2% - {\ifcsname\??ff#1#2\endcsname - % raw(Regular) raw(key) - \csname\??ff#1#2\endcsname - \else\ifcsname\??ff\fontclass#1\endcsname - % exp(palatino Regular) raw(key) - \expandafter\truefontdata\csname\??ff\fontclass#1\endcsname#2% - \else\ifcsname\??ff#1\endcsname - % exp(Regular) raw(key) - \expandafter\truefontdata\csname\??ff#1\endcsname#2% - \else\ifcsname\??ff#2\endcsname - % raw(key) - \csname\??ff#2\endcsname - \fi\fi\fi\fi} +% \def\truefontname#1% +% {\@EA\dotruefontname#1*\empty*\relax} +% +% \def\dotruefontname#1*#2#3*#4\relax +% {\ifcsname\??ff\fontclass#1\endcsname +% \ifx#2\empty +% \@EA\truefontname\csname\??ff\fontclass#1\endcsname +% \else +% \@EA\redotruefontname\csname\??ff\fontclass#1\endcsname*#2#3% +% \fi +% \else\ifcsname\??ff#1\endcsname +% \ifx#2\empty +% \@EA\truefontname\csname\??ff#1\endcsname +% \else +% \@EA\redotruefontname\csname\??ff#1\endcsname*#2#3% +% \fi +% \else +% #1\ifx#2\empty\else*#2#3\fi +% \fi\fi} +% +% \def\redotruefontname#1% +% {\@EA\dodotruefontname#1*\relax} +% +% \def\dodotruefontname#1*#2\relax +% {\ifcsname\??ff\fontclass#1\endcsname +% \@EA\redotruefontname\csname\??ff\fontclass#1\endcsname +% \else\ifcsname\??ff#1\endcsname +% \@EA\redotruefontname\csname\??ff#1\endcsname +% \else +% #1% +% \fi\fi} +% +% \def\expandfontsynonym#1#2% #2 := onelevelexpansion(#1) +% {\ifcsname\??ff\fontclass#2\endcsname +% \expandafter\def\expandafter#1\expandafter{\csname\??ff\fontclass#2\endcsname}% +% \fi} +% +% \def\doifelsefontsynonym#1% +% {\ifcsname\??ff\fontclass#1\endcsname +% \expandafter\firstoftwoarguments +% \else +% \expandafter\secondoftwoarguments +% \fi} + +% maybe we need to stick in one branch \def\truefontname#1% {\@EA\dotruefontname#1*\empty*\relax} @@ -1448,6 +991,12 @@ \else \@EA\redotruefontname\csname\??ff\fontclass#1\endcsname*#2#3% \fi + \else\ifcsname\??ff\defaultfontclass#1\endcsname + \ifx#2\empty + \@EA\truefontname\csname\??ff\defaultfontclass#1\endcsname + \else + \@EA\redotruefontname\csname\??ff\defaultfontclass#1\endcsname*#2#3% + \fi \else\ifcsname\??ff#1\endcsname \ifx#2\empty \@EA\truefontname\csname\??ff#1\endcsname @@ -1456,7 +1005,7 @@ \fi \else #1\ifx#2\empty\else*#2#3\fi - \fi\fi} + \fi\fi\fi} \def\redotruefontname#1% {\@EA\dodotruefontname#1*\relax} @@ -1464,23 +1013,29 @@ \def\dodotruefontname#1*#2\relax {\ifcsname\??ff\fontclass#1\endcsname \@EA\redotruefontname\csname\??ff\fontclass#1\endcsname + \else\ifcsname\??ff\defaultfontclass#1\endcsname + \@EA\redotruefontname\csname\??ff\defaultfontclass#1\endcsname \else\ifcsname\??ff#1\endcsname \@EA\redotruefontname\csname\??ff#1\endcsname \else #1% - \fi\fi} + \fi\fi\fi} \def\expandfontsynonym#1#2% #2 := onelevelexpansion(#1) {\ifcsname\??ff\fontclass#2\endcsname \expandafter\def\expandafter#1\expandafter{\csname\??ff\fontclass#2\endcsname}% - \fi} + \else\ifcsname\??ff\defaultfontclass#2\endcsname + \expandafter\def\expandafter#1\expandafter{\csname\??ff\defaultfontclass#2\endcsname}% + \fi\fi} \def\doifelsefontsynonym#1% {\ifcsname\??ff\fontclass#1\endcsname - \expandafter\firstoftwoarguments + \@EA\firstoftwoarguments + \else\ifcsname\??ff\defaultfontclass#1\endcsname + \@EAEAEA\firstoftwoarguments \else - \expandafter\secondoftwoarguments - \fi} + \@EAEAEA\secondoftwoarguments + \fi\fi} % \definetypeface[palatino][rm][serif][palatino,allbold][default] % @@ -1498,7 +1053,7 @@ \def\dostartfontclass[#1]% {\pushmacro\fontclass - \doifelse{#1}{\v!each} + \doifelse{#1}\v!each {\let\fontclass\empty} {\doifsomething{#1}{\def\fontclass{#1}}}} @@ -1510,47 +1065,14 @@ %D %D A goody: -\def\tracedfontencoding#1% - {\ifcsname\??ff#1\s!encoding\endcsname - \space[\csname\??ff#1\s!encoding\endcsname]% - \fi} - \def\tracedfontname#1% - {\ifcsname\??ff\fontclass#1\endcsname - #1\tracedfontencoding{\fontclass#1}\space->\space - \@EA\tracedfontname\csname\??ff\fontclass#1\endcsname + {#1\ifcsname\??ff\fontclass#1\endcsname + \@EA\tracedfontname\csname\??ff\fontclass#1\endcsname \else\ifcsname\??ff#1\endcsname - #1\tracedfontencoding{#1}\space->\space - \@EA\tracedfontname\csname\??ff#1\endcsname - \else - #1% + \@EA\tracedfontname\csname\??ff#1\endcsname \fi\fi} %D \macros -%D {getfontfileparameters} -%D -%D For special purposes, one can use the next macro to -%D access font file characteristics, for instance: -%D -%D \starttyping -%D \getfontfileparameters{Regular} -%D \stoptyping -%D -%D can result in: -%D -%D \starttyping -%D \def\currentfontfileencoding{texnansi} -%D \stoptyping - -% \let\currentfontfileencoding\s!unknown -% \let\currentfontfilemapping \s!unknown -% \let\currentfontfilehandling\s!unknown - -% \def\getfontfileparameters#1% -% {\edef\@@truefontname{\truefontname{#1}}% -% \edef\currentfontfilefeatures{\truefontdata\@@truefontname\s!features}} - -%D \macros %D {definefont} %D %D Before we implement the main definition macro, we first show @@ -1568,14 +1090,23 @@ \def\definefont {\dotripleempty\dodefinefont} +% \def\dodefinefont[#1][#2][#3]% [name][spec][1.6 | line=10pt | setup_id] +% {\doifinstringelse{ }{#2} +% {\ifthirdargument +% \unexpanded\setvalue{#1}{\redodefinefont{#1}{#2}{#3}}% +% \else +% \unexpanded\setvalue{#1}{\dododefinefont{#1}{#2}}% +% \fi} +% {\definefont[#1][#2 sa *][#3]}} + +% we moved the unspecified size check to lua + \def\dodefinefont[#1][#2][#3]% [name][spec][1.6 | line=10pt | setup_id] - {\doifinstringelse{ }{#2} - {\ifthirdargument - \unexpanded\setvalue{#1}{\redodefinefont{#1}{#2}{#3}}% - \else - \unexpanded\setvalue{#1}{\dododefinefont{#1}{#2}}% - \fi} - {\definefont[#1][#2 sa *][#3]}} + {\ifthirdargument + \unexpanded\setvalue{#1}{\redodefinefont{#1}{#2}{#3}}% + \else + \unexpanded\setvalue{#1}{\dododefinefont{#1}{#2}}% + \fi} \def\redodefinefont#1#2#3% {\dododefinefont{#1}{#2}% @@ -1636,11 +1167,6 @@ \the\everyfontswitch \fi} -%D I considered checking for mistakenly use of \PLAIN's -%D \type{\magstep}'s but although it would take only a few -%D lines of code, this would not add to consistent use. I -%D therefore removed this check. - %D \macros %D {mapfontsize} %D @@ -1673,8 +1199,7 @@ {\dodoubleargument\domapfontsize} \def\domapfontsize[#1][#2]% - {\scratchdimen#1\relax % \relax is really needed here - \setvalue{\??ft*\the\scratchdimen}{#2}} + {\setvalue{\??ft*\the\dimexpr#1\relax}{#2}} \def\setmappedfontsize#1% {\ifcsname\??ft*#1\endcsname @@ -1695,26 +1220,25 @@ %D To be documented. -\let\sizelist\empty +\let\fontsizelist \empty +\let\fontalternativelist\empty +\let\fontstylelist \empty -\def\definefontsize[#1]% sneller met toks - {\addtocommalist{#1}\sizelist - \def\docommand##1% +\def\checkfontnamecombinations + {\def\docommand##1% {\def\dodocommand####1% - {\def\dododocommand########1% - %{\checkbodyfont{}{########1}{####1}{##1}}% - {\checkbodyfont{########1}{####1}{##1}}% - \processcommacommand[\stylelist]\dododocommand}% - \processcommacommand[\alternativelist]\dodocommand}% - \processcommacommand[\sizelist]\docommand} - -\def\alternativetextlist{\c!tf,\c!bf,\c!it,\c!sl,\c!bs,\c!bi,\c!sc} -\def\alternativemathlist{\c!mr,\c!mi,\c!sy,\c!ex,\c!ma,\c!mb} + {\def\dododocommand########1{\checkbodyfont{########1}{####1}{##1}}% + \processcommacommand[\fontstylelist]\dododocommand}% + \processcommacommand[\fontalternativelist]\dodocommand}% + \processcommacommand[\fontsizelist]\docommand} -\let\alternativelist\alternativetextlist % upward compatible +\def\definefontsize[#1]% sneller met toks + {\addtocommalist{#1}\fontsizelist + \checkfontnamecombinations} -%\definefontsize[\c!a] \definefontsize[\c!b] -%\definefontsize[\c!c] \definefontsize[\c!d] +\def\definefontalternative[#1]% + {\addtocommalist{#1}\fontalternativelist + \checkfontnamecombinations} %D \macros %D {currentfontscale,currentfontbodyscale} @@ -1810,7 +1334,7 @@ \let\bodyfontenvironmentlist\empty -\newcount\@@fontdefhack +\newcount\@@fontdefhack % check if this is still needed \def\@@beginfontdef {\ifcase\@@fontdefhack @@ -1843,29 +1367,44 @@ \@EA\dododefinebodyfontenvironment\@EA[\tempbodyfontsize][#1][#3]}% \@@endfontdef \else + \ifx\fontclass\empty\else + \writestatus\m!fonts{beware: fontclass ignored (if needed use: [fontclass][size][settings])}% + \fi + \pushmacro\fontclass + \let\fontclass\empty \definebodyfontenvironment[\fontclass][#1][#2]% change */* + \popmacro\fontclass \fi} \def\dododefinebodyfontenvironment[#1][#2][#3]% size class settings - {\@@beginfontdef - \doifundefined{\??ft#2#1\c!em} % \s!text goes wrong in testing because - {\def\docommand##1% % the 12pt alternative will called when - {\scratchdimen#1\relax % typesetting the test (or so) - \scratchdimen\csname\??ft\s!default##1\endcsname\scratchdimen + {\@@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 + \def\docommand##1% +% fails: \def\checkbodyfontenvironment[#1]{! #1 ! \definebodyfontenvironment[\fontclass][#1][]} \setupbodyfont[8.5pt] +% {\normalizebodyfontsize\csname\??ft\s!default##1\endcsname\dimexpr#1\relax\to\tempbodyfontsize +% \letvalue{\??ft#2#1##1}\tempbodyfontsize}% + {\scratchdimen\csname\??ft\s!default##1\endcsname\dimexpr#1\relax \normalizebodyfontsize\scratchdimen\to\tempbodyfontsize - \setevalue{\??ft#2#1##1}{\tempbodyfontsize}}% - \processcommacommand[\fontsizelist]\docommand + \letvalue{\??ft#2#1##1}\tempbodyfontsize}% + \processcommacommand[\fontrelativesizelist]\docommand \copyparameters [\??ft#2#1][\??ft\s!default] - [\c!interlinespace,\c!em]}% + [\c!interlinespace,\c!em]% + \fi \getparameters[\??ft#2#1][#3]% \@@endfontdef % new code, see remark - \ifloadingfonts \else % only runtime - \doifundefined{\@size@#1} % only once - {\letvalue{\@size@#1}\empty % prevent loop - \defineunknownfont{#1}}% % safeguard - \fi + \ifloadingfonts + % only runtime + \else\ifcsname\@size@#1\endcsname + % only once + \else + % prevent loop (hence \empty) + \letvalue{\@size@#1}\empty + \defineunknownfont{#1}% + \fi\fi % so far \setvalue{\@size@#1}{\docompletefontswitch[#1]}} @@ -1891,28 +1430,18 @@ \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} % this one already catches both define/setup \def\setupbodyfontenvironment{\definebodyfontenvironment} -% officially, but not needed (yet): -% -% \def\dosetupbodyfontenvironment[#1][#2][#3]% class size settings -% {\ifthirdargument -% \localbodyfontsize#2\relax -% \normalizebodyfontsize\localbodyfontsize\to\normalizedbodyfontsize -% \doifundefinedelse{\??ft#1\normalizedbodyfontsize\c!em} -% {\definebodyfontenvironment[#1][#2][#3]}% -% {\getparameters[\??ft#1\normalizedbodyfontsize][#3]}% -% \else -% \localbodyfontsize#1\relax -% \normalizebodyfontsize\localbodyfontsize\to\normalizedbodyfontsize -% \doifundefinedelse{\??ft\normalizedbodyfontsize\c!em} -% {\definebodyfontenvironment[#1][#2]}% -% {\getparameters[\??ft\normalizedbodyfontsize][#2]}% -% \fi} - %D Just a couple of interface macros: \def\bodyfontvariable#1% @@ -1952,7 +1481,8 @@ %D We show two examples, that show all the alternative %D scaling options. The \type{\tfa} alternatives can be %D extended with \type{\bfa}, \type{\slb}, etc. or even -%D \type{e} and higher alternatives. +%D \type{e} and higher alternatives. The magic scaled +%D values are derived from plain \TEX's \type {\magstep}: %D %D \starttyping %D \definebodyfont [12pt] [rm] @@ -1962,10 +1492,10 @@ %D sl=cmsl12, %D bi=cmbxti10 at 12pt, %D bs=cmbxsl10 at 12pt, -%D tfa=cmr12 scaled \magstep1, -%D tfb=cmr12 scaled \magstep2, -%D tfc=cmr12 scaled \magstep3, -%D tfd=cmr12 scaled \magstep4, +%D tfa=cmr12 scaled 1.200, +%D tfb=cmr12 scaled 1.440, +%D tfc=cmr12 scaled 1.728, +%D tfd=cmr12 scaled 2.074, %D sc=cmcsc10 at 12pt] %D %D \definebodyfont [12pt,11pt,10pt,9pt,8pt] [rm] @@ -2026,12 +1556,12 @@ \doifnumberelse{#1} {\doifassignmentelse{#3} {% [12pt] [style] [settings] - \doifundefined{#2}{\expanded{\definefontstyle[#2][#2]}}% new + \doifundefined{#2}{\normalexpanded{\noexpand\definefontstyle[#2][#2]}}% new \processcommalist[#1]{\dododefinebodyfont{#2}{#3}}} {% [12pt] [style] [identifier] \dodefinedefaultbodyfont[#1][#2][#3]}} % body style identifier {% [identifier] [style] [settings] % see *** - \setvalue{\s!default#1#2}##1##2{\expanded{\xdodefinebodyfont[##1][##2][#3]}}}% + \setvalue{\s!default#1#2}##1##2{\normalexpanded{\noexpand\xdodefinebodyfont[##1][##2][#3]}}}% \else\ifsecondargument \definebodyfont[#1][\c!rm][#2]% \else @@ -2042,9 +1572,8 @@ \fi\fi} \def\xdodefinebodyfont[#1][#2][#3]% body|identifier style defs|identifier - {%\writestatus{[#1]}{[#2][#3]}% - \checkrelativefontsize{#2}% rather new, inherit from other defs - \ifundefined{#2}\expanded{\definefontstyle[#2][#2]}\fi % new + {\checkrelativefontsize{#2}% rather new, inherit from other defs + \ifcsname#2\endcsname\else\normalexpanded{\noexpand\definefontstyle[#2][#2]}\fi % new \processcommalist[#1]{\dododefinebodyfont{#2}{#3}}% \let\relativefontsize\defaultrelativefontsize} @@ -2055,47 +1584,56 @@ \def\dodododefinebodyfont#1#2#3% style body def {\dododododefinebodyfont{#1}{#2}[#3]} -\def\iflocalclassfonts{\ifx\fontclass\empty} - -\def\dododododefinebodyfont#1#2[#3#4#5=#6]% style body def - {\ifundefined{#1#3#4#5}% - %\checkbodyfont{#2}{#1}{#3#4}{#5}% not \definefontsize[#5] - \checkbodyfont{#1}{#3#4}{#5}% not \definefontsize[#5] - \fi - \iflocalclassfonts - \letbeundefined{*\fontclass#2#1#3#4#5*}% - \scratchtoks{#6}% - \expanded{\unexpanded\noexpand\setvalue{#2#1#3#4#5}% - {\noexpand\xxdododefinefont{\relativefontsize}{#2}% - {#2#1#3#4#5}{\the\scratchtoks}}}% +\def\dododododefinebodyfont + {\ifx\fontclass\empty + \expandafter\dododododefinebodyfontnop \else - %\expanded{\writestatus{defining}{[\fontclass][#2#1#3#4#5] \resolvefontname#6 }}% - \global\letbeundefined{*\fontclass#2#1#3#4#5*}% - \scratchtoks{#6}% - \expanded{\unexpanded\noexpand\setgvalue{\fontclass#2#1#3#4#5}% - {\noexpand\xxdododefinefont{\relativefontsize}{#2}% - {#2#1#3#4#5}{\the\scratchtoks}}}% + \expandafter\dododododefinebodyfontyes \fi} -% \def\checkbodyfont#1#2#3#4% body style alt size / gdef % #4 can be empty -% {\def\c!!mm{#2}% -% \ifx\c!!mm\c!mm % prevents \max and alike (re)defs -% \unexpanded\setgvalue {#2}{\setcurrentfontstyle {#2}}% \rm -% \unexpanded\setgvalue {#3}{\setcurrentfontalternative {#3}}% \sl -% \else -% \unexpanded\setgvalue {#2#4}{\setcurrentfontstylesize {#2}{#4}}% \rma -% \unexpanded\setgvalue {#3#4}{\setcurrentfontalternativesize {#3}{#4}}% \sla -% \unexpanded\setgvalue {#2#3#4}{\setcurrentfontstylealternativesize{#2}{#3}{#4}}% \rmsla -% \unexpanded\setgvalue {#2}{\setcurrentfontstyle {#2}}% \rm -% \unexpanded\setgvalue {#3}{\setcurrentfontalternative {#3}}% \sl -% \unexpanded\setgvalue {#2\c!x}{\setcurrentfontxstylealternative {#2}}% \rmx -% \unexpanded\setgvalue{#2\c!xx}{\setcurrentfontxxstylealternative {#2}}% \rmxx -% \unexpanded\setgvalue {#3\c!x}{\setcurrentfontxalternative {#3}}% \slx -% \unexpanded\setgvalue{#3\c!xx}{\setcurrentfontxxalternative {#3}}% \slxx -% \unexpanded\setgvalue {#2#3}{\setcurrentfontstylealternative {#2}{#3}}% \rmsl -% \fi} -% -% leaner +\def\dododododefinebodyfontyes#1% style body def + {\edef\askedbodyfontstyle{#1}% + \ifx\askedbodyfontstyle\c!mm + \expandafter\dodefinebodyfontyesmm + \else + \expandafter\dodefinebodyfontyesxx + \fi\askedbodyfontstyle} % we can get rid of #1 + +\def\dododododefinebodyfontnop#1% style body def + {\edef\askedbodyfontstyle{#1}% + \ifx\askedbodyfontstyle\c!mm + \expandafter\dodefinebodyfontnopmm + \else + \expandafter\dodefinebodyfontnopxx + \fi\askedbodyfontstyle} % we can get rid of #1 + +\def\dodefinebodyfontnopxx#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] + \@EA\let\csname*#2#1#3#4#5*\endcsname\undefined + \normalprotected\@EA\edef\csname#2#1#3#4#5\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#5}{\normalunexpanded{#6}}}} + +\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] + \global\@EA\let\csname*\fontclass#2#1#3#4#5*\endcsname\undefined + \normalprotected\@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] + \@EA\let\csname*#2#1#3#4#51*\endcsname\undefined + \@EA\let\csname*#2#1#3#4#52*\endcsname\undefined + \@EA\let\csname*#2#1#3#4#53*\endcsname\undefined + \normalprotected\@EA\edef\csname#2#1#3#4#51\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#51}{\normalunexpanded{#6}}}% + \normalprotected\@EA\edef\csname#2#1#3#4#52\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#52}{\normalunexpanded{#6}}}% + \normalprotected\@EA\edef\csname#2#1#3#4#53\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#53}{\normalunexpanded{#6}}}} + +\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] + \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 + \normalprotected\@EA\xdef\csname\fontclass#2#1#3#4#51\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#51}{\normalunexpanded{#6}}}% + \normalprotected\@EA\xdef\csname\fontclass#2#1#3#4#52\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#52}{\normalunexpanded{#6}}}% + \normalprotected\@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 {\def\c!!mm{#1}% @@ -2108,9 +1646,9 @@ \def\checkmathbodyfont#1#2#3% style alt size / gdef % #3 can be empty {%\message{!m #1 #2 #3!}% % #1 #2 #3 = signal - \unexpanded\setgvalue {#1#2#3}{\setcurrentfontstylealternativesize{#1}{#2}{#3}}% \mmsla - \unexpanded\setgvalue {#1}{\setcurrentfontstyle {#1}}% \mm - \unexpanded\setgvalue {#2}{\setcurrentfontalternative {#2}}}% \sl + %unexpanded\setgvalue {#1#2#3}{\setcurrentfontstylealternativesize{#1}{#2}{#3}}% \mmsla + \unexpanded\setgvalue {#2}{\setcurrentfontalternative {#2}}% \sl + \unexpanded\setgvalue {#1}{\setcurrentfontstyle {#1}}}% \mm \def\checktextbodyfont#1#2#3% style alt size / gdef % #3 can be empty {%\message{!t #1 #2 #3!}% @@ -2144,40 +1682,42 @@ \newif\ifdefiningunknownfont \def\dodefineunknownfont#1#2% - {\doifdefined{\??ft\s!default#2} - {\donetrue - \scratchdimen#1\relax - \scratchdimen\csname\??ft\s!default#2\endcsname\scratchdimen - \normalizebodyfontsize\scratchdimen\to\!!stringa - \letvalue{\??ft#1#2}\!!stringa}} + {\ifcsname\??ft\s!default#2\endcsname + \donetrue + \normalizebodyfontsize\csname\??ft\s!default#2\endcsname\dimexpr#1\relax\to\tempbodyfontsize + \letvalue{\??ft#1#2}\tempbodyfontsize + \fi} \def\dodefineunknownbodyfont#1#2% see *** - {\doifdefined{\s!default\s!default#2}% somehow related to */* - {\donetrue - \getvalue{\s!default\s!default#2}{#1}{#2}}} + {\ifcsname\s!default\s!default#2\endcsname % somehow related to */* + \donetrue + \getvalue{\s!default\s!default#2}{#1}{#2}% + \fi} \def\dodefineunknownsubfont#1#2% - {\doifundefined{\@size@\getvalue{\??ft#1#2}} - {\donetrue - \defineunknownfont{\getvalue{\??ft#1#2}}}} + {\ifcsname\@size@\getvalue{\??ft#1#2}\endcsname + \else + \donetrue + \defineunknownfont{\getvalue{\??ft#1#2}}% + \fi} \def\defineunknownfont#1% {\let\c!savedtext\c!text \let\c!text\s!text \donefalse - \processcommacommand[\fontsizelist]{\dodefineunknownfont{#1}}% + \processcommacommand[\fontrelativesizelist]{\dodefineunknownfont{#1}}% \let\c!text\c!savedtext \ifdone \donefalse \processcommacommand - [\stylelist] + [\fontstylelist] {\dodefineunknownbodyfont{#1}}% \ifdone \donefalse \setvalue{\@size@#1}{\docompletefontswitch[#1]}% \ifdefiningunknownfont \else \definingunknownfonttrue - \processcommacommand[\fontsizelist]{\dodefineunknownsubfont{#1}}% + \processcommacommand[\fontrelativesizelist]{\dodefineunknownsubfont{#1}}% \definingunknownfontfalse \fi \fi @@ -2238,8 +1778,8 @@ %D size and the local (sometimes in the textflow) size. We %D store these dimensions in two \DIMENSION\ registers. -\newdimen\globalbodyfontsize \globalbodyfontsize=12pt -\newdimen\localbodyfontsize \localbodyfontsize =\globalbodyfontsize +\ifdefined\globalbodyfontsize\else \newdimen\globalbodyfontsize \fi \globalbodyfontsize=12pt +\ifdefined\localbodyfontsize \else \newdimen\localbodyfontsize \fi \localbodyfontsize =\globalbodyfontsize %D \macros %D {bodyfontsize} @@ -2273,34 +1813,41 @@ %D often not the way users specify the bodyfont size. Therefore %D we also store the normalized value. -\chardef\fontdigits=1 +\chardef\fontdigits=2 % was 1 \def\normalizebodyfontsize#1\to#2% - {\scratchdimen#1\relax - \ifcase\fontdigits\advance\scratchdimen.5\points\fi - \@EA\@EA\@EA\donormalizedbodyfontsize\@EA\WITHOUTPT\the\scratchdimen00\to#2} + {\@EA\@EA\@EA\donormalizedbodyfontsize\@EA\WITHOUTPT\the\dimexpr#1+\ifcase\fontdigits.5\or.05\or.005\fi\points\relax000\to#2} -\def\donormalizedbodyfontsize#1.#2#3#4\to#5% \points ? - {\edef#5% +\def\donormalizedbodyfontsize#1.#2#3#4#5\to#6% \points ? + {\edef#6% not \ifcase#2\else due to \relax adding {#1% - \ifcase\fontdigits\or - \ifcase#2 \else.#2\fi % and not: \ifcase#2\else ... - \else - \ifcase#2#3 \else.#2\ifcase#3 \else#3\fi\fi % not: \ifcase#2#3\else ... + \ifcase\fontdigits + \or \ifcase#2 \else .#2\fi % 1 + \or \ifcase#2#3 \else .#2\ifcase#3 \else #3\fi\fi % 2 + \else \ifcase#2#3#4 \else .#2\ifcase#4 \ifcase#3 \else#3\fi \else#3#4\fi\fi % 3 \fi \s!pt}} +% not faster, just less tracing +% +% \def\setfontdigits#1% +% {\chardef\fontdigits\ifnum#1>\plusthree\plusthree\else#1\fi\relax +% \@EA\let\@EA\normalizedbfs\csname normalizedbfs\number\fontdigits\endcsname} +% +% \def\normalizebodyfontsize#1\to#2% +% {\@EA\@EA\@EA\normalizedbfs\@EA\WITHOUTPT\the\dimexpr#1+\ifcase\fontdigits.5\or.05\or.005\fi\points\relax000\to#2} +% +% \setvalue{normalizedbfs0}#1.#2\to #3{\edef#3{#1\s!pt}} +% \setvalue{normalizedbfs1}#1.#2#3\to #4{\edef#4{#1\ifcase#2 \else.#2\fi\s!pt}} +% \setvalue{normalizedbfs2}#1.#2#3#4\to #5{\edef#5{#1\ifcase#2#3 \else.#2\ifcase#3 \else#3\fi\fi\s!pt}} +% \setvalue{normalizedbfs3}#1.#2#3#4#5\to#6{\edef#6{#1\ifcase#2#3#4 \else.#2\ifcase#4 \ifcase#3 \else#3\fi\else#3#4\fi\fi\s!pt}} +% +% \setfontdigits2 + \normalizebodyfontsize\bodyfontsize\to\normalizedglobalbodyfontsize \normalizebodyfontsize\bodyfontsize\to\normalizedlocalbodyfontsize \normalizebodyfontsize\bodyfontsize\to\normalizedbodyfontsize -%D To be internationalized: - -\def\korpsgrootte {\bodyfontsize} -\def\korpspunten {\bodyfontpoints} - -%D some day. - %D \macros %D {fontstyle,fontalternative,fontsize} %D @@ -2322,28 +1869,6 @@ \let\fontstyle = \defaultfontstyle \let\fontsize = \defaultfontsize -%D {\em The following approach is obsolete.} -%D -%D All things related to fonts are grouped into files with -%D names like \type{font-cmr}. These files are loaded by: - -\def\resetfontdefinitionfile[#1]% - {\letbeundefined{\c!file\f!fontprefix#1}} - -\newif\ifloadfontfileonce - -\def\doreadfontdefinitionfile#1#2% #1 = set/switch state - {\doifundefined{\c!file\f!fontprefix#2}% - {\ifloadfontfileonce - \letvalue{\c!file\f!fontprefix#2}\empty - \fi - \makeshortfilename[\truefilename{\f!fontprefix#2}]% - \startreadingfile - \readsysfile\shortfilename - {\showmessage\m!fonts2{#2}} - {\showmessage\m!fonts3{#2}}% - \stopreadingfile}} - %D When \type {\loadfontfileoncetrue}, such files are %D only loaded once! This permits redundant loading, but at %D the same time forced grouping when we want continuously mix @@ -2352,8 +1877,10 @@ %D needed to prevent problems with loading files that use this %D character in numbers. +% can be made faster (only used internally now) + \def\doswitchpoints[#1]% - {\expanded{\dodoswitchpoints{#1}}} + {\normalexpanded{\noexpand\dodoswitchpoints{#1}}} \def\dodoswitchpoints#1% {\doifundefined{\@size@#1} @@ -2363,6 +1890,7 @@ {\getvalue{\@size@#1}% \localbodyfontsize#1\relax \normalizebodyfontsize\localbodyfontsize\to\normalizedbodyfontsize +% \edef\fontbody{\fontbody}% to be tested but we can clean up mkiv further \checkbodyfontenvironment[\normalizedbodyfontsize]} {\showmessage\m!fonts4{#1}}} @@ -2425,17 +1953,29 @@ %D sequence of a session. After the loading job is done, the %D macro relaxes itself and reset the signal. +% \appendtoks +% \to \everysetupdocument + +\newconditional\fontsareloaded + \def\preloadfonts % never called, needs a clean up - {\showmessage\m!fonts6{\normalizedbodyfontsize\normalspace\fontstyle}% - \global\loadingfontsfalse - \doswitchpoints[\normalizedbodyfontsize]% - \doswitchstyle[\fontstyle]% - \the\everybodyfont - \the\everyglobalbodyfont - \saveinterlinespace + {\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} -% \prependtoks \preloadfonts \to \everydump % saves .1 s on a DELL P60 - 2GHZ +% maybe add this to \everystarttext +% +% \ifconditional\fontsareloaded\else +% \usetypescript[modern]% +% \setuptypeface[modern]% +% \fi %D Here comes the main font switching macros. These macros %D handle changes in size as well as returning to the global @@ -2446,36 +1986,68 @@ {\restoreglobalbodyfont} {\processcommacommand[#2]{\dodosetfont{#1}}% ##1 get also passed \ifloadingfonts\else + \global\settrue\fontsareloaded \doswitchpoints[\normalizedbodyfontsize]% \doswitchstyle[\fontstyle]% + \ifx\defaultfontclass\empty + \let\defaultfontclass\fontclass + \fi \fi}% \chardef\currentxfontsize\zerocount} \def\dodosetfont#1#2% #1 = set/switch state | check fo rempty, else space {\doifsomething{#2}{\dododosetfont{#1}{#2}{\showmessage\m!fonts4{#2}}}} -\def\dododosetfont#1#2#3% #1 = set/switch state - {\doifnumberelse{#2} - {\dodododosetfont{#1}{#2}{#3}} - {\doifdefinedelse{\??ft\normalizedbodyfontsize\interfaced{#2}} - {\edef\fontstep{\csname\bodyfontvariable\normalizedbodyfontsize\interfaced{#2}\endcsname}% - \expanded{\dodododosetfont{#1}{\fontstep}}{#3}} - {\doifelse{#2}\v!reset - {\let\fontstyle\empty % new 31/7/2006 - \let\fontsize \empty} - {\doifdefinedelse{\@style@#2} - {\edef\fontstyle{#2}} - {\doreadfontdefinitionfile{#1}{#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}} + +\def\redododosetfont#1#2#3% #1 = set/switch state ! ! ! !could also be used for mkii + {\edef\expandedfontthing{#2}% + \def\interfacedfontsize{\normalizedbodyfontsize\interfaced\expandedfontthing}% + \ifcsname\??ft\interfacedfontsize\endcsname + \edef\fontstep{\csname\bodyfontvariable\interfacedfontsize\endcsname}% + \normalexpanded{\noexpand\dodododosetfont{#1}{\fontstep}}{#3}% + \else\ifx\expandedfontthing\v!reset + \let\fontstyle\empty % new 31/7/2006 + \let\fontsize \empty + \else + \ifcsname\@style@\expandedfontthing\endcsname + \let\fontstyle\expandedfontthing + \else + \setcurrentfontclass\expandedfontthing + \ifcase#1\relax + \let\globalfontclass\globalfontclass + \else + \let\globalfontclass\fontclass + \fi + \ifx\fontclass\empty + \let\fontstyle\c!rm + \else\ifcsname\??tf\fontclass\s!default\endcsname + \edef\fontstyle{\csname\??tf\fontclass\s!default\endcsname}% + \else + \let\fontstyle\c!rm + \fi\fi + \fi + \fi\fi} \def\dodododosetfont#1#2#3% #1 = set/switch state - {\scratchdimen#2\relax - \normalizebodyfontsize\scratchdimen\to\normalizedsetfont - \doifundefined{\@size@\normalizedsetfont} - {\defineunknownfont{#2}}% - \doifdefinedelse{\@size@\normalizedsetfont} - {\localbodyfontsize\normalizedsetfont - \let\normalizedbodyfontsize\normalizedsetfont} - {#3\dosetsubstitutefont{#1}{#2}}} + {\normalizebodyfontsize#2\to\normalizedsetfont + \ifcsname\@size@\normalizedsetfont\endcsname \else + \defineunknownfont{#2}% + \fi + \ifcsname\@size@\normalizedsetfont\endcsname + \localbodyfontsize\normalizedsetfont + \let\normalizedbodyfontsize\normalizedsetfont + \else + #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 @@ -2515,8 +2087,15 @@ \let\fontclass\empty \let\globalfontclass\fontclass +% we need to check the fontclass + +\def\registerfontclass#1% + {\letgvalue{\@fontclass@#1}\v!yes} % global ? + \def\setcurrentfontclass#1% - {\edef\fontclass{#1}} + {\ifcsname\@fontclass@#1\endcsname + \edef\fontclass{#1}% + \fi} \let\defaultfontstyle \c!rm \let\defaultfontalternative \c!tf @@ -2553,7 +2132,7 @@ % already in sync \else \let\bigmathfontsize\fontsize - \synchronizemath \synchronizetext + \synchronizemath \fi} \def\checkbigmathsynchronization @@ -2572,10 +2151,7 @@ \checkbigmathsynchronization} \def\dosetcurrentfontalternative#1% - {\edef\fontalternative{#1}% - \ifmmode % maybe no test, or actually, an option - \fam\csname\fontalternative\s!fam\endcsname - \fi} + {\edef\fontalternative{#1}} \def\setcurrentfont#1#2#3#4% {%\message{[1 #1 #2 #3 #4]}% @@ -2660,6 +2236,7 @@ \global\let\fontstrategy\dofontstrategy \the\fontstrategies \relax % \relax still needed ? \fi + \autofontsizefalse \ifskipfontcharacteristics \setfontcharacteristics \the\everyfontswitch @@ -2675,6 +2252,8 @@ #1\csname\fontclass#2#3#4#5\endcsname \tryingfontfalse \fi} +% old sequence + \appendtoks \iftryingfont \fontstrategy \autofontsizefalse % --- --- --- --- % pt tt bf a \fontbody \fontstyle \fontalternative \fontsize \fi \to \fontstrategies @@ -2706,7 +2285,6 @@ \prependtoks \ifsynchronizefonts \synchronizemath - \synchronizetext \synchronizefont % problem: syncs last font \fi \to \everybodyfont @@ -2757,9 +2335,6 @@ % This alterative is not really needed, but for old time's sake % we keep it there. We can speed it up when needed. -% \def\setcurrentfontxstylealternative #1{\csname#1\endcsname\tfx} -% \def\setcurrentfontxxstylealternative#1{\csname#1\endcsname\tfxx} - \def\setcurrentfontxstylealternative #1{\csname#1\endcsname\tx} \def\setcurrentfontxxstylealternative#1{\csname#1\endcsname\txx} @@ -2808,10 +2383,11 @@ %D \stoptyping \def\dodefinefontstyle[#1][#2]% - {\rawdoifinsetelse{#2}{\stylelist} - {}%\debuggerinfo\m!fonts{unknown style #2}} - {\addtocommalist{#2}\stylelist - \showmessage\m!fonts8{#2\space (#1)}}% + {\rawdoifinsetelse{#2}{\fontstylelist} + {%\debuggerinfo\m!fonts{unknown style #2}% + } + {%\debuggerinfo\m!fonts8{#2\space (#1)}% + \addtocommalist{#2}\fontstylelist}% % check kan hier \def\docommand##1% {\setvalue{\@shortstyle@##1}{#2}% @@ -2823,25 +2399,9 @@ \def\setfontstyle#1#2% #1:name (roman, romaan) #2:style (rm) {\edef\fontstyle{#1}% + \checkfontnamecombinations \setcurrentfontstyle\normalizedbodyfontsize} -\chardef\defaultskewcharmi=127 % '177 -\chardef\defaultskewcharsy= 48 % '60 - -% \def\dosetskewchar#1% -% {\skewchar\font\ifx\@@fontskewchar\empty#1\else\@@fontskewchar\fi} - -\def\dosetskewchar#1#2% - {\ifx\@@fontskewchar\empty - \skewchar\textfont #1#2% - \skewchar\scriptfont #1#2% - \skewchar\scriptscriptfont#1#2% - \else - \skewchar\textfont #1\@@fontskewchar - \skewchar\scriptfont #1\@@fontskewchar - \skewchar\scriptscriptfont#1\@@fontskewchar - \fi} - %D The previous macros show that it's is not always %D neccessary to define the whole bunch of fonts, take for %D instance the sequence: @@ -2878,7 +2438,7 @@ \def\docompletefontswitch[#1]% {\bodyfontsize#1\relax - \dimensiontocount\bodyfontsize\bodyfontpoints + \dimensiontocount\bodyfontsize\bodyfontpoints % rounded, still used in m-chart \edef\bodyfontfactor{\withoutpt\the\bodyfontsize}% \normalizebodyfontsize\bodyfontsize\to\normalizedbodyfontsize \dosetbodyfontface \textface \s!text @@ -2948,8 +2508,7 @@ \def\fastswitchtobodyfont#1% {\ifcsname\??ft\normalizedbodyfontsize#1\endcsname - \edef\futurebodyfontsize - {\csname\??ft\normalizedbodyfontsize#1\endcsname}% + \edef\futurebodyfontsize{\csname\??ft\normalizedbodyfontsize#1\endcsname}% \ifcsname\@size@\futurebodyfontsize\endcsname \csname\@size@\futurebodyfontsize\endcsname \localbodyfontsize\futurebodyfontsize\relax @@ -2958,46 +2517,10 @@ \csname\@style@\fontstyle\endcsname \the\everybodyfont} -%D Because the last macro can appear in arguments or be assigned -%D to parameters, we protect this one for unwanted expansion. - -\def\dodosetmathfont#1% - {\setcurrentfontalternative{#1}% - % \doifdefinedelse{#1\s!fam} % adapted - % {\edef\mffam{\getvalue{#1\s!fam}}} - % {\edef\mffam{\getvalue{\c!nn\s!fam}}}% - \textfont \mrfam\textfont \mffam - \scriptfont \mrfam\scriptfont \mffam - \scriptscriptfont\mrfam\scriptscriptfont\mffam} - -\def\domffam#1% - {\csname\ifcsname#1\s!fam\endcsname#1\else\c!nn\fi\s!fam\endcsname} - -\def\mffam - {\domffam\fontalternative} - -\def\dosetmathfont - {\def\rm{\fam\mrfam}\dodosetmathfont} - -\def\enableencodinginmath - {\appendtoks - \everyhbox{\mr\everyhbox\emptytoks}% - \everyvbox{\mr\everyvbox\emptytoks}% - \to \everymathematics} % was \everymath - -% \enableencodinginmath % too untested to enable by default - %D \starttyping %D $\cases{& \ccaron}$ $x=\hbox{\ccaron $x=\hbox{\ccaron}$}$ %D \stoptyping -%D The font specific features are bound to the filename. - -\def\updatefontparameters - {\edef\@@fontfeatures {\truefontdata\somefontfile\s!features}% - \edef\@@fontfallbacks{\truefontdata\somefontname\s!fallbacks}% - \edef\@@fontskewchar {\truefontdata\somefontfile\s!skewchar}} % will be replaced - \def\setfontcharacteristics {\the\everyfont} @@ -3020,27 +2543,53 @@ {\dotripleargument\dodefinefontfeature} \def\dodefinefontfeature[#1][#2][#3]% - {\ctxlua{fonts.define.specify.preset_context("#1","#2","#3")}} + {\global\expandafter\chardef\csname\??fq=#1\endcsname + \ctxlua{tex.write(fonts.define.specify.preset_context("#1","#2","#3"))}\relax} \definefontfeature [default] - [liga=yes,kern=yes,tlig=yes,trep=yes] % texligatures=yes,texquotes=yes + [%mode=node,% + liga=yes,kern=yes,tlig=yes,trep=yes] % texligatures=yes,texquotes=yes \definefontfeature [smallcaps] - [liga=yes,kern=yes,tlig=yes,trep=yes,smcp=yes] % texligatures=yes,texquotes=yes + [%mode=node,% + liga=yes,kern=yes,tlig=yes,trep=yes,smcp=yes] % texligatures=yes,texquotes=yes \definefontfeature [oldstyle] - [liga=yes,kern=yes,tlig=yes,trep=yes,onum=yes] % texligatures=yes,texquotes=yes + [%mode=node,% + liga=yes,kern=yes,tlig=yes,trep=yes,onum=yes] % texligatures=yes,texquotes=yes -\definefontfeature % no calt +\definefontfeature [arabic] - [mode=node,language=dflt,script=arab, + [mode=node,language=dflt,script=arab,ccmp=yes, init=yes,medi=yes,fina=yes,isol=yes, - liga=yes,dlig=yes,rlig=yes,clig=yes, + liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes, mark=yes,mkmk=yes,kern=yes,curs=yes] +\definefontfeature + [none] + [mode=none,features=off] + +\definefontfeature + [virtualmath] + [mode=base,liga=yes,kern=yes,tlig=yes,trep=yes] + +% for the moment here, this will change but we need it for mk.tex + +\definefontfeature[math-text] [virtualmath][ssty=no] +\definefontfeature[math-script] [virtualmath][ssty=1,mathsize=yes] +\definefontfeature[math-scriptscript][virtualmath][ssty=2,mathsize=yes] + +\definefontfeature [math-nostack-text] [math-text] [nostackmath=yes] +\definefontfeature [math-nostack-script] [math-script] [nostackmath=yes] +\definefontfeature [math-nostack-scriptscript][math-scriptscript][nostackmath=yes] + +% \definefontfeature[mathtext] [math-text] +% \definefontfeature[mathscript] [math-script] +% \definefontfeature[mathscriptscript] [math-scriptscript] + %D Also new: % handy for manuals @@ -3052,32 +2601,9 @@ \definecolor[font:init][r=.75] \definecolor[font:medi][g=.75] \definecolor[font:fina][b=.75] -\definecolor[font:isol][y=.75] -\definecolor[font:mark][m=.75] -\definecolor[font:rest][c=.75] - -%D goodies: -%D -%D \starttyping -%D \showinstalledfonts[officinasans.*][all] -%D \showinstalledfonts[officinaserif.*][all] -%D \showinstalledfonts[officina.*itc.*][all] -%D -%D \showinstalledfonts[officina.*itc.*][all,new] -%D \stoptyping - -\def\showinstalledfonts - {\dodoubleempty\doshowinstalledfonts} - -\def\doshowinstalledfonts[#1][#2]% - {\bgroup - \def\pattern{#1}% - \def\all{false}% - \def\reload{false}% - \doifnothing\pattern{\def\pattern{.*}}% - \processallactionsinset[#2][\v!new=>\def\reload{true},\v!all=>\def\all{true}]% - \ctxlua{fonts.names.table("#1",\reload,\all)}% - \egroup} +\definecolor[font:isol][r=.75,g=.75] % [y=.75] +\definecolor[font:mark][r=.75,b=.75] % [m=.75] +\definecolor[font:rest][g=.75,b=.75] % [c=.75] %D Experimental! @@ -3085,7 +2611,7 @@ {\dodoubleargument\doinstallfontfeature} \def\doinstallfontfeature[#1][#2]% - {\ctxlua{fonts.install_feature("#1","#2")}} + {\writestatus\m!fonts{installing font features was experimental}} % \ctxlua{fonts.install_feature("#1","#2")}} %D Not yet in \MKII. @@ -3099,13 +2625,35 @@ \let\currentfeature\empty +% ! ! ! very experimental, some test code for idris advanced features ! ! ! +% +% \startbuffer +% \definefontfeature[smallcaps][smallcaps][script=latn] +% \definefontfeature[oldstyle] [oldstyle] [script=latn] +% +% \definedfont[name:cambria at 15pt] +% +% Hello there {\setff{smallcaps}capped 123 \setff{oldstyle}123!} \blank +% Hello there {\addff{smallcaps}capped 123 \addff{oldstyle}123!} \blank +% Hello there {\addff{smallcaps}capped \subff{smallcaps}normal} \blank +% \stopbuffer +% +% \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} +\def\resetfontfeature#1{\let\currentfeature\empty\attribute\zerocount\zerocount} % initial value -\appendtoks - \setfontfeature\currentfeature -\to \everylanguage +\def\addfontfeaturetoset #1{\ctxlua{fonts.withset("#1", 1)}} +\def\subtractfontfeaturefromset #1{\ctxlua{fonts.withset("#1",-1)}} +\def\addfontfeaturetofont #1{\ctxlua{fonts.withfnt("#1", 2)}} +\def\subtractfontfeaturefromfont#1{\ctxlua{fonts.withfnt("#1",-2)}} + +\let\setff\setfontfeature +\let\addfs\addfontfeaturetoset +\let\subfs\subtractfontfeaturefromset +\let\addff\addfontfeaturetofont +\let\subff\subtractfontfeaturefromfont %D The next auxilliary macro is an alternative to \type %D {\fontname}. @@ -3140,75 +2688,23 @@ \the\everybodyfont} % needed ? %D \macros -%D {os,frak, goth, cal} -%D -%D Old style numerals can be typeset with \type{\os} and look -%D like {\os 1234567890} instead of the more common looking -%D 1234567890. +%D {os} %D -%D On behalf of {\frac Tobias Burnus}, we define some more of -%D these. Later we will link these names to real file names. - -% older -% -% \definefont [os] [OldStyle sa *] -% \definefont [frak] [Fraktur sa *] -% \definefont [goth] [Gothic sa *] -% \definefont [cal] [Calligraphic sa *] -% \definefont [bbd] [Blackboard sa *] -% -% newer +%D In good old \TEX, the old style numerals were often taken +%D from the math fonts. No longer. -\def\os {\mathortext{\fam\purefamily {oldstyle}}{\symbolicfont {OldStyle}}} -\def\frak{\mathortext{\fam\purefamily {fraktur}}{\symbolicfont {Fraktur}}} -\def\goth{\mathortext{\fam\purefamily {gothic}}{\symbolicfont {Gothic}}} -\def\cal {\mathortext{\fam\purefamily{calligraphic}}{\symbolicfont{Calligraphic}}} -\def\bbd {\mathortext{\fam\purefamily {blackboard}}{\symbolicfont {Blackboard}}} +\definefontfeature + [just-os] + [mode=node,onum=yes] -\definefontsynonym [OldStyle] [Serif] -\definefontsynonym [Fraktur] [Serif] -\definefontsynonym [Gothic] [Serif] -\definefontsynonym [Calligraphic] [Serif] -\definefontsynonym [Blackboard] [Serif] +% \def\sc{\setfontfeature{smallcaps}} +\def\os{\setfontfeature{just-os}} -%D \macros -%D {fraktur, gothic, calligraphic, blackboard} -%D -%D These macros assume that we use text fonts, and not math -%D families. +%D Code for swithcing to fraktur and script has also been +%D changed. We now have an alphabet switcher. \ifx\mathtext\undefined \let\mathtext\hbox \fi -\def\fraktur #1{\mathortext\domathtext\donothing{\frak#1}} -\def\gothic #1{\mathortext\domathtext\donothing{\goth#1}} -\def\calligraphic#1{\mathortext\domathtext\donothing{\cal #1}} -\def\blackboard #1{\mathortext\domathtext\donothing{\bbd#1}} - -%D Torture test: -%D -%D \starttyping -%D \usetypescript[modern] [texnansi] -%D \usetypescript[lucida] [texnansi] -%D \usetypescript[palatino][texnansi] -%D \usetypescript[times] [texnansi] -%D \usetypescript[fourier] [ec] -%D -%D \startbuffer -%D \section{\blackboard{T\high{\blackboard{T}}} \blackboard{E}\high{\blackboard{E}} \blackboard{X}\high{\blackboard{X}}} -%D -%D {\fontclass: 123 \os123 \cal TEX $\os 123$} -%D -%D $\blackboard{T}^{\blackboard{T}} \blackboard{E}^{\blackboard{E}} \blackboard{X}^{\blackboard{X}}$ -%D \blackboard{T}\high{\blackboard{T}} \blackboard{E}\high{\blackboard{E}} \blackboard{X}\high{\blackboard{X}} -%D \stopbuffer -%D -%D {\setupbodyfont[lucida] \getbuffer} -%D {\setupbodyfont[modern] \getbuffer} -%D {\setupbodyfont[palatino] \getbuffer} -%D {\setupbodyfont[times] \getbuffer} -%D {\setupbodyfont[fourier] \getbuffer} -%D \stoptyping - %D \macros %D {definebodyfontswitch} %D @@ -3264,7 +2760,7 @@ %D in the main bodyfont and style of the document. Returning to %D the global state can be done with the next macro: -\let\mainfontclass\empty +\let\globalfontstyle\c!rm \def\fullrestoreglobalbodyfont {\let\fontsize\defaultfontsize @@ -3420,7 +2916,7 @@ %D \stoptyping %D %D We deliberately pass an argument. This enables us to -%D assign converters that handle one agrument, like +%D assign converters that handle one argument, like %D \type{\cap}. %D %D By default the first specification is used to set the style, @@ -3429,43 +2925,11 @@ %D \type{\noconvertfont}. In nested calls, we can restore the %D conversion by saying \type{\redoconvertfont}. -% \def\@@dodoconvertfont#1{\csname\@letter@ #1\endcsname} -% \def\@@donoconvertfont#1{\csname\@noletter@#1\endcsname} -% -% \unexpanded\def\dodoconvertfont#1% #2% we need the protection -% {\doifdefinedelse{\@letter@#1} % in testing -% {\doifelsenothing{#1}\gobbleoneargument\@@dodoconvertfont} -% {\doifdefinedelse{#1}\getvalue \firstofoneargument}% -% {#1}} % {#2}} -% -% \let\doconvertfont\dodoconvertfont -% -% \def\noconvertfont#1% #2% -% {\doifdefinedelse{\@noletter@#1} -% {\doifelsenothing{#1}\gobbleoneargument\@@donoconvertfont}\gobbleoneargument -% {#1}} % {#2}} - -% \def\@@dodoconvertfont{\csname\@letter@ \p!defined\endcsname} -% \def\@@donoconvertfont{\csname\@noletter@\p!defined\endcsname} -% \def\@@redoconvertfont{\csname \p!defined\endcsname} -% -% \unexpanded\def\dodoconvertfont#1% #2% we need the protection -% {\edef\p!defined{#1}% -% \ifcsname\@letter@\detokenize\@EA{\p!defined}\endcsname -% \ifx\p!defined\empty\else\@EAEAEA\@@dodoconvertfont\fi -% \else -% \ifcsname\detokenize\@EA{\p!defined}\endcsname\@EAEAEA\@@redoconvertfont\else\@EAEAEA\p!defined\fi -% \fi} % {#2}} -% -% \unexpanded\def\noconvertfont#1% #2% -% {\edef\p!defined{#1}% -% \ifcsname\@noletter@\detokenize\@EA{\p!defined}\endcsname -% \ifx\p!defined\empty\else\@EAEAEA\@@donoconvertfont\fi -% \fi} % {#2}} +% subtle ... \expandafter is needed else problems with lookahead caps -\def\@@dodoconvertfont{\csname\@letter@ \p!defined\endcsname\gobbleoneargument} +\def\@@dodoconvertfont{\csname\@letter@ \p!defined\expandafter\endcsname\gobbleoneargument} \def\@@donoconvertfont{\csname\@noletter@\p!defined\endcsname} -\def\@@redoconvertfont{\csname \p!defined\endcsname\gobbleoneargument} +\def\@@redoconvertfont{\csname \p!defined\expandafter\endcsname\gobbleoneargument} % beware: p!defined can contain crap like \edef crap {...} and such % so we need to pass #1 as well @@ -3501,11 +2965,8 @@ %D Extras: -\unexpanded\def\dontconvertfont - {\let\doconvertfont\noconvertfont} - -\unexpanded\def\redoconvertfont - {\let\doconvertfont\dodoconvertfont} +\unexpanded\def\dontconvertfont{\let\doconvertfont\noconvertfont} +\unexpanded\def\redoconvertfont{\let\doconvertfont\dodoconvertfont} %D These commands are not grouped! Grouping is most probably %D done by the calling macro's and would lead to unnecessary @@ -3534,13 +2995,7 @@ %D or even better: -% \def\doemphasistypeface#1#2% -% {\doifelsevalue{\??ft\fontclass\normalizedbodyfontsize\c!em}\v!slanted#1% -% {\doifelsevalue{\??ft\fontclass\normalizedbodyfontsize\c!em}\v!italic #2% -% {\doifelsevalue{\??ft \normalizedbodyfontsize\c!em}\v!slanted#1% -% {\doifvalue {\??ft \normalizedbodyfontsize\c!em}\v!italic #2}}}} - -\def\doemphasistypeface#1#2% +\def\doemphasistypeface#1#2% slow {\doifelsevalue{\??ft\fontclass\normalizedbodyfontsize\c!em}\v!slanted {#1}% {\doifelsevalue{\??ft\fontclass\normalizedbodyfontsize\c!em}\v!italic @@ -3553,6 +3008,25 @@ {\getvalue{\??ft\normalizedbodyfontsize\c!em}}}} {\getvalue{\??ft\fontclass\normalizedbodyfontsize\c!em}}}}} +% \def\doemphasistypeface#1#2% +% {\edef\emphasizedtypeface{\csname\??ft\fontclass\normalizedbodyfontsize\c!em\endcsname}% +% \ifx\emphasizedtypeface\v!slanted +% #1% +% \else\ifx\emphasizedtypeface\v!italic +% #2% +% \else\ifx\emphasizedtypeface\v!empty +% \edef\emphasizedtypeface{\csname\??ft\normalizedbodyfontsize\c!em\endcsname}% +% \ifx\emphasizedtypeface\v!slanted +% #1% +% \else\ifx\emphasizedtypeface\v!italic +% #2% +% \else +% \getvalue\emphasizedtypeface +% \fi\fi +% \else +% \getvalue\emphasizedtypeface +% \fi\fi\fi} + \def\emphasistypeface{\doemphasistypeface\sl\it} \def\emphasisboldface{\doemphasistypeface\bs\bi} @@ -3571,15 +3045,15 @@ \setfalse\emneeded \fi \setemphasisboldface % new - \ifx\fontalternative\c!it % \ifnum\fam=\itfam + \ifx\fontalternative\c!it \def\emphasistypeface{\it}\tf - \else\ifx\fontalternative\c!sl % \ifnum\fam=\slfam + \else\ifx\fontalternative\c!sl \def\emphasistypeface{\sl}\tf - \else\ifx\fontalternative\c!bf % \ifnum\fam=\bffam + \else\ifx\fontalternative\c!bf \emphasisboldface - \else\ifx\fontalternative\c!bs % \ifnum\fam=\bsfam + \else\ifx\fontalternative\c!bs \def\emphasisboldface{\bs}\bf - \else\ifx\fontalternative\c!bi % \ifnum\fam=\bifam + \else\ifx\fontalternative\c!bi \def\emphasisboldface{\bi}\bf \else \emphasistypeface @@ -3605,9 +3079,9 @@ \unexpanded\def\bf {%\relax \let\bf\relax % new - \ifx\fontalternative\c!it % \ifnum\fam=\itfam + \ifx\fontalternative\c!it \bi - \else\ifx\fontalternative\c!sl % \ifnum\fam=\slfam + \else\ifx\fontalternative\c!sl \bs \else \normalbf @@ -3619,24 +3093,35 @@ %D look for something that looks like a dash, in which case we %D don't correct. -\let\italiccorrection=\/ +\let\italiccorrection=\/ % tex primitive \def\emphasiscorrection {\ifhmode \expandafter\emphasislook \fi} +% \def\emphasislook +% {\begingroup +% \beginrobusttest +% \futurelet\next\emphasistest} + +% \def\emphasistest +% {\normalifcat\noexpand\next,% +% \endrobusttest\expandafter\doemphasiscorrection +% \normalelse +% \endrobusttest\expandafter\dododoemphasiscorrection +% \normalfi} + \def\emphasislook {\begingroup - \beginrobusttest \futurelet\next\emphasistest} \def\emphasistest - {\normalifcat\noexpand\next,% - \endrobusttest\expandafter\doemphasiscorrection - \normalelse - \endrobusttest\expandafter\dododoemphasiscorrection - \normalfi} + {\ifcat\noexpand\next,% still ok? + \expandafter\doemphasiscorrection + \else + \expandafter\dododoemphasiscorrection + \fi} \def\doemphasiscorrection {\futurelet\next\dodoemphasiscorrection} @@ -3792,11 +3277,6 @@ %D \stopbuffer %D %D \typebuffer -%D -%D Below the table the name, encoding, mapping and handling are -%D shown. Special characters like the \type {\skewchar} and -%D \type {\hyphenchar} als marked. -%D %D \getbuffer % to be internationalized @@ -3954,49 +3434,6 @@ %D The shape as well as the size is adapted to the current %D environment. -%D Fonts can only be used when loaded. In \CONTEXT\ we -%D postpone the loading of fonts, even when we load \PLAIN. -%D This means that we have to redefine one of the \PLAIN\ -%D macros. Let's tell that to the user first: - -\writestatus{loading}{Postponed Plain TeX Font Definitions} - -%D \macros -%D {bordermatrix} -%D -%D In \PLAIN\ \TEX\ the width of a parenthesis is stored in -%D the \DIMENSION\ \type{\p@renwd}. This value is derived from -%D the width of \type{\tenrm B}, so let's take care of it now: - -\let\normalbordermatrix=\bordermatrix - -\def\bordermatrix% - {\bgroup - \setbox0\hbox{\getvalue{\textface\c!mm\c!ex}B}% - \global\p@renwd\wd0\relax - \egroup - \normalbordermatrix} - -%D Because we want to be as \PLAIN\ compatible as possible, we -%D make most of \PLAIN's font mechanisme available to the -%D \CONTEXT\ user. - -\def\setplainfonts#1#2% - {\setvalue {ten#1}{\getvalue{\!!tenpoint #2}}% - \setvalue{seven#1}{\getvalue{\!!sevenpoint#2}}% - \setvalue {five#1}{\getvalue{\!!fivepoint #2}}} - -\setplainfonts {\c!rm} {\c!rm\c!tf} -\setplainfonts {\c!bf} {\c!rm\c!bf} -\setplainfonts {\c!sl} {\c!rm\c!sl} -\setplainfonts {\c!it} {\c!rm\c!it} -\setplainfonts {\c!tt} {\c!rm\c!tt} -\setplainfonts {\c!sy} {\c!mm\c!sy} -\setplainfonts {\c!ex} {\c!mm\c!ex} -\setplainfonts {\c!i} {\c!mm\c!mi} - -\let\setplainfonts=\undefined - %D \macros %D {ss, SS, sz} %D @@ -4008,81 +3445,11 @@ \ifx\undefined\SS \let\SS=\ss \fi \ifx\undefined\sz \let\sz=\ss \fi -%D \macros -%D {xi} -%D -%D We are going to redefine \type{\xi}, but fortunately this -%D is a math mode character, so we can just say: - -\let\normalxi=\xi - -%D \macros -%D {smashaccent} -%D -%D When we let \TEX\ put an accent on top of a character, such -%D composed characters can get more height that height of a -%D standard \type{\strut}. The next macro takes care of such -%D unwanted compositions. -%D -%D We need to reach over the number that specifies the accent, -%D and in doing so we use \type{\scratchcounter} as a placeholder -%D because it accepts 8 bit numbers in octal, decimal or -%D hexadecimal format. Next we set the height of the accented -%D character to the natural height of the character. - -\unexpanded\def\smashaccent#1% - {\dontleavehmode - \bgroup - \setbox\scratchbox\hbox{#1}% - \ifdim\ht\scratchbox>\strutheight\relax\ht\scratchbox\strutheight\fi - \ifdim\dp\scratchbox>\strutdepth \relax\dp\scratchbox\strutdepth \fi - \box\scratchbox - \egroup} - -%D For instance we can say: -%D -%D \starttyping -%D \smashaccent{\"Uberhaupt} -%D \stoptyping -%D -%D But normally one will use it as a prefix in definitions. -%D The difference is in the height: -%D -%D \leavevmode\ruledhbox -%D {\ruledhbox{\smashaccent{\"U}berhaupt}\quad -%D oder\quad -%D \ruledhbox{\"Uberhaupt}} - -%D \macros -%D {moveaccent} -%D -%D Exact positioning of accents can be realized by saying: -%D -%D \starttyping -%D \moveaccent{-.1ex}{\"u}berhaupt -%D \stoptyping -%D -%D Again, this one will mostly used as a prefix in definitions. -%D Here the difference is in the position: -%D -%D \leavevmode\ruledhbox -%D {\ruledhbox{\moveaccent{-.1ex}{\"}Uberhaupt}\quad -%D oder\quad -%D \ruledhbox{\"Uberhaupt}} - -\unexpanded\def\moveaccent#1#2% - {\smashaccent - {\dimen0\exheight - \dimen2\dimen0 - \advance\dimen2 -#1% - \exheight\dimen2 - #2\relax - \exheight\dimen0}} - -%D Personally I think that using \TEX\ is complicated by the -%D way fonts are handled. Apart from the many encodings, we -%D also deal with different naming schemes. Confronted with -%D this problem, I decided to change the definitions into: +%D Personally I think that using \TEX\ macro packages is +%D complicated by the way fonts are handled. Apart from the +%D many encodings, we also deal with different naming schemes. +%D Confronted with this problem, I decided to change the +%D definitions into: %D %D \starttyping %D \definebodyfont [12pt] [rm] [tf=Times-Roman at 12pt] @@ -4244,22 +3611,31 @@ \definebodyfontswitch [fivepoint] [\!!fivepoint] \definebodyfontswitch [fourpoint] [\!!fourpoint] -\definebodyfontswitch [xii] [\!!twelvepoint] -\definebodyfontswitch [xi] [\!!elevenpoint] -\definebodyfontswitch [x] [\!!tenpoint] -\definebodyfontswitch [ix] [\!!ninepoint] -\definebodyfontswitch [viii] [\!!eightpoint] -\definebodyfontswitch [vii] [\!!sevenpoint] -\definebodyfontswitch [vi] [\!!sixpoint] +% \definebodyfontswitch [xii] [\!!twelvepoint] +% \definebodyfontswitch [xi] [\!!elevenpoint] +% \definebodyfontswitch [x] [\!!tenpoint] +% \definebodyfontswitch [ix] [\!!ninepoint] +% \definebodyfontswitch [viii] [\!!eightpoint] +% \definebodyfontswitch [vii] [\!!sevenpoint] +% \definebodyfontswitch [vi] [\!!sixpoint] %D So far. +\definefontstyle [\c!mm] [\c!mm] \definefontstyle [\c!rm,\v!roman,\v!serif,\v!regular] [\c!rm] \definefontstyle [\c!ss,\v!sansserif,\v!sans,\v!support] [\c!ss] \definefontstyle [\c!tt,\v!teletype,\v!type,\v!mono] [\c!tt] \definefontstyle [\c!hw,\v!handwritten] [\c!hw] \definefontstyle [\c!cg,\v!calligraphic] [\c!cg] +\definefontalternative[\c!tf] +\definefontalternative[\c!bf] +\definefontalternative[\c!it] +\definefontalternative[\c!sl] +\definefontalternative[\c!bs] +\definefontalternative[\c!bi] +\definefontalternative[\c!sc] + \definefontsize[\c!a] \definefontsize[\c!b] \definefontsize[\c!c] \definefontsize[\c!d] @@ -4295,41 +3671,11 @@ \definealternativestyle [\v!WORD] [\WORD] [\WORD] %D \macros -%D {...math} -%D -%D New or old? - -% tzt proper \define... -% -% watch out: \synchronizesymb resets the family so we need a second -% \mf (or maybe \mr): messy and to be sorted out - -\def\tfmath{\tf\mf\synchronizesymb\mf} -\def\bfmath{\bf\mf\synchronizesymb\mf} -\def\slmath{\sl\mf\synchronizesymb\mf} -\def\itmath{\it\mf\synchronizesymb\mf} -\def\bsmath{\bs\mf\synchronizesymb\mf} -\def\bimath{\bi\mf\synchronizesymb\mf} -\def\scmath{\sc\mf\synchronizesymb\mf} -\def\nnmath{\nn\mf\synchronizesymb\mf} - -\def\textmath {\synchronizesymb} - -%D \macros %D {fontstylesuffix} %D %D The next macro is used to map non latin fontnames on %D fonts. See \type {font-uni} for an example of its use. -%\def\fontstylesuffix% -% {\ifnum\fam=\tffam \s!Regular \else -% \ifnum\fam=\bffam \s!Bold \else -% \ifnum\fam=\slfam \s!Slanted \else -% \ifnum\fam=\itfam \s!Italic \else -% \ifnum\fam=\bsfam \s!BoldSlanted \else -% \ifnum\fam=\bifam \s!BoldItalic \else -% \s!Regular \fi\fi\fi\fi\fi\fi}% - \def\fontstylesuffix% why the \s!Regular ? see \getglyph {\ifx\fontalternative\c!tf \s!Regular \else \ifx\fontalternative\c!bf \s!Bold \else @@ -4340,10 +3686,6 @@ \ifx\fontalternative\c!sc \s!Caps \else \s!Regular \fi\fi\fi\fi\fi\fi\fi}% -%D We still have to take care of \type{\xi}, so: - -\def\xi{\ifmmode\normalxi\else\elevenpoint\fi} - %D \macros %D {definefontvariant,fontvariant,variant} %D @@ -4383,7 +3725,7 @@ \unexpanded\def\variant[#1]% slow {\dosetscaledfont - \expanded{\definedfont[\fontstringA\fontstylesuffix\fontvariant\fontstringA{#1} at \the\dimexpr\scaledfontsize\relax]}% + \normalexpanded{\noexpand\definedfont[\fontstringA\fontstylesuffix\fontvariant\fontstringA{#1} at \the\dimexpr\scaledfontsize\relax]}% \ignoreimplicitspaces} \ifx\Var\undefined \let\Var\variant \fi @@ -4393,262 +3735,113 @@ %D bodyfont. Sans serif and teletype are also available and %D can be called for by \type{\ss} and \type{\tt}. -\setupbodyfont [unk, rm] +% \setupbodyfont [unk, rm] +% \setupbodyfont [rm] %D Also needed is: \definefont[tinyfont][Mono at 1ex] -%D \macros -%D {doiffontpresentelse} -%D -%D \starttyping -%D \doiffontpresentelse{texnansi-lmr10}{YES}{NO} -%D \doiffontpresentelse{adam-lindsay-modern-serif}{YES}{NO} -%D \stoptyping +% \tracinglostchars=1 -\def\doiffontpresentelse#1{\ctxlua{commands.doifelse(fonts.names.exists("#1"))}} +% this needs some interfacing +% +% \setupfonts[check=...] -%D OPTIMIZATIONS +\def\checkcharactersinfont {\ctxlua{fonts.checkers.enabled=true}} +\def\removemissingcharacters{\ctxlua{fonts.checkers.enabled=true fonts.checkers.delete=true}} -\def\definefontsynonym[#1]#2[#3]% - {\edef\@@fontname{#1}% - \edef\@@fontfile{#3}% - \@EA\let\csname\??ff\fontclass\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion - \doifnextcharelse[\dodefinefontsynonym\nodefinefontsynonym} +%D New commands (not yet interfaced): -\def\dodefinefontsynonym[#1]% - {\let\@@ff@@features \undefined - \let\@@ff@@fallbacks\undefined - \let\@@ff@@skewchar \undefined - \expandafter\dogetfontparameter#1,]=,} +\def\style[#1]% for inline usage, like \color + {\groupedcommand{\ifcsname#1\endcsname\csname#1\endcsname\else\definedfont[#1]\fi}{}} -\def\dogetfontparameter#1=#2,% - {\if]#1% - \dododefinefontsynonym - \else - \expandafter\def\csname @@ff@@#1\endcsname{#2}% - \expandafter\dogetfontparameter - \fi} +\def\startstyle[#1]% + {\begingroup + \ifcsname#1\endcsname\csname#1\endcsname\else\definedfont[#1]\fi} -\def\nodefinefontsynonym - {\ifx\fontclass\empty - \@EA\let\csname\??ff\@@fontname\s!features \endcsname\undefined - \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\undefined - \@EA\let\csname\??ff\@@fontfile\s!skewchar \endcsname\undefined - \else - \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\@@fontfile\s!skewchar \endcsname\undefined - \fi} +\def\stopstyle + {\endgroup} -\def\dododefinefontsynonym - {\ifx\fontclass\empty - \@EA\let\csname\??ff\@@fontname\s!features \endcsname\@@ff@@features - \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks - \@EA\let\csname\??ff\@@fontfile\s!skewchar \endcsname\@@ff@@skewchar - \else - \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\@@fontfile\s!skewchar \endcsname\@@ff@@skewchar - \fi} +%D Still experimental (might even go away). -\def\truefontname#1% - {\ifcsname\??ff\fontclass#1\endcsname - \@EA\truefontname\csname\??ff\fontclass#1\endcsname - \else\ifcsname\??ff#1\endcsname - \@EA\truefontname\csname\??ff#1\endcsname - \else - #1% - \fi\fi} +% \definestylecollection[mine] -\def\updatefontparameters - {\edef\@@fontfeatures {\@@thefeatures \somefontname}% - \edef\@@fontfallbacks{\@@thefallbacks\somefontname}% - \edef\@@fontskewchar {\@@theskewchar \somefontname}} - -\def\@@thefeatures#1% - {\ifcsname\??ff\fontclass#1\s!features\endcsname \csname\??ff\fontclass#1\s!features\endcsname\else % class + symbolic_name - \ifcsname\??ff #1\s!features\endcsname \csname\??ff #1\s!features\endcsname\else % symbolic_name - \ifcsname\??ff\fontclass#1\endcsname \@EA\@@thefeatures\csname\??ff\fontclass#1\endcsname \else % fontclass + parent_name - \ifcsname\??ff #1\endcsname \@EA\@@thefeatures\csname\??ff #1\endcsname \fi\fi\fi\fi} % parent_name - -\def\@@thefallbacks#1% - {\ifcsname\??ff\fontclass#1\s!fallbacks\endcsname \csname\??ff\fontclass#1\s!fallbacks\endcsname\else % class + symbolic_name - \ifcsname\??ff #1\s!fallbacks\endcsname \csname\??ff #1\s!fallbacks\endcsname\else % symbolic_name - \ifcsname\??ff\fontclass#1\endcsname \@EA\@@thefallbacks\csname\??ff\fontclass#1\endcsname \else % fontclass + parent_name - \ifcsname\??ff #1\endcsname \@EA\@@thefallbacks\csname\??ff #1\endcsname \fi\fi\fi\fi} % parent_name - -\def\@@theskewchar#1% skew chars will be done differently (just a hash with registered skewchars) - {\ifcsname\??ff\fontclass#1\s!skewchar\endcsname \csname\??ff\fontclass#1\s!skewchar\endcsname\else % class + symbolic_name - \ifcsname\??ff #1\s!skewchar\endcsname \csname\??ff #1\s!skewchar\endcsname\else % symbolic_name - \ifcsname\??ff\fontclass#1\endcsname \@EA\@@theskewchar\csname\??ff\fontclass#1\endcsname \else % fontclass + parent_name - \ifcsname\??ff #1\endcsname \@EA\@@theskewchar\csname\??ff #1\endcsname \fi\fi\fi\fi} % parent_name - -% more efficient ? +% \definestyleinstance[mine][default][sorry] +% \definestyleinstance[mine][tt][bs][ttbs:\rm\sl] +% \definestyleinstance[mine][tt][bf][ttbf:\rm\sl] +% \definestyleinstance[mine][bf][\sl] +% \definestyleinstance[mine][sl][\tt] -\def\definefontsynonym[#1]#2[#3]% - {\edef\@@fontname{#1}% - \edef\@@fontfile{#3}% - \ifx\fontclass\empty - \expandafter\dodefinefontsynonymnop - \else - \expandafter\dodefinefontsynonymyes - \fi} +% {\bf test \mine test \sl test \mine test \bs oeps \mine oeps {\tt test \mine \bf test}} -\def\dodefinefontsynonymyes - {\@EA\let\csname\??ff\fontclass\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion - \doifnextcharelse[\dododefinefontsynonymyes\nonodefinefontsynonymyes} -\def\dodefinefontsynonymnop - {\@EA\let\csname\??ff\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion - \doifnextcharelse[\dododefinefontsynonymnop\nonodefinefontsynonymnop} +\definesystemvariable{sx} -\def\dododefinefontsynonymyes[#1]% - {\let\@@ff@@features \undefined - \let\@@ff@@fallbacks\undefined - \let\@@ff@@skewchar \undefined - \expandafter\dogetfontparameteryes#1,]=,} -\def\dododefinefontsynonymnop[#1]% - {\let\@@ff@@features \undefined - \let\@@ff@@fallbacks\undefined - \let\@@ff@@skewchar \undefined - \expandafter\dogetfontparameternop#1,]=,} +\def\definestylecollection + {\dosingleargument\dodefinestylecollection} -\def\dogetfontparameteryes#1=#2,% - {\if]#1% - \dodododefinefontsynonymyes - \else - \expandafter\def\csname @@ff@@#1\endcsname{#2}% - \expandafter\dogetfontparameteryes +\def\dodefinestylecollection[#1]% + {\iffirstargument + \unexpanded\setvalue{#1}{\styleinstance[#1]}% + \def\docommand##1% + {\def\dodocommand####1{\letbeundefined{\??sx##1:####1:\commalistelement}}% + \processcommacommand[\fontalternativelist,\s!default]\dodocommand}% + \processcommacommand[\fontstylelist,\s!default]\docommand \fi} -\def\dogetfontparameternop#1=#2,% - {\if]#1% - \dodododefinefontsynonymnop - \else - \expandafter\def\csname @@ff@@#1\endcsname{#2}% - \expandafter\dogetfontparameternop - \fi} - -\def\nonodefinefontsynonymyes - {\global\@EA\let\csname\??ff\@@fontname\s!features \endcsname\undefined - \global\@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\undefined - \global\@EA\let\csname\??ff\@@fontfile\s!skewchar \endcsname\undefined} -\def\nonodefinefontsynonymnop - {\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\undefined - \@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\undefined - \@EA\let\csname\??ff\fontclass\@@fontfile\s!skewchar \endcsname\undefined} - -\def\dodododefinefontsynonymyes - {\global\@EA\let\csname\??ff\@@fontname\s!features \endcsname\@@ff@@features - \global\@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks - \global\@EA\let\csname\??ff\@@fontfile\s!skewchar \endcsname\@@ff@@skewchar} -\def\dodododefinefontsynonymnop - {\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\@@ff@@features - \@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks - \@EA\let\csname\??ff\fontclass\@@fontfile\s!skewchar \endcsname\@@ff@@skewchar} - -% resolve - -\def\@@thefeaturesyes#1% - {\ifcsname\??ff\fontclass#1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??ff\fontclass#1\s!features \endcsname\else - \ifcsname\??ff #1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??ff #1\s!features \endcsname\else - \ifcsname\??ff\fontclass #1\endcsname\@EA \@@thefeaturesyes \csname\??ff\fontclass #1\endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@thefeaturesyes \csname\??ff #1\endcsname\else - \let \@@fontfeatures \empty \fi\fi\fi\fi} -\def\@@thefallbacksyes#1% - {\ifcsname\??ff\fontclass#1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??ff\fontclass#1\s!fallbacks\endcsname\else - \ifcsname\??ff #1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??ff #1\s!fallbacks\endcsname\else - \ifcsname\??ff\fontclass #1\endcsname\@EA \@@thefallbacksyes\csname\??ff\fontclass #1\endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@thefallbacksyes\csname\??ff #1\endcsname\else - \let \@@fontfallbacks \empty \fi\fi\fi\fi} -\def\@@theskewcharyes#1% - {\ifcsname\??ff\fontclass#1\s!skewchar \endcsname\@EA\let\@EA\@@fontskewchar \csname\??ff\fontclass#1\s!skewchar \endcsname\else - \ifcsname\??ff #1\s!skewchar \endcsname\@EA\let\@EA\@@fontskewchar \csname\??ff #1\s!skewchar \endcsname\else - \ifcsname\??ff\fontclass #1\endcsname\@EA \@@theskewcharyes \csname\??ff\fontclass #1\endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@theskewcharyes \csname\??ff #1\endcsname\else - \let \@@fontskewchar \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 - \let \@@fontfeatures \empty \fi\fi} -\def\@@thefallbacksnop#1% - {\ifcsname\??ff#1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??ff#1\s!fallbacks\endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@thefallbacksnop\csname\??ff #1\endcsname\else - \let \@@fontfallbacks \empty \fi\fi} -\def\@@theskewcharnop#1% - {\ifcsname\??ff#1\s!skewchar \endcsname\@EA\let\@EA\@@fontskewchar \csname\??ff#1\s!skewchar \endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@theskewcharnop \csname\??ff #1\endcsname\else - \let \@@fontskewchar \empty \fi\fi} -\def\updatefontparametersyes - {\@@thefeaturesyes \somefontname - \@@thefallbacksyes\somefontname - \@@theskewcharyes \somefontname} -\def\updatefontparametersnop - {\@@thefeaturesnop \somefontname - \@@thefallbacksnop\somefontname - \@@theskewcharnop \somefontname} +\def\definestyleinstance + {\doquadrupleargument\dodefinestyleinstance} -\def\updatefontparameters - {\ifx\fontclass\empty\updatefontparametersnop\else\updatefontparametersyes\fi} +\def\dodefinestyleinstance[#1][#2][#3][#4]% [name] [rm|ss|tt|..] [sl|bf|...] [whatever] + {\iffirstargument + \doifundefined{#1}{\definestylecollection[#1]}% + \fi + \iffourthargument + \setvalue{\??sx#1:#2:#3}{#4}% + \else\ifthirdargument + \setvalue{\??sx#1::#2}{#3}% + \else\ifsecondargument + \letvalue{\??sx#1::#2}\empty + \fi\fi\fi} + +\unexpanded\def\styleinstance[#1]% will be faster + {%\begingroup\normalexpanded{\noexpand\infofont[#1:\fontstyle:\fontalternative]}\endgroup + \executeifdefined{\??sx#1:\fontstyle:\fontalternative}% + {\executeifdefined{\??sx#1:\fontstyle:\s!default}% + {\executeifdefined{\??sx#1::\fontalternative} + {\getvalue {\??sx#1::\s!default}}}}} + +% \unexpanded\def\styleinstance[#1]% +% {\csname\??sx#1% +% \ifcsname:\fontstyle:\fontalternative\endcsname +% :\fontstyle:\fontalternative +% \else\ifcsname:\fontstyle:\s!default\endcsname +% :\fontstyle:\s!default +% \else\ifcsname::\fontalternative\endcsname +% ::\fontalternative +% \else\ifcsname::\s!default\endcsname +% ::\s!default +% \else +% % nothing, \relax +% \fi\fi\fi\fi +% \endcsname} \protect \endinput -% bewaren -% -% \def\truefontdata#1#2% -% {\ifcsname\??ff\fontclass#1#2\endcsname -% % raw(Regular) raw(key) -% \csname\??ff\fontclass#1#2\endcsname -% \else\ifcsname\??ff\fontclass#1\endcsname -% % exp(palatino Regular) raw(key) -% \expandafter\truefontdata\csname\??ff\fontclass#1\endcsname#2% -% \else\ifcsname\??ff#1\endcsname -% % exp(Regular) raw(key) -% \expandafter\truefontdata\csname\??ff#1\endcsname#2% -% \else\ifcsname\??ff#2\endcsname -% % raw(key) -% \csname\??ff#2\endcsname -% \fi\fi\fi\fi} - -% test file -% -% \starttypescript[serif][mine-1] -% \definefontsynonym[Serif] [TeXGyrePagella-Regular] -% \definefontsynonym[TeXGyrePagella-Regular][file:texgyrepagella-regular] -% \stoptypescript -% -% \starttypescript[serif][mine-2] -% \definefontsynonym[Serif] [TeXGyrePagella-Regular] [features=default] -% \definefontsynonym[TeXGyrePagella-Regular][file:texgyrepagella-regular] [features=oldstyle] -% \stoptypescript -% -% \starttypescript[serif][mine-3] -% \definefontsynonym[Serif] [TeXGyrePagella-Regular] [features=oldstyle] -% \definefontsynonym[TeXGyrePagella-Regular][file:texgyrepagella-regular] [features=default] -% \stoptypescript -% -% \starttypescript[serif][mine-4] -% \definefontsynonym[Serif] [TeXGyrePagella-Regular] [features=default] -% \definefontsynonym[TeXGyrePagella-Regular][file:texgyrepagella-regular] [features=default] -% \stoptypescript -% -% \starttypescript[serif][mine-5] -% \definefontsynonym[Serif] [TeXGyrePagella-Regular] [features=oldstyle] -% \definefontsynonym[TeXGyrePagella-Regular][file:texgyrepagella-regular] [features=oldstyle] -% \stoptypescript -% -% \starttext -% \dorecurse {5} { -% \expanded{\definetypeface[mine-\recurselevel][rm][serif][mine-\recurselevel][default]} -% \expanded{\setupbodyfont [mine-\recurselevel] mine-\recurselevel: text 1234567890 done} -% \par -% } -% \blank -% \dorecurse {5} { -% \expanded{\definetypeface[more-\recurselevel][rm][serif][mine-\recurselevel][default][features=oldstyle]} -% \expanded{\setupbodyfont [more-\recurselevel] mine-\recurselevel: text 1234567890 done} -% \par -% } -% \stoptext +% \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")}} + +% \doifelsecurrentfonthasfeature{smcp}{YES}{NO} +% \doifelsecurrentfonthasfeature{crap}{YES}{NO} +% \doifelsecurrentfonthasfeature{kern}{YES}{NO} |