kernel32: Implement GetCurrentConsoleFontEx.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47620
Signed-off-by: Gijs Vermeulen <gijsvrm@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Gijs Vermeulen 2019-11-20 11:45:29 +01:00 committed by Alexandre Julliard
parent 6ca93646be
commit ec810c84ab
7 changed files with 73 additions and 10 deletions

View File

@ -1639,17 +1639,28 @@ BOOL WINAPI SetConsoleKeyShortcuts(BOOL set, BYTE keys, VOID *a, DWORD b)
}
BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsole, BOOL maxwindow, LPCONSOLE_FONT_INFO fontinfo)
BOOL WINAPI GetCurrentConsoleFontEx(HANDLE hConsole, BOOL maxwindow, CONSOLE_FONT_INFOEX *fontinfo)
{
BOOL ret;
struct
{
unsigned int color_map[16];
WCHAR face_name[LF_FACESIZE];
} data;
memset(fontinfo, 0, sizeof(CONSOLE_FONT_INFO));
if (fontinfo->cbSize != sizeof(CONSOLE_FONT_INFOEX))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
SERVER_START_REQ(get_console_output_info)
{
req->handle = console_handle_unmap(hConsole);
wine_server_set_reply( req, &data, sizeof(data) - sizeof(WCHAR) );
if ((ret = !wine_server_call_err(req)))
{
fontinfo->nFont = 0;
if (maxwindow)
{
fontinfo->dwFontSize.X = min(reply->width, reply->max_width);
@ -1660,12 +1671,39 @@ BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsole, BOOL maxwindow, LPCONSOLE_FON
fontinfo->dwFontSize.X = reply->win_right - reply->win_left + 1;
fontinfo->dwFontSize.Y = reply->win_bottom - reply->win_top + 1;
}
if (wine_server_reply_size( reply ) > sizeof(data.color_map))
{
data_size_t len = wine_server_reply_size( reply ) - sizeof(data.color_map);
memcpy( fontinfo->FaceName, data.face_name, len );
fontinfo->FaceName[len / sizeof(WCHAR)] = 0;
}
else
fontinfo->FaceName[0] = 0;
fontinfo->FontFamily = reply->font_pitch_family;
fontinfo->FontWeight = reply->font_weight;
}
}
SERVER_END_REQ;
return ret;
}
BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsole, BOOL maxwindow, CONSOLE_FONT_INFO *fontinfo)
{
BOOL ret;
CONSOLE_FONT_INFOEX res;
res.cbSize = sizeof(CONSOLE_FONT_INFOEX);
ret = GetCurrentConsoleFontEx(hConsole, maxwindow, &res);
if(ret)
{
fontinfo->nFont = res.nFont;
fontinfo->dwFontSize.X = res.dwFontSize.X;
fontinfo->dwFontSize.Y = res.dwFontSize.Y;
}
return ret;
}
static COORD get_console_font_size(HANDLE hConsole, DWORD index)
{
COORD c = {0,0};

View File

@ -623,7 +623,7 @@
@ stdcall GetCurrencyFormatW(long long wstr ptr ptr long)
@ stdcall -import GetCurrentActCtx(ptr)
@ stdcall GetCurrentConsoleFont(long long ptr)
# @ stub GetCurrentConsoleFontEx
@ stdcall GetCurrentConsoleFontEx(long long ptr)
@ stdcall -import GetCurrentDirectoryA(long ptr)
@ stdcall -import GetCurrentDirectoryW(long ptr)
@ stdcall GetCurrentPackageFamilyName(ptr ptr)

View File

@ -2119,7 +2119,11 @@ struct get_console_output_info_reply
short int max_height;
short int font_width;
short int font_height;
/* VARARG(colors,uints); */
short int font_weight;
short int font_pitch_family;
/* VARARG(colors,uints,64); */
/* VARARG(face_name,unicode_str); */
char __pad_44[4];
};
@ -6693,6 +6697,6 @@ union generic_reply
struct resume_process_reply resume_process_reply;
};
#define SERVER_PROTOCOL_VERSION 590
#define SERVER_PROTOCOL_VERSION 591
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -1756,6 +1756,8 @@ DECL_HANDLER(set_console_output_info)
DECL_HANDLER(get_console_output_info)
{
struct screen_buffer *screen_buffer;
void *data;
data_size_t total;
if ((screen_buffer = (struct screen_buffer *)get_handle_obj( current->process, req->handle,
FILE_READ_PROPERTIES, &screen_buffer_ops)))
@ -1776,8 +1778,19 @@ DECL_HANDLER(get_console_output_info)
reply->max_height = screen_buffer->max_height;
reply->font_width = screen_buffer->font.width;
reply->font_height = screen_buffer->font.height;
set_reply_data( screen_buffer->color_map,
min( sizeof(screen_buffer->color_map), get_reply_max_size() ));
reply->font_weight = screen_buffer->font.weight;
reply->font_pitch_family = screen_buffer->font.pitch_family;
total = min( sizeof(screen_buffer->color_map) + screen_buffer->font.face_len, get_reply_max_size() );
if (total)
{
data = set_reply_data_size( total );
memcpy( data, screen_buffer->color_map, min( total, sizeof(screen_buffer->color_map) ));
if (screen_buffer->font.face_len && total > sizeof(screen_buffer->color_map))
{
memcpy( (char *)data + sizeof(screen_buffer->color_map), screen_buffer->font.face_name,
min( total - sizeof(screen_buffer->color_map), screen_buffer->font.face_len ));
}
}
release_object( screen_buffer );
}
}

View File

@ -1669,7 +1669,10 @@ struct console_renderer_event
short int max_height;
short int font_width; /* font size (width x height) */
short int font_height;
VARARG(colors,uints); /* color table */
short int font_weight; /* font weight */
short int font_pitch_family; /* font pitch & family */
VARARG(colors,uints,64); /* color table */
VARARG(face_name,unicode_str); /* font face name */
@END
/* Add input records to a console input queue */

View File

@ -1225,7 +1225,9 @@ C_ASSERT( FIELD_OFFSET(struct get_console_output_info_reply, max_width) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_console_output_info_reply, max_height) == 34 );
C_ASSERT( FIELD_OFFSET(struct get_console_output_info_reply, font_width) == 36 );
C_ASSERT( FIELD_OFFSET(struct get_console_output_info_reply, font_height) == 38 );
C_ASSERT( sizeof(struct get_console_output_info_reply) == 40 );
C_ASSERT( FIELD_OFFSET(struct get_console_output_info_reply, font_weight) == 40 );
C_ASSERT( FIELD_OFFSET(struct get_console_output_info_reply, font_pitch_family) == 42 );
C_ASSERT( sizeof(struct get_console_output_info_reply) == 48 );
C_ASSERT( FIELD_OFFSET(struct write_console_input_request, handle) == 12 );
C_ASSERT( sizeof(struct write_console_input_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct write_console_input_reply, written) == 8 );

View File

@ -2162,7 +2162,10 @@ static void dump_get_console_output_info_reply( const struct get_console_output_
fprintf( stderr, ", max_height=%d", req->max_height );
fprintf( stderr, ", font_width=%d", req->font_width );
fprintf( stderr, ", font_height=%d", req->font_height );
dump_varargs_uints( ", colors=", cur_size );
fprintf( stderr, ", font_weight=%d", req->font_weight );
fprintf( stderr, ", font_pitch_family=%d", req->font_pitch_family );
dump_varargs_uints( ", colors=", min(cur_size,64) );
dump_varargs_unicode_str( ", face_name=", cur_size );
}
static void dump_write_console_input_request( const struct write_console_input_request *req )