Recently I am getting this error when using msysgit, in particular when there is some non-ASCII content generated by the git output:
warning: Your console font probably doesn't support Unicode. If you experience strange characters in the output, consider switching to a TrueType font such as Lucida Console!
The funny thing is that although that message is telling me that my font doesn't support Unicode, it actually does and the text in question is displayed correctly (in the correct encoding & with all characters displayed).
The sad thing is that I don't find a way to disable this message. I tried changing the font in the Git Bash (I usually use PowerShell) but when I checked the font there, I noticed that it was actually already set to Lucida Console, and the warning appears in that same console too. So I'm a bit clueless what to do to fix this, or at least stop msysgit from printing this warning all the time.
I tried reinstalling msysgit, also with the option selected that is supposed to set the font to Lucida Console, but it didn't help. What can I do?
This test is done by the function warn_if_raster_font
in compat/winansi.c
. This uses the Win32 API GetCurrentConsoleFontEx to find the font in use by the console attached to the current output stream. This test should always be correct on Windows Vista and above. On Windows XP it has to resort to looking in the registry for the current default console font. So possibly you are on XP and while you have configured the shortcut for the console you are using, the default setting remains configured to use a non-unicode font.
If not, you might try compiling the following which uses roughly the same code and see what it prints out. Provided the output contains tt: 4 we would expect the corresponding git code to properly detect your console font as truetype.
#define STRICT
#define WINVER 0x0600
#define _WIN32_WINNT 0x600
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#ifdef __MINGW32__
typedef struct _CONSOLE_FONT_INFOEX {
ULONG cbSize;
DWORD nFont;
COORD dwFontSize;
UINT FontFamily;
UINT FontWeight;
WCHAR FaceName[LF_FACESIZE];
} CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
#endif
typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL,
PCONSOLE_FONT_INFOEX);
int
_tmain(int argc, TCHAR *argv[])
{
PGETCURRENTCONSOLEFONTEX pgccf;
pgccf = (PGETCURRENTCONSOLEFONTEX)
GetProcAddress(GetModuleHandleW(L"kernel32.dll"),
"GetCurrentConsoleFontEx");
if (pgccf == NULL) {
_tprintf(_T("error: failed to get function pointer\n"));
} else {
HANDLE console;
CONSOLE_FONT_INFOEX cfi;
cfi.cbSize = sizeof(cfi);
console = GetStdHandle(STD_OUTPUT_HANDLE);
if (!pgccf(console, 0, &cfi)) {
_tprintf(_T("error: failed to get console info\n"));
} else {
_tprintf(_T("font %08x tt:%d"), cfi.FontFamily,
(cfi.FontFamily&TMPF_TRUETYPE));
wprintf(L" %s", cfi.FaceName);
_tprintf(_T("\n"));
}
}
return 0;
}