1
2
3
4
5
6
7
8
9
10
11
12
13
14\startmodule[fontsstatistics]
15
16\startluacode
17
18moduledata.fonts = moduledata.fonts or { }
19moduledata.fonts.statistics = moduledata.fonts.statistics or { }
20
21local context = context
22local ctx_NC, ctx_BC, ctx_NR = context.NC, context.BC, context.NR
23
24function moduledata.fonts.statistics.showusage()
25 local t = table.load(tex.jobname.."-fonts-usage.lua")
26 if t then
27 local totalinstances = 0
28 local totalfilesize = 0
29 local totalfilenames = #t
30 if totalfilenames > 0 then
31 context.starttabulate { "|r|r|c||" }
32 context.FL()
33 ctx_BC() context("used")
34 ctx_BC() context("filesize")
35 ctx_BC() context("version")
36 ctx_BC() context("filename")
37 ctx_NR()
38 context.ML()
39 for i=1,#t do
40 local ti = t[i]
41 local version = tonumber(string.match(ti.version or "","^.-([%d%.]+)"))
42 local instances = ti.instances or 1
43 local filename = file.basename(ti.filename) or "unknown"
44 local filesize = ti.size or 0
45 totalinstances = totalinstances + instances
46 totalfilesize = totalfilesize + filesize
47 ctx_NC() context(instances)
48 ctx_NC() context("%0m",filesize)
49 ctx_NC() if version then context("%0.3f",version) end
50 ctx_NC() context.type(filename)
51 ctx_NR()
52 end
53 context.LL()
54 ctx_BC() context(totalinstances)
55 ctx_BC() context("%0m",totalfilesize)
56 ctx_BC() context()
57 ctx_BC() context("%i files loaded",totalfilenames)
58 ctx_NR()
59 context.stoptabulate()
60 end
61 end
62end
63
64\stopluacode
65
66\installmodulecommandluasingle \showfontusage {moduledata.fonts.statistics.showusage}
67
68\stopmodule
69
70\continueifinputfile{sfontsstatistics.mkiv}
71
72\enabletrackers[fonts.usage]
73
74\starttext
75
76 \input klein
77
78 \showfontusage
79
80\stoptext
81 |