libertinus-math.lfg /size: 9512 b    last modification: 2024-01-16 09:03
1-- Well, here we have yet another math font that does things differently: a huge prime in the ssty1
2-- slot (not an alternate but a single) and a small one in the normal location. Actually, only primes
3-- have an ssty feature. Now, because we have some magic with primes in ConTeXt we cannot use some
4-- fix-feature or just disable ssty, but we have to revert to a runtime fix. Lucky me that I didn't
5-- remove that hardly needed 'tweaks' mechanism yet.
6
7
8local common  = fonts.goodies.load("common-math.lfg")
9local presets = common.mathematics.tweaks.presets
10
11return {
12    name = "libertinus-math",
13    version = "1.00",
14    comment = "Goodies that complement libertinus.",
15    author = "Hans Hagen & Mikael Sundqvist",
16    copyright = "ConTeXt development team",
17    mathematics = {
18        parameters = {
19            FractionRuleThickness          =   50,
20            OverbarRuleThickness           =   50,
21            UnderbarRuleThickness          =   50,
22            AccentTopShiftUp               =  -35,
23            FlattenedAccentTopShiftUp      =  -35,
24            AccentBaseDepth                =   10,
25            DelimiterPercent               =   85,
26            DelimiterShortfall             =  400,
27            DelimiterDisplayPercent        =   90,
28            DelimiterDisplayShortfall      =  400,
29            PrimeShiftUp                   = "1.2*SuperscriptShiftUp",
30            PrimeShiftUpCramped            = "1.2*SuperscriptShiftUp",
31            -- RadicalDisplayStyleVerticalGap    = "RadicalVerticalGap", --170, 90
32            RadicalDisplayStyleVerticalGap = 50,-- 170
33            RadicalVerticalGap             = 50,-- 90
34        },
35        tweaks = {
36            aftercopying = {
37                {
38                    tweak    = "version",
39                    expected = "Version 7.040",
40                },
41                {
42                    tweak = "addmirrors",
43                },
44                -- we have a weird middle integral piece
45                {
46                    tweak = "dimensions",
47                    list  = {
48                        [0x23AE] = { xoffset =  -.19 },
49                    },
50                },
51                {
52                    tweak = "fixintegrals",
53                },
54                presets.scripttocalligraphic { },
55                presets.rsfstoscript         { rscale  = 0.97 },
56                presets.rsfsuprighttoscript  { rscale  = 0.97 },
57                presets.moderntocalligraphic { rscale  = 0.97 },
58                presets.eulertocalligraphic  { rscale  = 0.97 },
59                presets.xitsarabic           { rscale  = 0.85 },
60                presets.fallbacks            { },
61                presets.moveitalics          { correct = true },
62                presets.moveitalics          { correct = true, letters = true },
63                presets.moveintegrals        { factor = 1.5 },
64                presets.wipeitalics          { },
65                {
66                    tweak = "checkaccents",
67                },
68                {
69                    tweak = "simplifykerns",
70                },
71                {
72                    tweak = "kerns",
73                    list  = {
74                        [0x002F]                = { topleft  = -0.15, bottomright = -0.15 },
75                        ["0x7D.parts.top"]      = { topright = -0.2,                      }, -- right brace top
76                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.2  }, -- right brace bottom
77                        ["0x29.parts.top"]      = { topright = -0.15,                     }, -- right parenthesis top
78                        ["0x29.parts.bottom"]   = {                   bottomright = -0.15 }, -- right parenthesis bottom
79                        ["0x29.variants.*"]     = { topright = -0.15, bottomright = -0.15 }, -- right parenthesis variants
80                        ["0x221A.parts.top"]    = { topright =  0.2,                      }, -- right radical top
81                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  }, -- right radical bottom
82                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  }, -- right radical variants
83                        [0x27E9]                = { topright = -0.1,  bottomright = -0.1  }, -- angle
84                        ["0x27E9.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
85                        [0x27EB]                = { topright = -0.1,  bottomright = -0.1  },
86                        ["0x27EB.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
87                        --
88                        [0x00393] = { bottomright = -0.30, }, -- upright Gamma
89                    },
90                },
91                -- Accents are a mess. We migrate the extensibles from the combiners to the base accent
92                -- and then need to tweak the width (which is auto set because it was zero with a large
93                -- accent anchor offset). First we copy and fix.
94                {
95                    tweak = "extendaccents",
96                },
97                {
98                    tweak = "flattenaccents",
99                },
100                {
101                    tweak = "fixaccents",
102                },
103                -- First we set the dimensions of the initial accent which started out as zero but we want
104                -- a proper width.
105                -- {
106                --     tweak = "dimensions",
107                --     list  = {
108                --         [0x00302] = { width = 1.8, anchor = 1.40, xoffset =  .20 }, -- widehat
109                --         [0x00303] = { width = 2.0, anchor = 1.50, xoffset =  .30 }, -- widetilde
110                --         [0x00306] = { width = 1.6, anchor = 1.30, xoffset =  .15 }, -- widebreve
111                --         [0x0030C] = { width = 1.3, anchor = 1.15, xoffset = .075 }, -- widecheck
112                --     },
113                -- },
114                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
115                -- as well as the variants here. None in libertinus.
116                -- We now copy these to the not wide slots so that we can set these to stretch as well,
117                -- if only because it is less confusing and more consistent.
118                {
119                    tweak = "dimensions",
120                    list  = {
121                        [0x305] = { height = .8, yoffset = -.2  }, -- widehat
122                    },
123                },
124                {
125                    tweak = "copyaccents",
126                },
127                -- So far for the accents.
128                {
129                    tweak   = "radicaldegreeanchors",
130                    list = {
131                        [0x221A]                = { location = "left", hfactor  = .0, vfactor  = .625 },
132                        ["0x221A.variants.*"]   = { location = "left", hfactor  = .0, vfactor  = .5 },
133                        ["0x221A.variants.1"]   = { location = "left", hfactor  = .0, vfactor  = .55 },
134                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = .0, vfactor  = 1.15 },
135                    }
136                },
137                {
138                    tweak   = "fixprimes",
139                    factor  = 0.92,
140                    fake    = 0.75,
141                },
142                {
143                    tweak = "checkspacing",
144                },
145                {
146                    tweak = "addscripts",
147                },
148                {
149                    tweak = "accentdimensions",
150                },
151             -- {
152             --     tweak = "addrules",
153             -- },
154                {
155                    tweak   = "addbars",
156                    advance = 0.5,
157                },
158                {
159                    tweak    = "replacerules",
160                    minus    = {
161                        height      = .176,
162                        yoffset     = .825,
163                        leftoffset  = .065,
164                        rightoffset = .065,
165                    },
166                    fraction = {
167                        height  = .176,
168                        yoffset = .825,
169                    },
170                    radical  = {
171                        height      = .140,
172                        yoffset     = .6575,
173                        leftoffset  = .075,
174                        rightoffset = .075,
175                        yscale      = .8,
176                    },
177                    stacker  = {
178                        height  = .176,
179                        yoffset = .825,
180                    },
181                },
182                {
183                    tweak = "addactuarian",
184                },
185                {
186                    tweak = "addequals",
187                },
188                {
189                    tweak = "addfourier",
190                    variant = 1,
191                },
192                {
193                    tweak = "addprimed",
194                },
195                {
196                    -- needed for integrals (bad axis) and (less prominent) fences
197                    tweak = "setoptions",
198                    set   = { "ignorekerndimensions" }
199                },
200                -- this is the mkiv section
201                {
202                    tweak   = "emulatelmtx",
203                    feature = "emulatelmtx",
204                    comment = "this is for mkiv",
205                },
206            },
207        },
208        bigslots = {
209            1, 3, 5, 7
210        },
211    },
212}
213