Given a Font, find the height of multiple lines of text

Given a Font, is it possible to know the height required to display a certain amount of lines?

Is it enough to multiply the pixel height of the font by the number of lines, or there is more?

Has anyone implemented something like a:

float getTextHeight (const Font& font, int numberOfLines)

?

I did exactly this and it worked just fine.
If you don’t know the number of lines you can use the GlyphArrangement class, add the text, and get the height of that, like I did here:


arr is a GlyphArrangement instance

No, that is not enough, this is clearly visible in the fonts demo in the DemoRunner. Apart from font height, a designer can also specify an arbitrary line advance height.

I get your point but I suspect that in your screenshots the Height slider controls the height in points of the Font, which is the dimension that makes all them appear equally tall visually.

In contrast, it seems that @danielrudrich is right and Font::getHeight() returns the right value for the vertical room in pixels to reserve for a line of text.
In fact, in GlyphArrangement::addJustifiedText() the advancement of the y coordinate to the next line is done with:

y += font.getHeight() + leading;

where leading is a function parameter with default = 0.0f that is never otherwise used/specified throughout the JUCE codebase