Different TextLayout behaviour across platforms

#1

The behaviour of TextLayout::createLayout is different across platforms. On macOS and Linux the text is rendered to the end of the bounding rect while on Windows overflowing text is silently truncated. See the attached screenshot.


This is with word wrap set to AttributedString::WordWrap::none. In my opinion the first behaviour is right while the second isn’t. We would like to exploit the overflow behaviour to add an ellipsis character to indicate truncation.

Q: Why not use drawText, GlyphArrangement, etc?

  • Because we are in a painstaking transition of supporting mixed scripts and font fallbacks. The combination of AttributedString and TextLayout seems to be the only viable option in JUCE for the moment.
  • Also we need to know if a text has been truncated so we can show a tooltip containing the whole text. (I should probably issue a separate feature request post for better international script support.)

Q: Why not overshoot maxWidth in TextLayout::createLayout

This will potentially cause trouble when the text isn’t left-aligned anymore.


As a side question: Is it possible to determine if a TextLayout::Run is rendered RTL or LTR?

0 Likes