-- @titre Couleurs selon l'état -- @title Colour by state -- @categorie ranger -- @resume Donne une couleur d'étiquette à chaque glyphe selon son état dans le premier master : gris s'il est vide, bleu s'il n'est fait que de composants, aucune s'il est dessiné. La grille de la vue Fonte montre d'un coup d'œil ce qui reste à faire. -- @summary Gives each glyph a colour label from its state in the first master: grey when empty, blue when made only of components, none when drawn. The Font view grid then shows at a glance what is left to do. -- Fontista · bibliothèque de scripts · https://fontista.thinkspark.dev/scripts.html local EMPTY, COMPOSITE = 7, 5 -- colour labels: 0 red, 1 orange, 2 yellow, 3 green, 4 cyan, 5 blue, 6 purple, 7 grey local KEEP_OTHERS = true -- true: leave the labels you set yourself (other colours) as they are local en = lang == "en" local m = font.masters[1].id local counts = { 0, 0, 0 } for _, g in ipairs(font.glyphs) do local info = glyph(g) local l = layer(g, m) local mine = info.mark ~= nil and info.mark ~= EMPTY and info.mark ~= COMPOSITE if not (KEEP_OTHERS and mine) then if not l or l.empty then set_mark(g, EMPTY) counts[1] = counts[1] + 1 elseif #l.contours == 0 and #components(g, m) > 0 then set_mark(g, COMPOSITE) counts[2] = counts[2] + 1 else set_mark(g, nil) counts[3] = counts[3] + 1 end end end print(string.format(en and "%d empty (grey), %d composite (blue), %d drawn" or "%d vide(s) (gris), %d composite(s) (bleu), %d dessiné(s)", counts[1], counts[2], counts[3]))