lucida-math.lfg /size: 13 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 }
5----- integral_top      = {  topright    =  0.05 }
6local integral_bottom   = {  bottomright = -0.45 }
7
8return {
9    name = "lucida-opentype-math",
10    version = "1.00",
11    comment = "Goodies that complement lucida opentype.",
12    author = "Hans Hagen & Mikael Sundqvist",
13    copyright = "ConTeXt development team",
14    mathematics = {
15        parameters = {
16            FractionRuleThickness             =  55,
17         -- AccentBaseDepth                   = 250,
18            FlattenedAccentBaseHeight         = 710,-- slightly too large in the font
19            DelimiterPercent                  =  85,
20            DelimiterShortfall                = 400,
21            DelimiterDisplayPercent           =  90, -- MS
22            DelimiterDisplayShortfall         = 400,
23            SuperscriptBottomMaxWithSubscript = 325,
24            PrimeShiftUp                      = "1.3*SuperscriptShiftUp",
25            PrimeShiftUpCramped               = "1.3*SuperscriptShiftUp",
26            PrimeBaselineDropMax              = "0.5*SuperscriptBaselineDropMax",
27            RadicalDisplayStyleVerticalGap    = "RadicalVerticalGap", --172, 50
28-- RadicalKernBeforeExtensible       = 100,
29-- RadicalKernAfterExtensible        = 100,
30        },
31        scales = {
32            scriptxscale       = 1025,
33            scriptyscale       =  975,
34            scriptscriptxscale = 1050,
35            scriptscriptyscale =  950,
36            scriptweight       =   20,
37            scriptscriptweight =   40,
38        },
39        tweaks = {
40         -- beforepassing = {
41         --     {
42         --         tweak              = "scales",
43         --         scriptxscale       = 1100,
44         --         scriptyscale       =  900,
45         --         scriptscriptxscale = 1100,
46         --         scriptscriptyscale =  900,
47         --     },
48         -- },
49            aftercopying = {
50                {
51                    tweak    = "version",
52                    expected = "Version 1.901",
53                },
54                {
55                    tweak   = "fixoldschool",
56                    version = "Version 1.802",
57                },
58                {
59                    tweak   = "parameters",
60                    feature = "boldmath",
61                    list    = {
62                        RadicalRuleThickness  = 60,
63                     -- RadicalRuleThickness  = "1.09*RadicalRuleThickness",
64                     -- FractionRuleThickness = 65,
65                     -- OverRuleThickness     = 65,
66                     -- UnderRuleThickness    = 65,
67                    }
68                },
69                {
70                    tweak = "addmirrors",
71                },
72                presets.smalldigits          { factor  = 0.90 },
73                presets.scripttocalligraphic { },
74                presets.rsfstoscript         { rscale  = 1    },
75                presets.rsfsuprighttoscript  { rscale  = 1    },
76                presets.moderntocalligraphic { rscale  = 1    },
77                presets.eulertocalligraphic  { rscale  = 1    },
78                presets.xitsarabic           { rscale  = 1.05 },
79                presets.fallbacks            { },
80                presets.moveitalics          { correct = true },
81                presets.moveitalics          { correct = true, letters = true },
82                presets.moveintegrals        { factor = 1.5 },
83                presets.wipeitalics          { },
84                {
85                    tweak    = "replacealphabets",
86                    filename = "lucidabrightot.otf",
87                    keep     = true,
88                    list     = {
89                        { source = "latinsupplement" },
90                     -- { source = "latinextendeda" },
91                     -- { source = "latinextendedadditional" },
92                     -- { source = "latinextendedb" },
93                     -- { source = "latinextendedc" },
94                     -- { source = "latinextendedd" },
95                     -- { source = "latinextendede" },
96                     -- { source = "latinextendedf" },
97                     -- { source = "latinextendedg" },
98                    },
99                },
100                {
101                    tweak   = "replacealphabets",
102                    list    = {
103                        {
104                            source   = "uppercasescript",
105                            target   = "uppercasecalligraphic",
106                            feature  = "ss04",
107                        },
108                        {
109                            source   = "lowercasescript",
110                            target   = "lowercasecalligraphic",
111                            feature  = "ss04",
112                        },
113                        {
114                            source   = "uppercaseboldscript",
115                            target   = "uppercaseboldcalligraphic",
116                            feature  = "ss04",
117                        },
118                        -- No lowercase bold calligraphic/script in font
119                    },
120                },
121                {
122                    tweak   = "dimensions",
123                    version = "Version 1.802",
124                    list    = {
125                        -- The < and > are slightly too small. We scale them by 867/795
126                        ["0x003C"] = { scale = 1.09057, width = 1.09057, height = 1.09057 },
127                        ["0x003E"] = { scale = 1.09057, width = 1.09057, height = 1.09057 },
128                    },
129                },
130                {
131                    tweak   = "dimensions",
132                    version = "Version 1.802",
133                    list    = {
134                        -- these we fix here. Remove when we have new version of Lucida
135                        ["0x23DC.parts.1"]  = { xoffset = -0.075, height = 0.4,  yoffset = -0.6  },
136                        ["0x23DC.parts.2"]  = {                   height = 0.4,  yoffset = -0.6  },
137                        ["0x23DC.parts.3"]  = { xoffset =  0.075, height = 0.4,  yoffset = -0.6  },
138                        ["0x23DD.parts.1"]  = { xoffset = -0.075, depth  = 0.8,  yoffset =  0.2  },
139                        ["0x23DD.parts.2"]  = {                   depth  = 0.8,  yoffset =  0.2  },
140                        ["0x23DD.parts.3"]  = { xoffset =  0.075, depth  = 0.8,  yoffset =  0.2  },
141                        ["0x7C.variants.3"] = { squeeze =  0.90,  height = 0.90, depth   =  0.90 },
142                        ["0x7C.variants.4"] = { squeeze =  0.80,  height = 0.80, depth   =  0.80 },
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 = "checkaccents",
150                },
151                {
152                    tweak = "extendaccents",
153                },
154                {
155                    tweak = "flattenaccents",
156                },
157                {
158                    tweak = "fixaccents",
159                },
160{
161    tweak = "keepbases",
162    list  = { 0x302 }
163},
164                {
165                    tweak = "radicaldegreeanchors",
166                    list  = {
167                        ["0x221A.variants.3"]   = { location = "left", hfactor = 0,    vfactor = .55  },
168                        ["0x221A.variants.4"]   = { location = "left", hfactor = 0,    vfactor = .50  },
169                        ["0x221A.parts.bottom"] = { location = "left", hfactor = 0,    vfactor = .85  },
170                    }
171                },
172                -- First we set the dimensions of the initial accent which started out as zero but we want
173                -- a proper width. Not in lucida
174                -- Then we deal with all offsets and heights in one go. So we treat the initial accent
175                -- as well as the variants here. Not in lucida.
176                -- We now copy these to the not wide slots so that we can set these to stretch as well,
177                -- if only because it is less confusing and more consistent.
178                {
179                    tweak = "copyaccents",
180                },
181                -- So far for the accents.
182                {
183                    tweak = "fixslashes",
184                },
185                {
186                    tweak = "addbreve",
187                },
188                {
189                    tweak = "kerns",
190                    list  = {
191                        [0x002F]                = { topleft  = -0.2,  bottomright = -0.2  },
192                        ["0x007D.parts.top"]    = { topright = -0.15                      }, -- right brace top
193                        ["0x007D.parts.bottom"] = {                   bottomright = -0.15 }, -- right brace bottom
194                        ["0x007D.variants.*"]   = { topright = -0.15, bottomright = -0.15 }, -- right brace variants
195                        ["0x0029.parts.top"]    = { topright = -0.25                      }, -- right parenthesis top
196                        ["0x0029.parts.bottom"] = {                   bottomright = -0.25 }, -- right parenthesis bottom
197                        ["0x0029.variants.*"]   = { topright = -0.2,  bottomright = -0.2  }, -- right parenthesis variants
198                        ["0x221A.parts.top"]    = { topright =  0.2                       }, -- right radical top
199                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  }, -- right radical bottom
200                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  }, -- right radical variants
201                        [0x27E9]                = { topright = -0.2,  bottomright = -0.2  }, -- angle
202                        ["0x27E9.variants.*"]   = { topright = -0.3,  bottomright = -0.3  },
203                        [0x27EB]                = { topright = -0.2,  bottomright = -0.2  },
204                        ["0x27EB.variants.*"]   = { topright = -0.3,  bottomright = -0.3  },
205                    },
206                },
207                {
208                   tweak   = "fixprimes",
209                   factor  = 0.7,  -- accent base height
210                   fake    = 0.65, -- replace multiples with this width proportion
211                },
212                {
213                    tweak = "checkspacing",
214                },
215                {
216                    tweak = "addscripts",
217                },
218                {
219                    tweak = "accentdimensions",
220                },
221                {
222                    tweak = "addrules",
223                },
224                {
225                    tweak    = "replacerules",
226                    minus    = {
227                        leftoffset  = .12,
228                        rightoffset = .12,
229                    },
230                    fraction = {
231                        height  = .2,
232                        yoffset = .825,
233                    },
234                    radical  = {
235                        height      = .13,
236                        yoffset     = .825,
237                        leftoffset  = .124,
238                        rightoffset = .124,
239                        yscale      = .940,
240                    },
241radical  = {
242    height      = .140,
243    yoffset     = .610,
244    yscale      = .720,
245    leftoffset  = .124,
246    rightoffset = .124,
247},
248                    stacker  = {
249                        height  = .2,
250                        yoffset = .825,
251                    },
252                },
253                {
254                    tweak = "addactuarian",
255                },
256                {
257                    tweak   = "addfourier",
258                    variant = 1,
259                },
260                {
261                    tweak = "addprimed",
262                },
263                {
264                    tweak = "addarrows",
265                    left  = 0.1,
266                    right = 0.1,
267                    slack = 0.20,
268                    list  = {
269                        [0x21A9] = false,
270                        [0x21AA] = false,
271                        [0x2190] = false,
272                        [0x2192] = false,
273                        [0x219E] = false,
274                        [0x21A0] = false,
275                    }
276                },
277                -- fix a bug (todo: version)
278                {
279                    tweak       = "sortvariants",
280                    list        = { 0x23DE },
281                    orientation = "horizontal",
282                },
283                -- this is the mkiv section
284                {
285                    tweak   = "emulatelmtx",
286                    feature = "emulatelmtx",
287                    comment = "this is for mkiv",
288                },
289            },
290        },
291        alternates = {
292            textitalic   = { feature = 'ss01', value = 1, comment = "Mathematical Alternative Lowercase Italic" },
293            arrow        = { feature = 'ss02', value = 1, comment = "Mathematical Alternative Smaller Arrows" },
294            operator     = { feature = 'ss03', value = 1, comment = "Mathematical Alternative Smaller Operators" },
295            calligraphic = { feature = 'ss04', value = 1, comment = "Mathematical Alternative Calligraphic Characters" },
296            zero         = { feature = 'ss05', value = 1, comment = "Mathematical Alternative Zero" },
297            multipledots = { feature = 'ss06', value = 1, comment = "Mathematical Alternative Multiple Dots" },
298            ldots        = { feature = 'ss07', value = 1, comment = "Mathematical Alternative Ellipsis" },
299        },
300        bigslots = {
301            1, 2, 3, 4
302        },
303        --
304        -- experimental fixes for mkiv:
305        --
306        dimensions = dimensions,
307        kerns = kerns,
308    },
309}
310