How to Remove Overlapping Contours in FontForge

Overlapping contours are a common byproduct of designing glyphs using modular components, intersecting strokes, or imported vector graphics. In FontForge, leaving these overlapping paths unmerged can lead to rendering errors, invalid font files, and improper hinting. This guide explains how to automatically resolve and merge intersecting paths across individual glyphs or an entire typeface using FontForge's built-in vector union tools and automated scripting.

Method 1: Batch Removal via the Font View Interface

FontForge allows you to apply its Boolean union algorithm across every glyph in your font file simultaneously through the main graphical interface.

  1. Open Your Font: Launch FontForge and load your font project (.sfd, .otf, or .ttf).
  2. Select the Glyphs: In the main Font View window, select the glyphs you want to process. To process the entire font at once, press Ctrl + A (Windows/Linux) or Cmd + A (macOS).
  3. Correct Path Directions: Before resolving overlaps, ensure all contours have consistent winding rules (counter-clockwise for outer paths, clockwise for cutouts). Go to Element > Correct Direction or press Ctrl + Shift + D.
  4. Execute Remove Overlap: Navigate to Element > Overlap > Remove Overlap or press the keyboard shortcut Ctrl + Shift + O (Windows/Linux) or Cmd + Shift + O (macOS).

FontForge will calculate the intersections and automatically merge the vector shapes into a single, unified contour perimeter.

Method 2: Automated Python Scripting

If you run automated build pipelines or prefer command-line execution, FontForge includes a native Python module to clean contours programmatically.

Save the following code as remove_overlaps.py:

import fontforge

# Open the font file
font = fontforge.open("your-font.sfd")

for glyph in font.glyphs():
    # Ensure proper winding before merging
    glyph.correctDirection()
    # Merge overlapping paths
    glyph.removeOverlap()
    # Clean up redundant control points left by intersection cuts
    glyph.simplify()

# Save the cleaned font
font.save("cleaned-font.sfd")
font.close()

Run the script from your terminal using the FontForge interpreter:

fontforge -script remove_overlaps.py

Post-Processing: Simplifying Extraneous Nodes

The overlap removal algorithm frequently creates microscopic line segments and extra on-curve points at the exact intersection boundaries. To finalize your glyphs:

  1. Select your glyphs in the Font View.
  2. Navigate to Element > Simplify > Simplify (or Ctrl + Shift + M).
  3. Check Element > Add Extrema (or Ctrl + Shift + X) to ensure smooth Bézier curve rendering at standard vector poles.