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

Make crossterm implement terminal font support #166

Open
2 tasks
TimonPost opened this issue Jun 22, 2019 · 0 comments
Open
2 tasks

Make crossterm implement terminal font support #166

TimonPost opened this issue Jun 22, 2019 · 0 comments

Comments

@TimonPost
Copy link
Member

Task Description

Controlling, getting, the terminal font, would be a nice feature to have.

Task Todo

  • The font types supported by different terminals may be different, but they should all support adjusting the font size.

  • One idea is that we provide an interface to help the user detect which fonts are supported by the current terminal, and then the user can select one of these fonts as needed.

  • The font size setting should be a generic interface, which will give the terminal more possibilities.

  • Research how we can control the font with windows consols

  • Research how we can control the font with linux terminals

Notices

windows

struct CONSOLE_FONT
{
	DWORD index;
	COORD dim;
};

typedef BOOL (WINAPI *PROCSETCONSOLEFONT)(HANDLE, DWORD);
typedef BOOL (WINAPI *PROCGETCONSOLEFONTINFO)(HANDLE,BOOL,DWORD,CONSOLE_FONT*);
typedef COORD (WINAPI *PROCGETCONSOLEFONTSIZE)(HANDLE,DWORD);
typedef DWORD (WINAPI *PROCGETNUMBEROFCONSOLEFONTS)();
typedef BOOL (WINAPI *PROCGETCURRENTCONSOLEFONT)(HANDLE,BOOL,CONSOLE_FONT*);

PROCSETCONSOLEFONT SetConsoleFont;
PROCGETCONSOLEFONTINFO GetConsoleFontInfo;
PROCGETCONSOLEFONTSIZE GConsoleFontSize;
PROCGETNUMBEROFCONSOLEFONTS GetNumberOfConsoleFonts;
PROCGETCURRENTCONSOLEFONT GCurrentConsoleFont;

int _tmain(int argc, _TCHAR* argv[])
{
	int nNumFont;

	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);	
	HMODULE hKernel32 = GetModuleHandle(L"kernel32");

	SetConsoleFont = (PROCSETCONSOLEFONT)GetProcAddress(hKernel32,"SetConsoleFont");
	GetConsoleFontInfo = (PROCGETCONSOLEFONTINFO)GetProcAddress(hKernel32,"GetConsoleFontInfo");
	GConsoleFontSize = (PROCGETCONSOLEFONTSIZE)GetProcAddress(hKernel32,"GetConsoleFontSize");
	GetNumberOfConsoleFonts = (PROCGETNUMBEROFCONSOLEFONTS)GetProcAddress(hKernel32,"GetNumberOfConsoleFonts");
	GCurrentConsoleFont = (PROCGETCURRENTCONSOLEFONT)GetProcAddress(hKernel32,"GetCurrentConsoleFont");

	nNumFont = GetNumberOfConsoleFonts();
	CONSOLE_FONT *pFonts = new CONSOLE_FONT[nNumFont];
	GetConsoleFontInfo(hConsole, 0, nNumFont, pFonts);

	SetConsoleFont(hConsole, pFonts[5].index);

	cout << "This is Console C++!" << endl;

	return 0;
}
@TimonPost TimonPost changed the title Implement terminal font support Make crossterm implement terminal font support Jun 22, 2019
december1981 pushed a commit to december1981/crossterm that referenced this issue Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant