cambria-math.lfg /size: 9129 b    last modification: 2025-02-21 11:03
1local common  = fonts.goodies.load("common-math.lfg")
2local presets = common.mathematics.tweaks.presets
3
4return {
5    name = "cambria-math",
6    version = "1.00",
7    comment = "Goodies that complement cambria.",
8    author = "Hans Hagen & Mikael Sundqvist",
9    copyright = "ConTeXt development team",
10    mathematics = {
11        parameters = {
12            AccentBaseDepth          =  300,
13            DelimiterPercent         =   90,
14            DelimiterShortfall       =  400,
15            DisplayOperatorMinHeight = 2800, -- 2500 in font
16            PrimeShiftUp             = "1.25*SuperscriptShiftUp",
17            PrimeShiftUpCramped      = "1.25*SuperscriptShiftUp",
18            RadicalVerticalGap             = 100, -- "RadicalVerticalGap", --345, 166
19            RadicalDisplayStyleVerticalGap = 200, -- "RadicalVerticalGap", --345, 166
20        },
21        tweaks = {
22            aftercopying = {
23                {
24                    tweak = "addmirrors",
25                },
26                {
27                    tweak = "addcomposites",
28                },
29                presets.scripttocalligraphic { },
30                presets.rsfstoscript         { rscale  = 0.97 },
31                presets.rsfsuprighttoscript  { rscale  = 0.97 },
32                presets.moderntocalligraphic { rscale  = 0.97 },
33                presets.eulertocalligraphic  { rscale  = 0.97 },
34                presets.xitsarabic           { rscale  = 0.95 },
35                presets.fallbacks            { },
36                presets.moveitalics          { correct = true },
37                presets.moveitalics          { correct = true, letters = true },
38                presets.moveintegrals        { factor = 1.5}, -- needs checking
39                presets.wipeitalics          { },
40                presets.pagellaradical       { },
41                {
42                    tweak = "simplifykerns",
43                },
44                {
45                    tweak = "kerns",
46                    list  = {
47                        [0x002F]                = { topleft  = -0.2,  bottomright = -0.2 },
48                        ["0x002F.variants.*"]   = { topleft  = -0.2,  bottomright = -0.2 },
49                        --
50                        [0x007D]                = { topright = -0.05, bottomright = -0.05 }, -- right brace variants
51                        ["0x7D.variants.*"]     = { topright = -0.10, bottomright = -0.10 }, -- right brace variants
52                        ["0x7D.parts.top"]      = { topright = -0.10,                     }, -- right brace top
53                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.10 }, -- right brace bottom
54                        [0x0029]                = { topright = -0.15, bottomright = -0.15 }, -- right parenthesis variants
55                        ["0x29.variants.*"]     = { topright = -0.15, bottomright = -0.15 }, -- right parenthesis variants
56                        ["0x29.parts.top"]      = { topright = -0.15,                     }, -- right parenthesis top
57                        ["0x29.parts.bottom"]   = {                   bottomright = -0.15 }, -- right parenthesis bottom
58                        [0x221A]                = { topright =  0.2,  bottomright =  0.2  }, -- radical
59                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  },
60                        ["0x221A.parts.top"]    = { topright =  0.2,                      },
61                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  },
62                        [0x27E9]                = { topright = -0.1,  bottomright = -0.1  }, -- angle
63                        ["0x27E9.variants.*"]   = { topright = -0.3,  bottomright = -0.3  },
64                        [0x27EB]                = { topright = -0.1,  bottomright = -0.1  },
65                        ["0x27EB.variants.*"]   = { topright = -0.2,  bottomright = -0.2  },
66                        -- Keep as example. not needed in cambria (after all it is the reference):
67                        [0x2A0C] = { bottomright = -0.1 }, -- iiiint does not have any ic
68                    },
69                },
70
71                -- Accents are a mess. We migrate the extensibles from the combiners to the base accent
72                -- and then need to tweak the width (which is auto set because it was zero with a large
73                -- accent anchor offset). First we copy and fix.
74                {
75                    tweak = "extendaccents",
76                },
77                {
78                    tweak = "fixaccents",
79                },
80                {
81                    tweak   = "radicaldegreeanchors",
82                    list = {
83                        [0x221A]                = { location = "left", hfactor  = -0.15, vfactor  = 0.75 },
84                        ["0x221A.variants.*"]   = { location = "left", hfactor  = -0.1,  vfactor  = 0.15 },
85                        ["0x221A.variants.1"]   = { location = "left", hfactor  = -0.1,  vfactor  = 0.55 },
86                        ["0x221A.variants.2"]   = { location = "left", hfactor  = -0.1,  vfactor  = 0.375 },
87                        ["0x221A.variants.3"]   = { location = "left", hfactor  = -0.1,  vfactor  = 0.275 },
88                        ["0x221A.variants.4"]   = { location = "left", hfactor  = -0.1,  vfactor  = 0.22 },
89                        ["0x221A.variants.5"]   = { location = "left", hfactor  = -0.1,  vfactor  = 0.175 },
90                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = -0.1,  vfactor  = 0.95 },
91                    }
92                },
93{
94    tweak = "wipevariants",
95    list = {
96        [0x221A] = 1,
97    },
98},
99                -- First we set the dimensions of the initial accent which started out as zero but we want
100                -- a proper width.
101                -- {
102                --     tweak = "dimensions",
103                --     list  = {
104                --         [0x00302] = { width = 2, anchor = 1.5, xoffset = .25 }, -- widehat
105                --         [0x00303] = { width = 2, anchor = 1.5, xoffset = .25 }, -- widetilde
106                --         [0x00306] = { width = 2, anchor = 1.5, xoffset = .25 }, -- widebreve
107                --         [0x0030C] = { width = 2, anchor = 1.5, xoffset = .25 }, -- widecheck
108                --     },
109                -- },
110                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
111                -- as well as the variants here.
112                {
113                    tweak = "dimensions",
114                    list  = {
115                        -- here we want to apply to all
116                        [0x020DB] = { yoffset =  -0.03,    height = .95, all = true }, -- widedddot : 0x20DB (self)
117                    },
118                },
119                -- We now copy these to the not wide slots so that we can set these to stretch as well,
120                -- if only because it is less confusing and more consistent.
121                {
122                    tweak = "copyaccents",
123                },
124                -- So far for the accents.
125
126                {
127                    tweak   = "fixprimes",
128                    factor  = 0.83,
129                    fake    = 0.8,
130                },
131                {
132                    tweak = "checkspacing",
133                },
134                {
135                    tweak = "addscripts",
136                },
137                {
138                    tweak = "accentdimensions",
139                    list  = { "over", "under" },
140                },
141                {
142                    tweak = "addrules",
143                },
144                {
145                    tweak    = "replacerules",
146                    minus = {
147                        leftoffset  = .0925,
148                        rightoffset = .0925,
149                    },
150                    fraction = {
151                        height  = .204,
152                        yoffset = .796,
153                    },
154                    radical  = {
155                        height     = .204,
156                        yoffset    = .796,
157                        leftoffset  = .0925,
158                        rightoffset = .0925,
159                    },
160                    stacker  = {
161                        height  = .204,
162                        yoffset = .796,
163                    },
164                },
165                {
166                    tweak = "wipecues",
167                },
168                {
169                    tweak = "addarrows",
170                },
171                {
172                    tweak = "fixslashes",
173                },
174                {
175                    tweak   = "addbars",
176                    advance = 0.33,
177                },
178                {
179                    tweak = "addactuarian",
180                },
181                {
182                    tweak = "addequals",
183                },
184                {
185                    tweak = "addfourier",
186                    variant = 2,
187                },
188                {
189                    tweak   = "addprimed",
190                },
191            },
192        },
193        bigslots = {
194            1, 2, 3, 4
195        },
196    },
197}
198