dejavu-math.lfg /size: 12 Kb    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.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                {
46                    tweak = "addcomposites",
47                },
48                presets.scripttocalligraphic { },
49                presets.rsfstoscript         { rscale = 1.02 },
50                presets.rsfsuprighttoscript  { rscale = 1.02 },
51                presets.moderntocalligraphic { rscale = 1.02 },
52                presets.eulertocalligraphic  { rscale = 1.02 },
53                presets.xitsarabic           { rscale = 1.05 },
54                presets.fallbacks            { },
55                presets.moveitalics          { correct = true },
56                presets.moveitalics          { correct = true, letters = true },
57                presets.moveintegrals        { factor = 1.5 }, -- we need to check this
58                presets.wipeitalics          { },
59                -- We don't have italic correction in for instance math italic f which means that
60                -- we also didn't fix it. Therefore we need at least some reasonable kerns. Using
61                -- a dimension tweak before the above (e.g. 0.2 italic and 0.8 width) doesn't work
62                -- because once the advance is set the move is blocked and the ic stil wiped. So,
63                -- we kern. Actually the upright (ascii) f has italic correction.
64                {
65                    tweak = "checkaccents",
66                },
67                {
68                    tweak = "wipecues",
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                        -- The font lacks italic correction and corner kerns
90                        -- It is probably meant to be "spacy", but we add bottomright
91                        -- to a few of the most used latin and greek letters
92                        --
93                        [0x1D435] = { bottomright = -.05 },   -- italic B
94                        [0x1D436] = { bottomright = -.1 },    -- italic C
95                        [0x1D437] = { bottomright = -.05 },   -- italic D
96                        [0x1D438] = { bottomright = -.1 },    -- italic E
97                        [0x1D439] = { bottomright = -.1 },    -- italic F
98                        [0x1D43A] = { bottomright = -.05 },   -- italic G
99                        [0x1D43B] = { bottomright = -.1 },    -- italic H
100                        [0x1D43C] = { bottomright = -.15 },   -- italic I
101                        [0x1D43D] = { bottomright = -.15 },   -- italic J
102                        [0x1D43E] = { bottomright = -.1 },    -- italic K
103                        [0x1D440] = { bottomright = -.1 },    -- italic M
104                        [0x1D441] = { bottomright = -.1 },    -- italic N
105                        [0x1D443] = { bottomright = -.1 },    -- italic P
106                        [0x1D446] = { bottomright = -.05 },   -- italic S
107                        [0x1D447] = { bottomright = -.3 },    -- italic T
108                        [0x1D448] = { bottomright = -.2 },    -- italic U
109                        [0x1D449] = { bottomright = -.25 },   -- italic V
110                        [0x1D44A] = { bottomright = -.2 },    -- italic W
111                        [0x1D44B] = { bottomright = -.1 },    -- italic X
112                        [0x1D44C] = { bottomright = -.25 },   -- italic Y
113                        [0x1D44D] = { bottomright = -.1 },    -- italic Z
114                        [0x1D451] = { bottomright = -.1 },    -- italic d
115                        [0x1D453] = { bottomright = -.2 },    -- italic f
116                        [0x1D45F] = { bottomright = -.1 },    -- italic r
117                        [0x1D461] = { bottomright = -.1 },    -- italic t
118                        [0x1D463] = { bottomright = -.1 },    -- italic v
119                        [0x1D464] = { bottomright = -.05 },   -- italic w
120                        [0x1D465] = { bottomright = -.05 },   -- italic x
121                        [0x1D466] = { bottomright = -.05 },   -- italic y
122                        [0x1D467] = { bottomright = -.05 },   -- italic z
123                        [0x00393] = { bottomright = -0.3, },  -- upright Gamma
124                        [0x003A5] = { bottomright = -0.2, },  -- upright Upsilon
125                        [0x003A8] = { bottomright = -0.1, },  -- upright Psi
126                        [0x02207] = { bottomright = -0.2, },  -- upright Nabla
127                        [0x1D6FB] = { bottomright = -0.2, },  -- italic Nabla
128                        [0x1D701] = { bottomright = -.15 },   -- italic zeta
129                        [0x1D703] = { bottomright = -.05 },   -- italic theta
130                        [0x1D705] = { bottomright = -.05 },   -- italic kappa
131                        [0x1D709] = { bottomright = -.15 },   -- italic xi
132                        [0x1D70B] = { bottomright = -.1 },    -- italic pi
133                        [0x1D70E] = { bottomright = -.15 },   -- italic sigma
134                        [0x1D70F] = { bottomright = -.15 },   -- italic tau
135                        [0x1D712] = { bottomright = -.15 },   -- italic chi
136                        [0x1D713] = { bottomright = -.1 },    -- italic psi
137                        [0x1D718] = { bottomright = -.05 },   -- italic varkappa
138                        --
139                        ["0x222B.parts.bottom"] = { bottomright = -0.20 }, -- int
140                        ["0x222C.parts.bottom"] = { bottomright = -0.15 }, -- iint
141                        ["0x222D.parts.bottom"] = { bottomright = -0.10 }, -- iiint
142                        ["0x2A0C.parts.bottom"] = { bottomright = -0.05 }, -- iiiint
143                    },
144                },
145                -- Accents are a mess. We migrate the extensibles from the combiners to the base accent
146                -- and then need to tweak the width (which is auto set because it was zero with a large
147                -- accent anchor offset). First we copy and fix.
148                {
149                    tweak = "extendaccents",
150                },
151                {
152                    tweak   = "radicaldegreeanchors",
153                    list = {
154                        [0x221A]                = { location = "left", hfactor  = .1, vfactor  = .65 },
155                        ["0x221A.variants.*"]   = { location = "left", hfactor  = .1, vfactor  = .6 },
156                        ["0x221A.variants.1"]   = { location = "left", hfactor  = .1, vfactor  = .65 },
157                        ["0x221A.variants.2"]   = { location = "left", hfactor  = .1, vfactor  = .65 },
158                        ["0x221A.parts.bottom"] = { location = "left", hfactor  = .1, vfactor  = 1.1 },
159                    }
160                },
161                {
162                    tweak = "flattenaccents",
163                },
164                {
165                    tweak = "fixaccents",
166                },
167                -- First we set the dimensions of the initial accent which started out as zero but we want
168                -- a proper width.
169                -- {
170                --     tweak = "dimensions",
171                --     list  = {
172                --         [0x00302] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widehat
173                --         [0x00303] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widetilde
174                --         [0x00306] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widebreve
175                --         [0x0030C] = { width = 1.4, anchor = 1.20, xoffset = .10 }, -- widecheck
176                --     },
177                -- },
178                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
179                -- as well as the variants here.
180                {
181                    tweak = "dimensions",
182                    list  = {
183                        [0x020DB] = { yoffset =  0.015, height = .95, all = true }, -- widedddot : 0x20DB (self)
184                    },
185                },
186                -- We now copy these to the not wide slots so that we can set these to stretch as well,
187                -- if only because it is less confusing and more consistent.
188                {
189                    tweak = "copyaccents",
190                },
191                presets.addmathkerns { },
192                {
193                    tweak = "checkspacing",
194                },
195                {
196                    tweak = "addscripts",
197                },
198                {
199                    tweak = "accentdimensions",
200                },
201                {
202                    tweak = "addrules",
203                },
204                {
205                    tweak    = "replacerules",
206                    fraction = { height = .254, yoffset = .746, leftoffset = .1, rightoffset = .1,  },
207                    radical  = { height = .17, leftoffset = .1, rightoffset = .1, yoffset = .485, yscale = .65  },
208                    stacker  = { height = .254, yoffset = .746 },
209                },
210                {
211                    tweak = "wipecues",
212                },
213                {
214                    tweak   = "addbars",
215                    advance = 0.175,
216                },
217                {
218                    tweak = "addactuarian",
219                },
220                {
221                    tweak = "addequals",
222                },
223                {
224                    tweak   = "addfourier",
225                    variant = 1,
226                },
227                {
228                    tweak = "addprimed",
229                },
230                -- this is the mkiv section
231                {
232                    tweak   = "emulatelmtx",
233                    feature = "emulatelmtx",
234                    comment = "this is for mkiv",
235                },
236            },
237        },
238        alternates = {
239            dotless = { feature = 'dtls', value = 1, comment = "Mathematical Dotless Forms" },
240        },
241        bigslots = {
242            1, 3, 5, 7
243        },
244    },
245}
246