newcomputermodern-math.lfg /size: 16 Kb    last modification: 2025-02-21 11:03
1local common  = fonts.goodies.load("common-math.lfg")
2local presets = common.mathematics.tweaks.presets
3-- In order to be able to use beta math fonts, we use our own file name and
4-- always remap. As this font is experimental we don't spend too much time
5-- on it now. Even then, we migth stick to design sizes only.
6
7local dimensions, kerns  if CONTEXTLMTXMODE == 0 then
8
9    local kern_150 = { bottomright = { { kern = -150 } } }
10    local kern_200 = { bottomright = { { kern = -200 } } }
11
12    kerns = {
13        [0x1D449] = kern_150, --
14        [0x1D44A] = kern_200, -- 𝑊
15    }
16
17    dimensions = {
18        -- always applied
19     -- default = {
20     -- },
21        -- driven by 'mathdimensions' feature
22        default = {
23            -- the root is quite displaced
24            [0x221A] = {
25                -- 73, -960, 853, 40
26                yoffset = 960 - 40,
27                height  = 960,
28                depth   =  40,
29            },
30        -- [0xFE932] = { xoffset = 50, width = 290 }, -- used prime
31        -- [0x2032]  = { xoffset = 50, width = 290 }, -- prime
32        },
33    -- -- seems ok now --
34    -- signs   = {
35    --  -- [0x00B1] = { -- ±
36    --  --     height = 500, depth = 0,
37    --  -- },
38    --  -- [0x2213] = { -- ∓
39    --  --     height = 500, depth = 0,
40    --  -- },
41    --     -- move in boundingbox
42    --     [0x00B1] = { -- ±
43    --         yoffset =  100,
44    --     },
45    --     [0x2213] = { -- ∓
46    --         yoffset = -100,
47    --     },
48    -- },
49    }
50
51end
52
53return {
54    name = "newcomputermodern",
55    version = "1.00",
56    comment = "Goodies that complement newcomputermodern.",
57    author = "Hans Hagen & Mikael Sundqvist",
58    copyright = "ConTeXt development team",
59    mathematics = {
60        parameters = {
61            -- Borrow values from lm:
62            FractionNumeratorDisplayStyleShiftUp = function(value,target,original)
63                local o = original.mathparameters.FractionNumeratorDisplayStyleShiftUp
64                if o > 675 then
65                    o = 600
66                else
67                    -- probably tuned
68                end
69                return o * target.parameters.factor
70            end,
71            NoLimitSupFactor                     =   0,
72            NoLimitSubFactor                     = 1200,
73            DelimiterPercent                     =  85,
74            DelimiterShortfall                   = 400,
75            DelimiterDisplayPercent              =  90, -- MS
76            DelimiterDisplayShortfall            = 400,
77            AccentTopShiftUp                     = -60,
78            FlattenedAccentTopShiftUp            = -60,
79            SubscriptBaselineDropMin             =  50, -- 200 in font (multiplied by 0.59999/2.39868)
80            SubscriptShiftDown                   =  150, -- 247 in font (multiplied to be consistent with cm)
81            SubscriptShiftDownWithSuperscript    =  247, -- relates to the previous one (see math-act)
82            SuperscriptBaselineDropMax           =  386, -- 250 in font (multiplied by 4.6333/2.99 (values in cm/values in lm))
83            SuperscriptShiftUp                   =  413, -- 363 in font (multiplied with 4.9547/4.3536, got 413)
84            SuperscriptShiftUpCramped            =  329, -- 289 in font (same factor as uncramped one (no distinction, old TeX)
85            PrimeShiftUp                         = "1.1*SuperscriptShiftUp",
86            PrimeShiftUpCramped                  = "1.1*SuperscriptShiftUp",
87            RadicalDisplayStyleVerticalGap       = 100,--"RadicalVerticalGap" too small, 148, 50
88        },
89        tweaks = {
90            aftercopying = {
91                {
92                    tweak    = "version",
93                    expected = "Version 1.958",
94                },
95                {
96                    tweak   = "fixprimes",
97                    factor  = 0.825,
98                    smaller = true,
99                    fake    = 0.6,
100                },
101                presets.scripttocalligraphic { },
102                presets.rsfstoscript         { },
103                presets.rsfsuprighttoscript  { },
104                presets.moderntocalligraphic { },
105                presets.eulertocalligraphic  { },
106                presets.xitsarabic           { rscale  = 0.80 },
107                presets.fallbacks            { },
108                presets.moveitalics          { correct = true },
109                presets.moveitalics          { correct = true, letters = true },
110                presets.moveintegrals        { factor = 1.4, icfactor = 0.8 }, -- the icfactor is due to the very slanted integral.
111                presets.wipeanchors          { },
112                presets.wipeitalics          { },
113                {
114                    tweak = "addcomposites",
115                },
116                {
117                    tweak = "checkaccents",
118                },
119                {
120                    tweak = "wipecues",
121                },
122                {
123                    tweak = "kerns",
124                    list  = {
125                        [0x0002F] = { topleft = -0.2, bottomright = -0.2 }, -- solidus
126                        --
127                        [0x00393] = { bottomright = -0.20, }, -- upright Gamma
128                        --
129                        ["0x7D.parts.top"]      = { topright = -0.25                      }, -- right brace top
130                        ["0x7D.parts.bottom"]   = {                   bottomright = -0.25 }, -- right brace bottom
131                        ["0x7D.variants.*"]     = { topright = -0.25, bottomright = -0.25 }, -- right brace variants
132                        ["0x29.parts.top"]      = { topright =  -0.3,                     }, -- right parenthesis top
133                        ["0x29.parts.bottom"]   = {                   bottomright = -0.3  }, -- right parenthesis bottom
134                        ["0x29.variants.*"]     = { topright = -0.15, bottomright = -0.15 }, -- right parenthesis variants
135                        ["0x221A.parts.top"]    = { topright =  0.2,                      }, -- right radical top
136                        ["0x221A.parts.bottom"] = {                   bottomright =  0.2  }, -- right radical bottom
137                        ["0x221A.variants.*"]   = { topright =  0.2,  bottomright =  0.2  }, -- right radical variants
138                        [0x27E9]                = { topright = -0.2,  bottomright = -0.2  }, -- angles
139                        ["0x27E9.variants.*"]   = { topright = -0.3,  bottomright = -0.3  },
140                        [0x27EB]                = { topright = -0.2,  bottomright = -0.2  },
141                        ["0x27EB.variants.*"]   = { topright = -0.3,  bottomright = -0.3  },
142
143                    },
144                },
145                {
146                    tweak = "flattenaccents",
147                },
148                {
149                    tweak = "checkspacing",
150                },
151                {
152                    tweak = "fixradicals",
153                },
154                {
155                    tweak = "addscripts",
156                },
157                {
158                    tweak = "accentdimensions",
159                },
160                {
161                    tweak = "addrules",
162                },
163                {
164                    tweak    = "replacerules",
165                 -- minus    = true, -- we have an extensible
166                    fraction = { height = .15, yoffset = .85 },
167                    radical  = { height = .15, yoffset = .823, leftoffset = .065, rightoffset = .065, leftoverlap = 0.03 },
168                    stacker  = { height = .15, yoffset = .85 },
169                },
170                {
171                    tweak = "fixvariants",
172                    list  = {
173                        [0x007C] = { template = 0x005B, index = 1, yoffset = .03 },
174                        [0x2016] = { template = 0x005B, index = 1, yoffset = .03 },
175                        [0x2980] = { template = 0x005B, index = 1, yoffset = .03 },
176                    }
177                },
178                {
179                    tweak = "addfourier",
180                    variant = 1,
181                },
182                {
183                    tweak   = "addprimed",
184                },
185            },
186        },
187        bigs = {
188            1, 3, 5, 7
189        },
190        --
191        -- experimental fixes for mkiv:
192        --
193        dimensions = dimensions,
194        kerns = kerns,
195    },
196--     filenames = {
197--         ["latinmodern-math-regular.otf"] = {
198--             "latinmodern-math.otf", -- the beta
199--             "lmmath-regular.otf",
200--             "latinmodernmath-regular.otf",
201--             "lmmath-regular.otf",
202--             "lmodernmath-regular.otf",
203--             "lmodern-math.otf",
204--         },
205--     },
206--     designsizes = {
207--         ["LMMathRoman-Regular"] = {
208--             ["4pt"]  = "LMMath5-Regular@lmroman5-math",
209--             ["5pt"]  = "LMMath5-Regular@lmroman5-math",
210--             ["6pt"]  = "LMMath6-Regular@lmroman6-math",
211--             ["7pt"]  = "LMMath7-Regular@lmroman7-math",
212--             ["8pt"]  = "LMMath8-Regular@lmroman8-math",
213--             ["9pt"]  = "LMMath9-Regular@lmroman9-math",
214--             ["10pt"] = "LMMath10-Regular@lmroman10-math",
215--             ["11pt"] = "LMMath10-Regular@lmroman10-math",
216--             ["12pt"] = "LMMath12-Regular@lmroman12-math",
217--             default  = "LMMath10-Regular@lmroman10-math"
218--         },
219--         ["LMMathRoman-Bold"] = { -- not yet ready
220--             ["4pt"]  = "LMMath5-Regular@lmroman5-math",
221--             ["5pt"]  = "LMMath5-Regular@lmroman5-math",
222--             ["6pt"]  = "LMMath6-Regular@lmroman6-math",
223--             ["7pt"]  = "LMMath7-Regular@lmroman7-math",
224--             ["8pt"]  = "LMMath8-Regular@lmroman8-math",
225--             ["9pt"]  = "LMMath9-Regular@lmroman9-math",
226--             ["10pt"] = "LMMath10-Regular@lmroman10-math",
227--             ["11pt"] = "LMMath10-Regular@lmroman10-math",
228--             ["12pt"] = "LMMath12-Regular@lmroman12-math",
229--             default  = "LMMath10-Regular@lmroman10-math"
230--         },
231--         ["LMRoman-Regular"] = {
232--             ["4pt"]  = "file:lmroman5-regular",
233--             ["5pt"]  = "file:lmroman5-regular",
234--             ["6pt"]  = "file:lmroman6-regular",
235--             ["7pt"]  = "file:lmroman7-regular",
236--             ["8pt"]  = "file:lmroman8-regular",
237--             ["9pt"]  = "file:lmroman9-regular",
238--             ["10pt"] = "file:lmroman10-regular",
239--             ["11pt"] = "file:lmroman10-regular",
240--             ["12pt"] = "file:lmroman12-regular",
241--             default  = "file:lmroman10-regular",
242--         },
243--         ["LMRoman-Bold"] = {
244--             ["4pt"]  = "file:lmroman5-bold",
245--             ["5pt"]  = "file:lmroman5-bold",
246--             ["6pt"]  = "file:lmroman6-bold",
247--             ["7pt"]  = "file:lmroman7-bold",
248--             ["8pt"]  = "file:lmroman8-bold",
249--             ["9pt"]  = "file:lmroman9-bold",
250--             ["10pt"] = "file:lmroman10-bold",
251--             ["11pt"] = "file:lmroman10-bold",
252--             ["12pt"] = "file:lmroman12-bold",
253--             default  = "file:lmroman10-bold",
254--         },
255--         ["LMRoman-Demi"] = {
256--             default  = "file:lmromandemi10-regular",
257--         },
258--         ["LMRoman-Italic"] = {
259--             ["4pt"]  = "file:lmroman7-italic",
260--             ["5pt"]  = "file:lmroman7-italic",
261--             ["6pt"]  = "file:lmroman7-italic",
262--             ["7pt"]  = "file:lmroman7-italic",
263--             ["8pt"]  = "file:lmroman8-italic",
264--             ["9pt"]  = "file:lmroman9-italic",
265--             ["10pt"] = "file:lmroman10-italic",
266--             ["11pt"] = "file:lmroman10-italic",
267--             ["12pt"] = "file:lmroman12-italic",
268--             default  = "file:lmroman10-italic",
269--         },
270--         ["LMRoman-Oblique"] = {
271--             ["4pt"]  = "file:lmromanslant8-regular",
272--             ["5pt"]  = "file:lmromanslant8-regular",
273--             ["6pt"]  = "file:lmromanslant8-regular",
274--             ["7pt"]  = "file:lmromanslant8-regular",
275--             ["8pt"]  = "file:lmromanslant8-regular",
276--             ["9pt"]  = "file:lmromanslant9-regular",
277--             ["10pt"] = "file:lmromanslant10-regular",
278--             ["11pt"] = "file:lmromanslant10-regular",
279--             ["12pt"] = "file:lmromanslant12-regular",
280--             default  = "file:lmromanslant10-regular",
281--         },
282--         ["LMRoman-BoldItalic"] = {
283--             default  = "file:lmroman10-bolditalic",
284--         },
285--         ["LMRoman-BoldOblique"] = {
286--             default  = "file:lmromanslant10-bold",
287--         },
288--         ["LMRoman-DemiOblique"] = {
289--             default  = "file:lmromandemi10-oblique",
290--         },
291--         ["LMRoman-CapsRegular"] = {
292--             default  = "file:lmromancaps10-regular",
293--         },
294--         ["LMRoman-CapsOblique"] = {
295--             default  = "file:lmromancaps10-oblique",
296--         },
297--         ["LMRoman-Dunhill"] = {
298--             default  = "file:lmromandunh10-regular",
299--         },
300--         ["LMRoman-DunhillOblique"] = {
301--             default  = "file:lmromandunh10-oblique",
302--         },
303--         ["LMRoman-Unslanted"] = {
304--             default  = "file:lmromanunsl10-regular",
305--         },
306--         ["LMSans-Regular"] = {
307--             ["8pt"]  = "file:lmsans8-regular",
308--             ["9pt"]  = "file:lmsans9-regular",
309--             ["10pt"] = "file:lmsans10-regular",
310--             ["11pt"] = "file:lmsans10-regular",
311--             ["12pt"] = "file:lmsans12-regular",
312--             default  = "file:lmsans10-regular",
313--         },
314--         ["LMSans-Oblique"] = {
315--             ["8pt"]  = "file:lmsans8-oblique",
316--             ["9pt"]  = "file:lmsans9-oblique",
317--             ["10pt"] = "file:lmsans10-oblique",
318--             ["11pt"] = "file:lmsans10-oblique",
319--             ["12pt"] = "file:lmsans12-oblique",
320--             default  = "file:lmsans10-oblique",
321--         },
322--         ["LMSans-Bold"] = {
323--             default  = "file:lmsans10-bold",
324--         },
325--         ["LMSans-BoldOblique"] = {
326--             default  = "file:lmsans10-boldoblique",
327--         },
328--         ["LMSans-DemiCondensed"] = {
329--             default  = "file:lmsansdemicond10-regular",
330--         },
331--         ["LMSans-DemiCondensedOblique"] = {
332--             default  = "file:lmsansdemicond10-oblique",
333--         },
334--         ["LMTypewriter-Regular"] = {
335--             ["8pt"]  = "file:lmmono8-regular",
336--             ["9pt"]  = "file:lmmono9-regular",
337--             ["10pt"] = "file:lmmono10-regular",
338--             ["11pt"] = "file:lmmono10-regular",
339--             ["12pt"] = "file:lmmono12-regular",
340--             default  = "file:lmmono10-regular",
341--         },
342--         ["LMTypewriter-Light"] = {
343--             default  = "file:lmmonolt10-regular",
344--         },
345--         ["LMTypewriter-Dark"] = {
346--             default  = "file:lmmonolt10-bold",
347--         },
348--         ["LMTypewriter-Italic"] = {
349--             default  = "file:lmmono10-italic",
350--         },
351--         ["LMTypewriter-LightOblique"] = {
352--             default  = "file:lmmonolt10-oblique",
353--         },
354--         ["LMTypewriter-Oblique"] = {
355--             default  = "file:lmmonoslant10-regular",
356--         },
357--         ["LMTypewriter-DarkOblique"] = {
358--             default  = "file:lmmonolt10-boldoblique",
359--         },
360--         ["LMTypewriter-LightCondensed"] = {
361--             default  = "file:lmmonoltcond10-regular",
362--         },
363--         ["LMTypewriter-LightCondensedOblique"] = {
364--             default  = "file:lmmonoltcond10-oblique",
365--         },
366--         ["LMTypewriterVarWd-Regular"] = {
367--             default  = "file:lmmonoproplt10-regular",
368--         },
369--         ["LMTypewriterVarWd-Oblique"] = {
370--             default  = "file:lmmonoproplt10-oblique",
371--         },
372--         ["LMTypewriterVarWd-Light"] = {
373--             default  = "file:lmmonoprop10-regular",
374--         },
375--         ["LMTypewriterVarWd-LightOblique"] = {
376--             default  = "file:lmmonoprop10-oblique",
377--         },
378--         ["LMTypewriterVarWd-Dark"] = {
379--             default  = "file:lmmonoproplt10-bold",
380--         },
381--         ["LMTypewriterVarWd-DarkOblique"] = {
382--             default  = "file:lmmonoproplt10-boldoblique",
383--         },
384--         ["LMTypewriter-CapsRegular"] = {
385--             default  = "file:lmmonocaps10-regular",
386--         },
387--         ["LMTypewriter-CapsOblique"] = {
388--             default  = "file:lmmonocaps10-oblique",
389--         },
390--     }
391}
392