diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2010-05-11 14:20:37 +0300 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2010-05-11 14:20:37 +0300 |
commit | 6c669a52cf5503bac7e507ccfb0ca04d0ddf3378 (patch) | |
tree | 9d3b2339453494607e2b3f451036e66c3958d8e7 | |
parent | ee90fe0345edd9aef912bec57f952974d7c578b3 (diff) | |
download | luaotfload-6c669a52cf5503bac7e507ccfb0ca04d0ddf3378.tar.gz |
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.
-rw-r--r-- | otfl-font-nms.lua | 20 |
1 files 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") |