Debian Codegraph @

texmf-dist/tex/optex/base/math-preload.opm

raw
1 %% This is part of the OpTeX project, see http://petr.olsak.net/optex
2
3 \_codedecl \normalmath {Math fonts CM + AMS preloaded <2022-12-01>} % preloaded in format
4
5 \_doc ------------------------------
6 We have two math macros \`\normalmath` for the normal shape of all math
7 symbols and \`\boldmath` for the bold shape of all math symbols. The second one
8 can be used in bold titles, for example.
9 These macros load all fonts from all given math font families.
10 \_cod ------------------------------
11
12 \_def\_normalmath{%
13 \_loadmathfamily 0 cmr % CM Roman
14 \_loadmathfamily 1 cmmi % CM Math Italic
15 \_loadmathfamily 2 cmsy % CM Standard symbols
16 \_loadmathfamily 3 cmex % CM extra symbols
17 \_loadmathfamily 4 msam % AMS symbols A
18 \_loadmathfamily 5 msbm % AMS symbols B
19 \_loadmathfamily 6 rsfs % script
20 \_loadmathfamily 7 eufm % fractur
21 \_loadmathfamily 8 bfsans % sans serif bold
22 \_loadmathfamily 9 bisans % sans serif bold slanted (for vectors)
23 % \_setmathfamily 10 \_tentt
24 % \_setmathfamily 11 \_tenit
25 \_setmathdimens
26 }
27 \_def\_boldmath{%
28 \_loadmathfamily 0 cmbx % CM Roman Bold Extended
29 \_loadmathfamily 1 cmmib % CM Math Italic Bold
30 \_loadmathfamily 2 cmbsy % CM Standard symbols Bold
31 \_loadmathfamily 3 cmexb % CM extra symbols Bold
32 \_loadmathfamily 4 msam % AMS symbols A (bold not available?)
33 \_loadmathfamily 5 msbm % AMS symbols B (bold not available?)
34 \_loadmathfamily 6 rsfs % script (bold not available?)
35 \_loadmathfamily 7 eufb % fractur bold
36 \_loadmathfamily 8 bbfsans % sans serif extra bold
37 \_loadmathfamily 9 bbisans % sans serif extra bold slanted (for vectors)
38 % \_setmathfamily 10 \_tentt
39 % \_setmathfamily 11 \_tenbi
40 \_setmathdimens
41 }
42 \_def \normalmath {\_normalmath} \_def\boldmath {\_boldmath}
43
44 \_doc -----------------------------
45 The classical math family selectors
46 \`\mit`, \^`\cal`, \^`\bbchar`, \^`\frak` and \^`\script`
47 are defined here.
48 The \^`\rm`, \^`\bf`, \^`\it`, \^`\bi` and \^`\tt` does two things:
49 they are variant selectors for text fonts and math family selectors for math fonts.
50 The idea was adapted from plain \TeX/.\nl
51 These macros are redefined when `unimat-codes.opm` is loaded,
52 see the section~\ref[unimath-codes].
53 \_cod -----------------------------
54
55 \_chardef\_bffam = 8
56 \_chardef\_bifam = 9
57 %\_chardef\_ttfam = 10
58 %\_chardef\_itfam = 11
59
60 \_protected\_def \_marm {\_fam0 }
61 \_protected\_def \_mabf {\_fam\_bffam}
62 \_protected\_def \_mait {\_fam1 }
63 \_protected\_def \_mabi {\_fam\_bifam}
64 \_protected\_def \_matt {}
65
66 \_protected\_def \_mit {\_fam1 }
67 \_protected\_def \_cal {\_fam2 }
68 \_protected\_def \_bbchar {\_fam5 } % double stroked letters
69 \_protected\_def \_frak {\_fam7 } % fraktur
70 \_protected\_def \_script {\_fam6 } % more extensive script than \cal
71
72 \_public \mit \cal \bbchar \frak \script ;
73
74 \_doc -----------------------------
75 The optical sizes of Computer Modern fonts, AMS, and other fonts
76 are declared here.
77 \_cod -----------------------------
78
79 %% CM math fonts, optical sizes:
80
81 \_regtfm cmmi 0 cmmi5 5.5 cmmi6 6.5 cmmi7 7.5 cmmi8 8.5 cmmi9 9.5
82 cmmi10 11.1 cmmi12 *
83 \_regtfm cmmib 0 cmmib5 5.5 cmmib6 6.5 cmmib7 7.5 cmmib8 8.5 cmmib9 9.5 cmmib10 *
84 \_regtfm cmtex 0 cstex8 8.5 cstex9 9.5 cstex10 *
85 \_regtfm cmsy 0 cmsy5 5.5 cmsy6 6.5 cmsy7 7.5 cmsy8 8.5 cmsy9 9.5 cmsy10 *
86 \_regtfm cmbsy 0 cmbsy5 5.5 cmbsy6 6.5 cmbsy7 7.5 cmbsy8 8.5 cmbsy9 9.5 cmbsy10 *
87 \_regtfm cmex 0 cmex7 7.5 cmex8 8.5 cmex9 9.5 cmex10 *
88 \_regtfm cmexb 0 cmexb10 *
89
90 \_regtfm cmr 0 cmr5 5.5 cmr6 6.5 cmr7 7.5 cmr8 8.5 cmr9 9.5
91 cmr10 11.1 cmr12 15 cmr17 *
92 \_regtfm cmbx 0 cmbx5 5.5 cmbx6 6.5 cmbx7 7.5 cmbx8 8.5 cmbx9 9.5
93 cmbx10 11.1 cmbx12 *
94 \_regtfm cmti 0 cmti7 7.5 cmti8 8.5 cmti9 9.5 cmti10 11.1 cmti12 *
95 \_regtfm cmtt 0 cmtt8 8.5 cmtt9 9.5 cmtt10 11.1 cmtt12 *
96
97 %% AMS math fonts, optical sizes:
98
99 \_regtfm msam 0 msam5 5.5 msam6 6.5 msam7 7.5 msam8 8.5 msam9 9.5 msam10 *
100 \_regtfm msbm 0 msbm5 5.5 msbm6 6.5 msbm7 7.5 msbm8 8.5 msbm9 9.5 msbm10 *
101
102 %% fraktur, rsfs, optical sizes:
103
104 \_regtfm eufm 0 eufm5 6 eufm7 8.5 eufm10 *
105 \_regtfm eufb 0 eufb5 6 eufb7 8.5 eufb10 *
106 \_regtfm rsfs 0 rsfs5 6 rsfs7 8.5 rsfs10 *
107
108 %% bf and bi sansserif math alternatives:
109
110 \_regtfm bfsans 0 ecsx0500 5.5 ecsx0600 6.5 ecsx0700 7.5 ecsx0800
111 8.5 ecsx0900 9.5 ecsx1000 11.1 ecsx1200 *
112 \_regtfm bisans 0 ecso0500 5.5 ecso0600 6.5 ecso0700 7.5 ecso0800
113 8.5 ecso0900 9.5 ecso1000 11.1 ecso1200 *
114 \_regtfm bbfsans 0 ecsx0500 5.5 ecsx0600 6.5 ecsx0700 7.5 ecsx0800
115 8.5 ecsx0900 9.5 ecsx1000 11.1 ecsx1200 *
116 \_regtfm bbisans 0 ecso0500 5.5 ecso0600 6.5 ecso0700 7.5 ecso0800
117 8.5 ecso0900 9.5 ecso1000 11.1 ecso1200 *
118
119 \_doc -----------------------------
120 \`\_loadmathfamily` `<number> <font>` loads one math family, i.\,e.\
121 the triple of fonts in the text size, script size and script-script size.
122 The `<font>` is `<font-id>` used in the `\_regtfm` parameter or
123 the real TFM name. The family is saved as `\fam<number>`.
124 \nl
125 \`\_setmathfamily` `<number> \<font-switch>` loads one math family
126 like `\_loadmathfamily` does it. But the second parameter is a
127 `\<font-switch>` declared previously by the `\font` primitive.
128 \nl
129 The `<number>` is saved by \^`\_loadmathfamily`, \^`\_setmathfamily`
130 to the \`\_mfam`.
131 \nl
132 The font family is loaded at \`\_sizemtext`, \`\_sizemscript` and
133 \`\_sizemsscript` sizes. These sizes are set by the
134 \`\setmathsizes` `[<text-size>/<script-size>/<scriptscript-size>]` macro.
135 These parameters are given in the \`\ptmunit` unit, it is set to
136 1\`\ptunit` and it is set to 1\,pt by default.
137 \nl
138 \`\_mfactor` sets scaling factor for given math fonts family
139 related to text font size. It does the setting `\_ptmunit=<factor>\_ptunit` where
140 the <factor> is defined by `\sdef{_mfactor:<family>}{<factor>}`.
141 For example, you can set `\sdef{_mfactor:1}{0.95}` if you found that
142 this scaling of math family 1 gives better visual compatibility
143 with used text fonts. If not declared then scaling factor is~1.
144 \_cod -----------------------------
145
146 \_def\_loadmathfamily {\_afterassignment\_loadmathfamilyA \_chardef\_mfam}
147 \_def\_loadmathfamilyA #1 {\_mfactor
148 \_edef\_optsizesave{\_the\_optsize}%
149 \_optsize=\_sizemtext \_font\_mF \_optfn{#1} at\_optsize \_textfont\_mfam=\_mF
150 \_optsize=\_sizemscript \_font\_mF \_optfn{#1} at\_optsize \_scriptfont\_mfam=\_mF
151 \_optsize=\_sizemsscript \_font\_mF \_optfn{#1} at\_optsize \_scriptscriptfont\_mfam=\_mF
152 \_optsize=\_optsizesave
153 }
154 \_def\_setmathfamily {\_afterassignment\_setmathfamilyA \_chardef\_mfam}
155 \_def\_setmathfamilyA #1{\_mfactor \_let\_mF=#1%
156 \_edef\_optsizesave{\_the\_optsize}%
157 \_optsize=\_sizemtext \_fontlet#1#1at\_optsize \_textfont\_mfam=#1%
158 \_optsize=\_sizemscript \_fontlet#1#1at\_optsize \_scriptfont\_mfam=#1%
159 \_optsize=\_sizemsscript \_fontlet#1#1at\_optsize \_scriptscriptfont\_mfam=#1%
160 \_optsize=\_optsizesave \_let#1=\_mF
161 }
162 \_def\_setmathsizes[#1/#2/#3]{\_ptmunit=\_ptunit
163 \_def\_sizemtext{#1\_ptmunit}\_def\_sizemscript{#2\_ptmunit}%
164 \_def\_sizemsscript{#3\_ptmunit}%
165 }
166 \_def\_mfactor{\_ptmunit=\_trycs{_mfactor:\_the\_mfam}{}\_ptunit}
167
168 \_newdimen\_ptunit \_ptunit=1pt
169 \_newdimen\_ptmunit \_ptmunit=1\_ptunit
170
171 \_public \setmathsizes \ptunit ;
172
173 \_doc -----------------------------
174 \`\_setmathparam``<luatex-param> {<factor>}` sets
175 <luatex-param> (like `\Umathspaceafterscript`) to values dependent
176 on `1em` of textfont, scriptfont, scriptscriptfont. The <factor> is
177 scaling factor of mentioned `1em`.
178 \_cod -----------------------------
179
180 \_def\_setmathparam#1#2{%
181 #1\_displaystyle =#2\_fontdimen6\_textfont1
182 #1\_crampeddisplaystyle =#2\_fontdimen6\_textfont1
183 #1\_textstyle =#2\_fontdimen6\_textfont1
184 #1\_crampedtextstyle =#2\_fontdimen6\_textfont1
185 #1\_scriptstyle =#2\_fontdimen6\_scriptfont1
186 #1\_crampedscriptstyle =#2\_fontdimen6\_scriptfont1
187 #1\_scriptscriptstyle =#2\_fontdimen6\_scriptscriptfont1
188 #1\_crampedscriptscriptstyle =#2\_fontdimen6\_scriptscriptfont1
189 }
190
191 \_doc -----------------------------
192 The \`\_setmathdimens` macro is used in \^`\normalmath` or \^`\boldmath`
193 macros. It makes math dimensions dependent on the font size (plain \TeX/ sets
194 them only for 10\,pt typesetting). The `\skewchar` of some math families are
195 set here too.\nl
196 \^`\_setmathparam \Umathspaceafterscript` is used instead `\scriptspace`
197 setting because \LuaTeX/ ignores `\scriptspace` in most cases. There is
198 small difference from classical \TeX/: we set \"scaled"
199 `\Umathspaceafterscript` dependent on textstyle, scriptstyle, etc.\ sizes.
200 The \`\_scriptspacefactor` is set to 0.05 which gives the same result
201 as Plain \TeX/ `\scriptspace=0.5pt` at 10\,pt font size.
202 \_cod -----------------------------
203
204 \_def\_setmathdimens{% PlainTeX sets these dimens for 10pt size only:
205 \_delimitershortfall=0.5\_fontdimen6\_textfont3
206 \_nulldelimiterspace=0.12\_fontdimen6\_textfont3
207 \_setmathparam\_Umathspaceafterscript \_scriptspacefactor
208 \_skewchar\_textfont1=127 \_skewchar\_scriptfont1=127
209 \_skewchar\_scriptscriptfont1=127
210 \_skewchar\_textfont2=48 \_skewchar\_scriptfont2=48
211 \_skewchar\_scriptscriptfont2=48
212 \_skewchar\_textfont6=127 \_skewchar\_scriptfont6=127
213 \_skewchar\_scriptscriptfont6=127
214 }
215 \_def\_scriptspacefactor{.05}
216
217 \_doc -----------------------------
218 Finally, we preload a math fonts collection in [10/7/5] sizes
219 when the format is generated. This is done when
220 `\_suppressfontnotfounderror=1` because we need not errors when the format is
221 generated. Maybe there are not all fonts in the \TeX/ distribution
222 installed.
223 \_cod -----------------------------
224
225 \_suppressfontnotfounderror=1
226 \_setmathsizes[10/7/5]
227 \_ifx\fontspreload\_relax \_else \_normalmath \_fi
228 \_suppressfontnotfounderror=0
229
230
231 \_endcode %---------------------------------------------------
232
233 The Computer Modern and AMS fonts are preloaded here in classical math-fam
234 concept, where each math family includes three fonts with max 256 characters
235 (typically 128 characters).
236
237 On the other hand, when \^`\fontfam` macro is used in the document then text
238 font family and appropriate math family is loaded with Unicode fonts, i.e.
239 Unicode-math is used. It re-defines all settings given here.
240
241 The general rule of usage the math fonts in different sizes in \OpTeX/ says: set three
242 sizes by the macro
243 \^`\setmathsizes` `[<text-size>/<script-size>/<scriptscript-size>]` and then
244 load all math fonts in given sizes by \^`\normalmath` or \^`\boldmath` macros.
245 For example
246 \begtt
247 \setmathsizes[12/8.4/6]\normalmath ... math typesetting at 12 pt is ready.
248 \endtt
249
250 \_endinput
251
252 2022-12-01 reading number by \_loadmathfamily, \_setmathfamily more robust
253 2022-11-16: \_corrmsize removed, \_mfactor introduced
254 2022-09-04: \crampedstyles settings added.
255 2022-07-22: \_setmathparam\_Umathspaceafterscript added.
256 2022-02-22: \rm, \it, etc moved to fonts-select, \_marm, \_mait etc. introduced
257 2020-05-06: \itfam, \ttfam removed, (Unicode math preferred)
258 2020-04-14: \skewchar\fam6 added