summaryrefslogtreecommitdiff
path: root/tex/context/fonts/mkiv/libertinus-math.lfg
blob: c02f0506abfb67777454b7c47677e45fea17caf3 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
-- Well, here we have yet another math font that does things differently: a huge prime in the ssty1
-- slot (not an alternate but a single) and a small one in the normal location. Actually, only primes
-- have an ssty feature. Now, because we have some magic with primes in ConTeXt we cannot use some
-- fix-feature or just disable ssty, but we have to revert to a runtime fix. Lucky me that I didn't
-- remove that hardly needed 'tweaks' mechanism yet.

return {
    name = "libertinus-math",
    version = "1.00",
    comment = "Goodies that complement libertinus.",
    author = "Hans Hagen",
    copyright = "ConTeXt development team",
    mathematics = {
        tweaks = {
            aftercopying = {
             -- function(target,original)
             --     local okay = 983068
             --     local crap = {
             --         ["minute"] = "minute.ssty1",
             --         ["second"] = "second.ssty1",
             --      -- [8242] = 983068,
             --      -- [8243] = 983069,
             --         [8244] = 983070,
             --         [8245] = 983071,
             --         [8246] = 983072,
             --         [8247] = 983073,
             --     }
             --     local characters = target.characters
             --     local unicodes   = original.resources.unicodes
             --     if unicodes["minute.ssty1"] == okay then
             --         for old, new in next, crap do
             --             if type(old) == "string" then
             --                 old = unicodes[old]
             --             end
             --             if type(new) == "string" then
             --                 new = unicodes[new]
             --             end
             --             if old and new and characters[old] then
             --                 local c = characters[new]
             --                 if c then
             --                     characters[old] = c
             --                     c.commands = { { "up", .06 * c.height }, { "slot", 0, new, .7 } }
             --                 end
             --             end
             --         end
             --         local four = characters[0x2057]
             --         if four then
             --             local one = characters[okay]
             --             local owd = .75*one.width
             --             local off = .6*one.height
             --             four.width = 4*owd
             --             four.commands = {
             --                 { "offset",     0, off, okay },
             --                 { "offset",   owd, off, okay },
             --                 { "offset", 2*owd, off, okay },
             --                 { "offset", 3*owd, off, okay },
             --             }
             --         else
             --             -- we don't add (but we could), just patch, and there's no
             --             -- reverse quad either
             --         end
             --     else
             --         logs.report("fonts","the libertinus tweaks need to be checked")
             --     end
             -- end,
                function(target,original)
                    local crap = { 0x2032, 0x2033, 0x2034, 0x2036, 0x2037, 0x2038 } -- 0x2057
                    local characters = target.characters
                    local originals  = original.characters
                    local unicodes   = original.resources.unicodes
                    for i=1,#crap do
                        local old = crap[i]
                        local chr = characters[slot]
                        if chr then
                            local new = chr.smaller
                            if new then
                                local c = characters[new]
                                if c then
                                    characters[old] = c
                                    c.commands = { { "up", .06 * c.height }, { "slot", 0, new, .7 } }
                                end
                            end
                        end
                    end
                    local four = characters[0x2057]
                    if four then
                        local one = characters[0x2032]
                        local owd = .75*one.width
                        local off = .6*one.height
                        four.width = 4*owd
                        four.commands = {
                            { "offset",     0, off, okay },
                            { "offset",   owd, off, okay },
                            { "offset", 2*owd, off, okay },
                            { "offset", 3*owd, off, okay },
                        }
                    end
                end,
            },
        },
    },
}