termes-math.lfg /size: 9208 b    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.20 }
5local integral_bottom   = {  bottomright = -0.30 }
6
7return {
8    name = "termes-math",
9    version = "1.00",
10    comment = "Goodies that complement termes.",
11    author = "Hans Hagen & Mikael Sundqvist",
12    copyright = "ConTeXt development team",
13    mathematics = {
14        parameters = {
15            AccentTopShiftUp                  =  -15,
16            FlattenedAccentTopShiftUp         =  -15,
17            AccentBaseDepth                   =   50,
18            DelimiterPercent                  =   85,
19            DelimiterShortfall                =  400,
20            DelimiterDisplayPercent           =   90,
21            DelimiterDisplayShortfall         =  400,
22            DisplayOperatorMinHeight          = 1800, -- 1300 in font (only one)
23            SuperscriptShiftUp                =  310, -- 339
24            SubscriptShiftDown                =  200, -- 222
25            SubscriptShiftDownWithSuperscript = "1.40*SubscriptShiftDown", -- 1.5* in math-act
26            PrimeShiftUp                      = "1.35*SuperscriptShiftUp",
27            PrimeShiftUpCramped               = "1.35*SuperscriptShiftUp",
28        },
29        tweaks = {
30            aftercopying = {
31                {
32                    tweak    = "version",
33                    expected = "Version 1.543",
34                },
35                {
36                    tweak   = "fixprimes",
37                    factor  = 0.76,
38                },
39                {
40                    tweak = "addmirrors",
41                },
42                {
43                    tweak = "addcomposites",
44                },
45                {
46                    tweak   = "replacealphabets",
47                    list    = {
48                        {
49                            source   = { first = 0x02980 }, -- triplebar
50                            filename = "texgyretermesmathcompanion-regular.otf",
51                        },
52                    },
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.88 },
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 = "wipecues",
70                },
71                {
72                    tweak = "kerns",
73                    list  = {
74                        [0x002F]                = { topleft  = -0.2,  bottomright = -0.2  },
75                        ["0x7D.parts.top"]      = { topright = -0.15,                     }, -- right brace top
76                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.15 }, -- right brace bottom
77                        ["0x7D.variants.*"]     = { topright = -0.1,  bottomright = -0.1  }, -- right brace variants
78                        ["0x29.parts.top"]      = { topright = -0.1,                      }, -- right parenthesis top
79                        ["0x29.parts.bottom"]   = {                   bottomright = -0.1  }, -- 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.20, }, -- upright Gamma
90                        --
91                        ["0x222B.parts.bottom"] = { bottomright = -0.20 }, -- int
92                        ["0x222C.parts.bottom"] = { bottomright = -0.15 }, -- iint
93                        ["0x222D.parts.bottom"] = { bottomright = -0.10 }, -- iiint
94                        ["0x2A0C.parts.bottom"] = { bottomright = -0.05 }, -- iiiint
95                    },
96                },
97                -- Accents are a mess. We migrate the extensibles from the combiners to the base accent
98                -- and then need to tweak the width (which is auto set because it was zero with a large
99                -- accent anchor offset). First we copy and fix.
100                {
101                    tweak = "extendaccents",
102                },
103                {
104                    tweak = "flattenaccents",
105                },
106                {
107                    tweak = "fixaccents",
108                },
109                {
110                    tweak   = "radicaldegreeanchors",
111                    list = {
112                        [0x221A]                = { location = "left", hfactor  = 0.0, vfactor = 0.6 },
113                        ["0x221A.variants.*"]   = { location = "left", hfactor  = 0.0, vfactor = 0.6 },
114                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = 0.05, vfactor  = 1.1 },
115                    }
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.4, anchor = 1.20, xoffset =  .10 }, -- widehat
123                --         [0x00303] = { width = 1.4, anchor = 1.20, xoffset =  .10 }, -- widetilde
124                --         [0x00306] = { width = 1.4, anchor = 1.20, xoffset =  .10 }, -- widebreve
125                --         [0x0030C] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- 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. Not in termes.
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 = "copyaccents",
134                },
135                -- So far for the accents.
136                presets.addmathkerns { },
137                {
138                    tweak = "checkspacing",
139                },
140                {
141                    tweak = "addscripts",
142                },
143                {
144                    tweak = "accentdimensions",
145                },
146                {
147                    tweak = "addrules",
148                },
149                {
150                    tweak    = "replacerules",
151                    fraction = { height = .2, xleftoffset = .115, xrightoffset = .115, yoffset = .81 },
152                    radical  = { height = .2, leftoffset = .115, rightoffset = .115, yoffset = .81 },
153                    stacker  = { height = .2, xleftoffset = .115, xrightoffset = .115, yoffset = .81 },
154                },
155                -- {
156                --     tweak    = "replacerules",
157                --  -- minus    = true, -- we have an extensible
158                --     fraction = { height = .2, yoffset = .8 },
159                --     radical  = { height = .2, yoffset = .8 },
160                --     stacker  = { height = .2, yoffset = .8 },
161                -- },
162                -- {
163                --     tweak   = "addbars",
164                --     advance = 0.3,
165                -- },
166                {
167                    tweak = "addactuarian",
168                },
169                {
170                    tweak = "addprimed",
171                },
172                {
173                    tweak = "addequals",
174                },
175                {
176                    tweak = "addfourier",
177                    variant = 1,
178                },
179                -- this is the mkiv section
180                {
181                    tweak   = "emulatelmtx",
182                    feature = "emulatelmtx",
183                    comment = "this is for mkiv",
184                },
185            },
186        },
187        bigslots = {
188            1, 3, 5, 7
189        },
190        alternates = {
191            dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" },
192        },
193    },
194}
195