Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
10307383
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,发现更多精彩内容 >>
提交
10307383
编写于
4月 01, 2011
作者:
P
prr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
Reviewed-by: igor, jgodinez
上级
d539212d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
142 addition
and
21 deletion
+142
-21
src/share/classes/sun/awt/FontConfiguration.java
src/share/classes/sun/awt/FontConfiguration.java
+8
-0
src/share/classes/sun/font/FontManagerForSGE.java
src/share/classes/sun/font/FontManagerForSGE.java
+7
-0
src/share/classes/sun/font/SunFontManager.java
src/share/classes/sun/font/SunFontManager.java
+16
-3
src/share/classes/sun/java2d/SunGraphicsEnvironment.java
src/share/classes/sun/java2d/SunGraphicsEnvironment.java
+12
-0
src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
+0
-18
test/sun/java2d/SunGraphicsEnvironment/TestSGEuseAlternateFontforJALocales.java
...phicsEnvironment/TestSGEuseAlternateFontforJALocales.java
+99
-0
未找到文件。
src/share/classes/sun/awt/FontConfiguration.java
浏览文件 @
10307383
...
...
@@ -82,6 +82,10 @@ public abstract class FontConfiguration {
* one to ensure proper static initialisation takes place.
*/
public
FontConfiguration
(
SunFontManager
fm
)
{
if
(
FontUtilities
.
debugFonts
())
{
FontUtilities
.
getLogger
()
.
info
(
"Creating standard Font Configuration"
);
}
if
(
FontUtilities
.
debugFonts
()
&&
logger
==
null
)
{
logger
=
PlatformLogger
.
getLogger
(
"sun.awt.FontConfiguration"
);
}
...
...
@@ -111,6 +115,10 @@ public abstract class FontConfiguration {
boolean
preferLocaleFonts
,
boolean
preferPropFonts
)
{
fontManager
=
fm
;
if
(
FontUtilities
.
debugFonts
())
{
FontUtilities
.
getLogger
()
.
info
(
"Creating alternate Font Configuration"
);
}
this
.
preferLocaleFonts
=
preferLocaleFonts
;
this
.
preferPropFonts
=
preferPropFonts
;
/* fontConfig should be initialised by default constructor, and
...
...
src/share/classes/sun/font/FontManagerForSGE.java
浏览文件 @
10307383
...
...
@@ -54,4 +54,11 @@ public interface FontManagerForSGE extends FontManager {
public
Font
[]
getAllInstalledFonts
();
public
String
[]
getInstalledFontFamilyNames
(
Locale
requestedLocale
);
/* Modifies the behaviour of a subsequent call to preferLocaleFonts()
* to use Mincho instead of Gothic for dialoginput in JA locales
* on windows. Not needed on other platforms.
*/
public
void
useAlternateFontforJALocales
();
}
src/share/classes/sun/font/SunFontManager.java
浏览文件 @
10307383
...
...
@@ -2874,7 +2874,10 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
* on windows. Not needed on other platforms.
*/
public
synchronized
void
useAlternateFontforJALocales
()
{
if
(
FontUtilities
.
isLogging
())
{
FontUtilities
.
getLogger
()
.
info
(
"Entered useAlternateFontforJALocales()."
);
}
if
(!
FontUtilities
.
isWindows
)
{
return
;
}
...
...
@@ -2897,7 +2900,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
}
public
synchronized
void
preferLocaleFonts
()
{
if
(
FontUtilities
.
isLogging
())
{
FontUtilities
.
getLogger
().
info
(
"Entered preferLocaleFonts()."
);
}
/* Test if re-ordering will have any effect */
if
(!
FontConfiguration
.
willReorderForStartupLocale
())
{
return
;
...
...
@@ -2928,7 +2933,10 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
}
public
synchronized
void
preferProportionalFonts
()
{
if
(
FontUtilities
.
isLogging
())
{
FontUtilities
.
getLogger
()
.
info
(
"Entered preferProportionalFonts()."
);
}
/* If no proportional fonts are configured, there's no need
* to take any action.
*/
...
...
@@ -3456,6 +3464,11 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
initCompositeFonts
(
FontConfiguration
fontConfig
,
ConcurrentHashMap
<
String
,
Font2D
>
altNameCache
)
{
if
(
FontUtilities
.
isLogging
())
{
FontUtilities
.
getLogger
()
.
info
(
"Initialising composite fonts"
);
}
int
numCoreFonts
=
fontConfig
.
getNumberCoreFonts
();
String
[]
fcFonts
=
fontConfig
.
getPlatformFontNames
();
for
(
int
f
=
0
;
f
<
fcFonts
.
length
;
f
++)
{
...
...
src/share/classes/sun/java2d/SunGraphicsEnvironment.java
浏览文件 @
10307383
...
...
@@ -185,6 +185,18 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
FontManager
fm
=
FontManagerFactory
.
getInstance
();
return
(
FontManagerForSGE
)
fm
;
}
/* Modifies the behaviour of a subsequent call to preferLocaleFonts()
* to use Mincho instead of Gothic for dialoginput in JA locales
* on windows. Not needed on other platforms.
*
* DO NOT MOVE OR RENAME OR OTHERWISE ALTER THIS METHOD.
* ITS USED BY SOME NON-JRE INTERNAL CODE.
*/
public
static
void
useAlternateFontforJALocales
()
{
getFontManagerForSGE
().
useAlternateFontforJALocales
();
}
/**
* Returns all fonts available in this environment.
*/
...
...
src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
浏览文件 @
10307383
...
...
@@ -39,12 +39,8 @@ import java.util.NoSuchElementException;
import
java.util.StringTokenizer
;
import
sun.awt.DisplayChangedListener
;
import
sun.awt.SunDisplayChanger
;
import
sun.awt.windows.WFontConfiguration
;
import
sun.awt.windows.WPrinterJob
;
import
sun.awt.windows.WToolkit
;
import
sun.font.FontManager
;
import
sun.font.FontManagerFactory
;
import
sun.font.SunFontManager
;
import
sun.java2d.SunGraphicsEnvironment
;
import
sun.java2d.SurfaceManagerFactory
;
import
sun.java2d.WindowsSurfaceManagerFactory
;
...
...
@@ -231,20 +227,6 @@ public class Win32GraphicsEnvironment
return
device
;
}
// Implements SunGraphicsEnvironment.createFontConfiguration.
protected
FontConfiguration
createFontConfiguration
()
{
FontConfiguration
fc
=
new
WFontConfiguration
(
SunFontManager
.
getInstance
());
fc
.
init
();
return
fc
;
}
public
FontConfiguration
createFontConfiguration
(
boolean
preferLocaleFonts
,
boolean
preferPropFonts
)
{
return
new
WFontConfiguration
(
SunFontManager
.
getInstance
(),
preferLocaleFonts
,
preferPropFonts
);
}
public
boolean
isDisplayLocal
()
{
return
true
;
}
...
...
test/sun/java2d/SunGraphicsEnvironment/TestSGEuseAlternateFontforJALocales.java
0 → 100644
浏览文件 @
10307383
/*
* Copyright (c) 2011, 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.
*/
/**
* @test
* @bug 7032930
*
* @summary verify the existence of the method
* SunGraphicsEnvironment.useAlternateFontforJALocales
*
* @run main/othervm TestSGEuseAlternateFontforJALocales
* @run main/othervm -Dfile.encoding=windows-31j -Duser.language=ja -Duser.country=JA TestSGEuseAlternateFontforJALocales
*
*/
import
java.lang.reflect.Method
;
import
java.nio.charset.Charset
;
import
java.util.Locale
;
import
java.awt.Font
;
import
java.awt.FontMetrics
;
import
java.awt.Graphics2D
;
import
java.awt.GraphicsEnvironment
;
import
java.awt.image.BufferedImage
;
public
class
TestSGEuseAlternateFontforJALocales
{
public
static
void
main
(
String
args
[])
throws
Exception
{
System
.
out
.
println
(
"Default Charset = "
+
Charset
.
defaultCharset
().
name
());
System
.
out
.
println
(
"Locale = "
+
Locale
.
getDefault
());
String
os
=
System
.
getProperty
(
"os.name"
);
String
encoding
=
System
.
getProperty
(
"file.encoding"
);
/* Want to test the JA locale uses alternate font for DialogInput. */
boolean
jaTest
=
encoding
.
equalsIgnoreCase
(
"windows-31j"
);
if
(!
os
.
startsWith
(
"Win"
)
&&
jaTest
)
{
System
.
out
.
println
(
"Skipping Windows only test"
);
return
;
}
String
className
=
"sun.java2d.SunGraphicsEnvironment"
;
String
methodName
=
"useAlternateFontforJALocales"
;
Class
sge
=
Class
.
forName
(
className
);
Method
uafMethod
=
sge
.
getMethod
(
methodName
,
(
Class
[])
null
);
Object
ret
=
uafMethod
.
invoke
(
null
);
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
ge
.
preferLocaleFonts
();
ge
.
preferProportionalFonts
();
if
(
jaTest
)
{
Font
msMincho
=
new
Font
(
"MS Mincho"
,
Font
.
PLAIN
,
12
);
if
(!
msMincho
.
getFamily
(
Locale
.
ENGLISH
).
equals
(
"MS Mincho"
))
{
System
.
out
.
println
(
"MS Mincho not installed. Skipping test"
);
return
;
}
Font
dialogInput
=
new
Font
(
"DialogInput"
,
Font
.
PLAIN
,
12
);
Font
courierNew
=
new
Font
(
"Courier New"
,
Font
.
PLAIN
,
12
);
Font
msGothic
=
new
Font
(
"MS Gothic"
,
Font
.
PLAIN
,
12
);
BufferedImage
bi
=
new
BufferedImage
(
1
,
1
,
1
);
Graphics2D
g2d
=
bi
.
createGraphics
();
FontMetrics
cnMetrics
=
g2d
.
getFontMetrics
(
courierNew
);
FontMetrics
diMetrics
=
g2d
.
getFontMetrics
(
dialogInput
);
FontMetrics
mmMetrics
=
g2d
.
getFontMetrics
(
msMincho
);
FontMetrics
mgMetrics
=
g2d
.
getFontMetrics
(
msGothic
);
// This tests to make sure we at least have applied
// "preferLocaleFonts for Japanese
if
(
cnMetrics
.
charWidth
(
'A'
)
==
diMetrics
.
charWidth
(
'A'
))
{
throw
new
RuntimeException
(
"Courier New should not be used for DialogInput"
);
}
// This is supposed to make sure we are using MS Mincho instead
// of MS Gothic. However they are metrics identical so its
// not definite proof.
if
(
diMetrics
.
charWidth
(
'A'
)
!=
mmMetrics
.
charWidth
(
'A'
))
{
throw
new
RuntimeException
(
"MS Mincho should be used for DialogInput"
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录