ebgaramond-math.lfg /size: 12 Kb    last modification: 2025-02-21 11:03
1local common  = fonts.goodies.load("common-math.lfg")
2local presets = common.mathematics.tweaks.presets
3
4return {
5    name = "ebgaramond",
6    version = "1.00",
7    comment = "Goodies that complement ebgaramond.",
8    author = "Hans Hagen & Mikael Sundqvist",
9    copyright = "ConTeXt development team",
10    mathematics = {
11        parameters = {
12            FractionRuleThickness             =  60,
13            OverbarRuleThickness              =  60,
14            UnderbarRuleThickness             =  60,
15            AccentTopShiftUp                  = -25, -- was 075
16            FlattenedAccentBaseHeight         = 620, -- 420 in font (maybe some misunderstanding in the font regarding accents and heights)
17            FlattenedAccentTopShiftUp         = -25, -- was 075
18            AccentBaseDepth                   =  75,
19            DelimiterPercent                  =  85,
20            DelimiterShortfall                = 400,
21            DelimiterDisplayPercent           =  90,
22            DelimiterDisplayShortfall         = 400,
23            SubscriptShiftDown                = 200, -- 250 in font
24            SuperscriptShiftUp                = 400, -- 430 in font
25            SubscriptShiftDownWithSuperscript = "1.25*SubscriptShiftDown", -- trial and error
26            SubSuperscriptGapMin              = 200, -- 250 in font
27            PrimeShiftUp                      = "1.2*SuperscriptShiftUp",
28            PrimeShiftUpCramped               = "1.2*SuperscriptShiftUp",
29            PrimeBaselineDropMax              = "0.5*SuperscriptBaselineDropMax",
30            RadicalDisplayStyleVerticalGap = "RadicalVerticalGap", --150, 65
31        },
32        tweaks = {
33            aftercopying = {
34                {
35                    tweak    = "version",
36                    expected = "Version 2019-08-16",
37                },
38                {
39                    tweak   = "fixprimes",
40                    factor  = 0.73,
41                },
42                {
43                    tweak = "addmirrors",
44                },
45                {
46                    tweak = "addcomposites",
47                },
48                presets.scripttocalligraphic { },
49                presets.rsfstoscript         { rscale = 0.95  },
50                presets.rsfsuprighttoscript  { rscale = 0.95  },
51                presets.moderntocalligraphic { rscale = 0.95  },
52                presets.eulertocalligraphic  { rscale = 0.95  },
53                presets.xitsarabic           { rscale = 0.80  },
54                presets.fallbacks            { },
55                presets.moveitalics          { correct = true },
56                presets.moveitalics          { correct = true, letters = true },
57                presets.moveintegrals        { factor  = 1.5  },
58                presets.wipeitalics          { },
59                {
60                    tweak = "checkaccents",
61                },
62                {
63                    tweak = "simplifykerns",
64                },
65                {
66                    tweak = "topanchors",
67                    list  = {
68                        [0x1D453] = 0.88, -- italic f
69                    },
70                },
71                {
72                    tweak = "dimensions",
73                    list  = {
74                        [0x1D453] = {  width = 1.1 }, -- italic f
75                    },
76                },
77                {
78                    tweak = "kerns",
79                    list  = {
80                        [0x002F]                = { topleft  = -0.2,  bottomright = -0.2  },
81                        ["0x7D.parts.top"]      = { topright = -0.15,                     }, -- right brace top
82                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.15 }, -- right brace bottom
83                        ["0x7D.variants.*"]     = { topright = -0.05, bottomright = -0.05 }, -- right brace variants
84                        ["0x29.parts.top"]      = { topright = -0.25,                     }, -- right parenthesis top
85                        ["0x29.parts.bottom"]   = {                   bottomright = -0.25 }, -- right parenthesis bottom
86                        ["0x29.variants.*"]     = { topright = -0.2,  bottomright = -0.2  }, -- right parenthesis variants
87                        ["0x221A.parts.top"]    = { topright =  0.2,                      }, -- right radical top
88                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  }, -- right radical bottom
89                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  }, -- right radical variants                        -- angle
90                        [0x27E9]                = { topright = -0.1,  bottomright = -0.1  },
91                        ["0x27E9.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
92                        [0x27EB]                = { topright = -0.1,  bottomright = -0.1  },
93                        ["0x27EB.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
94
95                        [0x00051]               = { bottomright = 0.25 }, -- Upright Q
96                        [0x0211A]               = { bottomright = 0.2  }, -- Blackboard bold Q
97                        [0x1D410]               = { bottomright = 0.2  }, -- Bold Q
98                        [0x1D478]               = { bottomright = 0.05 }, -- Bold Q
99                        [0x1D5B0]               = { bottomright = 0.05 }, -- Sans Q
100                    },
101                },
102                {
103                    -- to be considered
104                    -- tweak = "kernpairs",
105                    list = {
106                        [mathematics.tweaks.subsets.gjqy] = {
107                            [mathematics.tweaks.subsets.f] = -.1,
108                            [0x1D70C]                      = -.1, -- italic \rho
109                        },
110                        [mathematics.tweaks.subsets.bhklt] = {
111                            [mathematics.tweaks.subsets.f] = -.25,
112                            [0x1D70C]                      = -.25, -- italic \rho
113                        },
114                        [mathematics.tweaks.subsets.d] = {
115                            [mathematics.tweaks.subsets.f] = -.25,
116                            [0x1D70C]                      = -.25, -- italic \rho
117                        },
118                        [mathematics.tweaks.subsets.f] = {
119                            [mathematics.tweaks.subsets.f] = -.25,
120                            [0x1D70C]                      = -.25, -- italic \rho
121                            [mathematics.tweaks.subsets.gjqy]  = -.25,
122                            [mathematics.tweaks.subsets.bhklt] = -.1,
123                            [mathematics.tweaks.subsets.d] = -.25,
124                            [mathematics.tweaks.subsets.i] = -.25,
125                            [mathematics.tweaks.subsets.mw] = -.25,
126                            [mathematics.tweaks.subsets.p] = -.25,
127                            [mathematics.tweaks.subsets.acenorsuvxz] = -.25,
128                            [mathematics.tweaks.subsets.dotless] = -.25,
129                        },
130                        [mathematics.tweaks.subsets.i] = {
131                            [mathematics.tweaks.subsets.f] = -.25,
132                            [0x1D70C]                      = -.25, -- italic \rho
133                        },
134                        [mathematics.tweaks.subsets.mw] = {
135                            [mathematics.tweaks.subsets.f] = -.25,
136                            [0x1D70C]                      = -.25, -- italic \rho
137                        },
138                        [mathematics.tweaks.subsets.p] = {
139                            [mathematics.tweaks.subsets.f] = -.25,
140                            [0x1D70C]                      = -.25, -- italic \rho
141                        },
142                        [mathematics.tweaks.subsets.acenorsuvxz] = {
143                            [mathematics.tweaks.subsets.f] = -.25,
144                            [0x1D70C]                      = -.25, -- italic \rho
145                        },
146                        [mathematics.tweaks.subsets.dotless] = {
147                            [mathematics.tweaks.subsets.f] = -.25,
148                            [0x1D70C]                      = -.25, -- italic \rho
149                        },
150                    },
151                },
152                -- Accents are a mess. We migrate the extensibles from the combiners to the base accent
153                -- and then need to tweak the width (which is auto set because it was zero with a large
154                -- accent anchor offset). First we copy and fix.
155                {
156                    tweak = "extendaccents",
157                },
158                {
159                    tweak = "flattenaccents",
160                },
161                {
162                    tweak = "radicaldegreeanchors",
163                    list  = {
164                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = .0, vfactor  = 1.0 },
165                    }
166                },
167                -- First we set the dimensions of the initial accent which started out as zero but we want
168                -- a proper width. None in ebgaramond.
169                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
170                -- as well as the variants here. None in ebgaramond
171                -- We now copy these to the not wide slots so that we can set these to stretch as well,
172                -- if only because it is less confusing and more consistent.
173                {
174                    tweak = "copyaccents",
175                },
176                {
177                    tweak = "checkspacing",
178                },
179                {
180                    tweak = "addscripts",
181                },
182                {
183                    tweak = "accentdimensions",
184                },
185                {
186                    tweak = "addrules",
187                },
188                {
189                    tweak    = "replacerules",
190                    minus = {
191                        leftoffset  = .075,
192                        rightoffset = .075,
193                    },
194                    fraction = {
195                        height  = .2,
196                        yoffset = .8,
197                    },
198                    radical = {
199                        height      = .2,
200                        yoffset     = .66,
201                        leftoverlap = .020,
202                        leftoffset  = .075, -- todo
203                        rightoffset = .075, -- todo
204                        yscale      = .84,
205                    },
206                    stacker = {
207                        height  = .2,
208                        yoffset = .8,
209                    },
210                },
211                {
212                    tweak   = "addbars",
213                    advance = 0.6,
214                },
215                {
216                    tweak = "addactuarian",
217                },
218                {
219                    tweak = "addequals",
220                },
221                {
222                    tweak = "addfourier",
223                    variant = 2,
224                },
225                {
226                    tweak = "addprimed",
227                },
228                -- this is the mkiv section
229                {
230                    tweak   = "emulatelmtx",
231                    feature = "emulatelmtx",
232                    comment = "this is for mkiv",
233                },
234                {
235                    tweak = "diagnose",
236                },
237            },
238        },
239        alternates = {
240            partial        = { feature = 'ss02', value = 1, comment = "Curved partial" },
241            semibold       = { feature = 'ss04', value = 1, comment = "Semibold" },
242            extrabold      = { feature = 'ss05', value = 1, comment = "Extrabold" },
243            hbar           = { feature = 'ss06', value = 1, comment = "Horizontal bar for h-bar" },
244            integral       = { feature = 'ss07', value = 1, comment = "A more slanted integral sign" },
245            tilde          = { feature = 'ss09', value = 1, comment = "A tilde variant" },
246            outbendingh    = { feature = 'ss10', value = 1, comment = "Out-bending h" },
247            largeoperators = { feature = 'ss11', value = 1, comment = "Larger operators" },
248        },
249        bigslots = {
250            1, 3, 5, 7
251        },
252    },
253}
254