From 8399c6a82127f3c6a2e5f781122567d27ae799f8 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 27 May 2022 15:07:33 +0300 Subject: [PATCH] Improve font selection on MS-Windows The Arial Unicode MS font claims in its USB (Unicode Subset Bitfields) values support for several scripts for which it doesn't actually have glyphs. This sometimes caused Emacs to decide to use Arial Unicode MS for some script, only to discover later that there are no glyphs for that script's characters. This change fixes the USB values according to actual font coverage, as determined by BabelMap. * src/w32font.c (add_font_entity_to_list): Fix USB values of Arial Unicode MS font according to its actual coverage of scripts. --- src/w32font.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/w32font.c b/src/w32font.c index 4e60b818ced..611a0c89658 100644 --- a/src/w32font.c +++ b/src/w32font.c @@ -1540,6 +1540,19 @@ add_font_entity_to_list (ENUMLOGFONTEX *logical_font, || physical_font->ntmFontSig.fsUsb[1] || physical_font->ntmFontSig.fsUsb[0] & 0x3fffffff; + /* Kludgey fix for Arial Unicode MS font that claims support for + scripts it doesn't actually cover. */ + if (strncmp (logical_font->elfLogFont.lfFaceName, + "Arial Unicode MS", 16) == 0) + { + /* Reset bits 4 (Phonetic), 12 (Vai), 14 (Nko), 27 (Balinese). */ + physical_font->ntmFontSig.fsUsb[0] &= 0xf7ffafef; + /* Reset bits 53 (Phags-pa) and 58 (Phoenician). */ + physical_font->ntmFontSig.fsUsb[1] &= 0xfbdfffff; + /* Set bit 70 (Tibetan). */ + physical_font->ntmFontSig.fsUsb[2] |= 0x00000040; + } + /* Skip non matching fonts. */ /* For uniscribe backend, consider only truetype or opentype fonts -- 2.39.2