summaryrefslogtreecommitdiff
path: root/otfl-font-nms.lua
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-05-16 21:50:03 +0300
committerKhaled Hosny <khaledhosny@eglug.org>2010-05-16 21:50:03 +0300
commit0720db026ba8fc1f2cf3791a8d4d868b8c0c8d4d (patch)
treeb5daf3c7768df123cbb1508046674ddb86e79519 /otfl-font-nms.lua
parentf63d8db3576d9251e42297c61d98d4715c55b428 (diff)
downloadluaotfload-0720db026ba8fc1f2cf3791a8d4d868b8c0c8d4d.tar.gz
Update the database if a font is not found
We now try to update the database if a font is not found.
Diffstat (limited to 'otfl-font-nms.lua')
-rw-r--r--otfl-font-nms.lua38
1 files changed, 31 insertions, 7 deletions
diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua
index 20e5fbd..1f9da96 100644
--- a/otfl-font-nms.lua
+++ b/otfl-font-nms.lua
@@ -67,15 +67,12 @@ function names.load()
else
logs.report("load font",
"no font names database found, generating new one")
- local savepath = names.path.localdir .. names.path.basename
data = names.update()
- io.savedata(savepath, table.serialize(data, true))
+ names.save(data)
end
return data
end
-local loaded = false
-
local synonyms = {
regular = {
normal = true,
@@ -96,6 +93,9 @@ local synonyms = {
},
}
+local loaded = false
+local reloaded = false
+
function names.resolve(specification)
local tfm = resolvers.find_file(specification.name, "ofm")
local name = sanitize(specification.name)
@@ -215,7 +215,25 @@ function names.resolve(specification)
return closest.filename[1], closest.filename[2]
end
end
- -- no font found so far, fallback to filename
+ -- no font found so far
+ if not reloaded then
+ -- try reloading the database
+ names.data = names.update(names.data)
+ names.save(names.data)
+ reloaded = true
+ return names.resolve(specification)
+ else
+ -- else, fallback to filename
+ return specification.name, false
+ end
+ end
+ else
+ if not reloaded then
+ names.data = names.update()
+ names.save(names.data)
+ reloaded = true
+ return names.resolve(specification)
+ else
return specification.name, false
end
end
@@ -523,7 +541,7 @@ local function scan_os_fonts(fontnames, newfontnames)
end
end
-local function update(fontnames, force)
+local function update_names(fontnames, force)
--[[
The main function, scans everything
- fontnames is the final table to return
@@ -548,5 +566,11 @@ local function update(fontnames, force)
return newfontnames
end
+local function save_names(fontnames)
+ local savepath = names.path.localdir .. names.path.basename
+ io.savedata(savepath, table.serialize(fontnames, true))
+end
+
names.scan = scan_dir
-names.update = update
+names.update = update_names
+names.save = save_names