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