1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
if not modules then modules = { } end modules ['font-log'] = {
version = 1.001,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
}
local next, format, lower, concat = next, string.format, string.lower, table.concat
local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end)
local report_defining = logs.new("fonts","defining")
local fonts = fonts
fonts.logger = fonts.logger or { }
local logger = fonts.logger
--[[ldx--
<p>The following functions are used for reporting about the fonts
used. The message itself is not that useful in regular runs but since
we now have several readers it may be handy to know what reader is
used for which font.</p>
--ldx]]--
function logger.save(tfmtable,source,specification) -- save file name in spec here ! ! ! ! ! !
if tfmtable and specification and specification.specification then
local name = lower(specification.name)
if trace_defining and not fonts.used[name] then
report_defining("registering %s as %s (used: %s)",file.basename(specification.name),source,file.basename(specification.filename))
end
specification.source = source
fonts.loaded[lower(specification.specification)] = specification
-- fonts.used[name] = source
fonts.used[lower(specification.filename or specification.name)] = source
end
end
function logger.report(complete)
local t, n = { }, 0
for name, used in table.sortedhash(fonts.used) do
n = n + 1
if complete then
t[n] = used .. "->" .. file.basename(name)
else
t[n] = file.basename(name)
end
end
return t
end
function logger.format(name)
return fonts.used[name] or "unknown"
end
statistics.register("loaded fonts", function()
if next(fonts.used) then
local t = logger.report()
return (#t > 0 and format("%s files: %s",#t,concat(t," "))) or "none"
else
return nil
end
end)
|