From 542fc9edfb02a4e0cbde369e16dd66227cba95fc Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 3 May 2013 19:55:03 +0200 Subject: make cache flushing work with new cache file --- luaotfload-database.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index aaba55a..6f95208 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -116,6 +116,7 @@ Auxiliary functions local report = logs.names_report +--- string -> string local sanitize_string = function (str) if str ~= nil then return utf8gsub(utf8lower(str), "[^%a%d]", "") @@ -1537,6 +1538,7 @@ end --- export functionality to the namespace “fonts.names” names.flush_cache = flush_cache +names.save_lookups = save_lookups names.load = load_names names.save = save_names names.scan = scan_external_dir -- cgit v1.2.3 From 21b1fb201a2fd9f058c1fee24dbd29df1debe6f7 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 4 May 2013 11:49:12 +0200 Subject: bump version; add/update attributions --- luaotfload-database.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 6f95208..8faeba2 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1,7 +1,7 @@ if not modules then modules = { } end modules ['luaotfload-database'] = { version = 2.2, comment = "companion to luaotfload.lua", - author = "Khaled Hosny and Elie Roux", + author = "Khaled Hosny, Elie Roux, Philipp Gesang", copyright = "Luaotfload Development Team", license = "GNU GPL v2" } -- cgit v1.2.3 From 15ff8e6e3b942aa9df98ea1df572eaee6d9f292b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 5 May 2013 22:45:52 +0200 Subject: activate lookup cache by default --- luaotfload-database.lua | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 8faeba2..beef5b1 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -383,25 +383,20 @@ Even if we find a matching font eventually, the next time the user compiles Eir document E will have to stand through the delay again. Thus, some caching of results -- even between runs -- is in order. -We’ll just store successful lookups in the database in a record of -the respective lookup type. +We’ll just store successful name: lookups in a separate cache file. type lookup_cache = (string, (string * num)) dict -TODO: +Complete, needs testing: × 1) add cache to dbobj × 2) wrap lookups in cached versions × 3) make caching optional (via the config table) for debugging × 4) make names_update() cache aware (nil if “force”) × 5) add logging × 6) add cache control to luaotfload-tool - × 7) incr db version - 8) wishlist: save cache only at the end of a run - 9) ??? - n) PROFIT!!! + × 7) incr db version (now 2.203) + × 8) save cache only at the end of a run -The name lookup requires both the “name” and some other -keys, so we’ll concatenate them. The spec is modified in place (ugh), so we’ll have to catalogue what fields actually influence its behavior. @@ -416,20 +411,11 @@ Idk what the “spec” resolver is for. * name: contains both the name resolver from luatex-fonts and resolve() below -The following fields of a resolved spec need to be cached: ---doc]]-- -local cache_fields = { - "forced", "hash", "lookup", "name", "resolved", "sub", -} - ---[[doc-- From my reading of font-def.lua, what a resolver does is basically rewrite the “name” field of the specification record with the resolution. Also, the fields “resolved”, “sub”, “force” etc. influence the outcome. -We’ll just cache a deep copy of the entire spec as it leaves the -resolver, lest we want to worry if we caught all the details. --doc]]-- --- 'a -> 'a -> table -> (string * int|boolean * boolean) @@ -459,12 +445,8 @@ resolve_cached = function (_, _, specification) names.lookups[request] = entry --- obviously, the updated cache needs to be stored. - --- for the moment, we write the entire db to disk - --- whenever the cache is updated. --- TODO this should trigger a save only once the --- document is compiled (finish_pdffile callback?) - --- TODO we should speed up writing by separating - --- the cache from the db report("both", 5, "cache", "saving updated cache") save_lookups() return filename, subfont, true -- cgit v1.2.3 From 241b75b723615faf6be374bfe32506211a01307e Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 6 May 2013 10:41:24 +0200 Subject: fix unsupported style modifiers --- luaotfload-database.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index beef5b1..b7446c9 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -98,7 +98,7 @@ local writable_path if caches then writable_path = caches.getwritablepath("names","") if not writable_path then - error("Impossible to find a suitable writeable cache...") + luaotfload.error("Impossible to find a suitable writeable cache...") end names.path.dir = writable_path names.path.path = filejoin(writable_path, names.path.basename) -- cgit v1.2.3 From 1bd7bd84c9a73105fce7909f14628746328ed823 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 6 May 2013 11:48:23 +0200 Subject: reduce verbosity of most db related tasks --- luaotfload-database.lua | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index b7446c9..576341f 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -134,11 +134,10 @@ This is a sketch of the luaotfload db: // preliminary additions of v2.2: basenames : (string, int) hash; // where int is the index in mappings barenames : (string, int) hash; // where int is the index in mappings - request_cache : lookup_cache; // see below } and fontentry = { familyname : string; - filename : (string * bool); + filename : (string * int); // int: subfont fontname : string; fullname : string; names : { @@ -189,21 +188,15 @@ mtx-fonts has in names.tma: width : string; } - --doc]]-- local fontnames_init = function (keep_cache) --- returns dbobj return { mappings = { }, status = { }, - --- adding filename mapping increases the - --- size of the serialized db on my system - --- (5840 font files) by a factor of 1.09 - --- if we store only the indices in the - --- mappings table barenames = { }, basenames = { }, --- fullnames = { }, +-- fullnames = { }, // -> status version = names.version, } end @@ -262,18 +255,21 @@ local update_names local fonts_loaded = false local fonts_reloaded = false +--- limit output when approximate font matching (luaotfload-tool -F) +local fuzzy_limit = 1 --- display closest only + --- unit -> dbobj load_names = function ( ) local starttime = os.gettimeofday() local foundname, data = load_lua_file(names.path.path) if data then - report("info", 1, "db", + report("both", 2, "db", "Font names database loaded", "%s", foundname) report("info", 3, "db", "Loading took %0.f ms", 1000*(os.gettimeofday()-starttime)) else - report("info", 1, "db", + report("both", 0, "db", [[Font names database not found, generating new one. This can take several minutes; please be patient.]]) data = update_names(fontnames_init(false)) @@ -287,7 +283,7 @@ end load_lookups = function ( ) local foundname, data = load_lua_file(names.path.lookup_path) if data then - report("both", 1, "cache", + report("both", 3, "cache", "Lookup cache loaded (%s)", foundname) else report("both", 1, "cache", @@ -297,8 +293,6 @@ load_lookups = function ( ) return data end -local fuzzy_limit = 1 --- display closest only - local style_synonyms = { set = { } } do style_synonyms.list = { @@ -664,15 +658,12 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con if not fonts_reloaded then --- last straw: try reloading the database return reload_db( - "unresolved font name: “" .. name .. "”", + "unresolved font name: ‘" .. name .. "’", resolve, nil, nil, specification ) end --- else, fallback to requested name - --- specification.name is empty with absolute paths, looks - --- like a bug in the specification parser