16

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?

poke
  • 369,085
  • 72
  • 557
  • 602
  • 1
    I only saw that error on `git push` when the server returns some strange error message. Note that UTF8 is in the process of being supported: http://stackoverflow.com/questions/5854967/git-msysgit-accents-utf-8-the-definitive-answers/6043599#6043599 – VonC Jun 10 '11 at 19:07
  • This is a common issue with the binary distributed win32 msysgit. Compiling it myself and use in combination with console2 solved that problem. – mbx Nov 06 '11 at 13:41
  • @mbx Since the problem appeared, I reinstalled my computer (not because of this problem though), and the problem disappeared just like that. Just in the same way it previously appeared without really changing anything on the system. – poke Nov 06 '11 at 14:41

2 Answers2

2

Actually it is talking about changing the font in your Command Prompt.

:]

A T
  • 13,008
  • 21
  • 97
  • 158
  • Yes, but you're talking about PowerShell and Git Bash [MSYS]. What the installer is offering to change is your Command Prompt font (cmd.exe) – A T Nov 03 '11 at 10:45
  • 2
    My command promt is using a Unicode font too. Also this question is not about the installer dialog, but an error when *using* Git inside *any* console. – poke Nov 03 '11 at 17:32
  • That worked for me as soon as I configured my cmd.exe program to run with Lucida Console instead of the Raster font! :-) – Kayhadrin Sep 08 '15 at 07:35
0

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;
}
patthoyts
  • 32,320
  • 3
  • 62
  • 93
  • 5
    Too bad I was on Windows 7 when the problem appeared… :/ – poke Nov 06 '11 at 14:37
  • In that case, see the edited addition above for some code to try out. – patthoyts Nov 06 '11 at 17:34
  • Hm, that looks interesting. Too bad that I don’t have that error right now (see my comment to the question), but I’ll definitely keep this in mind and try it out, if it ever happens again :) – poke Nov 06 '11 at 18:25
  • I did some more testing on this. If you use --no-pager or `set PAGER=cat` and then use `git log` on a commit that has non-ASCII chars in the message or author then you get this message emitted. Appears to be a bug in the detection of the output pipe. Presumably in the past you set the PAGER or GIT_PAGER environment variables and have since lost that setting. – patthoyts Nov 07 '11 at 23:04
  • 1
    See http://article.gmane.org/gmane.comp.version-control.msysgit/13854 for the mailing list discussions on this and a fix that has now been applied for --no-pager/PAGER unset. – patthoyts Nov 08 '11 at 01:46