summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-11-13 00:32:35 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2013-11-13 00:32:35 +0100
commita914c23b674ff6bacb85a9701a828e03ec24cbc0 (patch)
tree8db9f9aef2cc694e4c494f7b75912795bb4357ef
parent14834c9ea172588cc6cd4f111cdb16ce88ce2c2f (diff)
downloadluaotfload-a914c23b674ff6bacb85a9701a828e03ec24cbc0.tar.gz
[tool,man,db] add --max-fonts option to restrict db size
-rw-r--r--luaotfload-database.lua24
-rwxr-xr-xluaotfload-tool.lua10
-rw-r--r--luaotfload-tool.rst2
3 files changed, 27 insertions, 9 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index a12cdd1..4ee07f4 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -533,6 +533,7 @@ local set_font_filter
--- state of the database
local fonts_reloaded = false
+local fonts_read = 0
--- limit output when approximate font matching (luaotfload-tool -F)
local fuzzy_limit = 1 --- display closest only
@@ -2112,15 +2113,20 @@ local scan_dir = function (dirname, currentnames, targetnames,
local fullname = found[j]
fullname = path_normalize(fullname)
local new
- if dry_run == true then
- report_status ("both", "db",
- "Would have been loading %q", fullname)
- else
- report_status ("both", "db", "Loading font %q", fullname)
- local new = read_font_names (fullname, currentnames,
- targetnames, texmf)
- if new == true then
- n_new = n_new + 1
+ if not luaotfloadconfig.max_fonts
+ or luaotfloadconfig.max_fonts and fonts_read < luaotfloadconfig.max_fonts
+ then
+ if dry_run == true then
+ report_status ("both", "db",
+ "Would have been loading %q", fullname)
+ else
+ report_status ("both", "db", "Loading font %q", fullname)
+ local new = read_font_names (fullname, currentnames,
+ targetnames, texmf)
+ if new == true then
+ fonts_read = fonts_read + 1
+ n_new = n_new + 1
+ end
end
end
end
diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua
index f1e4808..41ac4d7 100755
--- a/luaotfload-tool.lua
+++ b/luaotfload-tool.lua
@@ -225,6 +225,7 @@ This tool is part of the luaotfload package. Valid options are:
-D --dry-run skip loading of fonts, just scan
--formats=[+|-]EXTENSIONS set, add, or subtract formats to index
-p --prefer-texmf prefer fonts in the TEXMF over system fonts
+ --max-fonts=N process at most N font files
--find="font name" query the database for a font name
-F --fuzzy look for approximate matches if --find fails
@@ -1114,6 +1115,7 @@ local process_cmdline = function ( ) -- unit -> jobspec
limit = 1,
list = 1,
log = 1,
+ ["max-fonts"] = 1,
["no-reload"] = "n",
["no-strip"] = 0,
["skip-read"] = "R",
@@ -1219,6 +1221,14 @@ local process_cmdline = function ( ) -- unit -> jobspec
luaotfloadconfig.compress = false
elseif v == "no-strip" then
luaotfloadconfig.strip = false
+ elseif v == "max-fonts" then
+ local n = optarg[n]
+ if n then
+ n = tonumber(lvl)
+ if n and n > 0 then
+ luaotfloadconfig.max_fonts = n
+ end
+ end
end
end
diff --git a/luaotfload-tool.rst b/luaotfload-tool.rst
index abe5ed7..957ec85 100644
--- a/luaotfload-tool.rst
+++ b/luaotfload-tool.rst
@@ -74,6 +74,8 @@ update mode
--prefer-texmf, -p Organize the file name database in a way so
that it prefer fonts in the *TEXMF* tree over
system fonts if they are installed in both.
+--max-fonts=N Process at most *N* font files, including fonts
+ already indexed in the count.
--formats=EXTENSIONS Extensions of the font files to index.
Where *EXTENSIONS* is a comma-separated list of
supported file extensions (otf, ttf, ttc,