summaryrefslogtreecommitdiff
path: root/otfl-font-lua.lua
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2011-03-02 20:10:46 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2011-03-02 20:57:11 +0200
commit654f5f46c8c7bc43b73ce46035f3f6c1d5e9bbe5 (patch)
tree3df613c3e05ca044d521bfc872f0d28028cb15f8 /otfl-font-lua.lua
parenta0e1a5594231d9f3789c51f04fdfb24680ca2516 (diff)
downloadluaotfload-654f5f46c8c7bc43b73ce46035f3f6c1d5e9bbe5.tar.gz
Sync with ConTeXt 2011.02.25 22:03
This commit overrides all our local modification to ConTeXt file and is not tested at all.
Diffstat (limited to 'otfl-font-lua.lua')
-rw-r--r--otfl-font-lua.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/otfl-font-lua.lua b/otfl-font-lua.lua
new file mode 100644
index 0000000..a6fcc16
--- /dev/null
+++ b/otfl-font-lua.lua
@@ -0,0 +1,45 @@
+if not modules then modules = { } end modules ['font-lua'] = {
+ 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 trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end)
+
+local report_lua = logs.reporter("fonts","lua loading")
+
+fonts.formats.lua = "lua"
+
+local readers = fonts.tfm.readers
+
+local function check_lua(specification,fullname)
+ -- standard tex file lookup
+ local fullname = resolvers.findfile(fullname) or ""
+ if fullname ~= "" then
+ local loader = loadfile(fullname)
+ loader = loader and loader()
+ return loader and loader(specification)
+ end
+end
+
+function readers.lua(specification)
+ local original = specification.specification
+ if trace_defining then
+ report_lua("using lua reader for '%s'",original)
+ end
+ local fullname, tfmtable = specification.filename or "", nil
+ if fullname == "" then
+ local forced = specification.forced or ""
+ if forced ~= "" then
+ tfmtable = check_lua(specification,specification.name .. "." .. forced)
+ end
+ if not tfmtable then
+ tfmtable = check_lua(specification,specification.name)
+ end
+ else
+ tfmtable = check_lua(specification,fullname)
+ end
+ return tfmtable
+end