Cut geometry with booleans
Keep subtraction operands and text editable while cutting holes in a filled shape.
Use boolean type="subtraction" as a shape’s geometry. Put the base region first and each cutter after it. The enclosing shape supplies the paint for the resulting region. The operands contribute their transformed closed geometry, so edits to their positions or contours update the hole. Boolean operands and evaluation
In the cutout scene, the left block subtracts a circle from a blue rectangle. Pixel (48, 32) is empty and pixel (8, 32) is blue. Edit the cutter’s offset-x from 48 to 64 to move the hole. Alternatively, swap the original operands. The result becomes empty because the rectangle removes the entire circle.
The right block uses the shaped outlines of BOOK as its cutter. The O counters stay blue while their strokes leave transparent holes. Change the text operand’s copy to INK to move the holes with the new outlines. In the supplied PT Serif Bold environment, (148, 30) changes from transparent to blue. The white horizontal rule at (148, 36) remains visible because it paints as a later shape. Glyph geometry · Cutout observations
Use a geometry mask when the same outline should control the visibility of a drawable’s complete picture, including multiple children, strokes or filters.
Examples
Download the complete .nothing source · Source on GitHub
Rendered with ncf-preview at 304 × 64.
Bound resources
- fixtures/fonts/PT_Serif/PTSerif-Bold.ttf for
PT Serif@700

<boolean type="subtraction">
<shape><rect anchor-u="0" anchor-v="0" offset-x="104" offset-y="0" width="200" height="64" corner-radius="8"/></shape>
<shape><text x="204" y="48" text-anchor="middle" font-family="PT Serif" font-weight="700" font-size="44">BOOK</text></shape>
</boolean>