
Call that function in order to populate the CONSOLE_FONT_INFOEX structure, then modify only the desired values
In order to avoid setting invalid values, it's used in conjunction with its counterpart: : GetCurrentConsoleFontEx function. Print("\n".format(sys.version, sys.platform))ĬTypes allows low level access similar to C (only the syntax is Python)Ĭode uses : SetConsoleTextAttribute function Stdout = get_std_handle_func(STD_OUTPUT_HANDLE) Set_current_console_font_ex_func.restype = BOOL Set_current_console_font_ex_func.argtypes = Set_current_console_font_ex_func = kernel32_dll.SetCurrentConsoleFontEx Get_current_console_font_ex_func.restype = BOOL Get_current_console_font_ex_func.argtypes = Get_current_console_font_ex_func = kernel32_dll.GetCurrentConsoleFontEx Get_std_handle_func = kernel32_dll.GetStdHandle Get_last_error_func = kernel32_dll.GetLastError The CTypes home page (also listed in the above URL): : ctypes - A foreign function library for Pythonįrom ctypes import POINTER, WinDLL, Structure, sizeof, byrefįrom ctypes.wintypes import BOOL, SHORT, WCHAR, UINT, ULONG, DWORD, HANDLE I want to start by pointing out : C function called from Python via ctypes returns incorrect value answer) which describes a problem that most CTypes users run into. Handle, ctypes.c_long(False), ctypes.pointer(font)) ("FaceName", ctypes.c_wchar * LF_FACESIZE)]įont.cbSize = ctypes.sizeof(CONSOLE_FONT_INFOEX)
_fields_ = Ĭlass CONSOLE_FONT_INFOEX(ctypes.Structure):
I have no idea how ctypes works - all I want is to modify the size of the console font from inside Python.Īny actual working solutions? import ctypes However, whatever values I tweak, I can't seem to get any control over the font size, and also for some reason the console which gets opened when I run this script is very wide. I found the code below which is supposed to programmatically change the console font size.