summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/csplain/base/csfontsm.tex
blob: c9c822ffd1a41a4e5b17bedffd8cae4e51bf18a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

% csfontsm.tex, October 2012,    Petr Olsak (Ol\v s\'ak)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This file is a part of csplain used during format generation.
%
% Usage: \def\sizespec{at14pt}\resizefont\tenrm
% after this, the \tenrm font selector switches to csr10 at14pt
%
% The \resizefont macro takes the font selector declared by \font, uses the
% same font but re-sets this selector to (probably) new font size declared
% in the \sizespec macro. You can \def\sizespec{at<dimen>} or
% \def\sizespec{magstep<number>}. The \resizefont's setting is done
% locally, it means that you can do (for instance):
%
% {\def\sizespec{scaled\magstep3}\resizefont\tenbf \tenbf Title text}
%
% The \resizeall macro resizes the \tentt, \tenrm, \tenit, \tenbf, \tenbi
% font selectors by currently defined \sizespec.
% The \regfont adds a new `registered' font-selector to the \resizeall macro
% The font-loading macros can register their fonts by \regfont.

% You can use: \letfont \titlefont = \tenbf at15pt

\def\letfont#1#2{\ifx#2=\expandafter\letfont\expandafter#1\else
  \expandafter\font\expandafter#1\expandafter
     \rfontskipat\fontname#2 \relax\space \fi}

                    % XeTeX expands \fontname to "name with spaces":
\def\rfontskipat#1{\ifx#1"\expandafter\rfskipatX
                   \else\expandafter\rfskipatN\expandafter#1\fi}
\def\rfskipatX #1" #2\relax{"\whichtfm{#1}"} 
\def\rfskipatN #1 #2\relax{\whichtfm{#1}}

\ifx\whichtfm\undefined
   \def\whichtfm#1{#1}   % User can redefine it in order to select proper
\fi                      % dessign size of the font, see ams-math.tex for
                         % example.
\def\resizefont#1{\letfont#1#1\sizespec}

\ifx\resizeall\undefined \else \endinput \fi

\ifx\tenbi\undefined
   \font\tenbi=csbxti10  % it may be usable to have 
                         % the quartet \rm \it \bf \bi preloaded
   \def\bi{\tenbi}       % math \fam\bifam is not preloaded now
\fi

\def\regfont#1{\expandafter\def\expandafter\resizeall\expandafter{%
  \resizeall \resizefont#1}}

\def\regfontdefault{\def\resizeall{}%
   \regfont\tenrm \regfont\tenit \regfont\tenbf \regfont\tenbi \regfont\tentt
}
\regfontdefault

\def\sizespec{}  % by default: fonts are loaded in their implicit sizes

\endinput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The notice about resizing the current font.

You can't use \expandafer \resizefont \the\font because \the\font expands to
the token with internal meaning: ``current font'' and with external
representation \fontselector where \fontselector is the control sequence
used by primitive \font as a parameter. The internal meaning has a
precedence and the token \the\font is inaccesible. You can make an accesible
control sequence by re-packing it by \csname...\endcsname. Thus the macro
\currsize{<size>} which sets the typesetting of the current font to the
desired <size> may be:

\def\currsize#1{%
  {\escapechar=-1\xdef\tmp{\csname\expandafter\string\the\font\endcsname}}%
  \def\sizespec{at#1}\expandafter\resizefont\tmp \tmp}

or:

\def\currsize#1{%
  \expandafter\let \expandafter\tmp \the\font
  \def\sizespec{at#1}\resizefont\tmp \tmp}


% end of csfontsm.tex