summaryrefslogtreecommitdiff
path: root/luaotfload-database.lua
diff options
context:
space:
mode:
Diffstat (limited to 'luaotfload-database.lua')
-rw-r--r--luaotfload-database.lua40
1 files changed, 36 insertions, 4 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index bccfd7b..714c37c 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -47,7 +47,6 @@ local C, Cc, Cf, Cg, Cs, Ct
--- Luatex builtins
local load = load
local next = next
-local pcall = pcall
local require = require
local tonumber = tonumber
local unpack = table.unpack
@@ -59,6 +58,7 @@ local fontloaderopen = fontloader.open
local gzipopen = gzip.open
local iolines = io.lines
local ioopen = io.open
+local iopopen = io.popen
local kpseexpand_path = kpse.expand_path
local kpseexpand_var = kpse.expand_var
local kpsefind_file = kpse.find_file
@@ -123,6 +123,26 @@ local luaotfloadconfig = config.luaotfload --- always present
luaotfloadconfig.resolver = luaotfloadconfig.resolver or "normal"
luaotfloadconfig.formats = luaotfloadconfig.formats or "otf,ttf,ttc,dfont"
luaotfloadconfig.strip = luaotfloadconfig.strip == true
+--- The “termwidth” value is only considered when printing
+--- short status messages, e.g. when building the database
+--- online.
+if not luaotfloadconfig.termwidth then
+ local tw = 79
+ if not ( os.type == "windows" --- Assume broken terminal.
+ or os.getenv "TERM" == "dumb")
+ and iopopen
+ then
+ local p = iopopen "tput cols"
+ if p then
+ result = p:read "*all"
+ p:close ()
+ if result then
+ tw = tonumber (result) or tw
+ end
+ end
+ end
+ luaotfloadconfig.termwidth = tw
+end
--- this option allows for disabling updates
--- during a TeX run
@@ -1349,7 +1369,7 @@ local get_english_names = function (names, basename)
local english_names
if names then
- inspect(names)
+ --inspect(names)
for _, raw_namedata in next, names do
if raw_namedata.lang == "English (US)" then
english_names = raw_namedata.names
@@ -2086,6 +2106,16 @@ local find_font_files = function (root, recurse)
end
end
+--- truncate_string -- Cut the first part of a string to fit it
+--- into a given terminal width. The parameter “restrict” (int)
+--- indicates the number of characters already consumed on the
+--- line.
+local ellipsis = ".."
+local truncate_string = function (str, restrict)
+ local wd = luaotfloadconfig.termwidth - restrict - 2
+ return ellipsis .. stringsub(str, #str - wd)
+end
+
--[[doc--
scan_dir() scans a directory and populates the list of fonts
@@ -2131,10 +2161,12 @@ local scan_dir = function (dirname, currentnames, targetnames,
local new
if dry_run == true then
+ local truncated = truncate_string (fullname, 43)
report_status ("both", "db",
- "Would have been loading %q", fullname)
+ "Would have been loading %s", truncated)
else
- report_status ("both", "db", "Loading font %q", fullname)
+ local truncated = truncate_string (fullname, 32)
+ report_status ("both", "db", "Loading font %s", truncated)
local new = read_font_names (fullname, currentnames,
targetnames, texmf)
if new == true then