Text resizing if it goes offscreen

Hi there! I’m looking to make text in my game smaller when it’s about to go offscreen.
From something like this:
image
To something kind of like this:
image

If you see what I mean help would be greatly appreciated!

When numbers get that large, a lot of games switch to a number and letter format like 1.6 AA. I’m personally turned off by absurdly large numbers. It becomes meaningless. I realize others like it. There’s a psychological factor but I prefer numbers with meaning. It’s your game. I don’t judge or try to tell anyone how to make their games. Shrinking the font will eventually make it unreadable.