summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2011-10-16 20:07:43 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2011-10-16 20:07:43 +0200
commit8ead3332393b829e6dd500c5cae4ed7502f6a47c (patch)
tree02ac05695ec595bf2bb9d55c2b126dc637bf5562
parent13b3a5acabebf5147b34f07510d1ef96a07794cd (diff)
downloadluaotfload-8ead3332393b829e6dd500c5cae4ed7502f6a47c.tar.gz
Add support for compiled names cache
-rwxr-xr-xmkluatexfontdb.lua3
-rw-r--r--otfl-font-nms.lua24
2 files changed, 20 insertions, 7 deletions
diff --git a/mkluatexfontdb.lua b/mkluatexfontdb.lua
index 21d3cce..2cc67c9 100755
--- a/mkluatexfontdb.lua
+++ b/mkluatexfontdb.lua
@@ -9,7 +9,10 @@ luaotfload bundle, please see the luaotfload documentation for more info.
kpse.set_program_name("luatex")
+function string.quoted(s) return string.format("%q",s) end -- XXX
+
require("lualibs")
+require("otfl-basics-gen.lua")
require("otfl-font-nms")
require("alt_getopt")
diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua
index 34cef92..06c6dad 100644
--- a/otfl-font-nms.lua
+++ b/otfl-font-nms.lua
@@ -11,7 +11,7 @@ fonts.names = fonts.names or { }
local names = fonts.names
local names_dir = "luatex-cache/generic/names"
-names.version = 2.009 -- not the same as in context
+names.version = 2.010 -- not the same as in context
names.data = nil
names.path = {
basename = "otfl-names.lua",
@@ -58,13 +58,21 @@ local function fontnames_init()
}
end
+local function make_name(path)
+ return file.replacesuffix(path, "lua"), file.replacesuffix(path, "luc")
+end
+
local function load_names()
- local localpath = file.join(names.path.localdir, names.path.basename)
+ local path = file.join(names.path.localdir, names.path.basename)
+ local luaname, lucname = make_name(path)
local foundname
local data
- if file.isreadable(localpath) then
- data = dofile(localpath)
- foundname = localpath
+ if file.isreadable(lucname) then
+ data = dofile(lucname)
+ foundname = lucname
+ elseif file.isreadable(luaname) then
+ data = dofile(luaname)
+ foundname = luaname
end
if data then
logs.info("Font names database loaded", "%s", foundname)
@@ -727,8 +735,10 @@ local function save_names(fontnames)
end
savepath = file.join(savepath, names.path.basename)
if file.iswritable(savepath) then
- table.tofile(savepath, fontnames, true)
- logs.info("Font names database saved", "%s", savepath)
+ local luaname, lucname = make_name(savepath)
+ table.tofile(luaname, fontnames, true)
+ caches.compile(fontnames,luaname,lucname)
+ logs.info("Font names database saved")
return savepath
else
logs.info("Failed to save names database")