Fix npp displays Chinese characters in traditional characters in DirectWrite render mode since version 8.6
-
Since Notepad++ 8.6 added DirectWrite as the default rendering method, the program displays Chinese characters in traditional characters, and modifying to GBK font cannot fix the issue; reverting to GDI rendering resolves the problem.

I tracked the issue:
According to Scintilla’s description, DirectWrite determines which set of glyph variants to use for CJK characters based on localeName (locale name).
The default values for Scintilla (see Platform.h) are:constexpr const char *localeNameDefault = "en-us";The repair method is as follows:
After enabling DirectWrite, the correct font locale will be automatically set according to the system locale in the init method:
Taking the notepad-plus-plus-8.9.2 source code as an example, modify the if statement starting from ScintillaEditView.cpp:482 to the following:

// === New: Automatically set font locale based on system locale, and fix the issue with CJK font selection === wchar_t sysLocaleName[LOCALE_NAME_MAX_LENGTH] = { 0 }; if (GetUserDefaultLocaleName(sysLocaleName, LOCALE_NAME_MAX_LENGTH) > 0) { int len = WideCharToMultiByte(CP_UTF8, 0, sysLocaleName, -1, nullptr, 0, nullptr, nullptr); if (len > 0) { std::string localeUtf8(len, '\0'); WideCharToMultiByte(CP_UTF8, 0, sysLocaleName, -1, &localeUtf8[0], len, nullptr, nullptr); localeUtf8.resize(len - 1); execute(SCI_SETFONTLOCALE, 0, reinterpret_cast<LPARAM>(localeUtf8.c_str())); } } // === New end ===After DirectWrite initialization, this code reads the user’s system language (such as zh-CN) and notifies Scintilla to use the corresponding font variant through SCI_SETFONTLOCALE. This ensures that the Simplified Chinese system (zh-CN) correctly selects the Simplified Chinese font, while the Traditional Chinese system (zh-TW) selects the Traditional Chinese font.
Finally result:

-
Bravo!
You may also be interested in this issue: “ANSI auto-completion shows garbled text when typing Chinese characters (since v8.8)”