[FR] Improved text rendering

Text rendering in JUCE is in a sorry state.

  • Standard components will show replacement characters for various different scripts.
  • I won’t even mention emojis and friends :space_invader:.
  • TextLayout (JUCE’s only way to achieve a certain degree of font fallback) behaves very different across platforms:
    • Word-wrapping behaviour e.g. is highly inconsistent between Windows and Mac.
    • Also on one platform text overruns TextLayout's bounds on the other the text is truncated (a bug report has been filed but i never got a response).
  • It is very easy to spot apps and plug-ins developed with JUCE because JUCE is about the only platform that squeezes texts way out of proportion to make it fit. – Yes a very slight amount of squeezing (max to a factor of 0.98) is fine after reducing kerning

I can agree to some extent that the text system needs work, just not in the ways you mention. The thing is, JUCE uses the native text shaping (ie: glyph making), except on Linux I think (because there isn’t one…).

I’m not sure if you’re familiar enough, but the LookAndFeel lets you override that (look for drawLabel and drawFittedText in the repository). It’s entirely JUCE controlled, and tries to follow macOS conventions.

Also, juce::Label::setMinimumHorizontalScale will let you control that on a per instance level.


If you really wanted a fully featured font and glyph support system, you would wrap the latest Harfbuzz and Freetype for all platforms the same.


Right, this issue:

So this just follows suit with what I mentioned: blame native text shaping. The only way you’ll get consistent results is by using consistent implementations…

2 Likes

Thanks for your answers!

Yes, i am aware of those. Unfortunately there are quite a few usages of drawFittedText in standard components. So even when it’s right for labels it still fails at combo boxes and friends.

Never mind! I just found Font::setDefaultMinimumHorizontalScaleFactor a static call that seems to fix the issue on a global scale.