Printing International Fonts w/o changing console fonts


This one works, but is changing the whole console font and size.


Is there a windows way similar to how Linux does it w/o any font change?


#include <stdio.h>
#include <windows.h>

int main()
{
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_FONT_INFOEX font;
font.cbSize = sizeof(CONSOLE_FONT_INFOEX);
GetCurrentConsoleFontEx(console, FALSE, &font);
wcscpy(font.FaceName, L"Microsoft YaHei");
SetCurrentConsoleFontEx(console, FALSE, &font);

printf("你好世界\n");

return 0;
}


The Windows console is inherently different from the Linux terminal, and changing font settings in Windows is more involved due to the different APIs and system architecture. The code snippet you provided is indeed changing the console font and size, and unfortunately, there is no direct equivalent to the Linux method on Windows without changing the font.

However, if you're developing a Windows application and want to display Unicode characters without changing the console font, you may want to consider using a GUI library or framework instead, such as Qt or GTK. These libraries allow you to create graphical applications that can display text in various languages without affecting the console settings.
Registered users can post here. Sign in or register to post.