Commit 93b6c455 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

imm32: Use INPUTCONTEXT directly in ImmGetCompositionFont(A|W).

parent d4318270
...@@ -1413,38 +1413,53 @@ BOOL WINAPI ImmGetCandidateWindow( ...@@ -1413,38 +1413,53 @@ BOOL WINAPI ImmGetCandidateWindow(
/*********************************************************************** /***********************************************************************
* ImmGetCompositionFontA (IMM32.@) * ImmGetCompositionFontA (IMM32.@)
*/ */
BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) BOOL WINAPI ImmGetCompositionFontA( HIMC himc, LOGFONTA *fontA )
{ {
LOGFONTW lfW; INPUTCONTEXT *ctx;
BOOL rc; LOGFONTW fontW;
BOOL ret = TRUE;
TRACE("(%p, %p):\n", hIMC, lplf); TRACE( "himc %p, fontA %p\n", himc, fontA );
rc = ImmGetCompositionFontW(hIMC,&lfW); if (!fontA) return FALSE;
if (!rc || !lplf)
return FALSE;
memcpy(lplf,&lfW,sizeof(LOGFONTA)); if (!(ctx = ImmLockIMC( himc ))) return FALSE;
WideCharToMultiByte(CP_ACP, 0, lfW.lfFaceName, -1, lplf->lfFaceName, if (!(ctx->fdwInit & INIT_LOGFONT)) ret = FALSE;
LF_FACESIZE, NULL, NULL); else if (!input_context_is_unicode( ctx )) *fontA = ctx->lfFont.A;
return TRUE; else if ((ret = ImmGetCompositionFontW( himc, &fontW )))
{
memcpy( fontA, &fontW, offsetof(LOGFONTA, lfFaceName) );
WideCharToMultiByte( CP_ACP, 0, fontW.lfFaceName, -1, fontA->lfFaceName, LF_FACESIZE, NULL, NULL );
}
ImmUnlockIMC( himc );
return ret;
} }
/*********************************************************************** /***********************************************************************
* ImmGetCompositionFontW (IMM32.@) * ImmGetCompositionFontW (IMM32.@)
*/ */
BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf) BOOL WINAPI ImmGetCompositionFontW( HIMC himc, LOGFONTW *fontW )
{ {
struct imc *data = get_imc_data( hIMC ); INPUTCONTEXT *ctx;
LOGFONTA fontA;
BOOL ret = TRUE;
TRACE("(%p, %p):\n", hIMC, lplf); TRACE( "himc %p, fontW %p\n", himc, fontW );
if (!data || !lplf) if (!fontW) return FALSE;
return FALSE;
*lplf = data->IMC.lfFont.W; if (!(ctx = ImmLockIMC( himc ))) return FALSE;
if (!(ctx->fdwInit & INIT_LOGFONT)) ret = FALSE;
else if (input_context_is_unicode( ctx )) *fontW = ctx->lfFont.W;
else if ((ret = ImmGetCompositionFontA( himc, &fontA )))
{
memcpy( fontW, &fontA, offsetof(LOGFONTW, lfFaceName) );
MultiByteToWideChar( CP_ACP, 0, fontA.lfFaceName, -1, fontW->lfFaceName, LF_FACESIZE );
}
ImmUnlockIMC( himc );
return TRUE; return ret;
} }
......
...@@ -182,8 +182,8 @@ static void check_composition_form_( int line, COMPOSITIONFORM *form, const COMP ...@@ -182,8 +182,8 @@ static void check_composition_form_( int line, COMPOSITIONFORM *form, const COMP
check_member_rect_( __FILE__, line, *form, *expect, rcArea ); check_member_rect_( __FILE__, line, *form, *expect, rcArea );
} }
#define check_logfont_w( a, b ) check_logfont_w_( __LINE__, a, b, FALSE ) #define check_logfont_w( a, b ) check_logfont_w_( __LINE__, a, b )
static void check_logfont_w_( int line, LOGFONTW *font, const LOGFONTW *expect, BOOL todo ) static void check_logfont_w_( int line, LOGFONTW *font, const LOGFONTW *expect )
{ {
check_member_( __FILE__, line, *font, *expect, "%lu", lfHeight ); check_member_( __FILE__, line, *font, *expect, "%lu", lfHeight );
check_member_( __FILE__, line, *font, *expect, "%lu", lfWidth ); check_member_( __FILE__, line, *font, *expect, "%lu", lfWidth );
...@@ -198,11 +198,11 @@ static void check_logfont_w_( int line, LOGFONTW *font, const LOGFONTW *expect, ...@@ -198,11 +198,11 @@ static void check_logfont_w_( int line, LOGFONTW *font, const LOGFONTW *expect,
check_member_( __FILE__, line, *font, *expect, "%u", lfClipPrecision ); check_member_( __FILE__, line, *font, *expect, "%u", lfClipPrecision );
check_member_( __FILE__, line, *font, *expect, "%u", lfQuality ); check_member_( __FILE__, line, *font, *expect, "%u", lfQuality );
check_member_( __FILE__, line, *font, *expect, "%u", lfPitchAndFamily ); check_member_( __FILE__, line, *font, *expect, "%u", lfPitchAndFamily );
todo_wine_if(todo) check_member_wstr_( __FILE__, line, *font, *expect, lfFaceName ); check_member_wstr_( __FILE__, line, *font, *expect, lfFaceName );
} }
#define check_logfont_a( a, b ) check_logfont_a_( __LINE__, a, b, FALSE ) #define check_logfont_a( a, b ) check_logfont_a_( __LINE__, a, b )
static void check_logfont_a_( int line, LOGFONTA *font, const LOGFONTA *expect, BOOL todo ) static void check_logfont_a_( int line, LOGFONTA *font, const LOGFONTA *expect )
{ {
check_member_( __FILE__, line, *font, *expect, "%lu", lfHeight ); check_member_( __FILE__, line, *font, *expect, "%lu", lfHeight );
check_member_( __FILE__, line, *font, *expect, "%lu", lfWidth ); check_member_( __FILE__, line, *font, *expect, "%lu", lfWidth );
...@@ -217,7 +217,7 @@ static void check_logfont_a_( int line, LOGFONTA *font, const LOGFONTA *expect, ...@@ -217,7 +217,7 @@ static void check_logfont_a_( int line, LOGFONTA *font, const LOGFONTA *expect,
check_member_( __FILE__, line, *font, *expect, "%u", lfClipPrecision ); check_member_( __FILE__, line, *font, *expect, "%u", lfClipPrecision );
check_member_( __FILE__, line, *font, *expect, "%u", lfQuality ); check_member_( __FILE__, line, *font, *expect, "%u", lfQuality );
check_member_( __FILE__, line, *font, *expect, "%u", lfPitchAndFamily ); check_member_( __FILE__, line, *font, *expect, "%u", lfPitchAndFamily );
todo_wine_if(todo) check_member_str_( __FILE__, line, *font, *expect, lfFaceName ); check_member_str_( __FILE__, line, *font, *expect, lfFaceName );
} }
#define DEFINE_EXPECT(func) \ #define DEFINE_EXPECT(func) \
...@@ -6357,13 +6357,13 @@ static void test_ImmSetCompositionFont( BOOL unicode ) ...@@ -6357,13 +6357,13 @@ static void test_ImmSetCompositionFont( BOOL unicode )
if (unicode) ctx->lfFont.W = expect_fontW; if (unicode) ctx->lfFont.W = expect_fontW;
else ctx->lfFont.A = expect_fontA; else ctx->lfFont.A = expect_fontA;
ctx->fdwInit = ~INIT_LOGFONT; ctx->fdwInit = ~INIT_LOGFONT;
todo_wine ok_ret( 0, ImmGetCompositionFontW( himc, &fontW ) ); ok_ret( 0, ImmGetCompositionFontW( himc, &fontW ) );
todo_wine ok_ret( 0, ImmGetCompositionFontA( himc, &fontA ) ); ok_ret( 0, ImmGetCompositionFontA( himc, &fontA ) );
ctx->fdwInit = INIT_LOGFONT; ctx->fdwInit = INIT_LOGFONT;
ok_ret( 1, ImmGetCompositionFontW( himc, &fontW ) ); ok_ret( 1, ImmGetCompositionFontW( himc, &fontW ) );
check_logfont_w_( __LINE__, &fontW, &expect_fontW, !unicode ); check_logfont_w( &fontW, &expect_fontW );
ok_ret( 1, ImmGetCompositionFontA( himc, &fontA ) ); ok_ret( 1, ImmGetCompositionFontA( himc, &fontA ) );
check_logfont_a_( __LINE__, &fontA, &expect_fontA, !unicode ); check_logfont_a( &fontA, &expect_fontA );
ctx->hWnd = hwnd; ctx->hWnd = hwnd;
ctx->fdwInit = 0; ctx->fdwInit = 0;
...@@ -6377,9 +6377,9 @@ static void test_ImmSetCompositionFont( BOOL unicode ) ...@@ -6377,9 +6377,9 @@ static void test_ImmSetCompositionFont( BOOL unicode )
else check_logfont_a( &ctx->lfFont.A, &expect_fontA ); else check_logfont_a( &ctx->lfFont.A, &expect_fontA );
ok_ret( 1, ImmGetCompositionFontW( himc, &fontW ) ); ok_ret( 1, ImmGetCompositionFontW( himc, &fontW ) );
check_logfont_w_( __LINE__, &fontW, &expect_fontW, !unicode ); check_logfont_w( &fontW, &expect_fontW );
ok_ret( 1, ImmGetCompositionFontA( himc, &fontA ) ); ok_ret( 1, ImmGetCompositionFontA( himc, &fontA ) );
check_logfont_a_( __LINE__, &fontA, &expect_fontA, !unicode ); check_logfont_a( &fontA, &expect_fontA );
ctx->hWnd = hwnd; ctx->hWnd = hwnd;
ctx->fdwInit = 0; ctx->fdwInit = 0;
...@@ -6393,9 +6393,9 @@ static void test_ImmSetCompositionFont( BOOL unicode ) ...@@ -6393,9 +6393,9 @@ static void test_ImmSetCompositionFont( BOOL unicode )
else check_logfont_a( &ctx->lfFont.A, &expect_fontA ); else check_logfont_a( &ctx->lfFont.A, &expect_fontA );
ok_ret( 1, ImmGetCompositionFontW( himc, &fontW ) ); ok_ret( 1, ImmGetCompositionFontW( himc, &fontW ) );
check_logfont_w_( __LINE__, &fontW, &expect_fontW, !unicode ); check_logfont_w( &fontW, &expect_fontW );
ok_ret( 1, ImmGetCompositionFontA( himc, &fontA ) ); ok_ret( 1, ImmGetCompositionFontA( himc, &fontA ) );
check_logfont_a_( __LINE__, &fontA, &expect_fontA, !unicode ); check_logfont_a( &fontA, &expect_fontA );
ctx->hWnd = 0; ctx->hWnd = 0;
ok_ret( 1, ImmSetCompositionFontW( himc, &expect_fontW ) ); ok_ret( 1, ImmSetCompositionFontW( himc, &expect_fontW ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment