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
60085f4e
Commit
60085f4e
authored
Apr 12, 2018
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Scale stock fonts based on the DPI awareness.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
31967ef5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
19 deletions
+67
-19
gdiobj.c
dlls/gdi32/gdiobj.c
+22
-19
sysparams.c
dlls/user32/tests/sysparams.c
+45
-0
No files found.
dlls/gdi32/gdiobj.c
View file @
60085f4e
...
@@ -108,6 +108,7 @@ static const LOGPEN DCPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
...
@@ -108,6 +108,7 @@ static const LOGPEN DCPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
#define NB_STOCK_OBJECTS (STOCK_LAST+2)
#define NB_STOCK_OBJECTS (STOCK_LAST+2)
static
HGDIOBJ
stock_objects
[
NB_STOCK_OBJECTS
];
static
HGDIOBJ
stock_objects
[
NB_STOCK_OBJECTS
];
static
HGDIOBJ
scaled_stock_objects
[
NB_STOCK_OBJECTS
];
static
CRITICAL_SECTION
gdi_section
;
static
CRITICAL_SECTION
gdi_section
;
static
CRITICAL_SECTION_DEBUG
critsect_debug
=
static
CRITICAL_SECTION_DEBUG
critsect_debug
=
...
@@ -662,7 +663,6 @@ DWORD get_system_dpi(void)
...
@@ -662,7 +663,6 @@ DWORD get_system_dpi(void)
static
HFONT
create_scaled_font
(
const
LOGFONTW
*
deffont
)
static
HFONT
create_scaled_font
(
const
LOGFONTW
*
deffont
)
{
{
LOGFONTW
lf
;
LOGFONTW
lf
;
LONG
height
;
static
DWORD
dpi
;
static
DWORD
dpi
;
if
(
!
dpi
)
if
(
!
dpi
)
...
@@ -672,9 +672,7 @@ static HFONT create_scaled_font( const LOGFONTW *deffont )
...
@@ -672,9 +672,7 @@ static HFONT create_scaled_font( const LOGFONTW *deffont )
}
}
lf
=
*
deffont
;
lf
=
*
deffont
;
height
=
abs
(
lf
.
lfHeight
)
*
dpi
/
96
;
lf
.
lfHeight
=
MulDiv
(
lf
.
lfHeight
,
dpi
,
96
);
lf
.
lfHeight
=
deffont
->
lfHeight
<
0
?
-
height
:
height
;
return
CreateFontIndirectW
(
&
lf
);
return
CreateFontIndirectW
(
&
lf
);
}
}
...
@@ -716,10 +714,15 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
...
@@ -716,10 +714,15 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
/* language-dependent stock fonts */
/* language-dependent stock fonts */
deffonts
=
get_default_fonts
(
get_default_charset
());
deffonts
=
get_default_fonts
(
get_default_charset
());
stock_objects
[
SYSTEM_FONT
]
=
create_scaled_font
(
&
deffonts
->
SystemFont
);
stock_objects
[
SYSTEM_FONT
]
=
CreateFontIndirectW
(
&
deffonts
->
SystemFont
);
stock_objects
[
DEVICE_DEFAULT_FONT
]
=
create_scaled_font
(
&
deffonts
->
DeviceDefaultFont
);
stock_objects
[
DEVICE_DEFAULT_FONT
]
=
CreateFontIndirectW
(
&
deffonts
->
DeviceDefaultFont
);
stock_objects
[
SYSTEM_FIXED_FONT
]
=
CreateFontIndirectW
(
&
deffonts
->
SystemFixedFont
);
stock_objects
[
SYSTEM_FIXED_FONT
]
=
CreateFontIndirectW
(
&
deffonts
->
SystemFixedFont
);
stock_objects
[
DEFAULT_GUI_FONT
]
=
create_scaled_font
(
&
deffonts
->
DefaultGuiFont
);
stock_objects
[
DEFAULT_GUI_FONT
]
=
CreateFontIndirectW
(
&
deffonts
->
DefaultGuiFont
);
scaled_stock_objects
[
OEM_FIXED_FONT
]
=
create_scaled_font
(
&
OEMFixedFont
);
scaled_stock_objects
[
SYSTEM_FONT
]
=
create_scaled_font
(
&
deffonts
->
SystemFont
);
scaled_stock_objects
[
SYSTEM_FIXED_FONT
]
=
create_scaled_font
(
&
deffonts
->
SystemFixedFont
);
scaled_stock_objects
[
DEFAULT_GUI_FONT
]
=
create_scaled_font
(
&
deffonts
->
DefaultGuiFont
);
stock_objects
[
DC_BRUSH
]
=
CreateBrushIndirect
(
&
DCBrush
);
stock_objects
[
DC_BRUSH
]
=
CreateBrushIndirect
(
&
DCBrush
);
stock_objects
[
DC_PEN
]
=
CreatePenIndirect
(
&
DCPen
);
stock_objects
[
DC_PEN
]
=
CreatePenIndirect
(
&
DCPen
);
...
@@ -727,15 +730,9 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
...
@@ -727,15 +730,9 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
/* clear the NOSYSTEM bit on all stock objects*/
/* clear the NOSYSTEM bit on all stock objects*/
for
(
i
=
0
;
i
<
NB_STOCK_OBJECTS
;
i
++
)
for
(
i
=
0
;
i
<
NB_STOCK_OBJECTS
;
i
++
)
{
{
if
(
!
stock_objects
[
i
])
if
(
stock_objects
[
i
])
__wine_make_gdi_object_system
(
stock_objects
[
i
],
TRUE
);
{
if
(
scaled_stock_objects
[
i
])
__wine_make_gdi_object_system
(
scaled_stock_objects
[
i
],
TRUE
);
if
(
i
==
9
)
continue
;
/* there's no stock object 9 */
ERR
(
"could not create stock object %d
\n
"
,
i
);
return
FALSE
;
}
__wine_make_gdi_object_system
(
stock_objects
[
i
],
TRUE
);
}
}
return
TRUE
;
return
TRUE
;
}
}
...
@@ -1061,11 +1058,17 @@ void GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc)
...
@@ -1061,11 +1058,17 @@ void GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc)
*/
*/
HGDIOBJ
WINAPI
GetStockObject
(
INT
obj
)
HGDIOBJ
WINAPI
GetStockObject
(
INT
obj
)
{
{
HGDIOBJ
ret
;
if
((
obj
<
0
)
||
(
obj
>=
NB_STOCK_OBJECTS
))
return
0
;
if
((
obj
<
0
)
||
(
obj
>=
NB_STOCK_OBJECTS
))
return
0
;
ret
=
stock_objects
[
obj
];
switch
(
obj
)
TRACE
(
"returning %p
\n
"
,
ret
);
{
return
ret
;
case
OEM_FIXED_FONT
:
case
SYSTEM_FONT
:
case
SYSTEM_FIXED_FONT
:
case
DEFAULT_GUI_FONT
:
if
(
get_system_dpi
()
!=
96
)
return
scaled_stock_objects
[
obj
];
break
;
}
return
stock_objects
[
obj
];
}
}
...
...
dlls/user32/tests/sysparams.c
View file @
60085f4e
...
@@ -3001,6 +3001,50 @@ static void test_GetSysColorBrush(void)
...
@@ -3001,6 +3001,50 @@ static void test_GetSysColorBrush(void)
win_skip
(
"COLOR_MENUBAR unsupported
\n
"
);
win_skip
(
"COLOR_MENUBAR unsupported
\n
"
);
}
}
static
void
test_dpi_stock_objects
(
HDC
hdc
)
{
DPI_AWARENESS_CONTEXT
context
;
HGDIOBJ
obj
[
STOCK_LAST
+
1
],
obj2
[
STOCK_LAST
+
1
];
LOGFONTW
lf
,
lf2
;
UINT
i
,
dpi
;
context
=
pSetThreadDpiAwarenessContext
(
DPI_AWARENESS_CONTEXT_UNAWARE
);
dpi
=
GetDeviceCaps
(
hdc
,
LOGPIXELSX
);
ok
(
dpi
==
USER_DEFAULT_SCREEN_DPI
,
"wrong dpi %u
\n
"
,
dpi
);
ok
(
!
pIsProcessDPIAware
(),
"not aware
\n
"
);
for
(
i
=
0
;
i
<=
STOCK_LAST
;
i
++
)
obj
[
i
]
=
GetStockObject
(
i
);
pSetThreadDpiAwarenessContext
(
DPI_AWARENESS_CONTEXT_SYSTEM_AWARE
);
dpi
=
GetDeviceCaps
(
hdc
,
LOGPIXELSX
);
ok
(
dpi
==
real_dpi
,
"wrong dpi %u
\n
"
,
dpi
);
ok
(
pIsProcessDPIAware
(),
"not aware
\n
"
);
for
(
i
=
0
;
i
<=
STOCK_LAST
;
i
++
)
obj2
[
i
]
=
GetStockObject
(
i
);
for
(
i
=
0
;
i
<=
STOCK_LAST
;
i
++
)
{
switch
(
i
)
{
case
OEM_FIXED_FONT
:
case
SYSTEM_FIXED_FONT
:
ok
(
obj
[
i
]
!=
obj2
[
i
],
"%u: same object
\n
"
,
i
);
break
;
case
SYSTEM_FONT
:
case
DEFAULT_GUI_FONT
:
ok
(
obj
[
i
]
!=
obj2
[
i
],
"%u: same object
\n
"
,
i
);
GetObjectW
(
obj
[
i
],
sizeof
(
lf
),
&
lf
);
GetObjectW
(
obj2
[
i
],
sizeof
(
lf2
),
&
lf2
);
ok
(
lf
.
lfHeight
==
MulDiv
(
lf2
.
lfHeight
,
USER_DEFAULT_SCREEN_DPI
,
real_dpi
),
"%u: wrong height %d / %d
\n
"
,
i
,
lf
.
lfHeight
,
lf2
.
lfHeight
);
break
;
default:
ok
(
obj
[
i
]
==
obj2
[
i
],
"%u: different object
\n
"
,
i
);
break
;
}
}
pSetThreadDpiAwarenessContext
(
context
);
}
static
void
test_dpi_aware
(
void
)
static
void
test_dpi_aware
(
void
)
{
{
BOOL
ret
;
BOOL
ret
;
...
@@ -3181,6 +3225,7 @@ static void test_dpi_aware(void)
...
@@ -3181,6 +3225,7 @@ static void test_dpi_aware(void)
break
;
break
;
}
}
}
}
if
(
real_dpi
!=
USER_DEFAULT_SCREEN_DPI
)
test_dpi_stock_objects
(
hdc
);
ReleaseDC
(
0
,
hdc
);
ReleaseDC
(
0
,
hdc
);
}
}
else
win_skip
(
"SetProcessDpiAwarenessContext not supported
\n
"
);
else
win_skip
(
"SetProcessDpiAwarenessContext not supported
\n
"
);
...
...
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