summaryrefslogtreecommitdiff
path: root/tex/context/base/font-pat.lua
blob: 8f1817ec25b1fed5f7c7e7c3b17765f63a3b8c44 (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
if not modules then modules = { } end modules ['font-pat'] = {
    version   = 1.001,
    comment   = "companion to font-ini.tex",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

-- older versions of latin modern didn't have the designsize set
-- so for them we get it from the name

local patches = fonts.otf.enhance.patches

local function patch(data,filename)
    if data.design_size == 0 then
        local ds = (file.basename(filename:lower())):match("(%d+)")
        if ds then
            logs.report("load otf","patching design size (%s)",ds)
            data.design_size = tonumber(ds) * 10
        end
    end
end

patches["^lmroman"]      = patch
patches["^lmsans"]       = patch
patches["^lmtypewriter"] = patch

-- for some reason (either it's a bug in the font, or it's
-- a problem in the library) the palatino arabic fonts don't
-- have the mkmk features properly set up

local function patch(data,filename)
    if data.gpos then
        for _, v in ipairs(data.gpos) do
            if not v.features and v.type == "gpos_mark2mark" then
                logs.report("load otf","patching mkmk feature (name: %s)", v.name or "?")
                v.features = {
                    {
                        scripts = {
                            {
                                langs = { "ARA ", "FAR ", "URD ", "dflt" },
                                script = "arab",
                            },
                        },
                        tag = "mkmk"
                    }
                }
            end
        end
    end
end

patches["palatino.*arabic"] = patch