dejavu-math.lfg /size: 9646 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.25 }
6
7return {
8    name = "dejavu-math",
9    version = "1.00",
10    comment = "Goodies that complement dejavu.",
11    author = "Hans Hagen & Mikael Sundqvist",
12    copyright = "ConTeXt development team",
13    mathematics = {
14        parameters = {
15            FractionRuleThickness             =   60,
16            AccentTopShiftUp                  =  -25,
17            FlattenedAccentTopShiftUp         =  -25,
18            AccentBaseDepth                   =   30,
19            DelimiterPercent                  =   85,
20            DelimiterShortfall                =  400,
21            DelimiterDisplayPercent           =   90,
22            DelimiterDisplayShortfall         =  400,
23            DisplayOperatorMinHeight          = 1800, -- 1333 in font
24            SubscriptShiftDown                = 177, -- 277 in font
25            SuperscriptShiftUp                = 428, -- 381 in font
26            SubscriptShiftDownWithSuperscript = "1.3*SubscriptShiftDown", -- trial and error
27            PrimeShiftUp                      = "1.4*SuperscriptShiftUp",
28            PrimeShiftUpCramped               = "1.4*SuperscriptShiftUp",
29            PrimeBaselineDropMax              = "0.5*SuperscriptBaselineDropMax",
30        },
31        tweaks = {
32            aftercopying = {
33                {
34                    tweak    = "version",
35                    expected = "Version 1.106",
36                },
37                presets.braille { },
38                {
39                    tweak   = "fixprimes",
40                    factor  = 0.63,
41                },
42                {
43                    tweak = "addmirrors",
44                },
45                presets.scripttocalligraphic { },
46                presets.rsfstoscript         { rscale = 1.02 },
47                presets.rsfsuprighttoscript  { rscale = 1.02 },
48                presets.moderntocalligraphic { rscale = 1.02 },
49                presets.eulertocalligraphic  { rscale = 1.02 },
50                presets.xitsarabic           { rscale = 1.05 },
51                presets.fallbacks            { },
52                presets.moveitalics          { correct = true },
53                presets.moveitalics          { correct = true, letters = true },
54                presets.moveintegrals        { factor = 1.5 }, -- we need to check this
55                presets.wipeitalics          { },
56                -- We don't have italic correction in for instance math italic f which means that
57                -- we also didn't fix it. Therefore we need at least some reasonable kerns. Using
58                -- a dimension tweak before the above (e.g. 0.2 italic and 0.8 width) doesn't work
59                -- because once the advance is set the move is blocked and the ic stil wiped. So,
60                -- we kern. Actually the upright (ascii) f has italic correction.
61                {
62                    tweak = "checkaccents",
63                },
64                {
65                    tweak = "kerns",
66                    list  = {
67                        [0x1D453] = { bottomright = -.2 },
68                    }
69                },
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.05, bottomright = -0.05 }, -- right brace variants
78                        ["0x29.parts.top"]      = { topright = -0.15,                     }, -- right parenthesis top
79                        ["0x29.parts.bottom"]   = {                   bottomright = -0.15 }, -- right parenthesis bottom
80                        ["0x29.variants.*"]     = { topright = -0.1,  bottomright = -0.1  }, -- 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.30, }, -- 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   = "radicaldegreeanchors",
105                    list = {
106                        [0x221A]                = { location = "left", hfactor  = .1, vfactor  = .65 },
107                        ["0x221A.variants.*"]   = { location = "left", hfactor  = .1, vfactor  = .6 },
108                        ["0x221A.variants.1"]   = { location = "left", hfactor  = .1, vfactor  = .65 },
109                        ["0x221A.variants.2"]   = { location = "left", hfactor  = .1, vfactor  = .65 },
110                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = .1, vfactor  = 1.1 },
111                    }
112                },
113                {
114                    tweak = "flattenaccents",
115                },
116                {
117                    tweak = "fixaccents",
118                },
119                -- First we set the dimensions of the initial accent which started out as zero but we want
120                -- a proper width.
121                -- {
122                --     tweak = "dimensions",
123                --     list  = {
124                --         [0x00302] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widehat
125                --         [0x00303] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widetilde
126                --         [0x00306] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widebreve
127                --         [0x0030C] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widecheck
128                --     },
129                -- },
130                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
131                -- as well as the variants here.
132                {
133                    tweak = "dimensions",
134                    list  = {
135                        [0x020DB] = { yoffset =  0.015, height = .95, all = true }, -- widedddot : 0x20DB (self)
136                    },
137                },
138                -- We now copy these to the not wide slots so that we can set these to stretch as well,
139                -- if only because it is less confusing and more consistent.
140                {
141                    tweak = "copyaccents",
142                },
143                presets.addmathkerns { },
144                {
145                    tweak = "checkspacing",
146                },
147                {
148                    tweak = "addscripts",
149                },
150                {
151                    tweak = "accentdimensions",
152                },
153                {
154                    tweak = "addrules",
155                },
156                {
157                    tweak    = "replacerules",
158                    fraction = { height = .254, yoffset = .746, leftoffset = .1, rightoffset = .1,  },
159                    radical  = { height = .17, leftoffset = .1, rightoffset = .1, yoffset = .485, yscale = .65  },
160                    stacker  = { height = .254, yoffset = .746 },
161                },
162                {
163                    tweak = "wipecues",
164                },
165                {
166                    tweak   = "addbars",
167                    advance = 0.175,
168                },
169                {
170                    tweak = "addactuarian",
171                },
172                {
173                    tweak = "addequals",
174                },
175                {
176                    tweak   = "addfourier",
177                    variant = 1,
178                },
179                {
180                    tweak = "addprimed",
181                },
182                -- this is the mkiv section
183                {
184                    tweak   = "emulatelmtx",
185                    feature = "emulatelmtx",
186                    comment = "this is for mkiv",
187                },
188            },
189        },
190        alternates = {
191            dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" },
192        },
193        bigslots = {
194            1, 3, 5, 7
195        },
196    },
197}
198