Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/conhost/window.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/programs/conhost/window.c b/programs/conhost/window.c index 9fc310f3111..e408a9830e1 100644 --- a/programs/conhost/window.c +++ b/programs/conhost/window.c @@ -1206,6 +1206,7 @@ struct dialog_info struct console *console; struct console_config config; HWND dialog; /* handle to active propsheet */ + HFONT hfont; int font_count; /* number of fonts */ struct dialog_font_info { @@ -1571,7 +1572,6 @@ static int WINAPI font_enum_size( const LOGFONTW *lf, const TEXTMETRICW *tm,
static BOOL select_font( struct dialog_info *di ) { - struct console_config config; int font_idx, size_idx; HFONT font, old_font; DWORD_PTR args[2]; @@ -1588,19 +1588,20 @@ static BOOL select_font( struct dialog_info *di ) fill_logfont( &lf, di->font[size_idx].faceName, wcslen(di->font[size_idx].faceName) * sizeof(WCHAR), di->font[size_idx].height, di->font[size_idx].weight ); - font = select_font_config( &config, di->console->output_cp, di->console->win, &lf ); + font = select_font_config( &di->config, di->console->output_cp, di->console->win, &lf ); if (!font) return FALSE;
- if (config.cell_height != di->font[size_idx].height) - TRACE( "mismatched heights (%u<>%u)\n", config.cell_height, di->font[size_idx].height ); + if (di->config.cell_height != di->font[size_idx].height) + TRACE( "mismatched heights (%u<>%u)\n", di->config.cell_height, di->font[size_idx].height );
old_font = (HFONT)SendDlgItemMessageW( di->dialog, IDC_FNT_PREVIEW, WM_GETFONT, 0, 0 ); SendDlgItemMessageW( di->dialog, IDC_FNT_PREVIEW, WM_SETFONT, (WPARAM)font, TRUE ); + di->hfont = font; if (old_font) DeleteObject( old_font );
LoadStringW( GetModuleHandleW(NULL), IDS_FNT_DISPLAY, fmt, ARRAY_SIZE(fmt) ); - args[0] = config.cell_width; - args[1] = config.cell_height; + args[0] = di->config.cell_width; + args[1] = di->config.cell_height; FormatMessageW( FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY, fmt, 0, 0, buf, ARRAY_SIZE(buf), (__ms_va_list*)args );
@@ -1702,18 +1703,7 @@ static INT_PTR WINAPI font_dialog_proc( HWND dialog, UINT msg, WPARAM wparam, LP di->dialog = dialog; break; case PSN_APPLY: - val = SendDlgItemMessageW( dialog, IDC_FNT_LIST_SIZE, LB_GETCURSEL, 0, 0 ); - if (val < di->font_count) - { - LOGFONTW lf; - - fill_logfont( &lf, di->font[val].faceName, - wcslen(di->font[val].faceName) * sizeof(WCHAR), - di->font[val].height, di->font[val].weight ); - DeleteObject( select_font_config( &di->config, di->console->output_cp, - di->console->win, &lf )); - } - + DeleteObject( di->hfont ); val = (GetWindowLongW( GetDlgItem( dialog, IDC_FNT_COLOR_BK ), 0 ) << 4) | GetWindowLongW( GetDlgItem( dialog, IDC_FNT_COLOR_FG ), 0 ); di->config.attr = val; @@ -1980,6 +1970,7 @@ static BOOL config_dialog( struct console *console, BOOL current ) prev_config = di.config; di.font_count = 0; di.font = NULL; + di.hfont = NULL;
wndclass.style = 0; wndclass.lpfnWndProc = font_preview_proc;