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

local select, type = select, type
local insert = table.insert

local fonts             = fonts
local helpers           = fonts.helpers

local setmetatableindex = table.setmetatableindex
----- makeweak          = table.makeweak

-- Helpers dealing with virtual fonts: beware, these are final values so
-- don't change the content of tables fetched from here!

local push  = { "push" }
local pop   = { "pop" }
local dummy = { "comment" }

function helpers.prependcommands(commands,...)
    insert(commands,1,push)
    for i=select("#",...),1,-1 do
        local s = (select(i,...))
        if s then
            insert(commands,1,s)
        end
    end
    insert(commands,pop)
    return commands
end

function helpers.appendcommands(commands,...)
    insert(commands,1,push)
    insert(commands,pop)
    for i=1,select("#",...) do
        local s = (select(i,...))
        if s then
            insert(commands,s)
        end
    end
    return commands
end

function helpers.prependcommandtable(commands,t)
    insert(commands,1,push)
    for i=#t,1,-1 do
        local s = t[i]
        if s then
            insert(commands,1,s)
        end
    end
    insert(commands,pop)
    return commands
end

function helpers.appendcommandtable(commands,t)
    insert(commands,1,push)
    insert(commands,pop)
    for i=1,#t do
        local s = t[i]
        if s then
            insert(commands,s)
        end
    end
    return commands
end

helpers.commands = utilities.storage.allocate {
    char  = setmetatableindex(function(t,k) local v = { "slot",   0, k } t[k] = v return v end),
    right = setmetatableindex(function(t,k) local v = { "right",  k    } t[k] = v return v end),
    left  = setmetatableindex(function(t,k) local v = { "right", -k    } t[k] = v return v end), -- todo: left
    down  = setmetatableindex(function(t,k) local v = { "down",   k    } t[k] = v return v end),
    up    = setmetatableindex(function(t,k) local v = { "down",  -k    } t[k] = v return v end), -- todo: up
    push  = push,
    pop   = pop,
    dummy = dummy,
}