summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--luaotfload-features.lua23
-rw-r--r--luaotfload.dtx30
2 files changed, 47 insertions, 6 deletions
diff --git a/luaotfload-features.lua b/luaotfload-features.lua
index f3d9158..c939a3f 100644
--- a/luaotfload-features.lua
+++ b/luaotfload-features.lua
@@ -401,7 +401,7 @@ local import_values = {
"style", "optsize", "lookup", "sub" --[[‽]], "mode",
}
-local handle_name = function (specname, raw)
+local handle_tfmofm = function (specname, raw)
--- FIXME only file: and name: atm
local name = raw.file or raw.name or specname
local lookup
@@ -418,13 +418,28 @@ local handle_name = function (specname, raw)
return name, lookup
end
+local lookup_types = { "anon", "file", "name", "path" }
+
+local select_lookup = function (request)
+ for i=1, #lookup_types do
+ local lookup = lookup_types[i]
+ local value = request[lookup]
+ if value then
+ return lookup, value
+ end
+ end
+end
+
--- spec -> spec
local handle_request = function (specification)
- local request = lpegmatch(font_request,
- specification.specification)
+ local request = lpegmatch(font_request,
+ specification.specification)
+ local lookup, name = select_lookup(request)
request.features = set_default_features(request.features)
- local name, lookup = handle_name(specification.name, request)
+ --- FIXME what to do about tfm/ofm??
+ --local name, lookup = handle_tfmofm(specification.name, request)
+
if name then
specification.name = name
specification.lookup = lookup or specification.lookup
diff --git a/luaotfload.dtx b/luaotfload.dtx
index 8b3616a..ead0773 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -1371,8 +1371,10 @@ loadmodule"colors.lua" --- “font-clr”
-- specification.name = fonts.names.resolve('', '', specification)
--end
-fonts.definers.resolvers.file = function (specification)
- --inspect(specification)
+local resolvers = fonts.definers.resolvers
+local formats = fonts.formats
+
+resolvers.file = function (specification)
if specification.lookup == "file" then
local found = fonts.names.crude_file_lookup(specification.name)
--local found = fonts.names.crude_file_lookup_verbose(specification.name)
@@ -1380,6 +1382,30 @@ fonts.definers.resolvers.file = function (specification)
end
end
+--- TODO rewrite this according to the syntax spec
+resolvers.anon = function (specification)
+ local resolved, subfontno = fonts.names.resolve(nil, nil, specification)
+ if resolved then --- we follow fonts-def to some extent
+ specification.resolved = resolved
+ specification.sub = subfontno
+ local suffix = file.suffix(resolved)
+ if formats[suffix] then
+ specification.forced = suffix
+ specification.name = file.removesuffix(resolved)
+ else
+ specification.name = resolved
+ end
+ else
+ resolvers.file(specification)
+ end
+end
+
+--- TODO rewrite this according to the syntax spec
+resolvers.path = function (specification)
+ local found = fonts.names.crude_file_lookup(specification.name)
+ specification.name = found[1]
+end
+
% \end{macrocode}
% We create a callback for patching fonts on the fly, to be used by other
% packages.