fontlabapp.fontui.outline_routes.remove_overlap
remove_overlap
Remove overlaps in the outline shapes of the selected glyphs.
What: For each selected glyph and master, the table lists every outline shape whose contours overlap: the contour count now and after the merge. Remove Overlap merges them. Shapes without overlap stay untouched. Overlaps between separate shapes are not merged. This tool tests intersections between contours; a single self-intersecting contour is kept.
How: Each shape goes through FontLab's FontGate engine: a copy is made with flShape.convertToFgShape, fgShape.removeOverlap merges it (a shape has an overlap when native contours intersect or same-direction contours nest), and flShape.assign writes the result back into the same shape object. The start node of each new contour moves back to an old start point when one survives the merge, as FontLab's own command does. The preview runs the same merge on a copy, so the numbers are exact.
Why: Overlapping contours print and render fine in many places, but fonts for the web, variable fonts and many tools need clean outlines. With "Keep masters compatible" ticked, a glyph is held back when the masters would get different contours, or when only some masters are in scope: the merge would break interpolation.
Use: Select glyphs. Run the script. Choose the masters. Press Remove Overlap. Press Reload selection after you change the selection.
Benefit: Cleans many glyphs over many masters in one Undo step, and lists each merge before anything changes.
Safety: A status note reports only a newly introduced final off-curve with raw Smooth (fl#8517), which FontLab may change on save. Check node types after VFJ reopen. The merge rebuilds the contours of a merged shape: node names, node flags, contour names and corner_smooth (fl#8569) in that shape are not kept. FontGate assign also replaces the shape appearance. No name, note or appearance preservation is claimed for that round trip. These shapes are listed and kept:
- shared outline data (an edit would change other glyphs too);
- shapes with a transform (FontGate would merge them in stored coordinates);
- shapes with an open contour (an open contour has no inside).
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_remove_overlap.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 | ||
final_smooth_points |
function | (contours: list[Any]) -> set[tuple[float, float]] |
Coordinates of existing final off-curves with raw Smooth; read only. (shared captured text) |
fontgate_copy |
function | (shape: Any, merge: bool) -> Any |
FontGate copy of the shape; with merge, overlaps removed. |
main |
function | () -> Any |
Open the panel, or replace the one that is already open. |
node_counts |
function | (shape: Any) -> tuple[int, ...] |
Sorted FontGate node counts of the contours of shape (a FontGate shape). |
overlap_changes |
function | (layer: Any, cache: dict[int, Any] | None=None) -> list[outline_writer.Change] |
One row per shape whose merge changes its contours; notes for kept shapes. |
start_points |
function | (shape: Any) -> set[tuple[float, float]] |
Positions of the on-curve start nodes of the shape's contours. |