SetCurrentConsoleFontEx() has no effect #10565

Closed
opened 2026-01-31 02:24:45 +00:00 by claunia · 1 comment
Owner

Originally created by @aziascreations on GitHub (Sep 10, 2020).

Environment

Windows build number: Microsoft Windows [Version 10.0.19041.450]
Windows Terminal version: 1.2.2381.0
Software: Visual Studio 2019 and/or PureBasic IDE

Steps to reproduce

Compile the following C++ test program and run it:

#include <iostream>
#include <Windows.h>
#include <Wincon.h>
#include <Winbase.h>

int main() {
    std::cout << "Here is some text in the default console font.\n";
    std::cout << "Press enter to continue.\n";
    std::cin.get();

    // Setting up the variables
    HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_FONT_INFOEX fontInfo;
    fontInfo.cbSize = sizeof(CONSOLE_FONT_INFOEX);
    fontInfo.dwFontSize.X = 0;
    fontInfo.dwFontSize.Y = 24;
    fontInfo.FontFamily = TMPF_TRUETYPE;
    wcscpy_s(fontInfo.FaceName, L"Arial");

    // Changing the console font.
    if(SetCurrentConsoleFontEx(consoleHandle, FALSE, &fontInfo)) {
        std::cout << "The console font should now be: Arial\n";
    } else {
        std::cout << "Failed to change the font: " << GetLastError();
    }
    std::cout << "Press enter to exit.\n";
    std::cin.get();
}

The program simply uses the WinAPI function SetCurrentConsoleFontEx() to change the font.

Expected behavior

After pressing enter once, the console font should be changed to "Arial".

Actual behavior

On the Terminal app the font stays the same.

Notes

The old cmd.exe and powershell.exe both work correctly.

I also tried some monospaced fonts like "Consolas", "Ubuntu Mono" and "Lucida Console" instead of "Arial", but none of them worked. I tried them because the issue #295 mentionned the fact that monospaced fonts should work with conhost.exe just in case this application uses it.

Originally created by @aziascreations on GitHub (Sep 10, 2020). # Environment ```none Windows build number: Microsoft Windows [Version 10.0.19041.450] Windows Terminal version: 1.2.2381.0 Software: Visual Studio 2019 and/or PureBasic IDE ``` # Steps to reproduce Compile the following C++ test program and run it: ```cpp #include <iostream> #include <Windows.h> #include <Wincon.h> #include <Winbase.h> int main() { std::cout << "Here is some text in the default console font.\n"; std::cout << "Press enter to continue.\n"; std::cin.get(); // Setting up the variables HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_FONT_INFOEX fontInfo; fontInfo.cbSize = sizeof(CONSOLE_FONT_INFOEX); fontInfo.dwFontSize.X = 0; fontInfo.dwFontSize.Y = 24; fontInfo.FontFamily = TMPF_TRUETYPE; wcscpy_s(fontInfo.FaceName, L"Arial"); // Changing the console font. if(SetCurrentConsoleFontEx(consoleHandle, FALSE, &fontInfo)) { std::cout << "The console font should now be: Arial\n"; } else { std::cout << "Failed to change the font: " << GetLastError(); } std::cout << "Press enter to exit.\n"; std::cin.get(); } ``` The program simply uses the WinAPI function `SetCurrentConsoleFontEx()` to change the font. # Expected behavior After pressing enter once, the console font should be changed to "Arial". # Actual behavior On the Terminal app the font stays the same. # Notes The old `cmd.exe` and `powershell.exe` both work correctly. I also tried some monospaced fonts like "Consolas", "Ubuntu Mono" and "Lucida Console" instead of "Arial", but none of them worked. I tried them because the issue #295 mentionned the fact that monospaced fonts should work with `conhost.exe` just in case this application uses it.
claunia added the Resolution-By-DesignNeeds-TriageNeeds-Tag-Fix labels 2026-01-31 02:24:45 +00:00
Author
Owner

@DHowett commented on GitHub (Sep 10, 2020):

So, this is by design. There is a set of APIs that treat the console as an object to be controlled by the application, and those APIs are inherently troublesome for terminal multiplexers and remoting software (like SSH!)

More details here: https://github.com/microsoft/terminal/issues/6832#issuecomment-655684556

Sorry about that!

@DHowett commented on GitHub (Sep 10, 2020): So, this is by design. There is a set of APIs that treat the console as an object to be controlled by the application, and those APIs are inherently troublesome for terminal multiplexers and remoting software (like SSH!) More details here: https://github.com/microsoft/terminal/issues/6832#issuecomment-655684556 Sorry about that!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10565