summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-11-05 15:07:11 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2013-11-05 15:07:11 +0100
commit847b5a1a519b3945a1734f5859a80d459e865457 (patch)
treec649687b3124e3964da892dedb52671460725208
parent74e0f21a51d805f9599dee98a6fe3804e4edee06 (diff)
downloadluaotfload-847b5a1a519b3945a1734f5859a80d459e865457.tar.gz
[db,tool] adapt --find to new db model
-rw-r--r--luaotfload-database.lua72
-rwxr-xr-xluaotfload-tool.lua2
2 files changed, 51 insertions, 23 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index 390c3ea..1a79c3e 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -140,6 +140,16 @@ local noncomma = 1-comma
local splitcomma = Ct((C(noncomma^1) + comma)^1)
patterns.splitcomma = splitcomma
+local format_precedence = {
+ "otf", "ttc", "ttf",
+ "dfont", "afm", "pfb",
+ "pfa",
+}
+
+local location_precedence = {
+ "local", "system", "texmf",
+}
+
--[[doc--
We use the functions in the cache.* namespace that come with the
fontloader (see luat-basics-gen). it’s safe to use for the most part
@@ -614,23 +624,51 @@ crude_file_lookup_verbose = function (filename)
return filename, nil, false
end
+local lookup_filename = function (filename)
+ if not name_index then name_index = load_names () end
+ local files = name_index.files
+ local basedata = files.base
+ local baredata = files.bare
+ for i = 1, #location_precedence do
+ local location = location_precedence [i]
+ local basenames = basedata [location]
+ local barenames = baredata [location]
+ local idx
+ if basenames ~= nil then
+ idx = basenames [filename]
+ if idx then
+ goto done
+ end
+ end
+ if barenames ~= nil then
+ for j = 1, #format_precedence do
+ local format = format_precedence [j]
+ local filemap = barenames [format]
+ if filemap then
+ idx = barenames [format] [filename]
+ if idx then
+ break
+ end
+ end
+ end
+ end
+::done::
+ if idx then
+ return files.full [idx]
+ end
+ end
+end
+
--- string -> (string * string * bool)
crude_file_lookup = function (filename)
- if not name_index then name_index = load_names() end
- local mappings = name_index.mappings
- local files = name_index.files
-
- local found
+ local found = lookup_filename (filename)
- found = files.base[filename]
- or files.bare[filename]
+ if not found then
+ found = dummy_findfile(filename)
+ end
if found then
- found = files.full[found]
- if found == nil then
- found = dummy_findfile(filename)
- end
- return found or filename, nil, true
+ return found, nil, true
end
for i=1, #type1_formats do
@@ -1182,16 +1220,6 @@ local choose_size = function (sizes, askedsize)
return match
end
-local format_precedence = {
- "otf", "ttc", "ttf",
- "dfont", "afm", "pfb",
- "pfa",
-}
-
-local location_precedence = {
- "local", "system", "texmf",
-}
-
--[[doc--
resolve_familyname -- Query the families table for an entry
diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua
index 7c2beda..f9071d9 100755
--- a/luaotfload-tool.lua
+++ b/luaotfload-tool.lua
@@ -837,7 +837,7 @@ actions.query = function (job)
if tmpspec.lookup == "name"
or tmpspec.lookup == "anon" --- not *exactly* as resolvers.anon
then
- foundname, subfont = names.resolve (nil, nil, tmpspec)
+ foundname, subfont = names.resolve_name (tmpspec)
if foundname then
foundname, _, success = names.crude_file_lookup (foundname)
end