font-pat.lua /size: 3540 b    last modification: 2020-07-01 14:35
1if not modules then modules = { } end modules ['font-pat'] = {
2    version   = 1.001,
3    comment   = "companion to font-ini.mkiv",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files"
7}
8
9-- This functiononality is nowadays provided via lfg files so what you see here
10-- is more an example.
11
12local match, lower = string.match, string.lower
13
14local fonts    = fonts
15local otf      = fonts.handlers.otf
16local patches  = otf.enhancers.patches
17local register = patches.register
18local report   = patches.report
19
20-- For some reason (either it's a bug in the font, or it's a problem in the
21-- library) the palatino arabic fonts don't have the mkmk features properly
22-- set up.
23
24register("after","rehash features","^palatino.*arabic", function (data,filename)
25    local gpos = data.gpos
26    if gpos then
27        for k=1,#gpos do
28            local v = gpos[k]
29            if not v.features and v.type == "gpos_mark2mark" then
30                report("mkmk feature, name %a", v.name)
31                v.features = {
32                    {
33                        scripts = {
34                            arab = {
35                                ["ara "] = true,
36                                ["far "] = true,
37                                ["urd "] = true,
38                                ["dflt"] = true,
39                            }
40                        },
41                        tag     = "mkmk",
42                    }
43                }
44            end
45        end
46    end
47end)
48
49-- -- this code is now in lm-math.lfg
50--
51-- local function patch(data,filename)
52--     local uni_to_ind = data.map.map
53--     if not uni_to_ind[0x391] then
54--         -- beware, this is a hack, features for latin often don't apply to greek
55--         -- but lm has not much features anyway (and only greek for math)
56--         report("adding 13 greek capitals")
57--         uni_to_ind[0x391] = uni_to_ind[0x41]
58--         uni_to_ind[0x392] = uni_to_ind[0x42]
59--         uni_to_ind[0x395] = uni_to_ind[0x45]
60--         uni_to_ind[0x397] = uni_to_ind[0x48]
61--         uni_to_ind[0x399] = uni_to_ind[0x49]
62--         uni_to_ind[0x39A] = uni_to_ind[0x4B]
63--         uni_to_ind[0x39C] = uni_to_ind[0x4D]
64--         uni_to_ind[0x39D] = uni_to_ind[0x4E]
65--         uni_to_ind[0x39F] = uni_to_ind[0x4F]
66--         uni_to_ind[0x3A1] = uni_to_ind[0x52]
67--         uni_to_ind[0x3A4] = uni_to_ind[0x54]
68--         uni_to_ind[0x3A7] = uni_to_ind[0x58]
69--         uni_to_ind[0x396] = uni_to_ind[0x5A]
70--     end
71-- end
72--
73-- register("after","prepare glyphs","^lmroman",     patch)
74-- register("after","prepare glyphs","^lmsans",      patch)
75-- register("after","prepare glyphs","^lmtypewriter",patch)
76--
77-- -- this code is now in cambria-math.lfg and asana-math.lfg
78--
79-- local function patch_domh(data,filename,threshold)
80--     local m = data.metadata.math
81--     if m then
82--         local d = m.DisplayOperatorMinHeight or 0
83--         if d < threshold then
84--             report("DisplayOperatorMinHeight(%s -> %s)",d,threshold)
85--             m.DisplayOperatorMinHeight = threshold
86--         end
87--      end
88-- end
89--
90-- register("after","check math parameters","cambria", function(data,filename) patch_domh(data,filename,2800) end)
91-- register("after","check math parameters","cambmath",function(data,filename) patch_domh(data,filename,2800) end)
92-- register("after","check math parameters","asana",   function(data,filename) patch_domh(data,filename,1350) end)
93