Scale Text to Button

Hi, I want to create text that dynamically scales to a few pixels smaller than its respective button/boundaries size and also to the size of the screen. It is very easy to let it scale dynamically to the screen; however, I am finding it difficult to come up with an equation to let it scale to the button as well.

// Scaling the text with the screen
scale((float) width / DEFAULT_WIDTH);

However, the text compared to the rest of the screen is always the same size, not fit to the button/boundary.

(Top: What I want; Bottom: What it is currently)

Instead of scale, have you tried textSize( ) with the same scaling factor?

1 Like

check out this:

see textWidth() / Reference /