Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vladdeSV opened this issue Jun 7, 2020 · 2 comments
Closed

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

vladdeSV opened this issue Jun 7, 2020 · 2 comments
Assignees
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons.

Comments

@vladdeSV
Copy link

vladdeSV commented Jun 7, 2020

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

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jun 7, 2020
@DHowett
Copy link
Member

DHowett commented 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 DHowett added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons. labels Jun 7, 2020
@vladdeSV
Copy link
Author

vladdeSV commented 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.

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jun 8, 2020
@DHowett DHowett self-assigned this Jun 26, 2020
@DHowett DHowett removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jun 26, 2020
@DHowett DHowett closed this as completed Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons.
Projects
None yet
Development

No branches or pull requests

2 participants