How can I change console font?


I have a problem with output Unicode in Windows XP console. (Microsoft Windows XP [Version 5.1.2600]) First code is that(from


int main(void) {
    _setmode(_fileno(stdout), _O_U16TEXT);
    wprintf(L"\x043a\x043e\x0448\x043a\x0430 \x65e5\x672c\x56fd\n");
    return 0;

My codepage is 65001(CP_UTF8). Excep Ⴂ, every letter look good. But Ⴂ is look like square. Console's default font 'Lucida Console' doesn't have font for that letter. So, I downloaded some other font which can render Ⴂ correcly, but I cannot change (Visual Studio 2005 project) console font.

I changed HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe\FontName, but when I check Prompt's properties -> Font, it set as 'Lucida Console'. Is there any way to change console font with API?

The next code is what I tried. But it doesn't work. Help.

#include "stdafx.h"
#include "Windows.h"

using namespace std;

// Conventional wisdom is retarded, aka What the @#%&* is _O_U16TEXT?
int main() {

    // Windows Command Prompt use code page 850,
    // probably for backwards compatibility with old DOS programs. 
    // Unicode at the Windows command prompt (C++; .Net; Java)

    // INFO: SetConsoleOutputCP Only Effective with Unicode Fonts

    // Undocumented API : SetConsoleFont 
    HMODULE hm = GetModuleHandle(_T("KERNEL32.DLL"));
    SetConsoleFont = (FN_SETCONSOLEFONT) GetProcAddress(hm, "SetConsoleFont");
    int fontIndex = 10; // 10 is known to identify Lucida Console (a Unicode font)
    BOOL bRet = SetConsoleFont(GetStdHandle(STD_OUTPUT_HANDLE), fontIndex);

    //const UINT codePage = CP_UTF8;    //
    const UINT codePage = 1200;     // 1200(utf-16 Unicode) 

    wchar_t s[] = L"èéøÞǽлљΣæča\n";
    int bufferSize = WideCharToMultiByte(codePage, 0, s, -1, NULL, 0, NULL, NULL);
    char* m = new char[bufferSize]; 
    WideCharToMultiByte(codePage, 0, s, -1, m, bufferSize, NULL, NULL);
    // 0x00000459 "No mapping for the Unicode character exists in the target multi-byte code page."
    wprintf(L"%S", m);  // it doesn't work
    wprintf(L"%s", s);  // it work a bit

    // after L'Ⴂ' letter, wcout failed!

PS : BTW, when I put "include < fcntl.h >" in "code tag", the part with in <> (fcntl.h) disappeared. How can I put system include?

asked on Stack Overflow Jul 11, 2010 by P-P • edited Oct 8, 2014 by Community

1 Answer


Found these instructions through Google here:

Be default, the properties on a cmd.exe window allow you to select either Raster Fonts or Lucida Console. You can add other monospace fonts to the list via the registry.

In regedit, navigate to

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ Console\TrueTypeFont

Notice that Lucida Console is already under this key with a name of "0".

Add a new sting value with the name "00" (yep, that's the required name) and set the data to the name of a monospace font already installed in your C:\Windows\Fonts folder. In this example, I added the Consolas font. It seems that additional entries require names "000", "0000", etc. Names like "1" and "2" don't work. For Pete's sake, why?

Open up a new cmd window, right-click on the system menu, select Properties | Font and there is the newly added font.

I did this because I wanted a more readable font for my PowerShell window, since I've been spending some time staring at it.


I followed the instructions and made Consolas my default font for cmd. It worked as expected.

Note that it will only accept monospaced fonts.

answered on Stack Overflow Jul 11, 2010 by Gunslinger47 • edited Jul 11, 2010 by Gunslinger47

User contributions licensed under CC BY-SA 3.0