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