briddums
briddums

Reputation: 1846

Calculate font size based on size of display area

I know that I can calculate the display area for a given font using

TextRenderer.MeasureText("Text", New Font(Arial, 12.0F)

I want to calculate the size of a font I should be using in order to fit a given display area. Is there a function that allows me to do that?

Upvotes: 1

Views: 423

Answers (1)

Marco
Marco

Reputation: 57573

For what I know no, there's no any function to do that.
I used a function that, changing font size from a lower value to upper ones, checked which font size was the one I needed.
For example you can start from 8f and increase it with 1f; remember anyway that not any size is good for any font, so you can have some "distortion".

Upvotes: 2

Related Questions