BR:Changing fonts causes garbled text on Windows

Hi, JUCE developers.

The application we are developing supports display in Japanese and Chinese.
On macOS, any language can be displayed without garbling by using Arial Unicode MS, but Windows does not have such a standard font, so we switch the font of the entire app according to the language to be displayed.
However, we faced a problem that some strings were garbled when we switched.

We have confirmed that the bug also occurs in v7.0.4 and has not been resolved in the develop branch as of today.
I have created a simple sample app and would like you to check the issue with the following code and instructions.

MainComponent.h:

#pragma once

#include <JuceHeader.h>


class MainComponent  : public juce::Component
{
public:
    MainComponent();
    ~MainComponent() override;

    void paint (juce::Graphics&) override;
    void resized() override;

private:
    juce::ComboBox languageComboBox;

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};

MainComponent.cpp:

#include "MainComponent.h"

MainComponent::MainComponent()
{
    addAndMakeVisible(languageComboBox);

    languageComboBox.addItem("Chinese Font", 1);
    languageComboBox.addItem("Japanese Font", 2);
    juce::LookAndFeel::getDefaultLookAndFeel().setDefaultSansSerifTypefaceName("Microsoft YaHei UI"); // Chinese Font
    languageComboBox.setSelectedId(2, juce::dontSendNotification); // The correspondence is wrong, but this way the problem occurs.

    languageComboBox.onChange = [this] {
        switch (languageComboBox.getSelectedId())
        {
        case 1:
            juce::LookAndFeel::getDefaultLookAndFeel().setDefaultSansSerifTypefaceName("Microsoft YaHei UI"); // Chinese Font
            break;
        case 2:
            juce::LookAndFeel::getDefaultLookAndFeel().setDefaultSansSerifTypefaceName("MS UI Gothic"); // Japanese Font
            break;
        default:
            break;
        }
        sendLookAndFeelChange();
    };

    setSize (300, 250);
}

MainComponent::~MainComponent()
{
}

void MainComponent::paint (juce::Graphics& g)
{
    g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));   
}

void MainComponent::resized()
{
    languageComboBox.setBounds(50, 50, 200, 50);
}

Steps:

  • Switch the text in the ComboBox to “Chinese Font”.
  • Then switch the text in the ComboBox to “Japanese Font”.
  • Then, the ComboBox that should be displayed as “Japanese Font” will be garbled.

image

It is very strange that garbled characters occur even though they are not multibyte characters.
The same phenomenon occurs in the Slider class.
The behavior of the Label class seems suspicious, but I could not figure out what is causing it.
We are very stumped and would appreciate any help you can give us.

Thanks.