summaryrefslogtreecommitdiff
path: root/luaotfload-database.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-04-28 19:13:56 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-04-28 19:13:56 +0200
commit1c8a1d0a59de24f0d1f456c4fad29024e00ef23b (patch)
tree7c041d44346939525dae5a8fc24ff18790e0ee95 /luaotfload-database.lua
parent189085f9a7212320183d5fed0c4aa31df1602d5f (diff)
downloadluaotfload-1c8a1d0a59de24f0d1f456c4fad29024e00ef23b.tar.gz
test for file existence again, but try with ``lfs.isfile()`` first
Diffstat (limited to 'luaotfload-database.lua')
-rw-r--r--luaotfload-database.lua33
1 files changed, 20 insertions, 13 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index e5065bd..8caa35b 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -25,6 +25,7 @@ local kpseexpand_path = kpse.expand_path
local kpseexpand_var = kpse.expand_var
local kpselookup = kpse.lookup
local kpsereadable_file = kpse.readable_file
+local lfsisfile = lfs.isfile
local mathabs = math.abs
local mathmin = math.min
local stringfind = string.find
@@ -639,14 +640,15 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con
end
if #found == 1 then
- --- Since we do the file resolving ourselves, we don’t need the
- --- kpathsea lookup here any longer.
--- “found” is really synonymous with “registered in the db”.
- report("log", 0, "resolve",
- "font family='%s', subfamily='%s' found: %s",
- name, style, found[1].filename[1]
- )
- return found[1].filename[1], found[1].filename[2], true
+ local filename = found[1].filename[1]
+ if lfsisfile(filename) or kpselookup(filename) then
+ report("log", 0, "resolve",
+ "font family='%s', subfamily='%s' found: %s",
+ name, style, filename
+ )
+ return filename, found[1].filename[2], true
+ end
elseif #found > 1 then
-- we found matching font(s) but not in the requested optical
-- sizes, so we loop through the matches to find the one with
@@ -661,13 +663,18 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con
least = difference
end
end
- report("log", 0, "resolve",
- "font family='%s', subfamily='%s' found: %s",
- name, style, closest.filename[1]
- )
- return closest.filename[1], closest.filename[2], true
+ local filename = closest.filename[1]
+ if lfsisfile(filename) or kpselookup(filename) then
+ report("log", 0, "resolve",
+ "font family='%s', subfamily='%s' found: %s",
+ name, style, filename
+ )
+ return filename, closest.filename[2], true
+ end
elseif found.fallback then
- return found.fallback.filename[1], found.fallback.filename[2], true
+ return found.fallback.filename[1],
+ found.fallback.filename[2],
+ true
end
--- no font found so far