summaryrefslogtreecommitdiff
path: root/luaotfload-tool.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-06-25 18:16:22 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-06-25 18:16:22 +0200
commitf61e64740b13341624f1e9a52f3336a7eda6e3eb (patch)
tree638f91e17add7cd1713538eeb512e6d00d11edec /luaotfload-tool.lua
parenta87bac7a89c8fe38e0f2608f39b1c3c5f7850a93 (diff)
downloadluaotfload-f61e64740b13341624f1e9a52f3336a7eda6e3eb.tar.gz
add font metadata printer
Diffstat (limited to 'luaotfload-tool.lua')
-rwxr-xr-xluaotfload-tool.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua
index c5c1e47..31ea5c0 100755
--- a/luaotfload-tool.lua
+++ b/luaotfload-tool.lua
@@ -338,7 +338,9 @@ local reflow = function (text, width)
return reflowed
end
+--- string -> 'a -> string list
local print_field = function (key, val)
+ val = tostring(val)
local lhs = stringformat(key_fmt, key) .. fieldseparator .. " "
local wd_lhs = #lhs
local lines = reflow(val, textwidth - wd_lhs)
@@ -367,6 +369,54 @@ local display_names = function (names)
end
end
+--- see luafflib.c
+local general_fields = {
+ --- second: l -> literal | n -> length | d -> date
+ { "fullname", "l", "font name" },
+ { "version", "l", "font version" },
+ { "creationtime", "d", "creation time" },
+ { "modificationtime", "d", "modification time" },
+ { "subfonts", "n", "number of subfonts" },
+ { "glyphcnt", "l", "number of glyphs" },
+ { "weight", "l", "weight indicator" },
+ { "design_size", "l", "design size" },
+ { "design_range_bottom", "l", "design size min" },
+ { "design_range_top", "l", "design size max" },
+ { "fontstyle_id", "l", "font style id" },
+ { "fontstyle_name", "l", "font style name" },
+ { "strokewidth", "l", "stroke width" },
+ { "units_per_em", "l", "units per em" },
+ { "ascent", "l", "ascender height" },
+ { "descent", "l", "descender height" },
+ { "comments", "l", "comments" },
+ { "os2_version", "l", "os2 version" },
+ { "sfd_version", "l", "sfd version" },
+}
+
+local display_general = function (fullinfo)
+ texiowrite_nl ""
+ print_heading("General Information", 2)
+ for i=1, #general_fields do
+ local field = general_fields[i]
+ local key, mode, desc = unpack(field)
+ local val
+ if mode == "l" then
+ val = fullinfo[key]
+ elseif mode == "n" then
+ local v = fullinfo[key]
+ if v then
+ val = #fullinfo[key]
+ end
+ elseif mode == "d" then
+ val = os.date("%F %T", fullinfo[key])
+ end
+ if not val then
+ val = "<none>"
+ end
+ print_field(desc, val)
+ end
+end
+
local show_full_info = function (path, subfont, warnings)
local rawinfo, warn = fontloader.open(path, subfont)
if warnings then
@@ -382,6 +432,7 @@ local show_full_info = function (path, subfont, warnings)
fontloader.close(rawinfo)
--inspect(fields)
display_names(fullinfo.names)
+ display_general(fullinfo)
end
--- Subfonts returned by fontloader.info() do not correspond