Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
1b91c113
Commit
1b91c113
authored
Apr 20, 2019
by
Akihiro Sagawa
Committed by
Alexandre Julliard
Apr 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Fix edit control margins in CJK font case.
Signed-off-by:
Akihiro Sagawa
<
sagawa.aki@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
491b0611
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
16 deletions
+25
-16
edit.c
dlls/user32/edit.c
+25
-12
edit.c
dlls/user32/tests/edit.c
+0
-4
No files found.
dlls/user32/edit.c
View file @
1b91c113
...
...
@@ -2851,6 +2851,14 @@ static BOOL is_cjk_charset(HDC dc)
}
}
static
BOOL
is_cjk_font
(
HDC
dc
)
{
const
DWORD
FS_DBCS_MASK
=
FS_JISJAPAN
|
FS_CHINESESIMP
|
FS_WANSUNG
|
FS_CHINESETRAD
|
FS_JOHAB
;
FONTSIGNATURE
fs
;
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
;
...
...
@@ -2898,7 +2906,8 @@ static void EDIT_EM_SetMargins(EDITSTATE *es, INT action,
if
(
tm
.
tmPitchAndFamily
&
(
TMPF_VECTOR
|
TMPF_TRUETYPE
))
{
struct
char_width_info
width_info
;
if
(
is_cjk_charset
(
dc
)
&&
GetCharWidthInfo
(
dc
,
&
width_info
))
if
((
is_cjk_charset
(
dc
)
||
is_cjk_font
(
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
);
...
...
@@ -3803,21 +3812,29 @@ static void EDIT_WM_SetFocus(EDITSTATE *es)
EDIT_NOTIFY_PARENT
(
es
,
EN_SETFOCUS
);
}
static
DWORD
get_
cjk_font_margins
(
HDC
hdc
,
BOOL
unicode
)
static
DWORD
get_
font_margins
(
HDC
hdc
,
TEXTMETRICW
*
tm
,
BOOL
unicode
)
{
ABC
abc
[
256
];
SHORT
left
,
right
;
UINT
i
;
left
=
right
=
0
;
if
(
!
(
tm
->
tmPitchAndFamily
&
(
TMPF_VECTOR
|
TMPF_TRUETYPE
)))
return
MAKELONG
(
EC_USEFONTINFO
,
EC_USEFONTINFO
);
if
(
unicode
)
{
if
(
!
is_cjk_charset
(
hdc
)
&&
!
is_cjk_font
(
hdc
))
return
MAKELONG
(
EC_USEFONTINFO
,
EC_USEFONTINFO
);
if
(
!
GetCharABCWidthsW
(
hdc
,
0
,
255
,
abc
))
return
0
;
}
else
{
else
if
(
is_cjk_charset
(
hdc
))
{
if
(
!
GetCharABCWidthsA
(
hdc
,
0
,
255
,
abc
))
return
0
;
}
else
return
MAKELONG
(
EC_USEFONTINFO
,
EC_USEFONTINFO
);
left
=
right
=
0
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
abc
);
i
++
)
{
if
(
-
abc
[
i
].
abcA
>
right
)
right
=
-
abc
[
i
].
abcA
;
if
(
-
abc
[
i
].
abcC
>
left
)
left
=
-
abc
[
i
].
abcC
;
...
...
@@ -3840,7 +3857,7 @@ static void EDIT_WM_SetFont(EDITSTATE *es, HFONT font, BOOL redraw)
HDC
dc
;
HFONT
old_font
=
0
;
RECT
clientRect
;
DWORD
cjk_margins
=
MAKELONG
(
EC_USEFONTINFO
,
EC_USEFONTINFO
)
;
DWORD
margins
;
es
->
font
=
font
;
EDIT_InvalidateUniscribeData
(
es
);
...
...
@@ -3850,8 +3867,7 @@ static void EDIT_WM_SetFont(EDITSTATE *es, HFONT font, BOOL redraw)
GetTextMetricsW
(
dc
,
&
tm
);
es
->
line_height
=
tm
.
tmHeight
;
es
->
char_width
=
tm
.
tmAveCharWidth
;
if
((
tm
.
tmPitchAndFamily
&
(
TMPF_VECTOR
|
TMPF_TRUETYPE
))
&&
is_cjk_charset
(
dc
))
cjk_margins
=
get_cjk_font_margins
(
dc
,
es
->
is_unicode
);
margins
=
get_font_margins
(
dc
,
&
tm
,
es
->
is_unicode
);
if
(
font
)
SelectObject
(
dc
,
old_font
);
ReleaseDC
(
es
->
hwndSelf
,
dc
);
...
...
@@ -3859,12 +3875,9 @@ static void EDIT_WM_SetFont(EDITSTATE *es, HFONT font, BOOL redraw)
/* Reset the format rect and the margins */
GetClientRect
(
es
->
hwndSelf
,
&
clientRect
);
EDIT_SetRectNP
(
es
,
&
clientRect
);
if
(
cjk_margins
==
MAKELONG
(
EC_USEFONTINFO
,
EC_USEFONTINFO
))
EDIT_EM_SetMargins
(
es
,
EC_LEFTMARGIN
|
EC_RIGHTMARGIN
,
EC_USEFONTINFO
,
EC_USEFONTINFO
,
FALSE
);
else
if
(
cjk_margins
)
if
(
margins
)
EDIT_EM_SetMargins
(
es
,
EC_LEFTMARGIN
|
EC_RIGHTMARGIN
,
LOWORD
(
cjk_margins
),
HIWORD
(
cjk_
margins
),
FALSE
);
LOWORD
(
margins
),
HIWORD
(
margins
),
FALSE
);
if
(
es
->
style
&
ES_MULTILINE
)
EDIT_BuildLineDefs_ML
(
es
,
0
,
get_text_length
(
es
),
0
,
NULL
);
...
...
dlls/user32/tests/edit.c
View file @
1b91c113
...
...
@@ -1664,12 +1664,10 @@ static void test_margins_default(const char* facename, UINT charset)
SendMessageA
(
hwnd
,
EM_SETMARGINS
,
EC_LEFTMARGIN
|
EC_RIGHTMARGIN
,
small_margins
);
SendMessageA
(
hwnd
,
WM_SETFONT
,
(
WPARAM
)
hfont
,
MAKELPARAM
(
TRUE
,
0
));
margins
=
SendMessageA
(
hwnd
,
EM_GETMARGINS
,
0
,
0
);
todo_wine_if
(
cjk_font
&&
(
charset
==
GREEK_CHARSET
||
charset
==
ANSI_CHARSET
))
ok
(
margins
==
font_expect
,
"%s:%d: expected %d, %d, got %d, %d
\n
"
,
facename
,
charset
,
HIWORD
(
font_expect
),
LOWORD
(
font_expect
),
HIWORD
(
margins
),
LOWORD
(
margins
));
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_font
&&
(
charset
==
GREEK_CHARSET
||
charset
==
ANSI_CHARSET
))
ok
(
margins
==
expect
,
"%s:%d: expected %d, %d, got %d, %d
\n
"
,
facename
,
charset
,
HIWORD
(
expect
),
LOWORD
(
expect
),
HIWORD
(
margins
),
LOWORD
(
margins
));
DestroyWindow
(
hwnd
);
...
...
@@ -1698,12 +1696,10 @@ static void test_margins_default(const char* facename, UINT charset)
SendMessageA
(
hwnd
,
EM_SETMARGINS
,
EC_LEFTMARGIN
|
EC_RIGHTMARGIN
,
small_margins
);
SendMessageA
(
hwnd
,
WM_SETFONT
,
(
WPARAM
)
hfont
,
MAKELPARAM
(
TRUE
,
0
));
margins
=
SendMessageA
(
hwnd
,
EM_GETMARGINS
,
0
,
0
);
todo_wine_if
(
cjk_font
&&
(
charset
==
GREEK_CHARSET
||
charset
==
ANSI_CHARSET
))
ok
(
margins
==
font_expect
,
"%s:%d: expected %d, %d, got %d, %d
\n
"
,
facename
,
charset
,
HIWORD
(
font_expect
),
LOWORD
(
font_expect
),
HIWORD
(
margins
),
LOWORD
(
margins
));
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_font
&&
(
charset
==
GREEK_CHARSET
||
charset
==
ANSI_CHARSET
))
ok
(
margins
==
expect
,
"%s:%d: expected %d, %d, got %d, %d
\n
"
,
facename
,
charset
,
HIWORD
(
expect
),
LOWORD
(
expect
),
HIWORD
(
margins
),
LOWORD
(
margins
));
DestroyWindow
(
hwnd
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment