Remove Overlap using Glyphs API

So I’ve finally got around to making a plugin using the PluginMaker tool that you mentioned @GeorgSeifert .

By the way, it took a bit of looking around, comparing things to understand how things worked. The tutorial alone on writing plugins is useful if I want to work in XCode and write it using Objective C ( which I would like if only I had a good way of debug-logging when running in Glyphs, but NSLog doesn’t seem to do anything when I compile and run it in Glyphs ). I also had to set up a simple compilation script for compiling xib to nib in the terminal since XCode crashes when I just try to edit a xib and then export it to a nib (or maybe that’s the wrong way to make a nib from a xib in XCode), but at least the .xib InterfaceBuilder preview works.

#! /bin/sh
find . -name "*.xib" -type f | awk '{sub(/.xib/,"");print}' | xargs -I % ibtool --compile %.nib %.xib

Anyway, the real question here is, I’m trying to make an “inset” of a Glyph, that is, the inside shape that comes out if I make a stroke, and then apply flattenOutlinesRemoveOverlap_origHints_secondaryPath_extraHandles_error_, and then remove the outer and innermost shape.


It looks like I need to apply a “remove overlap” as well, but this isn’t a function in the GSLayer Object, but as an enum in GSPathOperator.

Is there some way to apply a GSPathOperator using the Glyphs API in Python?

Or maybe you have some other elegant way of making an inset effect? (The reason why I’m using the word “inset” is because it’s similar to the inset operation when working in Blender).

This tutorial is about python plugins: Writing plug-ins | Glyphs (it needs some updates)
This folder/Readme is all about python plugins: GlyphsSDK/Python Templates at Glyphs3 · schriftgestalt/GlyphsSDK · GitHub There are more details in the folders for each template

There is a droplet called “Compile .xib to .nib.app” that compiles .xibs to .nibs. I have it in the Dock.

Have you tried the Offset Curve filter with a negative offset?

it would still be nice to know how to do this with Python though. I’d like to make something similar to a Photoshop “action” with multiple steps. The initial pseudocode is.

  1. Copy glyph and make a .0001-glyph where the outlines have a stroke with X width
  2. Copy glyph and make a .0002-glyph with an inset slightly smaller than the stroke
  3. Copy the .0002-glyph and split it in two other glyphs at the middle vertically that make up .0003 and .0004
  4. Apply a hatch outline effect on .0003
  5. Combine all of these components into the initial Glyph
  6. And then maybe apply some color effects on the different components if it’s interesting.

So I think the next step is to find out how to apply a GSPathOperator using Python.
I’m also curious if I need to just rewrite the hatch outline effect or if I can apply another filter from my own filter.

Even if I want to do an Offset Curve filter with a negative offset I’ll still need a way to do that programatically.

Offset curve with a negative offset does seem to do the same thing, but the overlap problem persists. It might be a viable solution in some use cases, in others I think applying a Remove Overlap before removing the outermost and innermost shape fixes the problem.

noticed that it was as easy as “removeOverlap()” on the layer.

For some reason I couldn’t find it looking through the headers. I guess I got stuck in only one way of doing things.

You can find these things by snooping around the Method Reporter, a mekkablue script.

There is Layer.removeOverlap() and removeOverlap(paths)