summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-02-14 23:18:53 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2014-02-14 23:18:53 +0100
commitaa016b9643a986dc1cf0bed24fbb07e302b5d0d8 (patch)
tree432c5d80fd0f53436c17c0ffb0000dad1698ca60
parent5ea0298990512f196ce1fb54ae2e6becc7b725a6 (diff)
parent41a2ac387b7cbc1d724fd0016a156c4b210ec07e (diff)
downloadluaotfload-aa016b9643a986dc1cf0bed24fbb07e302b5d0d8.tar.gz
Merge pull request #199 from phi-gamma/texlive2014
scan local fonts during TeX run
-rw-r--r--NEWS2
-rw-r--r--src/luaotfload-database.lua77
-rw-r--r--src/luaotfload-main.lua5
-rwxr-xr-xsrc/luaotfload-tool.lua13
4 files changed, 49 insertions, 48 deletions
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)
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index 06a3dea..923f7c5 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
@@ -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
@@ -2407,20 +2404,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 +2931,13 @@ local retrieve_namedata = function (currentnames,
n_rawnames = n_rawnames + rawnames
n_newnames = n_newnames + new
+ 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
+ end
+
return n_rawnames, n_newnames
end
@@ -3113,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",
@@ -3123,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
@@ -3163,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
@@ -3204,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 9f00956..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
@@ -1174,7 +1169,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]