How to find the actual height (and width) of string to be rendered? I need to be able to draw text that is x mm high.
It should be easy to calculate the font size needed if I can get the actual text height.
Eg. start with a font size, measure the rendered text and calculate the new font size (new_font_size = old_font_size * wanted_height / measured_height)
I have tried using Graphics.MeasureString
, but that includes some padding which can get quite big for large sizes.
Graphics.MeasureString
andTextRenderer.MeasureText
are the methods I'm familiar with. Both of them measure the actual size of the text and add some margin. Perhaps theMeasureText
will give you a more accurate result. – Zohar Peled