Multi-language display in TextEditor

In the case when user inputs mixed language text into TextEditor, it won’t be able to display the text they entered. Because the text could be mixed with different language which requires different fonts, set a single font on TextEditor does not solve the problem.

I know AttributedText drawing has font fallback working well because it’s based on CoreText. And this is great for all kinds of other text drawing in the app. But TextEditor seems using a very special way to draw it’s text that I cannot override with LookAndFeel.

So I wonder if there is work around for this problem? Thanks.

1 Like

Facing the same thing here.
Haven’t found a good solution so far.

Have you tried a true Unicode font such as Bitstream Cyberbit?

These kind of font (such as google noto font) is huge (400MB) when including Chinese, Japanese, Korean fonts. Plus, they still consists of different font type files, I’m not sure a single type family will fall back properly.

Hi Fabian,

The Adobe Source and Google Noto fonts have all languages but, they are installed under different Font names, like:

And juce::Font can only point to only one of them at a time.

I found a way to let juce::Label and other drawText scenarios to work, by using AttributedString and TextLayout (which is using Native layout) and then they could draw any language with your installed fonts.

But for texteditor, it seems it’s hard to use the same trick.
The font name you gave above says it’s for non-commercial.

bool TextLayout::createNativeLayout (const AttributedString& text)
// Seems to be an unfathomable bug in CoreText which prevents the layout working with
// typefaces that were loaded from memory, so have to fallback if we hit any of those..
if (canAllTypefacesBeUsedInLayout (text))
    CoreTextTypeLayout::createLayout (*this, text);
    return true;

ignoreUnused (text);
return false;

I wonder if latest juce has any update regarding this? because it’s kind of important, as users won’t be able to type different languages into JUCE app.

It may be as simple as use textlayout to draw text in texteditor?

1 Like