summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/s-fonts-goodies.lua
blob: 381fc45eabf88a9b178b451a07d10f36cc696da3 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
if not modules then modules = { } end modules['s-fonts-goodies'] = {
    version   = 1.001,
    comment   = "companion to s-fonts-goodies.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.goodies = moduledata.fonts.goodies or { }

local NC, NR, HL = context.NC, context.NR, context.HL

local function initialized(specification)
    specification = interfaces.checkedspecification(specification)
    local name = specification.name
    if name then
        local goodies = fonts.goodies.load(name)
        if goodies then
            return specification, goodies
        end
    end
end

function moduledata.fonts.goodies.showstylistics(specification)
    local specification, goodies = initialized(specification)
    if goodies then
        local stylistics = goodies.stylistics
        if stylistics then
            context.starttabulate { "|Tl|Tpl|" }
            HL()
            NC() context.bold("feature")
            NC() context.bold("meaning")
            NC() NR()
            HL()
            for feature, meaning in table.sortedpairs(stylistics) do
                NC() context(feature)
                NC() context(string.lower(meaning))
                NC() NR()
            end
            HL()
            context.stoptabulate()
        end
    end
end

function moduledata.fonts.goodies.showfeaturesets(specification)
    local specification, goodies = initialized(specification)
    if goodies then
        local featuresets = goodies.featuresets
        if featuresets then
            context.starttabulate { "|Tl|Tpl|" }
            HL()
            NC() context.bold("featureset")
            NC() context.bold("definitions")
            NC() NR()
            HL()
            for featureset, definitions in table.sortedpairs(featuresets) do
                NC() context.type(featureset) NC()
                for k, v in table.sortedpairs(definitions) do
                    context("%s=%S",k,v)
                    context.quad()
                end
                NC() NR()
            end
            HL()
            context.stoptabulate()
        end
    end
end

function moduledata.fonts.goodies.showcolorschemes(specification)
    local specification, goodies = initialized(specification)
    if goodies then
        local colorschemes = goodies.colorschemes
        if colorschemes then
            context.starttabulate { "|Tl|Tpl|" }
            HL()
            NC() context.bold("colorscheme")
            NC() context.bold("numbers")
            NC() NR()
            HL()
            for colorscheme, numbers in table.sortedpairs(colorschemes) do
                NC() context.type(colorscheme) NC()
                for i=1,#numbers do
                    context(i)
                    context.quad()
                end
                NC() NR()
            end
            HL()
            context.stoptabulate()
        end
    end
end

function moduledata.fonts.goodies.showfiles(specification)
    local specification, goodies = initialized(specification)
    if goodies then
        local files = goodies.files
        if files and files.list then
            for filename, specification in table.sortedpairs(files.list) do
                context.start()
                context.dontleavehmode()
                context.definedfont{ filename .. "*default" }
                context("%s-%s-%s-%s-%s",
                    specification.name    or files.name,
                    specification.weight  or "normal",
                    specification.style   or "normal",
                    specification.width   or "normal",
                    specification.variant or "normal")
                context.par()
                context.stop()
            end
        end
    end
end