Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f8b7e9bf
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f8b7e9bf
编写于
6月 02, 2016
作者:
A
alexsch
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8157838: Personalized Windows Font Size is not taken into account in Java8u102
Reviewed-by: prr, serb
上级
cdf1bda9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
153 deletion
+35
-153
src/windows/native/sun/windows/ThemeReader.cpp
src/windows/native/sun/windows/ThemeReader.cpp
+0
-26
src/windows/native/sun/windows/awt_DesktopProperties.cpp
src/windows/native/sun/windows/awt_DesktopProperties.cpp
+33
-67
src/windows/native/sun/windows/awt_DesktopProperties.h
src/windows/native/sun/windows/awt_DesktopProperties.h
+2
-2
test/java/awt/font/FontScaling/FontScalingTest.java
test/java/awt/font/FontScaling/FontScalingTest.java
+0
-58
未找到文件。
src/windows/native/sun/windows/ThemeReader.cpp
浏览文件 @
f8b7e9bf
...
...
@@ -31,8 +31,6 @@
#include "awt_Object.h"
#include "awt_Component.h"
#include "math.h"
// Important note about VC6 and VC7 (or XP Platform SDK) !
//
// These type definitions have been imported from UxTheme.h
...
...
@@ -70,11 +68,6 @@ typedef struct _MARGINS
#define TMT_TRANSPARENT 2201
#endif // _UXTHEME_H_
#if defined(_MSC_VER) && _MSC_VER >= 1800
# define ROUND_TO_INT(num) ((int) round(num))
#else
# define ROUND_TO_INT(num) ((int) floor((num) + 0.5))
#endif
#define ALPHA_MASK 0xff000000
#define RED_MASK 0xff0000
...
...
@@ -752,23 +745,6 @@ JNIEXPORT jobject JNICALL Java_sun_awt_windows_ThemeReader_getPosition
return
NULL
;
}
void
rescale
(
SIZE
*
size
)
{
HWND
hWnd
=
::
GetDesktopWindow
();
HDC
hDC
=
::
GetDC
(
hWnd
);
int
dpiX
=
::
GetDeviceCaps
(
hDC
,
LOGPIXELSX
);
int
dpiY
=
::
GetDeviceCaps
(
hDC
,
LOGPIXELSY
);
if
(
dpiX
!=
0
&&
dpiX
!=
96
)
{
float
invScaleX
=
96.0
f
/
dpiX
;
size
->
cx
=
ROUND_TO_INT
(
size
->
cx
*
invScaleX
);
}
if
(
dpiY
!=
0
&&
dpiY
!=
96
)
{
float
invScaleY
=
96.0
f
/
dpiY
;
size
->
cy
=
ROUND_TO_INT
(
size
->
cy
*
invScaleY
);
}
::
ReleaseDC
(
hWnd
,
hDC
);
}
/*
* Class: sun_awt_windows_ThemeReader
* Method: getPartSize
...
...
@@ -794,8 +770,6 @@ JNIEXPORT jobject JNICALL Java_sun_awt_windows_ThemeReader_getPartSize
dimMID
=
env
->
GetMethodID
(
dimClassID
,
"<init>"
,
"(II)V"
);
CHECK_NULL_RETURN
(
dimMID
,
NULL
);
}
rescale
(
&
size
);
jobject
dimObj
=
env
->
NewObject
(
dimClassID
,
dimMID
,
size
.
cx
,
size
.
cy
);
if
(
safe_ExceptionOccurred
(
env
))
{
env
->
ExceptionDescribe
();
...
...
src/windows/native/sun/windows/awt_DesktopProperties.cpp
浏览文件 @
f8b7e9bf
...
...
@@ -35,14 +35,6 @@
#include <shellapi.h>
#include <shlobj.h>
#include "math.h"
#if defined(_MSC_VER) && _MSC_VER >= 1800
# define ROUND_TO_INT(num) ((int) round(num))
#else
# define ROUND_TO_INT(num) ((int) floor((num) + 0.5))
#endif
// WDesktopProperties fields
jfieldID
AwtDesktopProperties
::
pDataID
=
0
;
jmethodID
AwtDesktopProperties
::
setBooleanPropertyID
=
0
;
...
...
@@ -87,35 +79,18 @@ void AwtDesktopProperties::GetWindowsParameters() {
}
}
void
getInvScale
(
float
&
invScaleX
,
float
&
invScaleY
)
{
HWND
hWnd
=
::
GetDesktopWindow
();
HDC
hDC
=
::
GetDC
(
hWnd
);
int
dpiX
=
::
GetDeviceCaps
(
hDC
,
LOGPIXELSX
);
int
dpiY
=
::
GetDeviceCaps
(
hDC
,
LOGPIXELSY
);
::
ReleaseDC
(
hWnd
,
hDC
);
invScaleX
=
(
dpiX
==
0.0
f
)
?
1.0
f
:
96.0
f
/
dpiX
;
invScaleY
=
(
dpiY
==
0.0
f
)
?
1.0
f
:
96.0
f
/
dpiY
;
}
int
rescale
(
int
value
,
float
invScale
){
return
invScale
==
1.0
f
?
value
:
ROUND_TO_INT
(
value
*
invScale
);
}
void
AwtDesktopProperties
::
GetSystemProperties
()
{
HDC
dc
=
CreateDC
(
TEXT
(
"DISPLAY"
),
NULL
,
NULL
,
NULL
);
if
(
dc
!=
NULL
)
{
try
{
float
invScaleX
;
float
invScaleY
;
getInvScale
(
invScaleX
,
invScaleY
);
SetFontProperty
(
dc
,
ANSI_FIXED_FONT
,
TEXT
(
"win.ansiFixed.font"
),
1.0
f
);
SetFontProperty
(
dc
,
ANSI_VAR_FONT
,
TEXT
(
"win.ansiVar.font"
),
1.0
f
);
SetFontProperty
(
dc
,
DEVICE_DEFAULT_FONT
,
TEXT
(
"win.deviceDefault.font"
),
1.0
f
);
SetFontProperty
(
dc
,
DEFAULT_GUI_FONT
,
TEXT
(
"win.defaultGUI.font"
),
invScaleY
);
SetFontProperty
(
dc
,
OEM_FIXED_FONT
,
TEXT
(
"win.oemFixed.font"
),
1.0
f
);
SetFontProperty
(
dc
,
SYSTEM_FONT
,
TEXT
(
"win.system.font"
),
1.0
f
);
SetFontProperty
(
dc
,
SYSTEM_FIXED_FONT
,
TEXT
(
"win.systemFixed.font"
),
1.0
f
);
SetFontProperty
(
dc
,
ANSI_FIXED_FONT
,
TEXT
(
"win.ansiFixed.font"
));
SetFontProperty
(
dc
,
ANSI_VAR_FONT
,
TEXT
(
"win.ansiVar.font"
));
SetFontProperty
(
dc
,
DEVICE_DEFAULT_FONT
,
TEXT
(
"win.deviceDefault.font"
));
SetFontProperty
(
dc
,
DEFAULT_GUI_FONT
,
TEXT
(
"win.defaultGUI.font"
));
SetFontProperty
(
dc
,
OEM_FIXED_FONT
,
TEXT
(
"win.oemFixed.font"
));
SetFontProperty
(
dc
,
SYSTEM_FONT
,
TEXT
(
"win.system.font"
));
SetFontProperty
(
dc
,
SYSTEM_FIXED_FONT
,
TEXT
(
"win.systemFixed.font"
));
}
catch
(
std
::
bad_alloc
&
)
{
DeleteDC
(
dc
);
...
...
@@ -291,35 +266,31 @@ void AwtDesktopProperties::GetNonClientParameters() {
}
VERIFY
(
SystemParametersInfo
(
SPI_GETNONCLIENTMETRICS
,
ncmetrics
.
cbSize
,
&
ncmetrics
,
FALSE
)
);
float
invScaleX
;
float
invScaleY
;
getInvScale
(
invScaleX
,
invScaleY
);
SetFontProperty
(
TEXT
(
"win.frame.captionFont"
),
ncmetrics
.
lfCaptionFont
,
invScaleY
);
SetIntegerProperty
(
TEXT
(
"win.frame.captionHeight"
),
rescale
(
ncmetrics
.
iCaptionHeight
,
invScaleY
));
SetIntegerProperty
(
TEXT
(
"win.frame.captionButtonWidth"
),
rescale
(
ncmetrics
.
iCaptionWidth
,
invScaleX
));
SetIntegerProperty
(
TEXT
(
"win.frame.captionButtonHeight"
),
rescale
(
ncmetrics
.
iCaptionHeight
,
invScaleY
));
SetFontProperty
(
TEXT
(
"win.frame.smallCaptionFont"
),
ncmetrics
.
lfSmCaptionFont
,
invScaleY
);
SetIntegerProperty
(
TEXT
(
"win.frame.smallCaptionHeight"
),
rescale
(
ncmetrics
.
iSmCaptionHeight
,
invScaleY
));
SetIntegerProperty
(
TEXT
(
"win.frame.smallCaptionButtonWidth"
),
rescale
(
ncmetrics
.
iSmCaptionWidth
,
invScaleX
));
SetIntegerProperty
(
TEXT
(
"win.frame.smallCaptionButtonHeight"
),
rescale
(
ncmetrics
.
iSmCaptionHeight
,
invScaleY
));
SetIntegerProperty
(
TEXT
(
"win.frame.sizingBorderWidth"
),
rescale
(
ncmetrics
.
iBorderWidth
,
invScaleX
));
SetFontProperty
(
TEXT
(
"win.frame.captionFont"
),
ncmetrics
.
lfCaptionFont
);
SetIntegerProperty
(
TEXT
(
"win.frame.captionHeight"
),
ncmetrics
.
iCaptionHeight
);
SetIntegerProperty
(
TEXT
(
"win.frame.captionButtonWidth"
),
ncmetrics
.
iCaptionWidth
);
SetIntegerProperty
(
TEXT
(
"win.frame.captionButtonHeight"
),
ncmetrics
.
iCaptionHeight
);
SetFontProperty
(
TEXT
(
"win.frame.smallCaptionFont"
),
ncmetrics
.
lfSmCaptionFont
);
SetIntegerProperty
(
TEXT
(
"win.frame.smallCaptionHeight"
),
ncmetrics
.
iSmCaptionHeight
);
SetIntegerProperty
(
TEXT
(
"win.frame.smallCaptionButtonWidth"
),
ncmetrics
.
iSmCaptionWidth
);
SetIntegerProperty
(
TEXT
(
"win.frame.smallCaptionButtonHeight"
),
ncmetrics
.
iSmCaptionHeight
);
SetIntegerProperty
(
TEXT
(
"win.frame.sizingBorderWidth"
),
ncmetrics
.
iBorderWidth
);
// menu properties
SetFontProperty
(
TEXT
(
"win.menu.font"
),
ncmetrics
.
lfMenuFont
,
invScaleY
);
SetIntegerProperty
(
TEXT
(
"win.menu.height"
),
rescale
(
ncmetrics
.
iMenuHeight
,
invScaleY
)
);
SetIntegerProperty
(
TEXT
(
"win.menu.buttonWidth"
),
rescale
(
ncmetrics
.
iMenuWidth
,
invScaleX
)
);
SetFontProperty
(
TEXT
(
"win.menu.font"
),
ncmetrics
.
lfMenuFont
);
SetIntegerProperty
(
TEXT
(
"win.menu.height"
),
ncmetrics
.
iMenuHeight
);
SetIntegerProperty
(
TEXT
(
"win.menu.buttonWidth"
),
ncmetrics
.
iMenuWidth
);
// scrollbar properties
SetIntegerProperty
(
TEXT
(
"win.scrollbar.width"
),
rescale
(
ncmetrics
.
iScrollWidth
,
invScaleX
)
);
SetIntegerProperty
(
TEXT
(
"win.scrollbar.height"
),
rescale
(
ncmetrics
.
iScrollHeight
,
invScaleY
)
);
SetIntegerProperty
(
TEXT
(
"win.scrollbar.width"
),
ncmetrics
.
iScrollWidth
);
SetIntegerProperty
(
TEXT
(
"win.scrollbar.height"
),
ncmetrics
.
iScrollHeight
);
// status bar and tooltip properties
SetFontProperty
(
TEXT
(
"win.status.font"
),
ncmetrics
.
lfStatusFont
,
invScaleY
);
SetFontProperty
(
TEXT
(
"win.tooltip.font"
),
ncmetrics
.
lfStatusFont
,
invScaleY
);
SetFontProperty
(
TEXT
(
"win.status.font"
),
ncmetrics
.
lfStatusFont
);
SetFontProperty
(
TEXT
(
"win.tooltip.font"
),
ncmetrics
.
lfStatusFont
);
// message box properties
SetFontProperty
(
TEXT
(
"win.messagebox.font"
),
ncmetrics
.
lfMessageFont
,
invScaleY
);
SetFontProperty
(
TEXT
(
"win.messagebox.font"
),
ncmetrics
.
lfMessageFont
);
}
void
AwtDesktopProperties
::
GetIconParameters
()
{
...
...
@@ -331,13 +302,10 @@ void AwtDesktopProperties::GetIconParameters() {
iconmetrics
.
cbSize
=
sizeof
(
iconmetrics
);
VERIFY
(
SystemParametersInfo
(
SPI_GETICONMETRICS
,
iconmetrics
.
cbSize
,
&
iconmetrics
,
FALSE
)
);
float
invScaleX
;
float
invScaleY
;
getInvScale
(
invScaleX
,
invScaleY
);
SetIntegerProperty
(
TEXT
(
"win.icon.hspacing"
),
rescale
(
iconmetrics
.
iHorzSpacing
,
invScaleX
));
SetIntegerProperty
(
TEXT
(
"win.icon.vspacing"
),
rescale
(
iconmetrics
.
iVertSpacing
,
invScaleY
));
SetIntegerProperty
(
TEXT
(
"win.icon.hspacing"
),
iconmetrics
.
iHorzSpacing
);
SetIntegerProperty
(
TEXT
(
"win.icon.vspacing"
),
iconmetrics
.
iVertSpacing
);
SetBooleanProperty
(
TEXT
(
"win.icon.titleWrappingOn"
),
iconmetrics
.
iTitleWrap
!=
0
);
SetFontProperty
(
TEXT
(
"win.icon.font"
),
iconmetrics
.
lfFont
,
invScaleY
);
SetFontProperty
(
TEXT
(
"win.icon.font"
),
iconmetrics
.
lfFont
);
}
/*
Windows settings for these are also in the registry
...
...
@@ -750,7 +718,6 @@ void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) {
}
void
AwtDesktopProperties
::
SetIntegerProperty
(
LPCTSTR
propName
,
int
value
)
{
jstring
key
=
JNU_NewStringPlatform
(
GetEnv
(),
propName
);
if
(
key
==
NULL
)
{
throw
std
::
bad_alloc
();
...
...
@@ -785,8 +752,8 @@ void AwtDesktopProperties::SetColorProperty(LPCTSTR propName, DWORD value) {
}
void
AwtDesktopProperties
::
SetFontProperty
(
HDC
dc
,
int
fontID
,
LPCTSTR
propName
,
float
invScal
e
)
{
HGDIOBJ
font
=
GetStockObject
(
fontID
);
LPCTSTR
propNam
e
)
{
HGDIOBJ
font
=
GetStockObject
(
fontID
);
if
(
font
!=
NULL
&&
SelectObject
(
dc
,
font
)
!=
NULL
)
{
int
length
=
GetTextFace
(
dc
,
0
,
NULL
);
...
...
@@ -822,8 +789,8 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID,
throw
std
::
bad_alloc
();
}
jint
pointSize
=
rescale
(
metrics
.
tmHeight
-
metrics
.
tmInternalLeading
,
invScale
)
;
jint
pointSize
=
metrics
.
tmHeight
-
metrics
.
tmInternalLeading
;
jint
style
=
java_awt_Font_PLAIN
;
if
(
metrics
.
tmWeight
>=
FW_BOLD
)
{
...
...
@@ -851,8 +818,7 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID,
}
}
void
AwtDesktopProperties
::
SetFontProperty
(
LPCTSTR
propName
,
const
LOGFONT
&
font
,
float
invScale
)
{
void
AwtDesktopProperties
::
SetFontProperty
(
LPCTSTR
propName
,
const
LOGFONT
&
font
)
{
jstring
fontName
;
jint
pointSize
;
jint
style
;
...
...
@@ -870,7 +836,7 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon
ReleaseDC(NULL, hdc);
#endif
// Java uses point sizes, but assumes 1 pixel = 1 point
pointSize
=
rescale
(
-
font
.
lfHeight
,
invScale
)
;
pointSize
=
-
font
.
lfHeight
;
// convert Windows font style to Java style
style
=
java_awt_Font_PLAIN
;
...
...
src/windows/native/sun/windows/awt_DesktopProperties.h
浏览文件 @
f8b7e9bf
...
...
@@ -73,8 +73,8 @@ class AwtDesktopProperties {
void
SetIntegerProperty
(
LPCTSTR
,
int
);
void
SetStringProperty
(
LPCTSTR
,
LPTSTR
);
void
SetColorProperty
(
LPCTSTR
,
DWORD
);
void
SetFontProperty
(
HDC
,
int
,
LPCTSTR
,
float
invScale
);
void
SetFontProperty
(
LPCTSTR
,
const
LOGFONT
&
,
float
invScale
);
void
SetFontProperty
(
HDC
,
int
,
LPCTSTR
);
void
SetFontProperty
(
LPCTSTR
,
const
LOGFONT
&
);
void
SetSoundProperty
(
LPCTSTR
,
LPCTSTR
);
JNIEnv
*
GetEnv
()
{
...
...
test/java/awt/font/FontScaling/FontScalingTest.java
已删除
100644 → 0
浏览文件 @
cdf1bda9
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
javax.swing.JButton
;
import
javax.swing.SwingUtilities
;
import
javax.swing.UIManager
;
import
javax.swing.plaf.metal.MetalLookAndFeel
;
/*
* @test
* @bug 8076545
* @summary Text size is twice bigger under Windows L&F on Win 8.1 with
* HiDPI display
*/
public
class
FontScalingTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
int
metalFontSize
=
getFontSize
(
MetalLookAndFeel
.
class
.
getName
());
int
systemFontSize
=
getFontSize
(
UIManager
.
getSystemLookAndFeelClassName
());
if
(
Math
.
abs
(
systemFontSize
-
metalFontSize
)
>
8
)
{
throw
new
RuntimeException
(
"System L&F is too big!"
);
}
}
private
static
int
getFontSize
(
String
laf
)
throws
Exception
{
UIManager
.
setLookAndFeel
(
laf
);
final
int
[]
sizes
=
new
int
[
1
];
SwingUtilities
.
invokeAndWait
(()
->
{
JButton
button
=
new
JButton
(
"Test"
);
sizes
[
0
]
=
button
.
getFont
().
getSize
();
});
return
sizes
[
0
];
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录