From 4670a62342fead3d881710c12735b66108987a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Sun, 12 Jan 2025 17:23:41 +0100 Subject: [PATCH] Fix: [Win32] Font detection didn't work for locales not supporting code pages (#13306) --- src/os/windows/font_win32.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp index 6f021c270a..c0ae666bee 100644 --- a/src/os/windows/font_win32.cpp +++ b/src/os/windows/font_win32.cpp @@ -64,7 +64,18 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT if (info->callback->Monospace() && (logfont->elfLogFont.lfPitchAndFamily & (FF_MODERN | FIXED_PITCH)) != (FF_MODERN | FIXED_PITCH)) return 1; /* The font has to have at least one of the supported locales to be usable. */ - if ((metric->ntmFontSig.fsCsb[0] & info->locale.lsCsbSupported[0]) == 0 && (metric->ntmFontSig.fsCsb[1] & info->locale.lsCsbSupported[1]) == 0) return 1; + auto check_bitfields = [&]() { + /* First try Unicode Subset Bitfield. */ + for (uint8_t i = 0; i < 4; i++) { + if ((metric->ntmFontSig.fsUsb[i] & info->locale.lsUsb[i]) != 0) return true; + } + /* Keep Code Page Bitfield as a fallback. */ + for (uint8_t i = 0; i < 2; i++) { + if ((metric->ntmFontSig.fsCsb[i] & info->locale.lsCsbSupported[i]) != 0) return true; + } + return false; + }; + if (!check_bitfields()) return 1; char font_name[MAX_PATH]; convert_from_fs(logfont->elfFullName, font_name);