summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-02-14 21:50:50 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2014-02-14 21:50:50 +0100
commit0c7e35163064e7d40cddbad129745060d9666ee6 (patch)
tree6d103c1297c1890b445b38cf9061e203de9495ff
parentaafd73e8a91f986f011338301adac09f046b745f (diff)
downloadluaotfload-0c7e35163064e7d40cddbad129745060d9666ee6.tar.gz
[db] add “local” field to meta table in db
-rw-r--r--src/luaotfload-database.lua35
-rwxr-xr-xsrc/luaotfload-tool.lua2
2 files changed, 23 insertions, 14 deletions
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index 4b2d201..54474e2 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -140,7 +140,7 @@ luaotfloadconfig.compress = luaotfloadconfig.compress ~= false
local names = fonts.names
local name_index = nil --> upvalue for names.data
local lookup_cache = nil --> for names.lookups
-names.version = 2.5
+names.version = 2.51
names.data = nil --- contains the loaded database
names.lookups = nil --- contains the lookup cache
@@ -356,6 +356,7 @@ This is a sketch of the luaotfload db:
optical : (int, int) list; // design size -> index entry
}
and metadata = {
+ local : bool; (* set if local fonts were added to the db *)
formats : string list; // { "otf", "ttf", "ttc", "dfont" }
statistics : TODO;
version : float;
@@ -439,7 +440,9 @@ mtx-fonts has in names.tma:
--doc]]--
-local initialize_namedata = function (formats) --- returns dbobj
+--- string list -> dbobj
+
+local initialize_namedata = function (formats)
return {
--families = { },
status = { }, -- was: status; map abspath -> mapping
@@ -447,6 +450,7 @@ local initialize_namedata = function (formats) --- returns dbobj
names = { },
-- files = { }, -- created later
meta = {
+ ["local"] = false,
formats = formats,
statistics = { },
version = names.version,
@@ -2380,11 +2384,11 @@ local scan_os_fonts = function (currentnames,
return n_scanned, n_new
end
---- unit -> (bool, lookup_cache)
+--- unit -> bool
flush_lookup_cache = function ()
lookup_cache = { }
collectgarbage "collect"
- return true, lookup_cache
+ return true
end
@@ -3164,16 +3168,16 @@ update_names = function (currentnames, force, dry_run)
if dry_run ~= true then
- save_names ()
+ local success, reason = save_names ()
+ if not success then
+ report ("both", 0, "db",
+ "Failed to save database to disk: %s",
+ reason)
+ end
- local success, _lookups = flush_lookup_cache ()
- if success then
- local success = save_lookups ()
- if success then
- report ("info", 2, "cache",
- "Lookup cache emptied.")
- return targetnames
- end
+ if flush_lookup_cache () and save_lookups () then
+ report ("both", 2, "cache", "Lookup cache emptied.")
+ return targetnames
end
end
return targetnames
@@ -3211,6 +3215,11 @@ save_names = function (currentnames)
if not currentnames then
currentnames = name_index
end
+ if not currentnames or type (currentnames) ~= "table" then
+ return false, "invalid names table"
+ elseif currentnames.meta and currentnames.meta["local"] then
+ return false, "table contains local entries"
+ end
local path = names.path.index
local luaname, lucname = path.lua, path.luc
if fileiswritable (luaname) and fileiswritable (lucname) then
diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua
index 35765b5..01d0361 100755
--- a/src/luaotfload-tool.lua
+++ b/src/luaotfload-tool.lua
@@ -772,7 +772,7 @@ actions.generate = function (job)
end
actions.flush = function (job)
- local success, lookups = names.flush_lookup_cache()
+ local success = names.flush_lookup_cache()
if success then
local success = names.save_lookups()
if success then