termes-math.lfg /size: 9042 b    last modification: 2024-01-16 09: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   = "replacealphabets",
44                    list    = {
45                        {
46                            source   = { first = 0x02980 }, -- triplebar
47                            filename = "TeXGyreTermesMath-Companion.otf",
48                        },
49                    },
50                },
51                presets.scripttocalligraphic { },
52                presets.rsfstoscript         { rscale  = 0.97 },
53                presets.rsfsuprighttoscript  { rscale  = 0.97 },
54                presets.moderntocalligraphic { rscale  = 0.97 },
55                presets.eulertocalligraphic  { rscale  = 0.97 },
56                presets.xitsarabic           { rscale  = 0.88 },
57                presets.fallbacks            { },
58                presets.moveitalics          { correct = true },
59                presets.moveitalics          { correct = true, letters = true },
60                presets.moveintegrals        { factor  = 1.5  },
61                presets.wipeitalics          { },
62                {
63                    tweak = "checkaccents",
64                },
65                {
66                    tweak = "kerns",
67                    list  = {
68                        [0x002F]                = { topleft  = -0.2,  bottomright = -0.2  },
69                        ["0x7D.parts.top"]      = { topright = -0.15,                     }, -- right brace top
70                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.15 }, -- right brace bottom
71                        ["0x7D.variants.*"]     = { topright = -0.1,  bottomright = -0.1  }, -- right brace variants
72                        ["0x29.parts.top"]      = { topright = -0.1,                      }, -- right parenthesis top
73                        ["0x29.parts.bottom"]   = {                   bottomright = -0.1  }, -- right parenthesis bottom
74                        ["0x29.variants.*"]     = { topright = -0.15, bottomright = -0.15 }, -- right parenthesis variants
75                        ["0x221A.parts.top"]    = { topright =  0.2,                      }, -- right radical top
76                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  }, -- right radical bottom
77                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  }, -- right radical variants
78                        [0x27E9]                = { topright = -0.1,  bottomright = -0.1  }, -- angle
79                        ["0x27E9.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
80                        [0x27EB]                = { topright = -0.1,  bottomright = -0.1  },
81                        ["0x27EB.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
82                        --
83                        [0x00393] = { bottomright = -0.20, }, -- upright Gamma
84                        --
85                        ["0x222B.parts.bottom"] = { bottomright = -0.20 }, -- int
86                        ["0x222C.parts.bottom"] = { bottomright = -0.15 }, -- iint
87                        ["0x222D.parts.bottom"] = { bottomright = -0.10 }, -- iiint
88                        ["0x2A0C.parts.bottom"] = { bottomright = -0.05 }, -- iiiint
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                {
104                    tweak   = "radicaldegreeanchors",
105                    list = {
106                        [0x221A]                = { location = "left", hfactor  = 0.0, vfactor = 0.6 },
107                        ["0x221A.variants.*"]   = { location = "left", hfactor  = 0.0, vfactor = 0.6 },
108                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = 0.05, vfactor  = 1.1 },
109                    }
110                },
111                -- First we set the dimensions of the initial accent which started out as zero but we want
112                -- a proper width.
113                -- {
114                --     tweak = "dimensions",
115                --     list  = {
116                --         [0x00302] = { width = 1.4, anchor = 1.20, xoffset =  .10 }, -- widehat
117                --         [0x00303] = { width = 1.4, anchor = 1.20, xoffset =  .10 }, -- widetilde
118                --         [0x00306] = { width = 1.4, anchor = 1.20, xoffset =  .10 }, -- widebreve
119                --         [0x0030C] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widecheck
120                --     },
121                -- },
122                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
123                -- as well as the variants here. Not in termes.
124                -- We now copy these to the not wide slots so that we can set these to stretch as well,
125                -- if only because it is less confusing and more consistent.
126                {
127                    tweak = "copyaccents",
128                },
129                -- So far for the accents.
130                presets.addmathkerns { },
131                {
132                    tweak = "checkspacing",
133                },
134                {
135                    tweak = "addscripts",
136                },
137                {
138                    tweak = "accentdimensions",
139                },
140                {
141                    tweak = "addrules",
142                },
143                {
144                    tweak    = "replacerules",
145                    fraction = { height = .2, xleftoffset = .115, xrightoffset = .115, yoffset = .81 },
146                    radical  = { height = .2, leftoffset = .115, rightoffset = .115, yoffset = .81 },
147                    stacker  = { height = .2, xleftoffset = .115, xrightoffset = .115, yoffset = .81 },
148                },
149                -- {
150                --     tweak    = "replacerules",
151                --  -- minus    = true, -- we have an extensible
152                --     fraction = { height = .2, yoffset = .8 },
153                --     radical  = { height = .2, yoffset = .8 },
154                --     stacker  = { height = .2, yoffset = .8 },
155                -- },
156                -- {
157                --     tweak   = "addbars",
158                --     advance = 0.3,
159                -- },
160                {
161                    tweak = "addactuarian",
162                },
163                {
164                    tweak = "addprimed",
165                },
166                {
167                    tweak = "addequals",
168                },
169                {
170                    tweak = "addfourier",
171                    variant = 1,
172                },
173                -- this is the mkiv section
174                {
175                    tweak   = "emulatelmtx",
176                    feature = "emulatelmtx",
177                    comment = "this is for mkiv",
178                },
179            },
180        },
181        bigslots = {
182            1, 3, 5, 7
183        },
184        alternates = {
185            dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" },
186        },
187    },
188}
189