We use an automatically computed layout in a few places, which causes some text editors to be slightly taller than others. If we use the default indents for the editors this causes the text to be vertically off-centre, which looks weird.
Is there support for vertically aligning text in a single-line text editor? Right now we can use the indents but then we need to keep the indent, font size and editor size in sync. Maybe we can add some automatic mode for the vertical inset which keeps the text centred.
…and once again.
The lack becomes obvious especially when you use it beside a label where you can set a “layout” property to “centred right” etc.
Placeholders don’t have any justification settings, they default to Justification::centredLeft, this is particularly egregious when the actual text justification is set to something different, I had to fix my fork of JUCE to allow for setting the empty text justification.
Looking at your image though it seems like something funky has happened with the vertical alignment regardless, but looking at the commits for TextEditor vertical alignment was tackled some time ago.
Mmmm, i’ve added some indent for now which seems to have fixed it enough. But I still can’t explain why it’s bad. Maybe I’ve broken something in LookAndFeel somewhere…
No. This lack of vertical alignment is due to the font’s baseline being the only factor accounted for to align vertically. The font’s descent (and ascent, probably) should be used to line it up properly on a single line.
The issue with adding this is that it might break rendering larger fonts, whose descent will surpass the bottom of the area it’s being drawn into. The other issue is that it will likely break existing text layouts. Having it as an opt-in option would be nice to get around that.