[JUCE8] Text flipping when drawing certain text

Hi everyone,

After updating to JUCE 8, we noticed that drawing certain text with the Graphics object using drawText or drawFittedText flips/mangles the text around certain characters. Here’s an example of what I mean:

Here a TextButton’s text is being set using setButtonText, and the LookAndFeel’s drawButtonText method is just a slightly modified version of LookAndFeel_V2::drawButtonText that calls g.drawFittedText to draw the text. As you can see, the “date_time” string got flipped halfway around the “_”.

After some digging around in the JUCE 8 code, I was able to determine that this is coming from the new ShapedText class. Not sure where exactly though.

As a temporary workaround, I’m using AttributedString and TextLayout to draw the text and that is working fine. Only thing that is missing with that is ellipses, which is required in certain scenarios.

Any help for fixing this is greatly appreciated. Thanks in advance!

Adding more context/details in replies since I’m only allowed to embed one image per post as a new user:

It only happens when there is a special character between numerical characters. With alphabetical characters, it works fine as you can see below:

Screenshot 2024-05-15 104339

Here’s a side-by-side example of strings that work and string that get flipped/mangled. It is supposed to draw “[-10 - 10] V” in the image on the right


I noticed this bug as well.

Devs said the fix is forthcoming.

1 Like

Oh, I totally missed your comment and the devs’ responses. Thanks for pointing me to it! Will be on the lookout.