Hi
I have a TextEditor with some text in it.
I want its height to be minimal given its width (the width of its parent).
So what I did was:
int textWidth = te.getFont().getStringWidth(te.getText()); //didn't just use te.getTextWidth() because the TextEditor doesn't have a size yet.
double numLines = (double)textWidth / getWidth();
if (numLines - (int)numLines != 0) // please tell me if there's a juce method to ceil and not just round to closest int.
{
numLines++;
numLines = (int)numLines;
}
The problem with this code is that when word wrapping is active, an additional line may be required.
Any advice on how to approach this?
Thanks!