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

moduledata.fonts         = moduledata.fonts         or { }
moduledata.fonts.missing = moduledata.fonts.missing or { }

local legend = fonts.loggers.category_to_placeholder and

    function(id)
        local privates = fonts.helpers.getprivates(id)
        if privates then
            local categories = table.swapped(fonts.loggers.category_to_placeholder)
            context.starttabulate { "|c|l|" }
                context.HL()
                context.NC() context.bold("symbol")
                context.NC() context.bold("name")
                context.NC() context.NR()
                context.HL()
                for k, v in table.sortedhash(privates) do
                    local tag = characters.categorytags[categories[k]]
                    if tag and tag ~= "" then
                        context.NC() context.dontleavehmode() context.char(v)
                        context.NC() context(k)
                        context.NC() context.NR()
                    end
                end
                context.HL()
            context.stoptabulate()
        end
    end

or

    function(id)
        local mapping = fonts.checkers.mapping
        context.starttabulate { "|c|c|l|l|" }
            context.HL()
            context.NC() context.bold("symbol")
            context.NC() context.bold("tag")
            context.NC() context.bold("name")
            context.NC() context.NR()
            context.HL()
            for k, v in table.sortedhash(mapping) do
                local p = fonts.helpers.newprivateslot(v[1] .. "-" .. v[2])
                fonts.checkers.placeholder(font.current(),p,k)
                context.NC() context.char(p)
                context.NC() context(k)
                context.NC() context(v[1])
                context.NC() context.NR()
            end
            context.HL()
        context.stoptabulate()
    end

function moduledata.fonts.missing.showlegend(specification)
    specification = interfaces.checkedspecification(specification)
    context.begingroup()
    context.definedfont { "Mono*missing" } -- otherwise no privates added
    context(function() legend(specification.id or font.current()) end)
    context.endgroup()
end

local function missings()
    local collected = fonts.checkers.getmissing()
    for filename, list in table.sortedhash(collected) do
        if #list > 0 then
            context.starttabulate { "|l|l|" }
                context.NC() context.bold("filename")
                context.NC() context(file.basename(filename))
                context.NC() context.NR()
                context.NC() context.bold("missing")
                context.NC() context(#list)
                context.NC() context.NR()
            context.stoptabulate()
            context.starttabulate { "|l|c|l|" }
                for i=1,#list do
                    local u = list[i]
                    context.NC() context("%U",u)
                    context.NC() context.char(u)
                    context.NC() context(characters.data[u].description)
                    context.NC() context.NR()
                end
            context.stoptabulate()
        end
    end
end

function moduledata.fonts.missing.showcharacters(specification)
    context.begingroup()
    context.definedfont { "Mono*missing" } -- otherwise no privates added
    context(function() missings() end)
    context.endgroup()
end