Win32 Console Chess Black pawn font issue

Viewed 163

I'm creating a simple Windows console chess interface but faced into something strange with the Black Pawn (\u265F).

With MS Gothic it looks like other symbols except the black pawn take single spaces:

enter image description here

Here is my code. Am I doing something wrong or is there a way of preventing it?

#include <Windows.h>
#include <conio.h>

void writeConsole(HANDLE handle, const wchar_t* text)
{
    DWORD n;
    WriteConsoleW(handle, text, wcslen(text), &n, NULL);
}

int main()
{
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_FONT_INFOEX org = { 0 };
    CONSOLE_FONT_INFOEX cfi = { 0 };
    cfi.cbSize = sizeof(cfi);
    GetCurrentConsoleFontEx(handle, 0, &cfi);
    memcpy(&org, &cfi, sizeof(cfi));

    wcscpy_s(cfi.FaceName, LF_FACESIZE, L"MS Gothic");
    cfi.dwFontSize.X = 50;
    cfi.dwFontSize.Y = 50;

    SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
    SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY);

    writeConsole(handle, L"White King   : \u2654\u2654\u2654\u2654           \n");
    writeConsole(handle, L"White Queen  : \u2655\u2655\u2655\u2655           \n");
    writeConsole(handle, L"White Rook   : \u2656\u2656\u2656\u2656           \n");
    writeConsole(handle, L"White Bishop : \u2657\u2657\u2657\u2657           \n");
    writeConsole(handle, L"White Knight : \u2658\u2658\u2658\u2658           \n");
    writeConsole(handle, L"White Pawn   : \u2659\u2659\u2659\u2659           \n");

    writeConsole(handle, L"Black King   : \u265A\u265A\u265A\u265A           \n");
    writeConsole(handle, L"Black Queen  : \u265B\u265B\u265B\u265B           \n");
    writeConsole(handle, L"Black Rook   : \u265C\u265C\u265C\u265C           \n");
    writeConsole(handle, L"Black Bishop : \u265D\u265D\u265D\u265D           \n");
    writeConsole(handle, L"Black Knight : \u265E\u265E\u265E\u265E           \n");
    writeConsole(handle, L"Black Pawn   : \u265F\u265F\u265F\u265F           \n");

    writeConsole(handle, L"Press any key to exit.          \n");
    _getch();

    SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &org);
}
0 Answers
Related