1if not modules then modules = { } end modules ['font-lua'] = {
2 version = 1.001,
3 comment = "companion to font-ini.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end)
10
11local report_lua = logs.reporter("fonts","lua loading")
12
13local fonts = fonts
14local readers = fonts.readers
15fonts.formats.lua = "lua"
16
17
18
19local function check_lua(specification,fullname)
20
21 local fullname = resolvers.findfile(fullname) or ""
22 if fullname ~= "" then
23 local loader = loadfile(fullname)
24 loader = loader and loader()
25 return loader and loader(specification)
26 end
27end
28
29readers.check_lua = check_lua
30
31function readers.lua(specification)
32 local original = specification.specification
33 if trace_defining then
34 report_lua("using lua reader for %a",original)
35 end
36 local fullname = specification.filename or ""
37 if fullname == "" then
38 local forced = specification.forced or ""
39 if forced ~= "" then
40 fullname = specification.name .. "." .. forced
41 else
42 fullname = specification.name
43 end
44 end
45 return check_lua(specification,fullname)
46end
47 |