Subject: [PATCH v2 2/2] compat/winansi: drop pre-Vista workaround

From: "Matthias Aßhauer via GitGitGadget" <[email-masked]>
Date: Mon, 06 Apr 2026 05:45:30 +0000

From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= <[email-masked]>

1edeb9a (Win32: warn if the console font doesn't support Unicode,
2014-06-10) introduced both code to detect the current console font on
Windows Vista and newer and a fallback for older systems to detect the
default console font and issue a warning if that font doesn't support
unicode.

Since we haven't supported any Windows older than Vista in almost a
decade, we don't need to keep the workaround.

Signed-off-by: Matthias Aßhauer <[email-masked]>
Signed-off-by: Johannes Schindelin <[email-masked]>
---
 compat/winansi.c | 37 ++++---------------------------------
 1 file changed, 4 insertions(+), 33 deletions(-)

diff --git a/compat/winansi.c b/compat/winansi.c
index ac2ffb7869..3ce1900939 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -32,47 +32,18 @@ static int non_ascii_used = 0;
 static HANDLE hthread, hread, hwrite;
 static HANDLE hconsole1, hconsole2;
 
-#ifdef __MINGW32__
-#if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 5
-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
-#endif
-
 static void warn_if_raster_font(void)
 {
 	DWORD fontFamily = 0;
-	DECLARE_PROC_ADDR(kernel32.dll, BOOL, WINAPI,
-			GetCurrentConsoleFontEx, HANDLE, BOOL,
-			PCONSOLE_FONT_INFOEX);
+	CONSOLE_FONT_INFOEX cfi;
 
 	/* don't bother if output was ascii only */
 	if (!non_ascii_used)
 		return;
 
-	/* GetCurrentConsoleFontEx is available since Vista */
-	if (INIT_PROC_ADDR(GetCurrentConsoleFontEx)) {
-		CONSOLE_FONT_INFOEX cfi;
-		cfi.cbSize = sizeof(cfi);
-		if (GetCurrentConsoleFontEx(console, 0, &cfi))
-			fontFamily = cfi.FontFamily;
-	} else {
-		/* pre-Vista: check default console font in registry */
-		HKEY hkey;
-		if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_CURRENT_USER, "Console",
-				0, KEY_READ, &hkey)) {
-			DWORD size = sizeof(fontFamily);
-			RegQueryValueExA(hkey, "FontFamily", NULL, NULL,
-					(LPVOID) &fontFamily, &size);
-			RegCloseKey(hkey);
-		}
-	}
+	cfi.cbSize = sizeof(cfi);
+	if (GetCurrentConsoleFontEx(console, 0, &cfi))
+		fontFamily = cfi.FontFamily;
 
 	if (!(fontFamily & TMPF_TRUETYPE)) {
 		const wchar_t *msg = L"\nWarning: Your console font probably "
-- 
gitgitgadget