lpdf-vfc.lua /size: 1463 b    last modification: 2021-10-28 13:50
1if not modules then modules = { } end modules ['lpdf-vfc'] = {
2    version   = 1.001,
3    comment   = "companion to lpdf-ini.mkiv",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files"
7}
8
9local setmetatableindex = table.setmetatableindex
10local formatters = string.formatters
11
12local bp  = number.dimenfactors.bp
13local r   = 16384 * bp
14local f_1 = formatters["%.6F w 0 %.6F %.6F %.6F re f"]
15local f_2 = formatters["[] 0 d 0 J %.6F w %.6F %.6F %.6F %.6F re S"]
16
17local vfspecials = backends.pdf.tables.vfspecials
18
19vfspecials.backgrounds = setmetatableindex(function(t,h)
20    local h = h * bp
21    local v = setmetatableindex(function(t,d)
22        local d = d * bp
23        local v = setmetatableindex(function(t,w)
24            local v = { "pdf", "origin", f_1(r,-d,w*bp,h+d) }
25            t[w] = v
26            return v
27        end)
28        t[d] = v
29        return v
30    end)
31    t[h] = v
32    return v
33end)
34
35vfspecials.outlines = setmetatableindex(function(t,h)
36    local h = h * bp
37    local v = setmetatableindex(function(t,d)
38        local d = d * bp
39        local v = setmetatableindex(function(t,w)
40            -- the frame goes through the boundingbox
41            local v = { "pdf", "origin", f_2(r,r/2,-d+r/2,w*bp-r,h+d-r) }
42            t[w] = v
43            return v
44        end)
45        t[d] = v
46        return v
47    end)
48    t[h] = v
49    return v
50end)
51