summaryrefslogtreecommitdiff
path: root/tex/context/fonts/mkiv/stix-two-math.lfg
blob: 7652796a95307378cb3ae3da001da465c678aebb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- Bah, I really hate these patches especially because one needs to make
-- sure that they are still valid when the font gets updated. So, let's
-- do it runtime (not in the cached copy) and issue a warning every run.
-- As we cannot rely on version numbers (if we have more patches) we
-- check for values instead.
--
-- This font also has inconsistent italics in smalelr sizes which we can
-- fix in a more general way but I'm not sure if we want that.

local function fix_italic(target,original,name,value,factor)
    local m = target.parameters.mathsize
    local u = original.resources.unicodes[name]
    if m and u then
        local c = target.characters[u]
        if c then
            local i = c.italic
            if i then
                local d = original.descriptions[u]
                if d and d.math.italic == value then
                    if m then
                        logs.report("patching font","fixing italic correction of %U at math size %i by %0.3f",u,m,factor)
                        c.italic = factor * i
                    end
                end
            end
        end
    end
end

return {
    name = "stix-two-math",
    version = "1.00",
    comment = "Goodies that complement stix two opentype.",
    author = "Hans Hagen",
    copyright = "ConTeXt development team",
    mathematics = {
        -- these tags are suggestions and can still change
        alternates = {
            calligraphic = { feature = 'ss01', value = 1, comment = "Mathematical Alternative Calligraphic Characters" },
            italic       = { feature = 'ss02', value = 1, comment = "Mathematical Alternative Lowercase Italic" },
            barred       = { feature = 'ss03', value = 1, comment = "Mathematical Alternative Barred Characters" }, -- hbar, lambdabar etc
            primes       = { feature = 'ss04', value = 1, comment = "Mathematical Alternative Primes" },            -- larger/lower primes, minute etc
            arrow        = { feature = 'ss05', value = 1, comment = "Mathematical Alternative Smaller Arrows" },
            narrower     = { feature = 'ss06', value = 1, comment = "Mathematical Alternative Narrower Elements" }, -- narrower/shorter element etc
            small        = { feature = 'ss07', value = 1, comment = "Mathematical Alternative Smaller Operators" },
            upright      = { feature = 'ss08', value = 1, comment = "Mathematical Alternative Upright Symbols" },   -- upright integrals etc.
            negated      = { feature = 'ss09', value = 1, comment = "Mathematical Alternative Negated Symbols" },
            relation     = { feature = 'ss10', value = 1, comment = "Mathematical Alternative Relations" },
            negatedset   = { feature = 'ss09', value = 1, comment = "Mathematical Alternative Negated Set Symbols" },
         -- todo         = { feature = 'ss14', value = 1, comment = "" },
            circled      = { feature = 'ss16', value = 1, comment = "Mathematical Alternative Circled Operators" },
        },
        tweaks = {
            aftercopying = {
                function(target,original)
                    fix_italic(target,original,"uni222B.updsp",80,3)
                end,
            },
        },
    },
}