summaryrefslogtreecommitdiff
path: root/luaotfload-diagnostics.lua
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 /luaotfload-diagnostics.lua
parentc3e5006283891b494871128613a13ab40f8efc9a (diff)
downloadluaotfload-898fa8861c06b41acd946a1de35a13c64e26d22c.tar.gz
[diagnose] add diagnostics for font index
Diffstat (limited to 'luaotfload-diagnostics.lua')
-rw-r--r--luaotfload-diagnostics.lua50
1 files changed, 50 insertions, 0 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