GetCurrentConsoleFont(...) always returns size {0,16} #8879

Closed
opened 2026-01-31 01:40:18 +00:00 by claunia · 2 comments
Owner

Originally created by @vladdeSV on GitHub (Jun 7, 2020).

Originally assigned to: @DHowett on GitHub.

The API call to GetCurrentConsoleFont(...) always yields a size of {0,16} (consoleFontInfo.dwFontSize)

Environment

Windows build number: 10.0.18363.0
Windows Terminal version: 1.0.1401.0

Steps to reproduce

  1. Compile the following C++ program
#include <windows.h>
#include <iostream>

int main()
{
	HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

	CONSOLE_FONT_INFO consoleFontInfo;
	GetCurrentConsoleFont(hStdOut, FALSE, &consoleFontInfo);

	std::cout << "Font Size: {" << consoleFontInfo.dwFontSize.X << "," << consoleFontInfo.dwFontSize.Y << "}" << std::endl;
}
  1. Run the program in Terminal with either CMD or Powershell
  2. The output is always {0,16}, regardless of fontSize in settings.json

Expected behavior

As with regular cmd.exe and powershell.exe I would expect the output to display some reasonable data

resize in regular apps

Actual behavior

The size outputted is always {0,16}, regardless of settings.
resize in terminal

Originally created by @vladdeSV on GitHub (Jun 7, 2020). Originally assigned to: @DHowett on GitHub. The API call to `GetCurrentConsoleFont(...)` always yields a size of `{0,16}` (`consoleFontInfo.dwFontSize`) # Environment ```none Windows build number: 10.0.18363.0 Windows Terminal version: 1.0.1401.0 ``` # Steps to reproduce 1. Compile the following C++ program ```c++ #include <windows.h> #include <iostream> int main() { HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_FONT_INFO consoleFontInfo; GetCurrentConsoleFont(hStdOut, FALSE, &consoleFontInfo); std::cout << "Font Size: {" << consoleFontInfo.dwFontSize.X << "," << consoleFontInfo.dwFontSize.Y << "}" << std::endl; } ``` 2. Run the program in Terminal with either CMD or Powershell 3. The output is always `{0,16}`, regardless of `fontSize` in settings.json # Expected behavior As with regular `cmd.exe` and `powershell.exe` I would expect the output to display some reasonable data ![resize in regular apps](https://i.imgur.com/z0T2k4e.png) # Actual behavior The size outputted is always `{0,16}`, regardless of settings. ![resize in terminal](https://i.imgur.com/19chyku.png)
claunia added the Resolution-By-DesignNeeds-Tag-FixNeeds-Attention labels 2026-01-31 01:40:18 +00:00
Author
Owner

@DHowett commented on GitHub (Jun 7, 2020):

This is by design. The process is isolated from the Terminal just like it would be if it were over SSH. There is no font in SSH.

Giving the console application access to the font information was a big mistake, so we are only providing bare-minimum compatibility for this API.

What is your use case?

@DHowett commented on GitHub (Jun 7, 2020): This is by design. The process is isolated from the Terminal just like it would be if it were over SSH. There is no font in SSH. Giving the console application access to the font information was a big mistake, so we are only providing bare-minimum compatibility for this API. What is your use case?
Author
Owner

@vladdeSV commented on GitHub (Jun 8, 2020):

Before I resize the console in-app I use GetSystemMetrics(…) to get the minimum size of the console in pixels.

I then calculate how wide and tall the console would be in pixels based on the font size, and then check If the console can be set to that size.

See code here.

@vladdeSV commented on GitHub (Jun 8, 2020): Before I resize the console in-app I use `GetSystemMetrics(…)` to get the minimum size of the console in pixels. I then calculate how wide and tall the console would be in pixels based on the font size, and then check If the console can be set to that size. See code [here](https://github.com/vladdeSV/scone/blob/7c22cf0c91d7a98199df0588abc8ba2d9c04473b/source/scone/os/windows/output/windows_output.d#L60-L72).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8879