I want to change the font in our app when the user has chosen a different language, we set it to use "Arial Unicode MS" if the language is Japanese.
But we need to call setDefaultSansSerifTypefaceName before any component (font object) is created otherwise you can't change it, it will stick to 'Lucida Grande' (mac).
And because we show a splash-screen while loading settings we are already too late.
To reproduce:
In the Juce Demo (latest tip)
- Code: Select all
ContentComp (MainDemoWindow& mainWindow_)
: mainWindow (mainWindow_),
currentDemoId (0)
{
//if you set the defaultsans here it works fine
//LookAndFeel::getDefaultLookAndFeel().setDefaultSansSerifTypefaceName("Courier New");
setOpaque (true);
invokeDirectly (showRendering, true);
}
~ContentComp()
{
#if JUCE_OPENGL
openGLContext.detach();
#endif
}
void paint (Graphics& g)
{
g.fillAll (Colours::white);
}
//==============================================================================
void showDemo (Component* demoComp)
{
//but if you set the defaultsans here it sticks to whatever it was set to as the default in LookAndFeel class
//this is platform independent,on the mac that would be 'Lucida Grande'
LookAndFeel::getDefaultLookAndFeel().setDefaultSansSerifTypefaceName("Courier New");
currentDemo = demoComp;
addAndMakeVisible (currentDemo);
currentDemo->setBounds ("0, 0, parent.width, parent.height");
}
Tip for anyone needing a workaround for the missing font fallback mechanism.
In our language files we specify a font to use.
This is how our language translation file looks like.
We call TRANS("FontToRenderThisLanguageIn") to find out if we need to use another font.
- Code: Select all
language: Japanese
version: Avenue 4 GUI
"FontToRenderThisLanguageIn" = "Arial Unicode MS"
"Hello" = "こんにちは"
"Composition" = "コンポジション"
"Composition Properties" = "コンポジションプロパティ"
"Composition Settings" = "コンポジション設定"
"Composition Effects" = "コンポジションエフェクト"
"Composition Audio" = "コンポジションオーディオ"
"Composition Video" = "コンポジションビデオ"
.....
