Skip to content

fontlabapp.fontui.outline_routes.delete_duplicate_contours

delete_duplicate_contours

Find contours drawn twice in the same layer and keep only the first copy.

What: For each selected glyph and master, the table lists every contour that repeats an earlier contour of the same layer. Delete removes the copies.

How: Two contours are duplicates when they have the same nodes in the same cyclic order, from any start node in the same direction, and each node pair lies within the tolerance (in glyph coordinates, so moved shapes compare where you see them). On-curve and off-curve nodes must match. The first contour of a group stays; FontLab's own flShape.removeContour removes the others.

Reversed duplicate groups are listed as "reversed duplicate, kept". Every member stays, including further copies: their winding can cancel. Open contours are kept; cyclic rotation changes their open endpoints.

Why: Same-direction duplicates are invisible in a filled preview, but they break overlap removal, double the ink in some renderers and confuse contour order tools. With "Keep masters compatible" ticked, a glyph is held back when the masters would lose different contours, or when only some masters are in scope.

Use: Select glyphs. Run the script. Set the tolerance and the masters. Press Delete. Press Reload selection after you change the selection.

Benefit: Removes hidden copies over many glyphs and masters in one Undo step, and names the contour each copy repeats.

Safety: These shapes are listed and kept:

  • shared outline data (an edit would change other glyphs too);
  • shapes with scale, slant or rotation (stored nodes are not visible nodes).

A glyph that has an automatic layer is listed and skipped. So is a glyph that is a base of an automatic composite, also through other composites, unless you tick "Also edit bases of automatic composites" (FontLab then rebuilds those composites; anchor recovery through Undo is not assured). The script keeps the compatibility check; writes disclose queued ids and possible date changes. After the write, it reads the contour counts back. If FontLab fails part-way, the error says that native changes may remain. The change is recorded as one Undo step. The one-step write, the automatic-layer rule, the pending-update check and the panel are shared (fly.ap.contours.writer, fly.ap.contours.panel.model); the planner belongs to this script.

Source: the author's own FontLab sample outlines_delete_duplicate_contours.py, Apache-2.0. Adapted for the current FontLab 9 API.

Classes

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
KEY attribute
TITLE attribute
duplicate_changes function (layer: Any, tolerance: float) -> list[outline_writer.Change] One row per contour that repeats an earlier one; notes for kept shapes.
main function () -> Any Open the panel, or replace the one that is already open.
same_cycle function (a: list[outline_writer.Point], b: list[outline_writer.Point], tolerance: float) -> bool True when a and b are the same closed node sequence, any start, same direction.