From 6c669a52cf5503bac7e507ccfb0ca04d0ddf3378 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Tue, 11 May 2010 14:20:37 +0300 Subject: Make sure the font exists on the disk Sometimes the database is outdated in the font no longer exits in the saved path, now we make sure the file exists before returning path to luatex. This way the user gets the good old "font not loadable" error, instead of mysterious backend error and program exit. Later we may try to update the database at this point. --- otfl-font-nms.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index f856757..1922be3 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -141,8 +141,12 @@ function names.resolve(specification) end end if #found == 1 then - logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, found[1].filename[1]) - return found[1].filename[1], found[1].filename[2] + if kpse.lookup(found[1].filename[1]) then + logs.report("load font", + "font family='%s', subfamily='%s' found: %s", + name, style, found[1].filename[1]) + return found[1].filename[1], found[1].filename[2] + 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 @@ -157,11 +161,15 @@ function names.resolve(specification) least = difference end end - logs.report("load font", "font family='%s', subfamily='%s' found: %s", name, style, closest.filename[1]) - return closest.filename[1], closest.filename[2] - else - return specification.name, false -- fallback to filename + if kpse.lookup(closest.filename[1]) then + logs.report("load font", + "font family='%s', subfamily='%s' found: %s", + name, style, closest.filename[1]) + return closest.filename[1], closest.filename[2] + end end + -- no font found so far, fallback to filename + return specification.name, false end else logs.report("load font", "no font names database loaded") -- cgit v1.2.3