Source code
The monospaced families keep every character on one width and make 0 O 1 l I easy to tell apart.
(* Group the faces of a family by weight. *)
let by_weight faces =
List.fold_left
(fun acc face ->
let seen = Option.value ~default:[] (List.assoc_opt face.weight acc) in
(face.weight, face :: seen) :: List.remove_assoc face.weight acc)
[] faces
let () =
by_weight catalogue
|> List.iter (fun (w, fs) -> Printf.printf "%d -> %d\n" w (List.length fs))/* Sum the advance widths of a run of glyphs. */
static int run_width(const glyph_t *g, size_t n)
{
int w = 0;
for (size_t i = 0; i < n; i++) {
if (g[i].id != 0 && g[i].flags & GLYPH_VISIBLE)
w += g[i].advance - (i > 0 ? kern(g[i - 1].id, g[i].id) : 0);
}
return w >= 0 ? w : -1; /* 0O 1lI {} [] <= != -> */
}