-- @titre Compléter les masters -- @title Fill in the masters -- @categorie glyphes -- @resume Recopie le dessin du premier master (contours, chasse, ancres) dans les autres masters là où le glyphe est encore vide. Les masters deviennent compatibles ; il reste à ajuster chaque copie à sa graisse. -- @summary Copies the drawing of the first master (contours, width, anchors) into the other masters wherever the glyph is still empty. The masters become compatible; each copy still has to be adjusted to its weight. -- Fontista · bibliothèque de scripts · https://fontista.thinkspark.dev/scripts.html local MARK = 2 -- colour label for the copies (2 = yellow), nil for none local en = lang == "en" local src = font.masters[1].id local n = 0 for i = 2, #font.masters do local dst = font.masters[i].id for _, g in ipairs(font.glyphs) do local from, to = layer(g, src), layer(g, dst) if from and not from.empty and #from.contours > 0 and #components(g, src) == 0 and (not to or to.empty) then set_contours(g, dst, from.contours) set_width(g, dst, from.width) for name, p in pairs(anchors(g, src)) do set_anchor(g, dst, name, p.x, p.y) end if MARK then set_mark(g, MARK) end n = n + 1 end end end print(#font.masters < 2 and (en and "Only one master." or "Un seul master.") or string.format(en and "%d layer(s) filled from %s" or "%d calque(s) complété(s) depuis %s", n, font.masters[1].name))