Commit c5823e9c authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

user32: Implement EC_USEFONTINFO margins in the CJK case.

parent 8ba6c1f2
......@@ -2841,6 +2841,32 @@ static void EDIT_EM_SetLimitText(EDITSTATE *es, UINT limit)
es->buffer_limit = limit;
}
static BOOL is_cjk_charset(HDC dc)
{
switch (GdiGetCodePage(dc)) {
case 932: case 936: case 949: case 950: case 1361:
return TRUE;
default:
return FALSE;
}
}
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 *);
/*********************************************************************
*
......@@ -2870,9 +2896,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_charset(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;
......
......@@ -1632,7 +1632,7 @@ 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_charset && 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);
......@@ -1652,7 +1652,7 @@ 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_charset && 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);
......
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