summaryrefslogtreecommitdiff
path: root/macros/optex/base/math-preload.opm
blob: 0ec9abae2f73b8c2a6199d9dab0b0a03c5c1870c (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
%% This is part of the OpTeX project, see http://petr.olsak.net/optex

\_codedecl \normalmath {Math fonts CM + AMS preloaded <2020-05-06>} % preloaded in format

  \_doc ------------------------------
  We have two math macros \`\normalmath` for the normal shape of all math
  symbols and \`\boldmath` for the bold shape of all math symbols. The second one
  can be used in bold titles, for example.
  These macros load all fonts from all given math font families.
  \_cod ------------------------------

\_def\_normalmath{%
  \_loadmathfamily 0 cmr  % CM Roman
  \_loadmathfamily 1 cmmi % CM Math Italic
  \_loadmathfamily 2 cmsy % CM Standard symbols
  \_loadmathfamily 3 cmex % CM extra symbols
  \_loadmathfamily 4 msam % AMS symbols A
  \_loadmathfamily 5 msbm % AMS symbols B
  \_loadmathfamily 6 rsfs % script
  \_loadmathfamily 7 eufm % fractur
  \_loadmathfamily 8 bfsans % sans serif bold
  \_loadmathfamily 9 bisans % sans serif bold slanted (for vectors)
%  \_setmathfamily 10 \_tentt
%  \_setmathfamily 11 \_tenit
  \_setmathdimens
}
\_def\_boldmath{%
  \_loadmathfamily 0 cmbx  % CM Roman Bold Extended
  \_loadmathfamily 1 cmmib % CM Math Italic Bold
  \_loadmathfamily 2 cmbsy % CM Standard symbols Bold
  \_loadmathfamily 3 cmexb % CM extra symbols Bold
  \_loadmathfamily 4 msam  % AMS symbols A (bold not available?)
  \_loadmathfamily 5 msbm  % AMS symbols B (bold not available?)
  \_loadmathfamily 6 rsfs  % script (bold not available?)
  \_loadmathfamily 7 eufb  % fractur bold
  \_loadmathfamily 8 bbfsans % sans serif extra bold
  \_loadmathfamily 9 bbisans % sans serif extra bold slanted (for vectors)
%  \_setmathfamily 10 \_tentt
%  \_setmathfamily 11 \_tenbi
  \_setmathdimens
}
\_count18=9   % families declared by \newfam are 12, 13, ...

\_def \normalmath {\_normalmath}  \_def\boldmath {\_boldmath}

   \_doc -----------------------------
   The classical math family selectors
   \`\mit`, \^`\cal`, \^`\bbchar`, \^`\frak` and \^`\script`
   are defined here.
   The \^`\rm`, \^`\bf`, \^`\it`, \^`\bi` and \^`\tt` does two things:
   they are variant selectors for text fonts and math family selectors for math fonts.
   The idea was adapted from plain \TeX/.\nl
   These macros are redefined when `unimat-codes.opm` is loaded,
   see the section~\ref[unimath-codes].
   \_cod -----------------------------

\_chardef\_bffam = 8
\_chardef\_bifam = 9
%\_chardef\_ttfam = 10
%\_chardef\_itfam = 11

\_protected\_def \_rm {\_tryloadrm \_tenrm \_fam0 }
\_protected\_def \_bf {\_tryloadbf \_tenbf \_fam\_bffam}
\_protected\_def \_it {\_tryloadit \_tenit \_fam1 }
\_protected\_def \_bi {\_tryloadbi \_tenbi \_fam\_bifam}
\_protected\_def \_tt {\_tryloadtt \_tentt}

\_protected\_def \_mit    {\_fam1 }
\_protected\_def \_cal    {\_fam2 }
\_protected\_def \_bbchar {\_fam5 }  % double stroked letters
\_protected\_def \_frak   {\_fam7 }  % fraktur
\_protected\_def \_script {\_fam6 }  % more extensive script than \cal

\_public \rm \bf \it \bi \tt \mit \cal \bbchar \frak \script ;

   \_doc -----------------------------
   The optical sizes of Computer Modern fonts, AMS, and other fonts
   are declared here.
   \_cod -----------------------------

%% CM math fonts, optical sizes:

\_regtfm cmmi 0 cmmi5 5.5 cmmi6 6.5 cmmi7 7.5 cmmi8 8.5 cmmi9 9.5
                cmmi10 11.1 cmmi12 *
\_regtfm cmmib 0 cmmib5 5.5 cmmib6 6.5 cmmib7 7.5 cmmib8 8.5 cmmib9 9.5 cmmib10 *
\_regtfm cmtex 0 cstex8 8.5 cstex9 9.5 cstex10 *
\_regtfm cmsy 0 cmsy5 5.5 cmsy6 6.5 cmsy7 7.5 cmsy8 8.5 cmsy9 9.5 cmsy10 *
\_regtfm cmbsy 0 cmbsy5 5.5 cmbsy6 6.5 cmbsy7 7.5 cmbsy8 8.5 cmbsy9 9.5 cmbsy10 *
\_regtfm cmex 0 cmex7 7.5 cmex8 8.5 cmex9 9.5 cmex10 *
\_regtfm cmexb 0 cmexb10 *

\_regtfm cmr  0 cmr5 5.5 cmr6 6.5 cmr7 7.5 cmr8 8.5 cmr9 9.5
                cmr10 11.1 cmr12 15 cmr17 *
\_regtfm cmbx 0 cmbx5 5.5 cmbx6 6.5 cmbx7 7.5 cmbx8 8.5 cmbx9 9.5
                cmbx10 11.1 cmbx12 *
\_regtfm cmti 0 cmti7 7.5 cmti8 8.5 cmti9 9.5 cmti10 11.1 cmti12 *
\_regtfm cmtt 0 cmtt8 8.5 cmtt9 9.5 cmtt10 11.1 cmtt12 *

%% AMS math fonts, optical sizes:

\_regtfm msam 0 msam5 5.5 msam6 6.5 msam7 7.5 msam8 8.5 msam9 9.5 msam10 *
\_regtfm msbm 0 msbm5 5.5 msbm6 6.5 msbm7 7.5 msbm8 8.5 msbm9 9.5 msbm10 *

%% fraktur, rsfs, optical sizes:

\_regtfm eufm 0 eufm5 6 eufm7 8.5 eufm10 *
\_regtfm eufb 0 eufb5 6 eufb7 8.5 eufb10 *
\_regtfm rsfs 0 rsfs5 6 rsfs7 8.5 rsfs10 *

%% bf and bi sansserif math alternatives:

\_regtfm bfsans 0 ecsx0500 5.5 ecsx0600 6.5 ecsx0700 7.5 ecsx0800
             8.5 ecsx0900 9.5 ecsx1000 11.1 ecsx1200 *
\_regtfm bisans 0 ecso0500 5.5 ecso0600 6.5 ecso0700 7.5 ecso0800
             8.5 ecso0900 9.5 ecso1000 11.1 ecso1200 *
\_regtfm bbfsans 0 ecsx0500 5.5 ecsx0600 6.5 ecsx0700 7.5 ecsx0800
             8.5 ecsx0900 9.5 ecsx1000 11.1 ecsx1200 *
\_regtfm bbisans 0 ecso0500 5.5 ecso0600 6.5 ecso0700 7.5 ecso0800
             8.5 ecso0900 9.5 ecso1000 11.1 ecso1200 *

   \_doc -----------------------------
   \`\_loadmathfamily` `<number> <font>` loads one math family, i.\,e.\
   the triple of fonts in the text size, script size and script-script size.
   The `<font>` is `<font-id>` used in the `\_regtfm` parameter or
   the real TFM name. The family is saved as `\fam<number>`.
   \nl
   \`\_setmathfamily` `<number> \<font-switch>` loads one math family
   like `\_loadmathfamily` does it. But the second parameter is a
   `\<font-switch>` declared previously by the `\font` primitive.
   \nl
   The font family is loaded at \`\_sizemtext`, \`\_sizemscript` and
   \`\_sizemsscript` sizes. These sizes are set by the
   \`\setmathsizes` `[<text-size>/<script-size>/<scriptscript-size>]` macro.
   These parameters are given in the \`\ptmunit` unit, it is set to
   1\`\ptunit` and it is set to 1\,pt by  default.
   \nl
   \`\_corrmsize` `<factor><space>` can be used just before
   `\_loadmathfamily` or `\_setmathfamily`.
   The `<factor>` is decimal number, it denotes
   scale-factor \"size of loaded math font in `\textstyle` : size of text font".
   You can use it in `\_normalmath` or `\_boldmath` macros if you want to do a
   corrections (for example due to different ex-height in text and math
   font). The `\_corrmsize` is applied only to one following
   `\_loadmathfamily` or `\_setmathfamily`. If it is missing
   then the `<factor>` is 1 for such math family (i.e.\ no size corrections).
   \_cod -----------------------------

\_def\_corrmsize#1 {\_ptmunit=#1\_ptunit} % for corrections of sizes in diferent fonts

\_def\_loadmathfamily #1 #2 {%
  \_edef\_optsizesave{\_the\_optsize}%
  \_optsize=\_sizemtext    \_font\_mF=\_whichtfm{#2} at\_optsize \_textfont#1=\_mF
  \_optsize=\_sizemscript  \_font\_mF=\_whichtfm{#2} at\_optsize \_scriptfont#1=\_mF
  \_optsize=\_sizemsscript \_font\_mF=\_whichtfm{#2} at\_optsize \_scriptscriptfont#1=\_mF
  \_optsize=\_optsizesave \_ptmunit=\_ptunit
}
\_def\_setmathfamily #1 #2{\_let\_mF=#2%
  \_edef\_optsizesave{\_the\_optsize}%
  \_optsize=\_sizemtext    \_fontlet#2=#2 at\_optsize \_textfont#1=#2%
  \_optsize=\_sizemscript  \_fontlet#2=#2 at\_optsize \_scriptfont#1=#2%
  \_optsize=\_sizemsscript \_fontlet#2=#2 at\_optsize \_scriptscriptfont#1=#2%
  \_optsize=\_optsizesave \_ptmunit=\_ptunit \_let#2=\_mF
}
\_def\_setmathsizes[#1/#2/#3]{\_ptmunit=\_ptunit
   \_def\_sizemtext{#1\_ptmunit}\_def\_sizemscript{#2\_ptmunit}%
   \_def\_sizemsscript{#3\_ptmunit}%
}
\_newdimen\_ptunit   \_ptunit=1pt
\_newdimen\_ptmunit  \_ptmunit=1\_ptunit

\_public \setmathsizes \ptunit \ptmunit ;

   \_doc -----------------------------
   The \`\_setmathdimens` macro is used in \^`\normalmath` or \^`\boldmath`
   macros. It makes math dimensions dependent on the font size (plain \TeX/ sets
   them only for 10\,pt typesetting). The `\skewchar` of some math families are
   set here too.
   \_cod -----------------------------

\_def\_setmathdimens{% PlainTeX sets these dimens for 10pt size only:
  \_delimitershortfall=0.5\_fontdimen6\_textfont3
  \_nulldelimiterspace=0.12\_fontdimen6\_textfont3
  \_scriptspace=0.05\_fontdimen6\_textfont3
  \_skewchar\_textfont1=127 \_skewchar\_scriptfont1=127
  \_skewchar\_scriptscriptfont1=127
  \_skewchar\_textfont2=48  \_skewchar\_scriptfont2=48
  \_skewchar\_scriptscriptfont2=48
  \_skewchar\_textfont6=127 \_skewchar\_scriptfont6=127
  \_skewchar\_scriptscriptfont6=127
}

   \_doc -----------------------------
   Finally, we preload a math fonts collection in [10/7/5] sizes
   when the format is generated. This is done when
   `\_suppressfontnotfounderror=1` because we need not errors when the format is
   generated. Maybe there are not all fonts in the \TeX/ distribution
   installed.
   \_cod -----------------------------

\_suppressfontnotfounderror=1
\_setmathsizes[10/7/5]\_normalmath
\_suppressfontnotfounderror=0


\_endcode %---------------------------------------------------

The Computer Modern and AMS fonts are preloaded here in classical math-fam
concept, where each math family includes three fonts with max 256 characters
(typically 128 characters).

On the other hand, when \^`\fontfam` macro is used in the document then text
font family and appropriate math family is loaded with Unicode fonts, i.e.
Unicode-math is used. It re-defines all settings given here.

The general rule of usage the math fonts in different sizes in \OpTeX/ says: set three
sizes by the macro
\^`\setmathsizes` `[<text-size>/<script-size>/<scriptscript-size>]` and then
load all math fonts in given sizes by \^`\normalmath` or \^`\boldmath` macros.
For example
\begtt
\setmathsizes[12/8.4/6]\normalmath ... math typesetting at 12 pt is ready.
\endtt

\_endinput

2020-05-06: \itfam, \ttfam removed, (Unicode math preferred)
2020-04-14: \skewchar\fam6 added