fonts-demo-rule.lua /size: 1803 b    last modification: 2020-07-01 14:35
1local startactualtext = backends.codeinjections.startunicodetoactualtext
2local stopactualtext  = backends.codeinjections.stopunicodetoactualtext
3
4return function(specification)
5    local features = specification.features.normal
6    local name     = features.original or "dejavu-serif"
7    local option   = features.option      -- we only support "line"
8    local size     = specification.size   -- always set
9    local detail   = specification.detail -- e.g. default
10    if detail then
11        name = name .. "*" .. detail
12    end
13    local f, id = fonts.constructors.readanddefine(name,size)
14    if f then
15        f.properties.name = specification.name
16        f.properties.virtualized = true
17        f.fonts = {
18            { id = id },
19        }
20        for s in string.gmatch("aeuioy",".") do
21            local n = utf.byte(s)
22            local c = f.characters[n]
23            if c then
24                local w = c.width  or 0
25                local h = c.height or 0
26                local d = c.depth  or 0
27                if option == "line" then
28                    f.characters[n].commands = {
29                        { "special", "pdf:direct:" .. startactualtext(n) },
30                        { "rule", option == "line" and size/10, w },
31                        { "special", "pdf:direct:" .. stopactualtext() },
32                    }
33                else
34                    f.characters[n].commands = {
35                        { "special", "pdf:direct:" .. startactualtext(n) },
36                        { "down", d },
37                        { "rule", h + d, w },
38                        { "special", "pdf:direct:" .. stopactualtext() },
39                    }
40                end
41            else
42                -- probably a real bad font
43            end
44        end
45    end
46    return f
47end
48