RoboFont makes it possible to perform common boolean path operations (difference, union, intersection and exclusive or) with glyph objects directly, using special characters as operators.

operation operator
difference %
union |
intersection &
exclusive or ^

Here is an example with the four boolean path operations in action:

# get the current font
font = CurrentFont()

g1 = font["A"]
g2 = font["B"]

# difference
result = g1 % g2

dest = font.newGlyph("difference_1")
dest.clear()
dest.appendGlyph(result)

# difference
result = g2 % g1

dest = font.newGlyph("difference_2")
dest.clear()
dest.appendGlyph(result)

# union
result = g1 | g2

dest = font.newGlyph("union")
dest.clear()
dest.appendGlyph(result)

# intersection
result = g1 & g2

dest = font.newGlyph("intersection")
dest.clear()
dest.appendGlyph(result)

# xor
result = g1 ^ g2

dest = font.newGlyph("xor")
dest.clear()
dest.appendGlyph(result)

For the difference operation, the order of the operands matters!

Last edited on 27/01/2018