libertinus-math.lfg /size: 9 Kb    last modification: 2025-02-21 11: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 add extensiblesd when they are not there.
45                {
46                    tweak = "fixintegrals",
47                },
48-- {
49--     tweak = "dimensions",
50--     list  = {
51--         [0x302] = { width = 0 }, --hat
52--         [0x303] = { width = 0 }, --tilde
53--     },
54-- },
55                presets.scripttocalligraphic { },
56                presets.rsfstoscript         { rscale  = 0.97 },
57                presets.rsfsuprighttoscript  { rscale  = 0.97 },
58                presets.moderntocalligraphic { rscale  = 0.97 },
59                presets.eulertocalligraphic  { rscale  = 0.97 },
60                presets.xitsarabic           { rscale  = 0.85 },
61                presets.fallbacks            { },
62                presets.moveitalics          { correct = true },
63                presets.moveitalics          { correct = true, letters = true },
64                presets.moveintegrals        { factor = 1.5 },
65                presets.wipeitalics          { },
66                {
67                    tweak = "checkaccents",
68                },
69                {
70                    tweak = "simplifykerns",
71                },
72                {
73                    tweak = "kerns",
74                    list  = {
75                        [0x002F]                = { topleft  = -0.15, bottomright = -0.15 },
76                        ["0x7D.parts.top"]      = { topright = -0.2,                      }, -- right brace top
77                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.2  }, -- right brace bottom
78                        ["0x29.parts.top"]      = { topright = -0.15,                     }, -- right parenthesis top
79                        ["0x29.parts.bottom"]   = {                   bottomright = -0.15 }, -- right parenthesis bottom
80                        ["0x29.variants.*"]     = { topright = -0.15, bottomright = -0.15 }, -- right parenthesis variants
81                        ["0x221A.parts.top"]    = { topright =  0.2,                      }, -- right radical top
82                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  }, -- right radical bottom
83                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  }, -- right radical variants
84                        [0x27E9]                = { topright = -0.1,  bottomright = -0.1  }, -- angle
85                        ["0x27E9.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
86                        [0x27EB]                = { topright = -0.1,  bottomright = -0.1  },
87                        ["0x27EB.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
88                        --
89                        [0x00393] = { bottomright = -0.30, }, -- upright Gamma
90                    },
91                },
92                -- Accents are a mess. We migrate the extensibles from the combiners to the base accent
93                -- and then need to tweak the width (which is auto set because it was zero with a large
94                -- accent anchor offset). First we copy and fix.
95                {
96                    tweak = "dimensions",
97                    list  = {
98--                         [0x302] = { width = 0 }, --hat
99--                         [0x303] = { width = 0 }, --tilde
100                        -- The middle pice is shifted compared to the larger pieces.
101                        -- And the integral stick out down left.
102                        -- We fix the width and shift.
103                        [0x2320] = { width = 1.2, xoffset = 0.191 },
104                        [0x23AE] = { width = 1.2, }, --  bug
105                        [0x2321] = { width = 1.2, xoffset = 0.191 },
106                    },
107                },
108                {
109                    tweak = "extendaccents",
110                },
111                {
112                    tweak = "flattenaccents",
113                },
114                {
115                    tweak = "fixaccents",
116                },
117                -- First we set the dimensions of the initial accent which started out as zero but we want
118                -- a proper width.
119                -- {
120                --     tweak = "dimensions",
121                --     list  = {
122                --         [0x00302] = { width = 1.8, anchor = 1.40, xoffset =  .20 }, -- widehat
123                --         [0x00303] = { width = 2.0, anchor = 1.50, xoffset =  .30 }, -- widetilde
124                --         [0x00306] = { width = 1.6, anchor = 1.30, xoffset =  .15 }, -- widebreve
125                --         [0x0030C] = { width = 1.3, anchor = 1.15, xoffset = .075 }, -- widecheck
126                --     },
127                -- },
128                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
129                -- as well as the variants here. None in libertinus.
130                -- We now copy these to the not wide slots so that we can set these to stretch as well,
131                -- if only because it is less confusing and more consistent.
132                {
133                    tweak = "dimensions",
134                    list  = {
135                        [0x305] = { height = .8, yoffset = -.2  }, -- widehat
136                    },
137                },
138                {
139                    tweak = "copyaccents",
140                },
141                -- So far for the accents.
142                {
143                    tweak   = "radicaldegreeanchors",
144                    list = {
145                        [0x221A]                = { location = "left", hfactor  = .0, vfactor  = .625 },
146                        ["0x221A.variants.*"]   = { location = "left", hfactor  = .0, vfactor  = .5 },
147                        ["0x221A.variants.1"]   = { location = "left", hfactor  = .0, vfactor  = .55 },
148                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = .0, vfactor  = 1.15 },
149                    }
150                },
151                {
152                    tweak   = "fixprimes",
153                    factor  = 0.92,
154                    fake    = 0.75,
155                },
156                {
157                    tweak = "checkspacing",
158                },
159                {
160                    tweak = "addscripts",
161                },
162                {
163                    tweak = "accentdimensions",
164                },
165             -- {
166             --     tweak = "addrules",
167             -- },
168                {
169                    tweak   = "addbars",
170                    advance = 0.5,
171                },
172                {
173                    tweak    = "replacerules",
174                    minus    = {
175                        height      = .176,
176                        yoffset     = .825,
177                        leftoffset  = .065,
178                        rightoffset = .065,
179                    },
180                    fraction = {
181                        height  = .176,
182                        yoffset = .825,
183                    },
184                    radical  = {
185                        height      = .140,
186                        yoffset     = .6575,
187                        leftoffset  = .075,
188                        rightoffset = .075,
189                        yscale      = .8,
190                    },
191                    stacker  = {
192                        height  = .176,
193                        yoffset = .825,
194                    },
195                },
196                {
197                    tweak = "addactuarian",
198                },
199                {
200                    tweak = "addequals",
201                },
202                {
203                    tweak = "addfourier",
204                    variant = 1,
205                },
206                {
207                    tweak = "addprimed",
208                },
209                {
210                    -- needed for integrals (bad axis) and (less prominent) fences
211                    tweak = "setoptions",
212                    set   = { "ignorekerndimensions" }
213                },
214                -- this is the mkiv section
215                {
216                    tweak   = "emulatelmtx",
217                    feature = "emulatelmtx",
218                    comment = "this is for mkiv",
219                },
220            },
221        },
222        bigslots = {
223            1, 3, 5, 7
224        },
225    },
226}
227