stixtwo-math.lfg /size: 14 Kb    last modification: 2025-02-21 11:03
1local common  = fonts.goodies.load("common-math.lfg")
2local presets = common.mathematics.tweaks.presets
3
4local integral_variants = {  bottomright = -0.4 }
5----- integral_top      = {  topright    =  0.05 }
6local integral_bottom   = {  bottomright = -0.35 }
7
8return {
9    name = "stix-two-math",
10    version = "1.00",
11    comment = "Goodies that complement stix two opentype.",
12    author = "Hans Hagen & Mikael Sundqvist",
13    copyright = "ConTeXt development team",
14    mathematics = {
15        alternates = {
16            lambdabar    = { feature = 'cv01', value = 1, comment = "Mathematical Alternative Lambda Bar" },
17            ramshorn     = { feature = 'cv02', value = 1, comment = "Mathematical Alternative Rams Horn" },
18            emptyset     = { feature = 'cv03', value = 1, comment = "Mathematical Alternative Empty Set" },
19            setminus     = { feature = 'cv04', value = 1, comment = "Mathematical Alternative Setminus" },
20            calligraphic = { feature = 'ss01', value = 1, comment = "Mathematical Alternative Calligraphic Characters" }, -- We do this differently
21            italic       = { feature = 'ss02', value = 1, comment = "Mathematical Alternative Lowercase Italic" },
22            barred       = { feature = 'ss03', value = 1, comment = "Mathematical Alternative Barred Characters" }, -- hbar, lambdabar etc
23            primes       = { feature = 'ss04', value = 1, comment = "Mathematical Alternative Primes" },            -- larger/lower primes, minute etc
24            arrow        = { feature = 'ss05', value = 1, comment = "Mathematical Alternative Smaller Arrows" },
25            narrower     = { feature = 'ss06', value = 1, comment = "Mathematical Alternative Narrower Elements" }, -- narrower/shorter element etc
26            small        = { feature = 'ss07', value = 1, comment = "Mathematical Alternative Smaller Operators" },
27            upright      = { feature = 'ss08', value = 1, comment = "Mathematical Alternative Upright Symbols" },   -- upright integrals etc.
28            negated      = { feature = 'ss09', value = 1, comment = "Mathematical Alternative Negated Symbols" },
29            relation     = { feature = 'ss10', value = 1, comment = "Mathematical Alternative Relations" },
30            negatedset   = { feature = 'ss11', value = 1, comment = "Mathematical Alternative Negated Set Symbols" },
31            propfrown    = { feature = 'ss12', value = 1, comment = "Mathematical Alternative Proportional and Frown" },
32            negsine      = { feature = 'ss13', value = 1, comment = "Mathematical Alternative Negated Sine Wave" },
33            intprod      = { feature = 'ss14', value = 1, comment = "Mathematical Alternative Interior Products" },
34            capcup       = { feature = 'ss15', value = 1, comment = "Mathematical Alternative Intersection and Union with serif" },
35            circled      = { feature = 'ss16', value = 1, comment = "Mathematical Alternative Circled Operators" },
36            simvar       = { feature = 'ss20', value = 1, comment = "Mathematical Alternative Similar and some more unrelated" },
37            -- demo features:
38            negated8774      = {
39                feature = 'ss09',
40                value   = 1,
41                comment = "Mathematical Alternative Negated 8774",
42                list    = { [8774] = true },
43            },
44            negated8775   = {
45                feature = 'ss09',
46                value   = 1,
47                comment = "Mathematical Alternative Negated 8775",
48                list    = { [8775] = true },
49            },
50        },
51        parameters = {
52            AccentBaseDepth                =   30,
53            FlattenedAccentTopShiftUp      =    0,
54            RadicalKernAfterDegree         = -500,
55            DelimiterPercent               =   85,
56            DelimiterShortfall             =  400,
57            DelimiterDisplayPercent        =   90,
58            DelimiterDisplayShortfall      =  400,
59            DisplayOperatorMinHeight       = 1800, -- 1800 in font
60            PrimeShiftUp                   = "1.3*SuperscriptShiftUp",
61            PrimeShiftUpCramped            = "1.3*SuperscriptShiftUp",
62            RadicalDisplayStyleVerticalGap = "RadicalVerticalGap", --170, 85
63         -- SuperscriptSnap                = 1000,
64         -- SubscriptSnap                  =  500,
65        },
66        tweaks = {
67            aftercopying = {
68                {
69                    tweak    = "version",
70                    expected = "Version 2.12 b168",
71                },
72                {
73                    tweak   = "fixprimes",
74                    factor  = 0.84,
75                },
76                {
77                    tweak = "addmirrors",
78                },
79                {
80                    tweak = "addcomposites",
81                },
82                -- MS: we need to check this, I moved it up
83                {
84                    tweak   = "replacealphabets",
85                    list    = {
86                        {
87                            source  = "uppercasescript",
88                            target  = "uppercasecalligraphic",
89                            unicode = "uppercasescript",
90                        },
91                        {
92                            source  = "uppercasescript",
93                            target  = "uppercasescript",
94                            feature = "ss01",
95                        },
96                        {
97                            source  = "uppercaseboldscript",
98                            target  = "uppercaseboldcalligraphic",
99                            unicode = "uppercasescriptbold",
100                        },
101                        {
102                            source  = "uppercaseboldscript",
103                            target  = "uppercaseboldscript",
104                            feature = "ss01",
105                        },
106                        {
107                            source  = { first = 0xE17D, last = 0xE195 },
108                            target  = "uppercasesansgreek",
109                            unicode = "uppercasegreeknormal",
110                        },
111                        {
112                            source  = { first = 0xE196, last = 0xE1AE }, -- maybe last = E1B3
113                            target  = "lowercasesansgreek",
114                            unicode = "lowercasegreeknormal",
115                        },
116                        {
117                            source  = { first = 0xE1BF, last = 0xE1D7 },
118                            target  = "uppercaseitalicsansgreek",
119                            unicode = "uppercasegreekitalic",
120                        },
121                        {
122                            source  = { first = 0xE1D8, last = 0xE1F0 }, -- maybe last = E1F5
123                            target  = "lowercaseitalicsansgreek",
124                            unicode = "lowercasegreekitalic",
125                        },
126                    },
127                },
128                {
129                    tweak    = "replacealphabets",
130                    filename = "TeXGyrePagellaMath.otf",
131                    list     = {
132                        { unicodes = { 0x007C, 0x2223, 0x2016, 0x2980, 0x007C } }, -- single single double triple
133                    }
134                },
135                presets.scripttocalligraphic  { },
136                presets.rsfstoscript          { },
137                presets.rsfsuprighttoscript   { },
138                presets.moderntocalligraphic  { },
139                presets.eulertocalligraphic   { },
140                presets.xitsarabic            { rscale  = 0.95 },
141                presets.fallbacks             { },
142                presets.moveitalics           { correct = true },
143                presets.moveitalics           { correct = true, letters = true },
144                presets.moveintegrals         { },
145                presets.wipeitalics           { },
146                {
147                    tweak = "checkaccents",
148                },
149                {
150                    tweak = "wipecues",
151                },
152                -- Extensibles use .s1 (variant 1), so we cannot wipe all
153                {
154                    tweak = "wipevariants",
155                    list = {
156                        [0x20D6] = 3,
157                        [0x20D7] = 3,
158                        [0x20EE] = 3,
159                        [0x20EF] = 3,
160                    },
161                },
162                {
163                    tweak = "simplifykerns",
164                },
165                {
166                    tweak = "kerns",
167                    list  = {
168                        [0x002F]                = { topleft  = -0.2,  bottomright = -0.2  },
169                        ["0x7D.parts.top"]      = { topright = -0.15,                     }, -- right brace top
170                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.15 }, -- right brace bottom
171                        ["0x29.parts.top"]      = { topright = -0.1,                      }, -- right parenthesis top
172                        ["0x29.parts.bottom"]   = {                   bottomright = -0.1  }, -- right parenthesis bottom
173                        ["0x29.variants.*"]     = { topright = -0.2,  bottomright = -0.2  }, -- right parenthesis variants
174                        ["0x221A.parts.top"]    = { topright =  0.2,                      }, -- right radical top
175                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  }, -- right radical bottom
176                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  }, -- right radical variants
177                        [0x27E9]                = { topright = -0.1,  bottomright = -0.1  }, -- angle
178                        ["0x27E9.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
179                        [0x27EB]                = { topright = -0.1,  bottomright = -0.1  },
180                        ["0x27EB.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
181                        --
182                        [0x1D45F]               = { bottomright = -.20 },  -- italic r
183                        ["0x222B.parts.bottom"] = { bottomright = -0.30 }, -- int
184                    },
185                },
186                -- Accents are a mess. We migrate the extensibles from the combiners to the base accent
187                -- and then need to tweak the width (which is auto set because it was zero with a large
188                -- accent anchor offset). First we copy and fix.
189                {
190                    tweak = "extendaccents",
191                },
192                {
193                    tweak   = "radicaldegreeanchors",
194                    list = {
195                        [0x221A]                = { location = "left", hfactor = 0.00, vfactor = 0.7 },
196                        ["0x221A.variants.*"]   = { location = "left", hfactor  = 0.00, vfactor = 0.55 },
197                        ["0x221A.variants.3"]   = { location = "left", hfactor  = 0.00, vfactor  = .525 },
198                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = 0.05, vfactor  = 1.00 },
199                    }
200                },
201                {
202                    tweak = "flattenaccents",
203                },
204                {
205                    tweak = "fixaccents",
206                },
207                -- First we set the dimensions of the initial accent which started out as zero but we want
208                -- a proper width.
209                -- {
210                --     tweak = "dimensions",
211                --     list  = {
212                --         [0x00302] = { width = 1.2, anchor = 1.10, xoffset = .05 }, -- widehat
213                --         [0x00303] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widetilde
214                --         [0x00306] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widebreve
215                --         [0x0030C] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widecheck
216                --     },
217                -- },
218                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
219                -- as well as the variants here.
220                {
221                    tweak = "dimensions",
222                    list  = {
223                     -- here we want to apply to all
224                        [0x020DB] = { yoffset =  0.025, height = .95, all = true }, -- widedddot : 0x20DB (self)
225                    },
226                },
227                -- We now copy these to the not wide slots so that we can set these to stretch as well,
228                -- if only because it is less confusing and more consistent.
229                {
230                    tweak = "copyaccents",
231                },
232                -- So far for the accents.
233                {
234                    tweak = "checkspacing",
235                },
236                {
237                    tweak = "addscripts",
238                },
239                {
240                    tweak = "accentdimensions",
241                },
242                {
243                    tweak = "addrules",
244                },
245                {
246                    tweak = "addarrows",
247                },
248                {
249                    tweak = "fixslashes",
250                },
251                {
252                    tweak    = "replacerules",
253                    minus    = {
254                        height      = .233,
255                        yoffset     = .768,
256                        leftoffset  = .08,
257                        rightoffset = .08,
258                    },
259                    fraction = {
260                        height  = .233,
261                        yoffset = .768,
262                    },
263                    radical  = {
264                        height      = .233,
265                        yoffset     = .768,
266                        leftoffset  = .08,
267                        rightoffset = .08,
268                    },
269                    stacker  = {
270                        height  = .233,
271                        yoffset = .768,
272                    },
273                },
274                {
275                    tweak = "addactuarian",
276                },
277                {
278                    tweak = "addfourier",
279                    variant = 1,
280                },
281                {
282                    tweak = "addprimed",
283                },
284                {
285                    tweak = "addparts",
286                    list  = {
287                        [0x21F4] = {
288                            horizontal = true,
289                            template   = 0x2192,
290                            sequence   = {
291                                { glyph = "first", factor = 2 },
292                                { glyph = 0x2218 },
293                                { glyph = "first", factor = 2 },
294                                { glyph = "last"  },
295                            }
296                        }
297                    }
298                },
299{
300    tweak   = "addbars",
301    advance = 0.3,
302    check   = true, -- only add triples
303},
304                -- this is the mkiv section
305                {
306                    tweak   = "emulatelmtx",
307                    feature = "emulatelmtx",
308                    comment = "this is for mkiv",
309                },
310            },
311        },
312        bigslots = {
313            1, 3, 5, 7
314        },
315    },
316}
317