# Use Text as Mask / Transparent Text in Opaque Background

**URL:** <https://forums.unrealengine.com/t/use-text-as-mask-transparent-text-in-opaque-background/1218348>\
**Category:** UI\
**Tags:** unreal-engine, question\
**Created:** [July 3, 2023, 4:32pm UTC](https://forums.unrealengine.com/t/use-text-as-mask-transparent-text-in-opaque-background/1218348 "2023-07-03T16:32:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evan\_Patterson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Evan\_Patterson](https://forums.unrealengine.com/u/Evan_Patterson)\
**Post date:** [July 3, 2023, 4:32pm UTC](https://forums.unrealengine.com/t/use-text-as-mask-transparent-text-in-opaque-background/1218348/1 "2023-07-03T16:32:39Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/5/e/85ef5fc471ce524d00b685d2769e5d34e2742de9.jpeg)  
I’m trying to recreate this effect for a UI widget. The text will be variable, so pre-made images will not work. Is this possible in UE4 with the default engine?

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [July 3, 2023, 4:58pm UTC](https://forums.unrealengine.com/t/use-text-as-mask-transparent-text-in-opaque-background/1218348/2 "2023-07-03T16:58:08Z")

</div>

I dont think there is a straight way of doing it but I may be wrong.

If you really must achieve that I think on a possible workaround…tedious but would work.  
You can make all the chars in bitmaps and create a charmap Struct that contains the char bitmap, the char symbol (string) and the space for each char ( integer (width) )

Then you can create a widget with a construct and a public string that you update and  
some function creates the word as you want.

---

<div class="post-metadata">

**Author:** ![Evan\_Patterson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Evan\_Patterson](https://forums.unrealengine.com/u/Evan_Patterson)\
**Post date:** [July 3, 2023, 5:38pm UTC](https://forums.unrealengine.com/t/use-text-as-mask-transparent-text-in-opaque-background/1218348/3 "2023-07-03T17:38:15Z")

</div>

Interesting solution. Very tedious like you said. I’ve done a bit more research and I think there may be an easier method with a canvas render target inside a material. You can draw text to the render target and mask it from the background inside the material. I’ll give that a try and post back here if it works.

---

<div class="post-metadata">

**Author:** ![Evan\_Patterson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Evan\_Patterson](https://forums.unrealengine.com/u/Evan_Patterson)\
**Post date:** [July 3, 2023, 6:24pm UTC](https://forums.unrealengine.com/t/use-text-as-mask-transparent-text-in-opaque-background/1218348/4 "2023-07-03T18:24:50Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/b/9/bb9b1904084cbdb36761a9a5412b6e51c5c45b7e.jpeg)

Here’s the solution.

In the widget BP:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/f/fbf502f43e6018efee00c279f3e3e5d365458a00.png)  
Inverted Text is an image in the designer. It’s image size is 500x100 in the brush settings.

And the material:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/e/5/fe59c36d6f9f1fd5138623c42fc834110d3c7f01.png)

The font that you use for DrawText affects the size of the text, you have to set the legacy size in the font.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/2/6/126f419df8b0f47320cc0807724314c19d350871.png)

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [July 3, 2023, 6:35pm UTC](https://forums.unrealengine.com/t/use-text-as-mask-transparent-text-in-opaque-background/1218348/5 "2023-07-03T18:35:59Z")

</div>

Very Clever! 🙌

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [August 2, 2023, 6:36pm UTC](https://forums.unrealengine.com/t/use-text-as-mask-transparent-text-in-opaque-background/1218348/6 "2023-08-02T18:36:15Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
