I've no idea about the unicode chars you actually need or which ones are in your font, but this is just showing you how to turn extended unicode chars into a string.
..ok, typo in the example, from trying several combinations. But that didn't help. The symbols I am after are defined in unicode standard Rev. 8, as described in the link I posted before: http://www.unicode.org/charts/PDF/U1D100.pdf
What confuses me also is, that your example had three bytes. I remember that UTF32 is always multibyte, so that was the moment I was insecure. At least I know now, that it "should" print something.
I donât think current versions of Windows have a Arial Unicode MS font, so you would use âArialâ.
Anyway itâs generally not possible to display arbitrary unicode in Juce, because (1) it uses a very outdated way to render text, and (2) the design of the look-and-feel system makes it hard to globally override the default font in widgets.
The other important thing for people to note is that they also need to make sure their text editor is saving the file as UTF8. Thereâs not much point telling the compiler to treat it as UTF8 if the editor actually dumped it as some other codepage format!
(And you can make your code readable by surrounding it with triple-backticks or just indenting it all be 4 spaces)
Hi! Well, what I put in place does work. Also, we allow the user to override the display language if they so wish through the Wotja menu system; which is also a really helpful feature for testing.
the char problem is a headache âŠ
Itâs strange use a code âCharPointer_UTF8 (â\xe4\xb8\x80\xe4\xba\x9b\xe6\x96\x87\xe5\xad\x97"); everywhere like thisâŠ
qt will have a locaze function globallyâŠ
I know this is an old thread, but thought Iâd add my latest code⊠as we now support Japanese, and this whole area is tricky to get right. I hope it helps somebody!
juce::String WJX_StringLocale::sGetTypefaceNameForCurrentLocale(bool isMonospaced) {
#if defined(IM_TARGET_IOS) || defined(IM_TARGET_TVOS)
auto&& locale = WJUI_StringLocale::sGetLocale();
if (locale.hasPrefix("zh")) {
return "PingFang SC";
} else if (locale.hasPrefix("ja")) {
return "Hiragino Sans";
} else {
return ".SFUIText";
}
#elif defined(IM_TARGET_MACOS)
auto&& locale = WJUI_StringLocale::sGetLocale();
if (locale.hasPrefix("zh")) {
return "PingFang SC";
} else if (locale.hasPrefix("ja")) {
return "Hiragino Sans";
} else {
auto macOSVersionNumber = NSAppKitVersionNumber;
if (floor(macOSVersionNumber) <= NSAppKitVersionNumber10_12) {
// On a 10.12.x or earlier system ... i.e. Sierra!
return "Heletica Neue";
}
return ".AppleSystemUIFont";
}
#elif defined(IM_TARGET_WINDOWS)
if (isMonospaced) {
return "Consolas";
}
auto&& locale = WJUI_StringLocale::sGetLocale();
if (locale.hasPrefix("zh")) {
return "Microsoft YaHei"; // Chinese font
} else if (locale.hasPrefix("ja")) {
return "Yu Gothic UI"; // Japanese font
}
// Default case: English font
// Note: "Segoe UI Symbol" supports the Unicode tick if you need it.
return "Segoe UI";
#else // IM_TARGET_ANDROID
return "Roboto";
#endif //
}
juce::Typeface::Ptr WJX_StringLocale::sGetTypefaceForFont(juce::LookAndFeel_V3& lookAndFeel, const juce::Font& font) {
juce::Font f(font);
if (font.getTypefaceName() == "<Monospaced>") {
// This is the Code Editor case...
#ifdef IM_TARGET_WINDOWS
f.setTypefaceName(sGetTypefaceNameForCurrentLocale(true)); // true means - monospaced
#else // IM_TARGET_WINDOWS
f.setTypefaceName(juce::Font::getDefaultMonospacedFontName());
#endif // IM_TARGET_WINDOWS
} else {
f.setTypefaceName(sGetTypefaceNameForCurrentLocale());
}
return juce::Typeface::createSystemTypefaceFor(f);
}
Hi @t0m just FWIW, you might want to consider putting something like the above in a future JUCE update. The macOS font selection by JUCE âout of the boxâ is never quite right and for Chinese / Japanese, it is essential to use the correct font especially for Windows.