comctl32/edit: Implement EC_USEFONTINFO margins in the CJK case.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
28400eff29
commit
ef94a9fc6c
|
@ -2685,6 +2685,36 @@ static void EDIT_EM_SetLimitText(EDITSTATE *es, UINT limit)
|
|||
es->buffer_limit = limit;
|
||||
}
|
||||
|
||||
static BOOL is_cjk(HDC dc)
|
||||
{
|
||||
const DWORD FS_DBCS_MASK = FS_JISJAPAN|FS_CHINESESIMP|FS_WANSUNG|FS_CHINESETRAD|FS_JOHAB;
|
||||
FONTSIGNATURE fs;
|
||||
|
||||
switch (GdiGetCodePage(dc)) {
|
||||
case 932: case 936: case 949: case 950: case 1361:
|
||||
return TRUE;
|
||||
default:
|
||||
return (GetTextCharsetInfo(dc, &fs, 0) != DEFAULT_CHARSET &&
|
||||
(fs.fsCsb[0] & FS_DBCS_MASK));
|
||||
}
|
||||
}
|
||||
|
||||
static int get_cjk_fontinfo_margin(int width, int side_bearing)
|
||||
{
|
||||
int margin;
|
||||
if (side_bearing < 0)
|
||||
margin = min(-side_bearing, width/2);
|
||||
else
|
||||
margin = 0;
|
||||
return margin;
|
||||
}
|
||||
|
||||
struct char_width_info {
|
||||
INT min_lsb, min_rsb, unknown;
|
||||
};
|
||||
|
||||
/* Undocumented gdi32 export */
|
||||
extern BOOL WINAPI GetCharWidthInfo(HDC, struct char_width_info *);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
|
@ -2714,9 +2744,18 @@ static void EDIT_EM_SetMargins(EDITSTATE *es, INT action,
|
|||
|
||||
/* The default margins are only non zero for TrueType or Vector fonts */
|
||||
if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
|
||||
/* FIXME: figure out the CJK values. */
|
||||
default_left_margin = width / 2;
|
||||
default_right_margin = width / 2;
|
||||
struct char_width_info width_info;
|
||||
|
||||
if (is_cjk(dc) && GetCharWidthInfo(dc, &width_info))
|
||||
{
|
||||
default_left_margin = get_cjk_fontinfo_margin(width, width_info.min_lsb);
|
||||
default_right_margin = get_cjk_fontinfo_margin(width, width_info.min_rsb);
|
||||
}
|
||||
else
|
||||
{
|
||||
default_left_margin = width / 2;
|
||||
default_right_margin = width / 2;
|
||||
}
|
||||
|
||||
GetClientRect(es->hwndSelf, &rc);
|
||||
rc_width = !IsRectEmpty(&rc) ? rc.right - rc.left : 80;
|
||||
|
|
|
@ -1686,7 +1686,6 @@ static void test_margins_default(const char* facename, UINT charset)
|
|||
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
||||
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
||||
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
||||
todo_wine_if(cjk && expect != MAKELONG(size.cx / 2, size.cx / 2))
|
||||
ok(margins == expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(expect), LOWORD(expect), HIWORD(margins), LOWORD(margins));
|
||||
DestroyWindow(hwnd);
|
||||
|
||||
|
@ -1706,7 +1705,6 @@ static void test_margins_default(const char* facename, UINT charset)
|
|||
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
||||
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
||||
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
||||
todo_wine_if(cjk && expect != MAKELONG(size.cx / 2, size.cx / 2))
|
||||
ok(margins == expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(expect), LOWORD(expect), HIWORD(margins), LOWORD(margins));
|
||||
DestroyWindow(hwnd);
|
||||
|
||||
|
|
Loading…
Reference in New Issue