From 23d194d78d1afbe9dcc000e2d108563ba2a8bf76 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 25 Jun 2013 16:13:40 +0200 Subject: add ascii heading formatter to luaotfload-tool --- luaotfload-tool.lua | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 7301db2..dd8484d 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -241,11 +241,22 @@ local version_msg = function ( ) config.luaotfload.self, version, names.version)) end + +--- makeshift formatting + +local head_adornchars = { + [1] = "*", [2] = "=", [3] = "~", [4] = "-", [5] = "ยท", +} local tw = 80 -local print_font_name = function (name) - local s = "-- " .. name .. " " - s = s .. string.rep("-", tw-string.len(s)) - texiowrite_nl (s) + +local print_heading = function (title, level) + if not level or level > #head_adornchars then + level = #head_adornchars + end + local adornchar = head_adornchars[level] + + local s = adornchar .. adornchar .. " " .. title .. " " + texiowrite_nl (s .. string.rep(adornchar, tw-utf.len(s))) texiowrite_nl "" end @@ -254,7 +265,7 @@ local warn_fmt = [[(%d %s)]] local show_info_items = function (fontinfo) local items = table.sortedkeys(fontinfo) - print_font_name(fontinfo.fullname) + print_heading(fontinfo.fullname, 1) for n = 1, #items do local item = items[n] texiowrite_nl(stringformat( @@ -270,9 +281,10 @@ local p_lines = Ct(p_line * (p_eol^1 * p_line^-1)^0) local show_fontloader_warnings = function (ws) local nws = #ws - texiowrite_nl(stringformat( - [[* the fontloader emitted %d warnings *]], - nws, name)) + print_heading(stringformat( + [[the fontloader emitted %d warnings]], + nws), 2) + texiowrite_nl "" for i=1, nws do local w = ws[i] texiowrite_nl (stringformat("%d:", i)) @@ -285,6 +297,13 @@ local show_fontloader_warnings = function (ws) end end +local display_names = function (names) + print_heading("Font Metadata", 2) + for i=1, #names do + local namedata = names[i] + end +end + local show_full_info = function (path, subfont, warnings) local rawinfo, warn = fontloader.open(path, subfont) if warnings then @@ -294,8 +313,12 @@ local show_full_info = function (path, subfont, warnings) texiowrite_nl(stringformat([[cannot open font %s]], path)) return end + local fontdata = { } local fullinfo = fontloader.to_table(rawinfo) + local fields = fontloader.fields(rawinfo.glyphs[0]) fontloader.close(rawinfo) + --inspect(fields) + display_names(fullinfo.names) end --- Subfonts returned by fontloader.info() do not correspond -- cgit v1.2.3