auto canBeRepresented = []( juce::StringRef text )
{
for ( auto t = text.text; ! t.isEmpty(); )
{
auto c = t.getAndAdvance();
// latin char and punctuation
if ( ! ( c < 0x024f || ( c >= 0x2000 && c < 0x20d0 ) ) )
{
return false;
}
}
return true;
};
juce::AttributedString s;
auto font = defaultFontWithHeight ( tooltipFontSize );
auto unicodeFont = juce::Font ( "Arial", font.getHeight (), 0 );
const auto col = findColour ( juce::TooltipWindow::textColourId );
s.setJustification ( juce::Justification::centredLeft );
auto arr = juce::StringArray::fromLines ( text );
for ( auto& str : arr )
s.append ( str + "\n", canBeRepresented ( str ) ? font : unicodeFont, col );
juce::TextLayout tl;
tl.createLayoutWithBalancedLineLengths ( s, 600.0f );
return tl;
On Windows, the following code draws boxes for the Japanese characters. However, if I use unicodeFont
for every line, then it works.