stix-two-math.lfg /size: 3407 b    last modification: 2020-07-01 14:35
1-- Bah, I really hate these patches especially because one needs to make
2-- sure that they are still valid when the font gets updated. So, let's
3-- do it runtime (not in the cached copy) and issue a warning every run.
4-- As we cannot rely on version numbers (if we have more patches) we
5-- check for values instead.
6--
7-- This font also has inconsistent italics in smaller sizes which we can
8-- fix in a more general way but I'm not sure if we want that.
9
10local function fix_italic(target,original,name,value,factor)
11    local m = target.parameters.mathsize
12    if m then
13        local u = type(name) == "number" and name or original.resources.unicodes[name]
14        if u then
15            local c = target.characters[u]
16            if c then
17                local i = c.italic
18                if i then
19                    local d = original.descriptions[u]
20                    if d and d.math.italic == value then
21                        if m then
22                            logs.report("patching font","fixing italic correction of %U at math size %i by %0.3f",u,m,factor)
23                            c.italic = factor * i
24                        end
25                    end
26                end
27            end
28        end
29    end
30end
31
32return {
33    name = "stix-two-math",
34    version = "1.00",
35    comment = "Goodies that complement stix two opentype.",
36    author = "Hans Hagen",
37    copyright = "ConTeXt development team",
38    mathematics = {
39        -- these tags are suggestions and can still change
40        alternates = {
41            calligraphic = { feature = 'ss01', value = 1, comment = "Mathematical Alternative Calligraphic Characters" },
42            italic       = { feature = 'ss02', value = 1, comment = "Mathematical Alternative Lowercase Italic" },
43            barred       = { feature = 'ss03', value = 1, comment = "Mathematical Alternative Barred Characters" }, -- hbar, lambdabar etc
44            primes       = { feature = 'ss04', value = 1, comment = "Mathematical Alternative Primes" },            -- larger/lower primes, minute etc
45            arrow        = { feature = 'ss05', value = 1, comment = "Mathematical Alternative Smaller Arrows" },
46            narrower     = { feature = 'ss06', value = 1, comment = "Mathematical Alternative Narrower Elements" }, -- narrower/shorter element etc
47            small        = { feature = 'ss07', value = 1, comment = "Mathematical Alternative Smaller Operators" },
48            upright      = { feature = 'ss08', value = 1, comment = "Mathematical Alternative Upright Symbols" },   -- upright integrals etc.
49            negated      = { feature = 'ss09', value = 1, comment = "Mathematical Alternative Negated Symbols" },
50            relation     = { feature = 'ss10', value = 1, comment = "Mathematical Alternative Relations" },
51            negatedset   = { feature = 'ss09', value = 1, comment = "Mathematical Alternative Negated Set Symbols" },
52         -- todo         = { feature = 'ss14', value = 1, comment = "" },
53            circled      = { feature = 'ss16', value = 1, comment = "Mathematical Alternative Circled Operators" },
54        },
55        tweaks = {
56            aftercopying = {
57                function(target,original)
58                    fix_italic(target,original,"uni222B.updsp",80,3.5)
59                    fix_italic(target,original,"uni222B.up",   80,2.5)
60                end,
61            },
62        },
63    },
64}
65
66
67