RoboFont adds common boolean path operations – difference, union, intersection and exclusive or – to glyph objects, using special characters as operators.

operation operator
difference %
union |
intersection &
exclusive or ^

The example below shows the four boolean path operations in action:

When performing a difference operation, the order of the operands matters!

# 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)
Last edited on 01/09/2021