summaryrefslogtreecommitdiff
path: root/tex/context/fonts/mkiv/bonum-math.lfg
blob: 2852c6449dccd28ef75cd61528ad245021a1d0b4 (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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
local common  = fonts.goodies.load("common-math.lfg")
local presets = common.mathematics.tweaks.presets

local integral_variants = { bottomright = -0.20 }
local integral_top      = { topright    =  0 }
local integral_bottom   = { bottomright = -0.10 } -- if too big it looks bad with triple integrals

return {
    name = "bonum-math",
    version = "1.00",
    comment = "Goodies that complement bonum.",
    author = "Hans Hagen & Mikael Sundqvist",
    copyright = "ConTeXt development team",
    mathematics = {
        parameters = {
            AccentTopShiftUp                  =  -15,
            FlattenedAccentTopShiftUp         =  -15,
            AccentBaseDepth                   =   50,
            DelimiterPercent                  =   90,
            DelimiterShortfall                =  400,
            DisplayOperatorMinHeight          = 1900, -- 1250 in font
            SubscriptShiftDown                =  201, -- 231 in font
            SuperscriptShiftUp                =  364, -- 334 in font
            SubscriptShiftDownWithSuperscript = "1.4*SubscriptShiftDown", -- trial and error
            PrimeShiftUp                      = "1.25*SuperscriptShiftUp",
            PrimeShiftUpCramped               = "1.25*SuperscriptShiftUp",
        },
        tweaks = {
            aftercopying = {
                {
                    tweak    = "version",
                    expected = "Version 1.005",
                },
                {
                    tweak   = "fixprimes",
                    factor  = 0.77,
                },
                {
                    tweak = "addmirrors",
                },
                {
                    tweak   = "replacealphabets",
                    list    = {
                        {
                            source   = { first = 0x003B1 }, -- upright alpha
                            filename = "texgyrebonummath-companion.otf",
                        },
                        {
                            source   = { first = 0x1D6FC }, -- italic alpha
                            filename = "texgyrebonummath-companion.otf",
                        },
                        {
                            source   = { first = 0x1D6C2 }, -- bold upright alpha
                            filename = "texgyrebonummath-companion.otf",
                        },
                        {
                            source   = { first = 0x1D736 }, -- bold italic alpha
                            filename = "texgyrebonummath-companion.otf",
                        },
                    },
                },
                presets.scripttocalligraphic { },
                presets.rsfstoscript         { rscale  = 0.98 },
                presets.rsfsuprighttoscript  { rscale  = 0.98 },
                presets.moderntocalligraphic { rscale  = 0.98 },
                presets.eulertocalligraphic  { rscale  = 0.98 },
                presets.xitsarabic           { rscale  = 1    },
                presets.fallbacks            { },
                presets.moveintegrals        { factor  = 1.5  },
                presets.moveitalics          { correct = true },
                presets.wipeanchors          { },
                presets.wipeitalics          { },
                {
                    -- We need to check these, are the tweaks necessary or not?
                    tweak = "dimensions",
                    list  = {
                        ["lowercasefraktur"] = {
                            width    = 1.25,
                            extend   = 1.25,
                            height   = 1.15,
                            depth    = 1.15,
                            squeeze  = 1.15,
                        },

                        ["lowercasescript"] = {
                            factor = 1.2,
                        },
                    },
                },
                {
                    tweak = "kerns",
                    list  = {
                        [0x002F]                = { topleft  = -0.2,  bottomright = -0.2 },
                        ["0x002F.variants.*"]   = { topleft  = -0.2,  bottomright = -0.2 },
                        [0x007D]                = { topright = -0.05, bottomright = -0.05 }, -- right brace variants
                        ["0x7D.variants.*"]     = { topright = -0.05, bottomright = -0.05 }, -- right brace variants
                        ["0x7D.parts.top"]      = { topright = -0.15,                     }, -- right brace top
                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.15 }, -- right brace bottom
                        [0x0029]                = { topright = -0.15, bottomright = -0.15 }, -- right parenthesis variants
                        ["0x29.variants.*"]     = { topright = -0.15, bottomright = -0.15 }, -- right parenthesis variants
                        ["0x29.parts.top"]      = { topright = -0.15,                     }, -- right parenthesis top
                        ["0x29.parts.bottom"]   = {                   bottomright = -0.15 }, -- right parenthesis bottom
                        [0x221A]                = { topright =  0.2,  bottomright =  0.2  }, -- radical
                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  },
                        ["0x221A.parts.top"]    = { topright =  0.2,                      },
                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  },
                        [0x27E9]                = { topright = -0.1,  bottomright = -0.1  }, -- angle
                        ["0x27E9.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
                        [0x27EB]                = { topright = -0.1,  bottomright = -0.1  },
                        ["0x27EB.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
                        --
                        [0x1D465] = { bottomright = -0.05, }, -- italic x (ic is too large)
                        [0x00393] = { bottomright = -0.30, }, -- upright Gamma
                        [0x1D43F] = { bottomright =  0.01, }, -- upright L
                        ["0x222B.parts.bottom"] = { bottomright = -0.20 }, -- int
                        ["0x222C.parts.bottom"] = { bottomright = -0.15 }, -- iint
                        ["0x222D.parts.bottom"] = { bottomright = -0.10 }, -- iiint
                        ["0x2A0C.parts.bottom"] = { bottomright = -0.05 }, -- iiiint
                    },
                },
                -- Accents are a mess. We migrate the extensibles from the combiners to the base accent
                -- and then need to tweak the width (which is auto set because it was zero with a large
                -- accent anchor offset). First we copy and fix.
                {
                    tweak = "extendaccents",
                },
                {
                    tweak = "flattenaccents",
                },
                {
                    tweak = "fixaccents", -- after flatten (zero width intefrerence)
                },
                {
                    tweak   = "radicaldegreeanchors",
                    list = {
                        [0x221A]                = { location = "left", hfactor  = .1, vfactor  = .3 },
                        ["0x221A.variants.*"]   = { location = "left", hfactor  = .1, vfactor  = .625 },
                        ["0x221A.variants.1"]   = { location = "left", hfactor  = .1, vfactor  = .575 },
                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = .1, vfactor  = 1.15 },
                    }
                },
                {
                    tweak = "dimensions",
                    list  = {
                        -- [0x007D]                = { topright = -0.05, bottomright = -0.05 }, -- right brace variants
                        ["0x7C"]                = { width = 1.4, xoffset=0.2 }, -- vertical bar
                        -- ["0x7C.variants.*"]     = { width = 1, extend = 2.4 }, -- vertical bar
                        -- ["0x7C.parts.top"]      = { ,                     }, -- vertical bar
                        -- ["0x7C.parts.bottom"]   = {                   bottomright = -0.15 }, -- vertical bar
                    },
                },
--                 {
--                     tweak = "fixaccents",
--                 },
                -- First we set the dimensions of the initial accent which started out as zero but we want
                -- a proper width.
                {
                    tweak = "dimensions",
                    list  = {
                        [0x00302] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widehat
                        [0x00303] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widetilde
                        [0x00306] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widebreve
                        [0x0030C] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widecheck
                    },
                },
                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
                -- as well as the variants here. But none for Bonum.
                -- We now copy these to the not wide slots so that we can set these to stretch as well,
                -- if only because it is less confusing and more consistent.
                {
                    tweak = "copyaccents",
                },
                -- So far for the accents.
                {
                    -- This one fakes margins to get larger/smaller accents with for example the
                    -- \widetilde.
                    tweak = "margins",
                    list  = {
                        [0x1D7DC] = { left = -.1,  right = -.1 }, -- doublestruck 4

                        [0x1D712] = { left = -.1,  right = -.1 }, -- italic chi
                        [0x1D713] = { left = -.1,  right = -.1 }, -- italic psi
                        [0x1D714] = { left = -.1,  right = -.1 }, -- italic omega

                        [0x003B1] = { left = -.1,  right = -.1 }, -- upright alpha
                        [0x003B3] = { left = -.1,  right = -.1 }, -- upright gamma
                        [0x003BA] = { left = -.1,  right = -.1 }, -- upright kappa
                        [0x003BC] = { left = -.1,  right = -.1 }, -- upright mu
                        [0x003C0] = { left = -.1,  right = -.1 }, -- upright pi
                        [0x003C3] = { left = -.1,  right = -.1 }, -- upright sigma
                        [0x003C5] = { left = -.1,  right = -.1 }, -- upright upsilon
                        [0x003C6] = { left = -.1,  right = -.1 }, -- upright phi
                        [0x003C8] = { left = -.1,  right = -.1 }, -- upright psi
                        [0x003C9] = { left = -.1,  right = -.1 }, -- upright omega

                        -- Greek lowercase sans (bold, italic) can be improved

                        [0x1D451] = { left = -.1,  right = -.1 }, -- italic d
                        [0x1D453] = { left = -.1,  right = -.1 }, -- italic f

                        [0x00394] = { left =  .1,  right =  .1 }, -- upright Delta
                        [0x003A3] = { left =  .1,  right =  .1 }, -- upright Sigma

                        [0x00046] = { left =  .1,  right =  .1 }, -- F
                        [0x0004C] = { left =  .1,  right =  .1 }, -- L
                        [0x00050] = { left =  .1,  right =  .1 }, -- P
                        [0x00053] = { left =  .1,  right =  .1 }, -- S
                        [0x00054] = { left =  .1,  right =  .1 }, -- T
                        [0x0005A] = { left =  .1,  right =  .1 }, -- Z

                        [0x1D43D] = { left = -.1,  right = -.1  }, -- italic J
                        [0x1D44B] = { left = -.05, right = -.05 }, -- italic X
                    },
                },
                {
                    -- The v could have a bit more sidebearing
                    tweak = "dimensions",
                    list  = {
                        ["0x1D463"] = { width = 1.075, }, -- italic v
                    },
                },
                {
                    tweak = "addprivates",
                },
                {
                    tweak = "addscripts",
                },
                {
                    tweak = "accentdimensions",
                },
                {
                    tweak = "addrules",
                },
                {
                    tweak    = "replacerules",
                 -- minus    = true, -- we have an extensible
                    fraction = { height = .244, yoffset = .757 },
                    radical  = { height = .244, yoffset = .754 },
                    stacker  = { height = .244, yoffset = .757 },
                },
                {
                    -- This tweak is only needed for the funny arrows and these now get properly
                    -- centered. (Could actually be done in the engine).
                    tweak = "addarrows",
                    -- These are for documentation purposed as they are the defaults anyway:
                    left  = 0.05,
                    right = 0.05,
                    slack = 0.10,
                    -- The equal doesn't really match the double arrows, as in plain etc, so it still
                    -- looks somewhat bad when zoomed in. This is the best we could do. Anyway, this
                    -- in only used when testing (forced) so it doesn't kick in normally.
                    list  = { [0x3D] = { squeeze = .85, yoffset = .0975 } }
                },
                {
                    -- Do we need these in the future?
                    -- Maybe a more general setup?
                    -- Maybe "reset llx"
                    tweak = "kernpairs",
                    list = {
                        [mathematics.tweaks.subsets.acenorsuvxz] = {
                            [0x1D453] = -.1, -- f
                            [0x1D457] = -.1, -- j
                        },
                        [mathematics.tweaks.subsets.bhklt] = {
                            [0x1D453] = -.1, -- f
                            [0x1D457] = -.1, -- j
                        },
                        [mathematics.tweaks.subsets.d] = {
                            [0x1D453] = -.075, -- f
                            [0x1D457] = -.075, -- j
                        },
                        [mathematics.tweaks.subsets.f] = {
                            -- [mathematics.tweaks.subsets.aceimnorsuvwxz] = -.05,
                            [mathematics.tweaks.subsets.gjqy] = -.15,
                            [0x1D453] = -.2, -- ff
                        },
                        [mathematics.tweaks.subsets.i] = {
                            [0x1D453] = -.2, -- f
                            [0x1D457] = -.2, -- j
                        },
                        [mathematics.tweaks.subsets.mw] = {
                            [0x1D453] = -.05, -- f
                            [0x1D457] = -.05, -- j
                        },
                        [mathematics.tweaks.subsets.p] = {
                            [0x1D453] = -.05, -- f
                            [0x1D457] = -.05, -- j
                        },
                        [0x1D45F] = { -- r
                            [0x1D460] = -.1, -- s
                        },
                    }
                },
                {
                    tweak   = "addbars",
                    advance = 0.475,
                },
                {
                    tweak = "addactuarian",
                },
                {
                    tweak = "addequals",
                },
                {
                    tweak   = "addfourier",
                    variant = 1,
                },
                {
                    tweak   = "addprimed",
                },
                -- this is the mkiv section
                {
                    tweak   = "emulatelmtx",
                    feature = "emulatelmtx",
                    comment = "this is for mkiv",
                },
            },
        },
        alternates = {
            dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" },
        },
        bigslots = {
            1, 3, 5, 7
        },
    },
}