unit setdefaultcodepages;

interface

uses
  Windows;

implementation

Const
  LF_FACESIZE = 32;

Type
  CONSOLE_FONT_INFOEX = record
    cbSize      : ULONG;
    nFont       : DWORD;
    dwFontSizeX : SHORT;
    dwFontSizeY : SHORT;
    FontFamily  : UINT;
    FontWeight  : UINT;
    FaceName    : array [0..LF_FACESIZE-1] of WCHAR;
  end;

{ Only supported in Vista and onwards!}

function SetCurrentConsoleFontEx(hConsoleOutput: HANDLE; bMaximumWindow: BOOL; var CONSOLE_FONT_INFOEX): BOOL; stdcall; external 'kernel32.dll' name 'SetCurrentConsoleFontEx';
var
  New_CONSOLE_FONT_INFOEX : CONSOLE_FONT_INFOEX;

initialization

  {$IFDEF DisableUTF8RTL}
  SetConsoleOutputCP(DefaultSystemCodePage);
  SetTextCodepage(Output, DefaultSystemCodePage);
  {$ELSE DisableUTF8RTL}
  SetConsoleOutputCP(CP_UTF8);
  SetTextCodepage(Output, CP_UTF8);
  {$ENDIF DisableUTF8RTL}

  FillChar(New_CONSOLE_FONT_INFOEX, SizeOf(CONSOLE_FONT_INFOEX), 0);
  New_CONSOLE_FONT_INFOEX.cbSize := SizeOf(CONSOLE_FONT_INFOEX);

  New_CONSOLE_FONT_INFOEX.FaceName := 'Lucida Console';
  New_CONSOLE_FONT_INFOEX.FontWeight := 400;

  SetCurrentConsoleFontEx(StdOutputHandle, False, New_CONSOLE_FONT_INFOEX);
end.


