| 1 |
if 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 |
|
| 9 |
local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end) |
| 10 |
|
| 11 |
local report_lua = logs.reporter("fonts","lua loading") |
| 12 |
|
| 13 |
local fonts = fonts |
| 14 |
local readers = fonts.readers |
| 15 |
fonts.formats.lua = "lua" |
| 16 |
|
| 17 |
-- we could add support for features here |
| 18 |
|
| 19 |
local function check_lua(specification,fullname) |
| 20 |
-- standard tex file lookup |
| 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 |
| 27 |
end |
| 28 |
|
| 29 |
readers.check_lua = check_lua |
| 30 |
|
| 31 |
function 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) |
| 46 |
end |