bonum-math.lfg /size: 16 Kb    last modification: 2024-01-16 09:03
1local common  = fonts.goodies.load("common-math.lfg")
2local presets = common.mathematics.tweaks.presets
3
4local integral_variants = { bottomright = -0.20 }
5local integral_top      = { topright    =  0 }
6local integral_bottom   = { bottomright = -0.10 } -- if too big it looks bad with triple integrals
7
8return {
9    name = "bonum-math",
10    version = "1.00",
11    comment = "Goodies that complement bonum.",
12    author = "Hans Hagen & Mikael Sundqvist",
13    copyright = "ConTeXt development team",
14    mathematics = {
15        parameters = {
16            AccentTopShiftUp                  =  -15,
17            FlattenedAccentTopShiftUp         =  -15,
18            AccentBaseDepth                   =   50,
19            DelimiterPercent                  =   85,
20            DelimiterShortfall                =  400,
21            DelimiterDisplayPercent           =   90,
22            DelimiterDisplayShortfall         =  400,
23            DisplayOperatorMinHeight          = 1900, -- 1250 in font
24            SubscriptShiftDown                =  201, -- 231 in font
25            SuperscriptShiftUp                =  364, -- 334 in font
26            SubscriptShiftDownWithSuperscript = "1.4*SubscriptShiftDown", -- trial and error
27            PrimeShiftUp                      = "1.25*SuperscriptShiftUp",
28            PrimeShiftUpCramped               = "1.25*SuperscriptShiftUp",
29        },
30        tweaks = {
31            aftercopying = {
32                {
33                    tweak    = "version",
34                    expected = "Version 1.005",
35                },
36                {
37                    tweak   = "fixprimes",
38                    factor  = 0.77,
39                },
40                {
41                    tweak = "addmirrors",
42                },
43                {
44                    tweak   = "replacealphabets",
45                    list    = {
46                        {
47                            source   = { first = 0x003B1 }, -- upright alpha
48                            filename = "texgyrebonummath-companion.otf",
49                        },
50                        {
51                            source   = { first = 0x1D6FC }, -- italic alpha
52                            filename = "texgyrebonummath-companion.otf",
53                        },
54                        {
55                            source   = { first = 0x1D6C2 }, -- bold upright alpha
56                            filename = "texgyrebonummath-companion.otf",
57                        },
58                        {
59                            source   = { first = 0x1D736 }, -- bold italic alpha
60                            filename = "texgyrebonummath-companion.otf",
61                        },
62                        {
63                            source   = { first = 0x02980 }, -- triplebar
64                            filename = "TeXGyreBonumMath-Companion.otf",
65                        },
66                    },
67                },
68                presets.smalldigits          { factor  = 0.95 },
69                presets.scripttocalligraphic { },
70                presets.rsfstoscript         { rscale  = 0.98 },
71                presets.rsfsuprighttoscript  { rscale  = 0.98 },
72                presets.moderntocalligraphic { rscale  = 0.98 },
73                presets.eulertocalligraphic  { rscale  = 0.98 },
74                presets.xitsarabic           { rscale  = 1    },
75                presets.fallbacks            { },
76                presets.moveintegrals        { factor  = 1.5  },
77                presets.moveitalics          { correct = true },
78                presets.wipeanchors          { },
79                presets.wipeitalics          { },
80                {
81                    tweak = "checkaccents",
82                },
83                {
84                    -- We need to check these, are the tweaks necessary or not?
85                    tweak = "dimensions",
86                    list  = {
87                        ["lowercasefraktur"] = {
88                            width    = 1.25,
89                            extend   = 1.25,
90                            height   = 1.15,
91                            depth    = 1.15,
92                            squeeze  = 1.15,
93                        },
94
95                        ["lowercasescript"] = {
96                            factor = 1.2,
97                        },
98                    },
99                },
100                {
101                    tweak = "kerns",
102                    list  = {
103                        [0x002F]                = { topleft  = -0.2,  bottomright = -0.2  },
104                        ["0x002F.variants.*"]   = { topleft  = -0.2,  bottomright = -0.2  },
105                        [0x007D]                = { topright = -0.05, bottomright = -0.05 }, -- right brace variants
106                        ["0x7D.variants.*"]     = { topright = -0.05, bottomright = -0.05 }, -- right brace variants
107                        ["0x7D.parts.top"]      = { topright = -0.15,                     }, -- right brace top
108                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.15 }, -- right brace bottom
109                        [0x0029]                = { topright = -0.15, bottomright = -0.15 }, -- right parenthesis variants
110                        ["0x29.variants.*"]     = { topright = -0.15, bottomright = -0.15 }, -- right parenthesis variants
111                        ["0x29.parts.top"]      = { topright = -0.15,                     }, -- right parenthesis top
112                        ["0x29.parts.bottom"]   = {                   bottomright = -0.15 }, -- right parenthesis bottom
113                        [0x221A]                = { topright =  0.2,  bottomright =  0.2  }, -- radical
114                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  },
115                        ["0x221A.parts.top"]    = { topright =  0.2,                      },
116                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  },
117                        [0x27E9]                = { topright = -0.1,  bottomright = -0.1  }, -- angle
118                        ["0x27E9.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
119                        [0x27EB]                = { topright = -0.1,  bottomright = -0.1  },
120                        ["0x27EB.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
121                        --
122                        [0x1D465]               = { bottomright = -0.05 }, -- italic x (ic is too large)
123                        [0x00393]               = { bottomright = -0.30 }, -- upright Gamma
124                        [0x1D43F]               = { bottomright =  0.01 }, -- upright L
125                        ["0x222B.parts.bottom"] = { bottomright = -0.20 }, -- int
126                        ["0x222C.parts.bottom"] = { bottomright = -0.15 }, -- iint
127                        ["0x222D.parts.bottom"] = { bottomright = -0.10 }, -- iiint
128                        ["0x2A0C.parts.bottom"] = { bottomright = -0.05 }, -- iiiint
129                    },
130                },
131                -- Accents are a mess. We migrate the extensibles from the combiners to the base accent
132                -- and then need to tweak the width (which is auto set because it was zero with a large
133                -- accent anchor offset). First we copy and fix.
134                {
135                    tweak = "extendaccents",
136                },
137                {
138                    tweak = "flattenaccents",
139                },
140                {
141                    tweak = "fixaccents", -- after flatten (zero width intefrerence)
142                },
143                {
144                    tweak   = "radicaldegreeanchors",
145                    list = {
146                        [0x221A]                = { location = "left", hfactor  = .1, vfactor  = .3 },
147                        ["0x221A.variants.*"]   = { location = "left", hfactor  = .1, vfactor  = .625 },
148                        ["0x221A.variants.1"]   = { location = "left", hfactor  = .1, vfactor  = .575 },
149                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = .1, vfactor  = 1.15 },
150                    }
151                },
152                {
153                    tweak = "dimensions",
154                    list  = {
155                     -- [0x007D]              = { topright = -0.05, bottomright = -0.05 }, -- right brace variants
156                        ["0x7C"]              = { width = 1.4, xoffset=0.2 },              -- vertical bar (just looks better tis way)
157                     -- ["0x7C.variants.*"]   = { width = 1, extend = 2.4 },
158                     -- ["0x7C.parts.top"]    = { },
159                     -- ["0x7C.parts.bottom"] = { bottomright = -0.15 },
160                    },
161                },
162                -- First we set the dimensions of the initial accent which started out as zero but we want
163                -- a proper width. Thjis is no longer needed because we tweak the dimensions automatically,
164                -- so this is just some documented history.
165             -- {
166             --     tweak = "dimensions",
167             --     list  = {
168             --         [0x00302]              = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widehat
169             --         ["0x00302.flataccent"] = { width = 1.4, anchor = 1.20 },                -- no offset, because we copy
170             --     },
171             -- },
172                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
173                -- as well as the variants here. But none for Bonum.
174                -- We now copy these to the not wide slots so that we can set these to stretch as well,
175                -- if only because it is less confusing and more consistent.
176                {
177                    tweak = "copyaccents",
178                },
179                -- So far for the accents.
180                {
181                    -- This one fakes margins to get larger/smaller accents with for example the
182                    -- \widetilde.
183                    tweak = "margins",
184                    list  = {
185                        [0x1D7DC] = { left = -.1,  right = -.1 }, -- doublestruck 4
186
187                        [0x1D712] = { left = -.1,  right = -.1 }, -- italic chi
188                        [0x1D713] = { left = -.1,  right = -.1 }, -- italic psi
189                        [0x1D714] = { left = -.1,  right = -.1 }, -- italic omega
190
191                        [0x003B1] = { left = -.1,  right = -.1 }, -- upright alpha
192                        [0x003B3] = { left = -.1,  right = -.1 }, -- upright gamma
193                        [0x003BA] = { left = -.1,  right = -.1 }, -- upright kappa
194                        [0x003BC] = { left = -.1,  right = -.1 }, -- upright mu
195                        [0x003C0] = { left = -.1,  right = -.1 }, -- upright pi
196                        [0x003C3] = { left = -.1,  right = -.1 }, -- upright sigma
197                        [0x003C5] = { left = -.1,  right = -.1 }, -- upright upsilon
198                        [0x003C6] = { left = -.1,  right = -.1 }, -- upright phi
199                        [0x003C8] = { left = -.1,  right = -.1 }, -- upright psi
200                        [0x003C9] = { left = -.1,  right = -.1 }, -- upright omega
201
202                        -- Greek lowercase sans (bold, italic) can be improved
203
204                        [0x1D451] = { left = -.1,  right = -.1 }, -- italic d
205                        [0x1D453] = { left = -.1,  right = -.1 }, -- italic f
206
207                        [0x00394] = { left =  .1,  right =  .1 }, -- upright Delta
208                        [0x003A3] = { left =  .1,  right =  .1 }, -- upright Sigma
209
210                        [0x00046] = { left =  .1,  right =  .1 }, -- F
211                        [0x0004C] = { left =  .1,  right =  .1 }, -- L
212                        [0x00050] = { left =  .1,  right =  .1 }, -- P
213                        [0x00053] = { left =  .1,  right =  .1 }, -- S
214                        [0x00054] = { left =  .1,  right =  .1 }, -- T
215                        [0x0005A] = { left =  .1,  right =  .1 }, -- Z
216
217                        [0x1D43D] = { left = -.1,  right = -.1  }, -- italic J
218                        [0x1D44B] = { left = -.05, right = -.05 }, -- italic X
219                    },
220                },
221                {
222                    -- The v could have a bit more sidebearing
223                    tweak = "dimensions",
224                    list  = {
225                        ["0x1D463"] = { width = 1.075, }, -- italic v
226                    },
227                },
228                {
229                    tweak = "addprivates",
230                },
231                {
232                    tweak = "addscripts",
233                },
234                {
235                    tweak = "accentdimensions",
236                },
237                {
238                    tweak = "addrules",
239                },
240                {
241                    tweak    = "replacerules",
242                    fraction = { height = .244, yoffset = .758 },
243                    radical  = { height = .244, yoffset = .758, leftoffset = .1, rightoffset = .1 },
244                    stacker  = { height = .244, yoffset = .758 },
245                },
246                {
247                    -- This tweak is only needed for the funny arrows and these now get properly
248                    -- centered. (Could actually be done in the engine).
249                    tweak = "addarrows",
250                    -- These are for documentation purposed as they are the defaults anyway:
251                    left  = 0.05,
252                    right = 0.05,
253                    slack = 0.10,
254                    -- The equal doesn't really match the double arrows, as in plain etc, so it still
255                    -- looks somewhat bad when zoomed in. This is the best we could do. Anyway, this
256                    -- in only used when testing (forced) so it doesn't kick in normally.
257                    list  = { [0x3D] = { squeeze = .85, yoffset = .0975 } }
258                },
259                {
260                    -- Do we need these in the future?
261                    -- Maybe a more general setup?
262                    -- Maybe "reset llx"
263                    tweak = "kernpairs",
264                    list = {
265                        [mathematics.tweaks.subsets.acenorsuvxz] = {
266                            [0x1D453] = -.1, -- f
267                            [0x1D457] = -.1, -- j
268                        },
269                        [mathematics.tweaks.subsets.bhklt] = {
270                            [0x1D453] = -.1, -- f
271                            [0x1D457] = -.1, -- j
272                        },
273                        [mathematics.tweaks.subsets.d] = {
274                            [0x1D453] = -.075, -- f
275                            [0x1D457] = -.075, -- j
276                        },
277                        [mathematics.tweaks.subsets.f] = {
278                            -- [mathematics.tweaks.subsets.aceimnorsuvwxz] = -.05,
279                            [mathematics.tweaks.subsets.gjqy] = -.15,
280                            [0x1D453] = -.2, -- ff
281                        },
282                        [mathematics.tweaks.subsets.i] = {
283                            [0x1D453] = -.2, -- f
284                            [0x1D457] = -.2, -- j
285                        },
286                        [mathematics.tweaks.subsets.mw] = {
287                            [0x1D453] = -.05, -- f
288                            [0x1D457] = -.05, -- j
289                        },
290                        [mathematics.tweaks.subsets.p] = {
291                            [0x1D453] = -.05, -- f
292                            [0x1D457] = -.05, -- j
293                        },
294                        [0x1D45F] = { -- r
295                            [0x1D460] = -.1, -- s
296                        },
297                    }
298                },
299                -- {
300                --     tweak   = "addbars",
301                --     advance = 0.475,
302                -- },
303                {
304                    tweak = "addactuarian",
305                },
306                {
307                    tweak = "addequals",
308                },
309                {
310                    tweak   = "addfourier",
311                    variant = 1,
312                },
313                {
314                    tweak   = "addprimed",
315                },
316                -- this is the mkiv section
317                {
318                    tweak   = "emulatelmtx",
319                    feature = "emulatelmtx",
320                    comment = "this is for mkiv",
321                },
322            },
323        },
324        alternates = {
325            dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" },
326        },
327        bigslots = {
328            1, 3, 5, 7
329        },
330    },
331}
332