diff options
Diffstat (limited to 'otfl-font-nms.lua')
-rw-r--r-- | otfl-font-nms.lua | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 938b6bd..b565aac 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -47,7 +47,7 @@ local function fontnames_init() } end -function names.load() +local function load_names() local localpath = file.join(names.path.localdir, names.path.basename) local systempath = file.join(names.path.systemdir, names.path.basename) local kpsefound = kpse.find_file(names.path.basename) @@ -238,7 +238,7 @@ end local lastislog = 0 -function log(fmt, ...) +local function log(fmt, ...) lastislog = 1 texio.write_nl(format("luaotfload | %s", format(fmt,...))) io.flush() @@ -248,8 +248,6 @@ logs = logs or { } logs.report = logs.report or log logs.info = logs.info or log -local log = names.log - local function font_fullinfo(filename, subfont, texmf) local t = { } local f = fontloader.open(filename, subfont) @@ -635,9 +633,10 @@ local function update_names(fontnames, force) if force then fontnames = fontnames_init() else - if not fontnames - or not fontnames.version - or fontnames.version ~= names.version then + if not fontnames then + fontnames = names.load() + end + if fontnames.version ~= names.version then fontnames = fontnames_init() if trace_search then logs.report("No font names database or old one found; " @@ -659,7 +658,15 @@ local function save_names(fontnames) if not lfs.isdir(savepath) then dir.mkdirs(savepath) end - table.tofile(file.join(savepath, names.path.basename), fontnames, true) + savepath = file.join(savepath, names.path.basename) + if file.iswritable(savepath) then + table.tofile(savepath, fontnames, true) + logs.info("Font names database saved: %s \n", savepath) + return savepath + else + logs.info("Failed to save names database\n") + return nil + end end local function scan_external_dir(dir) @@ -676,5 +683,6 @@ local function scan_external_dir(dir) end names.scan = scan_external_dir +names.load = load_names names.update = update_names names.save = save_names |