Boolean Glyph

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 |
interesection &
exclusive or ^

Example

Here are the four boolean path operations in action. Note that, for the difference operation, the order of the operands matters.

glyph-booleans

f = CurrentFont()
g1 = f['A']
g2 = f['B']

# difference 1
r = g1 % g2
g = f.newGlyph('difference_1')
g.appendGlyph(r)

# difference 2
r = g2 % g1
g = f.newGlyph('difference_2')
g.appendGlyph(r)

# union
r = g2 | g1
g = f.newGlyph('union')
g.appendGlyph(r)

# intersection
r = g2 & g1
g = f.newGlyph('intersection')
g.appendGlyph(r)

# xor
r = g2 ^ g1
g = f.newGlyph('xor')
g.appendGlyph(r)