How to Edit Font Material Or Alternative Approach To Masking

Our situation is we have cards which use SpriteRenderers. The cards have text on them and when these cards are in a scrollview we need to be able to mask the text.

However, because our scrollview uses a SpriteMask (not a Mask) the text does not get masked.

I have limited understanding of shaders but we found if you change the Stencil id to 1 and the Stencil Comp to 3 we can achieve masking.

The problem is, this makes all other text which shared this material invisible unless they are inside a mask.

So my thought was we will create a cloned font where one has the stencil setting and one does not. However when I clone the font I cannot change the material:

Can you advise us on how to create a special “stencil” material and swap the font that uses this to mask as needed or suggest a way we can handle this situation where the text needs to be masked by a SpriteMask instead of a Mask?

One other thing I tried was hot swapping the font on the fly (one which has stencil one which does not) but then it mucked up the shader in the other text files anyway and I dont know what happened.

  public void DisableMasking()
    {
        foreach(TextMeshProUGUI text in _textToHaveMaskingFontApplied)
        {
            text.font = Fonts.normalFont;
        }
    }

    public void EnableMasking()
    {
        foreach (TextMeshProUGUI text in _textToHaveMaskingFontApplied)
        {
            text.font = Fonts.stencilFont;
        }
    }

Note this was done where I copied the font and I suspect they still share the same underlying material which I cant seem to change:

So any suggestion on how to change the underlying material OR a better approach to masking that can work with a SpriteMask would be extremely helpful