-- @titre Bilan du crénage -- @title Kerning summary -- @categorie relire -- @resume Pour chaque master : le nombre de paires, les paires les plus serrées et les plus ouvertes, et les paires qui nomment un glyphe absent de la fonte. -- @summary For every master: the number of pairs, the tightest and loosest pairs, and pairs naming a glyph that is not in the font. -- Fontista · bibliothèque de scripts · https://fontista.thinkspark.dev/scripts.html local SHOW = 10 -- how many of the strongest pairs to list on each side local en = lang == "en" local have = {} for _, g in ipairs(font.glyphs) do have[g] = true end -- group names (kerning classes) are not glyph names local function known(n) return have[n] or n:sub(1, 1) == "@" or n:find("^public%.kern") ~= nil end for _, m in ipairs(font.masters) do local list, orphans = {}, {} for left, row in pairs(kerning(m.id)) do for right, v in pairs(row) do list[#list + 1] = { left, right, v } if not known(left) or not known(right) then orphans[#orphans + 1] = left .. " " .. right end end end table.sort(list, function(a, b) return a[3] < b[3] end) print(string.format(en and "— %s: %d pairs" or "— %s : %d paires", m.name, #list)) for i = 1, math.min(SHOW, #list) do if list[i][3] < 0 then print(string.format(" %-14s %-14s %5d", list[i][1], list[i][2], list[i][3])) end end for i = #list, math.max(1, #list - SHOW + 1), -1 do if list[i][3] > 0 then print(string.format(" %-14s %-14s %+5d", list[i][1], list[i][2], list[i][3])) end end if #orphans > 0 then table.sort(orphans) print(string.format(en and " %d pair(s) naming a missing glyph: %s" or " %d paire(s) avec un glyphe absent : %s", #orphans, table.concat(orphans, ", "))) end end