title: Python Programmatically Change Console font size
body: <p>I found the code below which is supposed to programmatically change the console font size. I'm on Windows 10.</p>
  
  <p>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.</p>
  
  <p>I have no idea how ctypes works - all I want is to modify the size of the console font from inside Python.</p>
  
  <p>Any actual working solutions?</p>
  
  <pre><code>import ctypes
  
  LF_FACESIZE = 32
  STD_OUTPUT_HANDLE = -11
  
  class COORD(ctypes.Structure):
      _fields_ = [("X", ctypes.c_short), ("Y", ctypes.c_short)]
  
  class CONSOLE_FONT_INFOEX(ctypes.Structure):
      _fields_ = [("cbSize", ctypes.c_ulong),
                  ("nFont", ctypes.c_ulong),
                  ("dwFontSize", COORD),
                  ("FontFamily", ctypes.c_uint),
                  ("FontWeight", ctypes.c_uint),
                  ("FaceName", ctypes.c_wchar * LF_FACESIZE)]
  
  font = CONSOLE_FONT_INFOEX()
  font.cbSize = ctypes.sizeof(CONSOLE_FONT_INFOEX)
  font.nFont = 12
  font.dwFontSize.X = 11
  font.dwFontSize.Y = 18
  font.FontFamily = 54
  font.FontWeight = 400
  font.FaceName = "Lucida Console"
  
  handle = ctypes.windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
  ctypes.windll.kernel32.SetCurrentConsoleFontEx(
          handle, ctypes.c_long(False), ctypes.pointer(font))
  
  
  print("Foo")
  </code></pre>