From 898fa8861c06b41acd946a1de35a13c64e26d22c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 1 Aug 2013 16:27:45 +0200 Subject: [diagnose] add diagnostics for font index --- luaotfload-diagnostics.lua | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'luaotfload-diagnostics.lua') 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 -- cgit v1.2.3