summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/s-fonts-vectors.lua
blob: af8042f8458b1283659e5b9127b35c9b7b138c9d (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
if not modules then modules = { } end modules ['s-fonts-vectors'] = {
    version   = 1.001,
    comment   = "companion to s-fonts-vectors.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.protrusions = moduledata.fonts.protrusions or { }
moduledata.fonts.expansions  = moduledata.fonts.expansions  or { }

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

local classes = fonts.protrusions.classes
local vectors = fonts.protrusions.vectors

function moduledata.fonts.protrusions.showvector(specification)
    specification = interfaces.checkedspecification(specification)
    local vector = vectors[specification.name or "?"]
    if vector then
        context.blank()
        context.startcolumns { n = specification.columns or 3, balance="yes"  }
            context.starttabulate { "|T||cw(.5em)||" }
                for unicode, values in table.sortedhash(vector) do
                    NC() context("%U",unicode)
                    NC() context("%.02f",values[1])
                    NC() context("%c",unicode)
                    NC() context("%.02f",values[2])
                    NC() NR()
                end
            context.stoptabulate()
        context.stopcolumns()
        context.blank()
    end
end

function moduledata.fonts.protrusions.showclass(specification)
    specification = interfaces.checkedspecification(specification)
    local class = specification.name and classes[specification.name]
    local classes = class and { class} or classes
    context.starttabulate { "|l|l|r|r|r|" }
        NC() context.bold("name")
        NC() context.bold("vector")
        NC() context.bold("factor")
        NC() context.bold("left")
        NC() context.bold("right")
        NC() NR()
        for name, class in table.sortedhash(classes) do
            NC() context(name)
            NC() context(class.vector)
            NC() context("%.02f",class.factor)
            NC() context("%.02f",class.left)
            NC() context("%.02f",class.right)
            NC() NR()
        end
    context.stoptabulate()
end

local classes = fonts.expansions.classes
local vectors = fonts.expansions.vectors

function moduledata.fonts.expansions.showvector(specification)
    specification = interfaces.checkedspecification(specification)
    local vector = vectors[specification.name or "?"]
    if vector then
        context.blank()
        context.startcolumns { n = specification.columns or 3, balance="yes"  }
            context.starttabulate { "|T|cw(.5em)||" }
                for unicode, value in table.sortedhash(vector) do
                    NC() context("%U",unicode)
                    NC() context("%c",unicode)
                    NC() context("%.02f",value)
                    NC() NR()
                end
            context.stoptabulate()
        context.stopcolumns()
        context.blank()
    end
end

function moduledata.fonts.expansions.showclass(specification)
    specification = interfaces.checkedspecification(specification)
    local class = specification.name and classes[specification.name]
    local classes = class and { class} or classes
    context.starttabulate { "|l|l|r|r|r|" }
        NC() context.bold("name")
        NC() context.bold("vector")
        NC() context.bold("step")
        NC() context.bold("factor")
        NC() context.bold("stretch")
        NC() context.bold("shrink")
        NC() NR()
        for name, class in table.sortedhash(classes) do
            NC() context(name)
            NC() context(class.vector)
            NC() context("%.02f",class.step)
            NC() context("%.02f",class.factor)
            NC() context("% 2i",class.stretch)
            NC() context("% 2i",class.shrink)
            NC() NR()
        end
    context.stoptabulate()
end