summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-08-01 16:27:45 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-08-01 16:27:45 +0200
commit898fa8861c06b41acd946a1de35a13c64e26d22c (patch)
treeb548800d77f100c19c4a26132d7a3f7f610b6add
parentc3e5006283891b494871128613a13ab40f8efc9a (diff)
downloadluaotfload-898fa8861c06b41acd946a1de35a13c64e26d22c.tar.gz
[diagnose] add diagnostics for font index
-rw-r--r--luaotfload-diagnostics.lua50
-rwxr-xr-xluaotfload-tool.lua3
-rw-r--r--luaotfload-tool.rst4
3 files changed, 55 insertions, 2 deletions
diff --git a/luaotfload-diagnostics.lua b/luaotfload-diagnostics.lua
index 46ae412..efb7e5e 100644
--- a/luaotfload-diagnostics.lua
+++ b/luaotfload-diagnostics.lua
@@ -29,14 +29,17 @@ local osname = os.name
local osremove = os.remove
local ostype = os.type
local stringformat = string.format
+local stringlower = string.lower
local stringsub = string.sub
local fileisreadable = file.isreadable
local fileiswritable = file.iswritable
local filesplitpath = file.splitpath
+local filesuffix = file.suffix
local ioloaddata = io.loaddata
local lua_of_json = utilities.json.tolua
local tableconcat = table.concat
+local tablesortedkeys = table.sortedkeys
local tabletohash = table.tohash
local lpeg = require "lpeg"
@@ -47,6 +50,47 @@ local out = function (...)
logs.names_report (false, 0, "diagnose", ...)
end
+local check_index = function (errcnt)
+
+ out "================= font names =================="
+
+ if not names.data then
+ names.data = names.load ()
+ end
+
+ local namedata = names.data
+ local mappings = namedata.mappings
+
+ if not namedata and namedata.formats and namedata.version then
+ out "Database corrupt."
+ return errcnt + 1
+ end
+
+ out ("Database version: %.3f.", names.version)
+ out ("Font formats indexed: %s.",
+ tableconcat (namedata.formats, ", "))
+ out ("%d font files indexed.", #mappings)
+
+ local by_format = { }
+ for i = 1, #mappings do
+ local record = mappings[i]
+ local format = stringlower (filesuffix (record.filename))
+ local count = by_format[format]
+ if count then
+ by_format[format] = count + 1
+ else
+ by_format[format] = 1
+ end
+ end
+
+ local formats = tablesortedkeys (by_format)
+ for i = 1, #formats do
+ local format = formats[i]
+ out ("%20s: %5d", format, by_format[format])
+ end
+ return errcnt
+end
+
local verify_files = function (errcnt, status)
out "================ verify files ================="
local hashes = status.hashes
@@ -553,6 +597,7 @@ end
local anamneses = {
"environment",
"files",
+ "index",
"repository",
"permissions"
}
@@ -569,6 +614,11 @@ local diagnose = function (job)
asked = tabletohash (asked, true)
end
+ if asked.index == true then
+ errcnt = check_index (errcnt)
+ asked.index = nil
+ end
+
if asked.environment == true then
errcnt = check_environment (errcnt)
asked.environment = nil
diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua
index b5c7976..3bec847 100755
--- a/luaotfload-tool.lua
+++ b/luaotfload-tool.lua
@@ -199,7 +199,8 @@ This tool is part of the luaotfload package. Valid options are:
-V --version print version and exit
-h --help print this message
--diagnose=CHECK run a self test procedure; one of "files",
- "permissions", or "repository"
+ "environment", "index", "permissions", or
+ "repository"
--alias=<name> force behavior of "luaotfload-tool" or legacy
"mkluatexfontdb"
diff --git a/luaotfload-tool.rst b/luaotfload-tool.rst
index 80884cd..2d3ae2f 100644
--- a/luaotfload-tool.rst
+++ b/luaotfload-tool.rst
@@ -159,7 +159,9 @@ miscellaneous
3) ``environment`` -> print relevant
environment and kpse variables;
4) ``repository`` -> check the git repository
- for new releases.
+ for new releases,
+ 5) ``index`` -> check database, display
+ information about it.
Procedures can be chained by concatenating with
commas, e.g. ``--diagnose=files,permissions``.