How to detect an outside open corner

I need to create UFOs and would like to find any instance of these kinds of corners to convert them before exporting, is this possible with a script?

You can’t detect them from a script. You could run all paths throu a pen. The path.draw() method will remove them (and will apply caps and corners).

Can it remove only outside corners and not the inside ones?

Yes. It gives back what is drawn in black in edit mode. It removed the gray parts.

Which pen should I use?


from fontTools.pens.basePen import BasePen
Font = Glyphs.font
FontMaster = Font.selectedFontMaster
selectedLayers = Font.selectedLayers

for thisLayer in Font.selectedLayers:
	for thisPath in thisLayer.paths:

Gives me this error:

Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "GlyphsApp/", line 5483, in DrawPathWithPen
TypeError: unbound method moveTo() must be called with BasePen instance as first argument (got NSPoint instance instead)

bump please

Does this help?

from GlyphsApp import GSPathPen
layer = Font.selectedLayers[0]
pen = GSPathPen.alloc().init()
print pen.layer().paths

If your example, you passed the class of the pen as an argument. You would need to instantiate it, first. But the Base objects should not be used. You need to pick a subclass that actually implements something.

1 Like

thanks georg! this works, however i get this error:

from GlyphsApp import GSPathPen
thisLayer = Font.selectedLayers[0]

for eachPath in thisLayer.paths:
	newPath = eachPath.copy()
	pen = GSPathPen.alloc().init()
	newPath = pen.layer().paths
	newPath = newPath[0]



Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "GlyphsApp/", line 135, in __iter__
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/", line 589, in enumeratorGenerator
    yield container_unwrap(anEnumerator.nextObject(), StopIteration)
objc.error: NSGenericException - *** Collection <__NSArrayM: 0x7fb731d18cc0> was mutated while being enumerated.

The traceback says it: you remove items that you actually iterate over. this is not possible. either iterate in reversed order, or do multiple iterations.

1 Like

Got it thanks~!

from GlyphsApp import GSPathPen
thisLayer = Font.selectedLayers[0]

layerPaths = [l for l in thisLayer.paths]

thisLayer.paths = []

for eachPath in layerPaths:
	pen = GSPathPen.alloc().init()
	eachPath = pen.layer().paths
	eachPath = eachPath[0]

Hey this script suddenly converts smooth points into corner points…? anyway to stop this.

Simply run the cleanUpPaths() method of the layer afterwards.

Is there a method similar to cleanUpPaths which doesn’t ever remove nodes?

What is the point of cleaning up paths of you are not removing nodes? Can you give an example of what you want to do?

There is a checkConnections() on GSLayer and GSPath.

The point of not removing nodes is when you have overlapping nodes for interpolation purposes.
I have the same issue where I need to clean up paths without removing stacked nodes.