How do I draw transparent text?

I want to draw a rectangle with text in it that “cuts out” the rectangle (i.e rectangle is transparent where the text is). Any tips on how to go about this?


A bit fiddly, but you can:

  • get a Path
  • add a rectangle to it
  • create a GlyphArrangement of your text, and use its createPath() to add this to your other path
  • make sure zero-winding is enabled or it’ll just be a solid block
  • fill the path

Thnx Jules, works like a charm.