s-fonts-statistics.mkiv /size: 2579 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [      file=s-fonts-statistics,
3%D        version=2018.03.21, % guess
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Listing font statistics,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\startmodule[fonts-statistics]
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{s-fonts-statistics.mkiv}
71
72\enabletrackers[fonts.usage]
73
74\starttext
75
76    \input klein
77
78    \showfontusage
79
80\stoptext
81