1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

conhost: Set correct face name when the specified font is not available.

conhost.exe currently copies the user-specified face name from the
LOGFONT structure. This results in an invalid face name when the
specified font is not available.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 303f8042f9)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
Hugh McMaster 2022-05-24 23:27:23 +10:00 committed by Alexandre Julliard
parent 7398ee371a
commit a40055a461

View file

@ -675,6 +675,7 @@ static BOOL set_console_font( struct console *console, const LOGFONTW *logfont )
struct font_info *font_info = &console->active->font;
HFONT font, old_font;
TEXTMETRICW tm;
WCHAR face_name[LF_FACESIZE];
CPINFO cpinfo;
HDC dc;
@ -700,6 +701,7 @@ static BOOL set_console_font( struct console *console, const LOGFONTW *logfont )
old_font = SelectObject( dc, font );
GetTextMetricsW( dc, &tm );
font_info->face_len = GetTextFaceW( dc, ARRAY_SIZE(face_name), face_name ) - 1;
SelectObject( dc, old_font );
ReleaseDC( console->win, dc );
@ -708,9 +710,8 @@ static BOOL set_console_font( struct console *console, const LOGFONTW *logfont )
font_info->weight = tm.tmWeight;
free( font_info->face_name );
font_info->face_len = wcslen( logfont->lfFaceName );
font_info->face_name = malloc( font_info->face_len * sizeof(WCHAR) );
memcpy( font_info->face_name, logfont->lfFaceName, font_info->face_len * sizeof(WCHAR) );
memcpy( font_info->face_name, face_name, font_info->face_len * sizeof(WCHAR) );
/* FIXME: use maximum width for DBCS codepages since some chars take two cells */
if (GetCPInfo( console->output_cp, &cpinfo ) && cpinfo.MaxCharSize == 2)