Best way to find intersection II

Monotype gives me an error upon uploading a font concerning intersections.
Until now I used a script by @GeorgSeifert which always did well.

Now it seems not to find overlaps, instead gives me this error:
Show Metrics Keys plugin:
drawForegroundForLayer_: ‘NoneType’ object is not callable

#MenuTitle: Find Overlaps
# -*- coding: utf-8 -*-
__doc__="""
Find Overlaps.
"""

master = Font.masters[Font.masterIndex]

def findOverlaps(layer):
	AllPaths = []
	for component in layer.components:
		AllPaths.append(component.bezierPath)
	for path in layer.paths:
		AllPaths.append(path.bezierPath)
	
	for path in AllPaths:
		for otherPath in AllPaths:
			if path != otherPath:
				if path.intersectWithPath_(otherPath):
					layer.color = 2
					return

for glyph in Font.glyphs:
	layer = glyph.layers[master.id]
	findOverlaps(layer)

This script will not decompose anything. I just marks all glyphs where it found an overlap.

////

I’d be really great to have a script or plugin that would let me easily find intersections!

Many Thanks!
Georg

The error message has nothing to do with the script. The “Show Metrics Keys plugin” seems to cause this. Disable it for now.

Thank you!

I thought it didn’t work because there were no overlaps found :slight_smile:

No I realized, it’s not overlaps causing the trouble,
it’s very small selfintersecting paths!

Is there a way to find these intersections?

Here is another script that finds self intersections:

from GlyphsApp import GSPathFinder
master = Font.masters[Font.masterIndex]

def findOverlaps(layer):
	segments = []
	#for component in layer.components:
	#	AllPaths.append(component.bezierPath)
	for path in layer.paths:
		segments.extend(path.pathSegments())

	if len(segments) == 0:
		return
	operator = GSPathFinder.new()
	origCount = len(segments)
	operator.addIntersections_(segments)
	resultCount = len(segments)
	if origCount != resultCount:
		print "Intersection", layer.parent.name
		layer.color = 2
		return

for glyph in Font.glyphs:
	layer = glyph.layers[master.id]
	findOverlaps(layer)

Thank you Georg!
It’s working great :slight_smile:

Just to explain: I’m working on a Shadow Master.
These intersections happen, when subtracting the frontmost path.