[PATCH 3/3] conhost: Detect DBCS code pages using lead byte comparison

Hugh McMaster hugh.mcmaster at outlook.com
Mon Nov 22 05:43:30 CST 2021


Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 programs/conhost/window.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/programs/conhost/window.c b/programs/conhost/window.c
index 319463537d5..eab98c11d54 100644
--- a/programs/conhost/window.c
+++ b/programs/conhost/window.c
@@ -627,6 +627,7 @@ static HFONT select_font_config( struct console_config *config, unsigned int cp,
     TEXTMETRICW tm;
     CPINFO cpinfo;
     HDC dc;
+    static const BYTE lead_bytes[MAX_LEADBYTES] = { 0 };
 
     if (!(dc = GetDC( hwnd ))) return NULL;
     if (!(font = CreateFontIndirectW( lf )))
@@ -646,7 +647,8 @@ static HFONT select_font_config( struct console_config *config, unsigned int cp,
     lstrcpyW( config->face_name, lf->lfFaceName );
 
     /* FIXME: use maximum width for DBCS codepages since some chars take two cells */
-    if (GetCPInfo( cp, &cpinfo ) && cpinfo.MaxCharSize > 1)
+    GetCPInfo( cp, &cpinfo );
+    if (memcmp( cpinfo.LeadByte, lead_bytes, sizeof(cpinfo.LeadByte) ))
         config->cell_width  = tm.tmMaxCharWidth;
 
     return font;
-- 
2.34.0




More information about the wine-devel mailing list