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