Gijs Vermeulen : kernel32: Implement GetCurrentConsoleFontEx.
Alexandre Julliard
julliard at winehq.org
Mon Nov 25 16:41:56 CST 2019
Module: wine
Branch: master
Commit: ec810c84ab906f22dc0d00e52ab1a77c9932aaa4
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ec810c84ab906f22dc0d00e52ab1a77c9932aaa4
Author: Gijs Vermeulen <gijsvrm at codeweavers.com>
Date: Wed Nov 20 11:45:29 2019 +0100
kernel32: Implement GetCurrentConsoleFontEx.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47620
Signed-off-by: Gijs Vermeulen <gijsvrm at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/console.c | 42 ++++++++++++++++++++++++++++++++++++++++--
dlls/kernel32/kernel32.spec | 2 +-
include/wine/server_protocol.h | 8 ++++++--
server/console.c | 17 +++++++++++++++--
server/protocol.def | 5 ++++-
server/request.h | 4 +++-
server/trace.c | 5 ++++-
7 files changed, 73 insertions(+), 10 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index a698e53efe..0842bb71a6 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -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};
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index f6c40a9c42..367f5d2373 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -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)
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 3213f433d9..0712170c80 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -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 */
diff --git a/server/console.c b/server/console.c
index 97d247c98e..59f8843a75 100644
--- a/server/console.c
+++ b/server/console.c
@@ -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 );
}
}
diff --git a/server/protocol.def b/server/protocol.def
index 1b4085ecbf..c5c15ea1d7 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -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 */
diff --git a/server/request.h b/server/request.h
index e7846b55b3..f0d2003cd7 100644
--- a/server/request.h
+++ b/server/request.h
@@ -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 );
diff --git a/server/trace.c b/server/trace.c
index 94def43537..11df768755 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -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 )
More information about the wine-cvs
mailing list