From 1a6a253e85e609d37113585081b6cf9711757208 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 18 Feb 2016 08:35:22 +0100 Subject: [features,loaders] allow for direct injection of tfmdata when defining fonts --- src/luaotfload-loaders.lua | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'src/luaotfload-loaders.lua') diff --git a/src/luaotfload-loaders.lua b/src/luaotfload-loaders.lua index 0f22f46..8e5248b 100644 --- a/src/luaotfload-loaders.lua +++ b/src/luaotfload-loaders.lua @@ -14,13 +14,43 @@ if not luaotfload then error "this module requires Luaotfload" end local logreport = luaotfload.log and luaotfload.log.report or print +local lua_reader = function (specification) + local fullname = specification.filename or "" + if fullname == "" then + local forced = specification.forced or "" + if forced ~= "" then + fullname = specification.name .. "." .. forced + else + fullname = specification.name + end + end + local fullname = resolvers.findfile (fullname) or "" + if fullname ~= "" then + local loader = loadfile (fullname) + loader = loader and loader () + return loader and loader (specification) + end +end + +local data_reader = function (specification) + local data = specification.data + if data and type (data) == "function" then + logreport ("both", 0, "loaders", + "data: found tfmdata for “%s”, injecting.", + specification.name) + return data () + end +end + local install_formats = function () local fonts = fonts if not fonts then return false end - local readers = fonts.readers - local handlers = fonts.handlers - local formats = fonts.formats + local readers = fonts.readers + local sequence = readers.sequence + local seqset = table.tohash (sequence) + local handlers = fonts.handlers + local formats = fonts.formats if not readers or not handlers or not formats then return false end local aux = function (which, reader) @@ -32,10 +62,18 @@ local install_formats = function () formats [which] = "type1" readers [which] = reader handlers [which] = { } + if not seqset [which] then + logreport ("both", 0, "loaders", + "Extending reader sequence for “%s”.", which) + sequence [#sequence + 1] = which + seqset [which] = true + end return true end - return aux ("pfa", function (spec) return readers.opentype (spec, "pfa", "type1") end) + return aux ("dat", data_reader) + and aux ("lua", lua_reader) + and aux ("pfa", function (spec) return readers.opentype (spec, "pfa", "type1") end) and aux ("pfb", function (spec) return readers.opentype (spec, "pfb", "type1") end) and aux ("ofm", readers.tfm) end -- cgit v1.2.3 From 128b29a4260f0454996f5663a02c0f7c575b2d6b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 19 Feb 2016 00:51:24 +0100 Subject: =?UTF-8?q?[features,loaders]=20fix=20lookup=20conflicts=20via=20i?= =?UTF-8?q?ntroduction=20of=20=E2=80=9Cevl=E2=80=9D=20lookup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This introduces a forced lookup type “evl” that bypasses the other methods. The specification is extended with the correct values including a more meaningful hash string. As a result, the loader no longer attempts to interpret the specification as a “file:” request but the backend can still resolve the necessary files. --- src/luaotfload-loaders.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/luaotfload-loaders.lua') diff --git a/src/luaotfload-loaders.lua b/src/luaotfload-loaders.lua index 8e5248b..80ce41a 100644 --- a/src/luaotfload-loaders.lua +++ b/src/luaotfload-loaders.lua @@ -32,14 +32,13 @@ local lua_reader = function (specification) end end -local data_reader = function (specification) - local data = specification.data - if data and type (data) == "function" then - logreport ("both", 0, "loaders", - "data: found tfmdata for “%s”, injecting.", - specification.name) - return data () - end +local eval_reader = function (specification) + local eval = specification.eval + if not eval or type (eval) ~= "function" then return nil end + logreport ("both", 0, "loaders", + "eval: found tfmdata for “%s”, injecting.", + specification.name) + return eval () end local install_formats = function () @@ -71,7 +70,7 @@ local install_formats = function () return true end - return aux ("dat", data_reader) + return aux ("evl", eval_reader) and aux ("lua", lua_reader) and aux ("pfa", function (spec) return readers.opentype (spec, "pfa", "type1") end) and aux ("pfb", function (spec) return readers.opentype (spec, "pfb", "type1") end) -- cgit v1.2.3 From 3447815896954281938500d49bedef715078a140 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 19 Feb 2016 22:41:23 +0100 Subject: [features,parsers] implement font fallbacks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building on the combination mechanism, this allows defining fallback fonts of which all glyphs are pulled that aren’t currently part of the base font. Example: \input luaotfload.sty \font \lm = file:lmroman10-regular.otf:mode=base \font \cmu = file:cmunrm.otf:mode=base \font \lmu = "combo: 1->\fontid\lm; 2->\fontid\cmu,fallback" \lmu Eh bien, mon prince. Gênes et Lueques ne sont plus que des apanages, des поместья, de la famille Buonaparte. \bye This allows setting Latin Modern text that contains Cyrillic letters. Note that -- as with the other combinations -- only glyphs are considered, no other properties of the fallback font. So besides the occasional letter in a different script this functionality is probably useless. --- src/luaotfload-loaders.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/luaotfload-loaders.lua') diff --git a/src/luaotfload-loaders.lua b/src/luaotfload-loaders.lua index 80ce41a..fb01821 100644 --- a/src/luaotfload-loaders.lua +++ b/src/luaotfload-loaders.lua @@ -123,6 +123,7 @@ do logreport ("both", 0, "loaders", " > name %q", result.name or "") logreport ("both", 0, "loaders", " > fontname %q", result.fontname or "") logreport ("both", 0, "loaders", " > fullname %q", result.fullname or "") + logreport ("both", 0, "loaders", " > type %s", result.type or "") return result end end -- cgit v1.2.3