1if not modules then modules = { } end modules ['font-imp-digits'] = {
2 version = 1.001,
3 comment = "companion to font-ini.mkiv",
4 author = "Hans Hagen, PRAGMA ADE",
5 copyright = "ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9if not context then return end
10
11local equaldigits = { }
12
13
14
15
16
17local function initialize(tfmdata,key,value)
18 if key and value then
19 local characters = tfmdata.characters
20 local wd, ht, dp = 0, 0, 0
21 for i=48,57 do
22 if not equaldigits[i] then
23 equaldigits[i] = fonts.helpers.newprivateslot(tonumber(i)..".equaldigits")
24 end
25 local c = characters[i]
26 local w = c.width or 0
27 local h = c.height or 0
28 local d = c.depth or 0
29 if w > wd then wd = w end
30 if h > ht then ht = h end
31 if d > dp then dp = d end
32 end
33 for i=48,57 do
34
35 local u = equaldigits[i]
36 local c = characters[i]
37 characters[u] = table.setmetatableindex( {
38 height = ht,
39 depth = dp,
40 width = wd,
41 xoffset = (wd - (c.width or 0)) / 2,
42 }, c)
43 end
44 end
45end
46
47fonts.handlers.otf.features.register {
48 name = "equaldigits",
49 description = "equaldigits",
50 manipulators = {
51 base = initialize,
52 node = initialize,
53 }
54}
55
56fonts.handlers.otf.addfeature {
57
58 name = "tabledigits",
59 type = "substitution",
60 nocheck = true,
61 data = equaldigits,
62}
63 |