Multi-language display in TextEditor


#1

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.


#2

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


#3

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


#4

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.


#5

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)
{
   #if JUCE_CORETEXT_AVAILABLE
// 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;
}
   #endif

ignoreUnused (text);
return false;
}