stixtwo-math.lfg /size: 13 Kb    last modification: 2024-01-16 10:22
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                -- MS: we need to check this, I moved it up
80                {
81                    tweak   = "replacealphabets",
82                    list    = {
83                        {
84                            source  = "uppercasescript",
85                            target  = "uppercasecalligraphic",
86                            unicode = "uppercasescript",
87                        },
88                        {
89                            source  = "uppercasescript",
90                            target  = "uppercasescript",
91                            feature = "ss01",
92                        },
93                        {
94                            source  = { first = 0xE17D, last = 0xE195 },
95                            target  = "uppercasesansgreek",
96                            unicode = "uppercasegreeknormal",
97                        },
98                        {
99                            source  = { first = 0xE196, last = 0xE1AE }, -- maybe last = E1B3
100                            target  = "lowercasesansgreek",
101                            unicode = "lowercasegreeknormal",
102                        },
103                        {
104                            source  = { first = 0xE1BF, last = 0xE1D7 },
105                            target  = "uppercaseitalicsansgreek",
106                            unicode = "uppercasegreekitalic",
107                        },
108                        {
109                            source  = { first = 0xE1D8, last = 0xE1F0 }, -- maybe last = E1F5
110                            target  = "lowercaseitalicsansgreek",
111                            unicode = "lowercasegreekitalic",
112                        },
113                    },
114                },
115                --
116                presets.scripttocalligraphic  { },
117                presets.rsfstoscript          { },
118                presets.rsfsuprighttoscript   { },
119                presets.moderntocalligraphic  { },
120                presets.eulertocalligraphic   { },
121                presets.xitsarabic            { rscale  = 0.95 },
122                presets.fallbacks             { },
123                presets.moveitalics           { correct = true },
124                presets.moveitalics           { correct = true, letters = true },
125                presets.moveintegrals         { },
126                presets.wipeitalics           { },
127                {
128                    tweak = "checkaccents",
129                },
130                -- Extensibles use .s1 (variant 1), so we cannot wipe all
131                {
132                    tweak = "wipevariants",
133                    list = {
134                        [0x20D6] = 3,
135                        [0x20D7] = 3,
136                        [0x20EE] = 3,
137                        [0x20EF] = 3,
138                    },
139                },
140                {
141                    tweak = "simplifykerns",
142                },
143                {
144                    tweak = "kerns",
145                    list  = {
146                        [0x002F]                = { topleft  = -0.2,  bottomright = -0.2  },
147                        ["0x7D.parts.top"]      = { topright = -0.15,                     }, -- right brace top
148                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.15 }, -- right brace bottom
149                        ["0x29.parts.top"]      = { topright = -0.1,                      }, -- right parenthesis top
150                        ["0x29.parts.bottom"]   = {                   bottomright = -0.1  }, -- right parenthesis bottom
151                        ["0x29.variants.*"]     = { topright = -0.2,  bottomright = -0.2  }, -- right parenthesis variants
152                        ["0x221A.parts.top"]    = { topright =  0.2,                      }, -- right radical top
153                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  }, -- right radical bottom
154                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  }, -- right radical variants
155                        [0x27E9]                = { topright = -0.1,  bottomright = -0.1  }, -- angle
156                        ["0x27E9.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
157                        [0x27EB]                = { topright = -0.1,  bottomright = -0.1  },
158                        ["0x27EB.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
159                        --
160                        ["0x222B.parts.bottom"] = { bottomright = -0.30 }, -- int
161                    },
162                },
163                -- Accents are a mess. We migrate the extensibles from the combiners to the base accent
164                -- and then need to tweak the width (which is auto set because it was zero with a large
165                -- accent anchor offset). First we copy and fix.
166                {
167                    tweak = "extendaccents",
168                },
169                {
170                    tweak   = "radicaldegreeanchors",
171                    list = {
172                        [0x221A]                = { location = "left", hfactor = 0.00, vfactor = 0.7 },
173                        ["0x221A.variants.*"]   = { location = "left", hfactor  = 0.00, vfactor = 0.55 },
174                        ["0x221A.variants.3"]   = { location = "left", hfactor  = 0.00, vfactor  = .525 },
175                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = 0.05, vfactor  = 1.00 },
176                    }
177                },
178                {
179                    tweak = "flattenaccents",
180                },
181                {
182                    tweak = "fixaccents",
183                },
184                -- First we set the dimensions of the initial accent which started out as zero but we want
185                -- a proper width.
186                -- {
187                --     tweak = "dimensions",
188                --     list  = {
189                --         [0x00302] = { width = 1.2, anchor = 1.10, xoffset = .05 }, -- widehat
190                --         [0x00303] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widetilde
191                --         [0x00306] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widebreve
192                --         [0x0030C] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widecheck
193                --     },
194                -- },
195                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
196                -- as well as the variants here.
197                {
198                    tweak = "dimensions",
199                    list  = {
200                     -- here we want to apply to all
201                        [0x020DB] = { yoffset =  0.025, height = .95, all = true }, -- widedddot : 0x20DB (self)
202                    },
203                },
204                -- We now copy these to the not wide slots so that we can set these to stretch as well,
205                -- if only because it is less confusing and more consistent.
206                {
207                    tweak = "copyaccents",
208                },
209                -- So far for the accents.
210                {
211                    tweak = "checkspacing",
212                },
213                {
214                    tweak = "addscripts",
215                },
216                {
217                    tweak = "accentdimensions",
218                },
219                {
220                    tweak = "addrules",
221                },
222                {
223                    tweak = "addarrows",
224                },
225                {
226                    tweak = "fixslashes",
227                },
228                {
229                    tweak    = "replacerules",
230                    minus    = {
231                        height      = .233,
232                        yoffset     = .768,
233                        leftoffset  = .08,
234                        rightoffset = .08,
235                    },
236                    fraction = {
237                        height  = .233,
238                        yoffset = .768,
239                    },
240                    radical  = {
241                        height      = .233,
242                        yoffset     = .768,
243                        leftoffset  = .08,
244                        rightoffset = .08,
245                    },
246                    stacker  = {
247                        height  = .233,
248                        yoffset = .768,
249                    },
250                },
251                {
252                    tweak = "addactuarian",
253                },
254                {
255                    tweak = "addfourier",
256                    variant = 1,
257                },
258                {
259                    tweak = "addprimed",
260                },
261                {
262                    tweak = "addparts",
263                    list  = {
264                        [0x21F4] = {
265                            horizontal = true,
266                            template   = 0x2192,
267                            sequence   = {
268                                { glyph = "first", factor = 2 },
269                                { glyph = 0x2218 },
270                                { glyph = "first", factor = 2 },
271                                { glyph = "last"  },
272                            }
273                        }
274                    }
275                },
276{
277    tweak   = "addbars",
278    advance = 0.3,
279    check   = true, -- only add triples
280},
281                -- this is the mkiv section
282                {
283                    tweak   = "emulatelmtx",
284                    feature = "emulatelmtx",
285                    comment = "this is for mkiv",
286                },
287            },
288        },
289        bigslots = {
290            1, 3, 5, 7
291        },
292    },
293}
294