From fa25005e7ad5ffc537b5aaf39d1b3562daf8f5eb Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 14 Feb 2014 23:01:00 +0100 Subject: [db,tool] make local font scan part of update_names() --- src/luaotfload-database.lua | 41 +++++++++++++++++++++-------------------- src/luaotfload-tool.lua | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua index 06a3dea..54a0398 100644 --- a/src/luaotfload-database.lua +++ b/src/luaotfload-database.lua @@ -535,28 +535,28 @@ local load_lua_file = function (path) end --- define locals in scope +local collect_families local crude_file_lookup local crude_file_lookup_verbose local find_closest local flush_lookup_cache -local ot_fullinfo -local t1_fullinfo -local load_names +local generate_filedata +local get_font_filter +local group_modifiers local load_lookups +local load_names +local order_design_sizes +local ot_fullinfo local read_blacklist local reload_db -local resolve_name local resolve_cached local resolve_fullpath -local save_names +local resolve_name local save_lookups -local update_names -local get_font_filter +local save_names local set_font_filter -local generate_filedata -local collect_families -local group_modifiers -local order_design_sizes +local t1_fullinfo +local update_names --- state of the database local fonts_reloaded = false @@ -2407,20 +2407,16 @@ end --doc]]-- -local scan_local_fonts = function () +local scan_local_fonts = function (currentnames, + targetnames, + dry_run) local n_scanned, n_new = 0, 0 local pwd = lfscurrentdir () - local name_index = name_index report ("both", 1, "db", "Scanning fonts in $PWD (%q) ...", pwd) - n_scanned, n_new = scan_dir (pwd, name_index, name_index, false, "local") + n_scanned, n_new = scan_dir (pwd, currentnames, targetnames, false, "local") if n_new > 0 then - name_index.files = generate_filedata (name_index.mappings) - name_index.families = collect_families (name_index.mappings) - name_index.families = group_modifiers (name_index.mappings, - name_index.families) - name_index.families = order_design_sizes (name_index.families) - name_index.meta["local"] = true --- prevent saving to disk + targetnames.meta["local"] = true --- prevent saving to disk end return n_scanned, n_new @@ -2938,6 +2934,11 @@ local retrieve_namedata = function (currentnames, n_rawnames = n_rawnames + rawnames n_newnames = n_newnames + new + rawnames, new = scan_local_fonts (currentnames, targetnames, dry_run) + + n_rawnames = n_rawnames + rawnames + n_newnames = n_newnames + new + return n_rawnames, n_newnames end diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua index 9f00956..d405dc7 100755 --- a/src/luaotfload-tool.lua +++ b/src/luaotfload-tool.lua @@ -1174,7 +1174,7 @@ local process_cmdline = function ( ) -- unit -> jobspec action_pending["flush"] = true elseif v == "L" then action_pending["generate"] = true - action_pending["scan_local"] = true + luaotfloadconfig.scan_local = true elseif v == "list" then action_pending["list"] = true result.criterion = optarg[n] -- cgit v1.2.3 From 93d0150fdba1a1e212aafeb4e16faef1cba82d60 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 14 Feb 2014 23:15:37 +0100 Subject: =?UTF-8?q?[db,main,tool]=20scan=20local=20fonts=20upon=20failed?= =?UTF-8?q?=20lookup=20during=20a=20TeX=20run=20(requires=20the=20config?= =?UTF-8?q?=20flag=20=E2=80=9Cscan=5Flocal=E2=80=9D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/luaotfload-database.lua | 42 ++++++++++++++++++++++-------------------- src/luaotfload-main.lua | 5 +++-- src/luaotfload-tool.lua | 11 +++-------- 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua index 54a0398..923f7c5 100644 --- a/src/luaotfload-database.lua +++ b/src/luaotfload-database.lua @@ -1171,9 +1171,6 @@ resolve_name = function (specification) name, style) end - if not resolved then - resolved = specification.name, false - end if not resolved then if not fonts_reloaded then @@ -2934,10 +2931,12 @@ local retrieve_namedata = function (currentnames, n_rawnames = n_rawnames + rawnames n_newnames = n_newnames + new - rawnames, new = scan_local_fonts (currentnames, targetnames, dry_run) + if luaotfloadconfig.scan_local == true then + rawnames, new = scan_local_fonts (currentnames, targetnames, dry_run) - n_rawnames = n_rawnames + rawnames - n_newnames = n_newnames + new + n_rawnames = n_rawnames + rawnames + n_newnames = n_newnames + new + end return n_rawnames, n_newnames end @@ -3114,8 +3113,8 @@ end --- dbobj? -> bool? -> bool? -> dbobj update_names = function (currentnames, force, dry_run) - local targetnames + local n_raw, n_new = 0, 0 if luaotfloadconfig.update_live == false then report ("info", 2, "db", @@ -3124,8 +3123,7 @@ update_names = function (currentnames, force, dry_run) return currentnames or name_index end - local starttime = osgettimeofday () - local n_rawnames, n_newnames = 0, 0 + local starttime = osgettimeofday () --[[ The main function, scans everything @@ -3164,14 +3162,14 @@ update_names = function (currentnames, force, dry_run) read_blacklist () - local n_raw, n_new = retrieve_namedata (currentnames, - targetnames, - dry_run, - n_rawnames, - n_newnames) + n_raw, n_new = retrieve_namedata (currentnames, + targetnames, + dry_run, + 0, + 0) report ("info", 3, "db", "Scanned %d font files; %d new entries.", - n_rawnames, n_newnames) + n_raw, n_new) end --- pass 2 (optional): collect some stats about the raw font info @@ -3205,11 +3203,15 @@ update_names = function (currentnames, force, dry_run) if dry_run ~= true then - local success, reason = save_names () - if not success then - report ("both", 0, "db", - "Failed to save database to disk: %s", - reason) + if n_new == 0 then + report ("info", 2, "db", "No new fonts found, skip saving to disk.") + else + local success, reason = save_names () + if not success then + report ("both", 0, "db", + "Failed to save database to disk: %s", + reason) + end end if flush_lookup_cache () and save_lookups () then diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index f5f012d..ed7fdd3 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -1,10 +1,10 @@ ----------------------------------------------------------------------- -- FILE: luaotfload-main.lua -- DESCRIPTION: Luatex fontloader initialization --- REQUIREMENTS: luatex v.0.78 or later, the lualibs package +-- REQUIREMENTS: luatex v.0.78 or later; the lualibs package -- AUTHOR: Élie Roux, Khaled Hosny, Philipp Gesang -- VERSION: same as Luaotfload --- MODIFIED: 2014-02-09 14:42:22+0100 +-- MODIFIED: 2014-02-14 22:51:09+0100 ----------------------------------------------------------------------- -- --- Note: @@ -59,6 +59,7 @@ config.luaotfload.names_dir = config.luaotfload.names_dir or "names config.luaotfload.cache_dir = config.luaotfload.cache_dir or "fonts" config.luaotfload.index_file = config.luaotfload.index_file or "luaotfload-names.lua" config.luaotfload.formats = config.luaotfload.formats or "otf,ttf,ttc,dfont" +config.luaotfload.scan_local = config.luaotfload.scan_local == true if not config.luaotfload.strip then config.luaotfload.strip = true diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua index d405dc7..f9b9b94 100755 --- a/src/luaotfload-tool.lua +++ b/src/luaotfload-tool.lua @@ -723,9 +723,9 @@ set. --]]-- local action_sequence = { - "loglevel", "help", "version", "diagnose", - "blacklist", "cache", "flush", "generate", - "scan_local", "list", "query", + "loglevel", "help", "version", "diagnose", + "blacklist", "cache", "flush", "generate", + "list", "query", } local action_pending = tabletohash(action_sequence, false) @@ -770,11 +770,6 @@ actions.generate = function (job) return false, false end -actions.scan_local = function (job) - names.scan_local_fonts () - return true, true -end - actions.flush = function (job) local success = names.flush_lookup_cache() if success then -- cgit v1.2.3 From 41a2ac387b7cbc1d724fd0016a156c4b210ec07e Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 14 Feb 2014 23:17:02 +0100 Subject: [*] update news --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index b130f1d..1966c03 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ Change History luaotfload-database (fontconfig) into the new file luaotfload-parsers.lua. * Move logging routines from luaotfload-override in to luaotfload-log. + * Scan local font files (``--local`` flag to luaotfload-tool, flag + ``scan_local`` during TeX run). 2013/12/31, luaotfload v2.4 * Additional self-tests, now in separate file (luaotfload-diagnostics.lua) -- cgit v1.2.3