How to mask TextMesh renderers

Our game has a number of sprites using SpriteRenderer that are masked with a SpriteMask. The sprites are organized with sorting groups and sort order, etc. This works well.

Now we need to attach a dynamic text display to some sprites. We can do this using TextMesh or the Text Mesh Pro text mesh, or even attaching a small Canvas in world space and using a Text UI component. All of these draw the text fine but none of them will respect the SpriteMask. How can we mask the text without a radical re-vamp of our game? Can this be done using a custom shader and if so, how?

UP! Have the same issue, how to mask UnityEngine.TextMesh?

Tried changing shader, but it didn’t help.
http://wiki.unity3d.com/index.php?title=3DText&_ga=2.157364792.305127198.1593794379-681413862.1592217226

Bump, I have this same problem. I am using MeshRenderer with TextMeshPro Text. I am not using a canvas, has anyone figured out how to mask this text?

I managed to get this working pretty well by writing a custom script that takes a Text, TextMesh, or TMP_Text and renders it into a Texture2D using a dedicated text rendering camera. Then I create a sprite from the texture and assign it to a SpriteRenderer and disable the original Text/TextMesh/TMP_Text.