Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
06a36d9d
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看板
提交
06a36d9d
编写于
1月 14, 2011
作者:
P
prr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6925760: Scaled graphics can cause overlapped LCD mode strings on Windows for pixel size > 48
Reviewed-by: igor, jgodinez
上级
b946903d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
137 addition
and
8 deletion
+137
-8
src/share/classes/sun/font/FileFontStrike.java
src/share/classes/sun/font/FileFontStrike.java
+54
-8
test/java/awt/FontClass/LCDScale.java
test/java/awt/FontClass/LCDScale.java
+83
-0
未找到文件。
src/share/classes/sun/font/FileFontStrike.java
浏览文件 @
06a36d9d
...
...
@@ -566,10 +566,44 @@ public class FileFontStrike extends PhysicalStrike {
if
(
glyphCode
>=
INVISIBLE_GLYPHS
)
{
return
0
f
;
}
/* Notes on the (getUserAdv == false) case.
*
* Setting getUserAdv == false is internal to this class.
* If there's no graphics transform we can let
* getGlyphAdvance take its course, and potentially caching in
* advances arrays, except for signalling that
* getUserAdv == false means there is no need to create an image.
* It is possible that code already calculated the user advance,
* and it is desirable to take advantage of that work.
* But, if there's a transform and we want device advance, we
* can't use any values cached in the advances arrays - unless
* first re-transform them into device space using 'desc.devTx'.
* invertDevTx is null if the graphics transform is identity,
* a translate, or non-invertible. The latter case should
* not ever occur in the getUserAdv == false path.
* In other words its either null, or the inversion of a
* simple uniform scale. If its null, we can populate and
* use the advance caches as normal.
*
* If we don't find a cached value, obtain the device advance and
* return it. This will get stashed on the image by the caller and any
* subsequent metrics calls will be able to use it as is the case
* whenever an image is what is initially requested.
*
* Don't query if there's a value cached on the image, since this
* getUserAdv==false code path is entered solely when none exists.
*/
if
(
horizontalAdvances
!=
null
)
{
advance
=
horizontalAdvances
[
glyphCode
];
if
(
advance
!=
Float
.
MAX_VALUE
)
{
return
advance
;
if
(!
getUserAdv
&&
invertDevTx
!=
null
)
{
Point2D
.
Float
metrics
=
new
Point2D
.
Float
(
advance
,
0
f
);
desc
.
devTx
.
deltaTransform
(
metrics
,
metrics
);
return
metrics
.
x
;
}
else
{
return
advance
;
}
}
}
else
if
(
segmentedCache
&&
segHorizontalAdvances
!=
null
)
{
int
segIndex
=
glyphCode
>>
SEGSHIFT
;
...
...
@@ -577,11 +611,23 @@ public class FileFontStrike extends PhysicalStrike {
if
(
subArray
!=
null
)
{
advance
=
subArray
[
glyphCode
%
SEGSIZE
];
if
(
advance
!=
Float
.
MAX_VALUE
)
{
return
advance
;
if
(!
getUserAdv
&&
invertDevTx
!=
null
)
{
Point2D
.
Float
metrics
=
new
Point2D
.
Float
(
advance
,
0
f
);
desc
.
devTx
.
deltaTransform
(
metrics
,
metrics
);
return
metrics
.
x
;
}
else
{
return
advance
;
}
}
}
}
if
(!
getUserAdv
&&
invertDevTx
!=
null
)
{
Point2D
.
Float
metrics
=
new
Point2D
.
Float
();
fileFont
.
getGlyphMetrics
(
pScalerContext
,
glyphCode
,
metrics
);
return
metrics
.
x
;
}
if
(
invertDevTx
!=
null
||
!
getUserAdv
)
{
/* If there is a device transform need x & y advance to
* transform back into user space.
...
...
@@ -725,7 +771,7 @@ public class FileFontStrike extends PhysicalStrike {
return
getGlyphMetrics
(
glyphCode
,
true
);
}
private
Point2D
.
Float
getGlyphMetrics
(
int
glyphCode
,
boolean
get
UserAdv
)
{
private
Point2D
.
Float
getGlyphMetrics
(
int
glyphCode
,
boolean
get
Image
)
{
Point2D
.
Float
metrics
=
new
Point2D
.
Float
();
// !!! or do we force sgv user glyphs?
...
...
@@ -733,7 +779,7 @@ public class FileFontStrike extends PhysicalStrike {
return
metrics
;
}
long
glyphPtr
;
if
(
getImageWithAdvance
&&
get
UserAdv
)
{
if
(
getImageWithAdvance
&&
get
Image
)
{
/* A heuristic optimisation says that for most cases its
* worthwhile retrieving the image at the same time as the
* metrics. So here we get the image data even if its not
...
...
@@ -750,9 +796,9 @@ public class FileFontStrike extends PhysicalStrike {
metrics
.
y
=
StrikeCache
.
unsafe
.
getFloat
(
glyphPtr
+
StrikeCache
.
yAdvanceOffset
);
/* advance is currently in device space, need to convert back
* into user space
, unless getUserAdv == false
.
* into user space.
* This must not include the translation component. */
if
(
invertDevTx
!=
null
&&
getUserAdv
)
{
if
(
invertDevTx
!=
null
)
{
invertDevTx
.
deltaTransform
(
metrics
,
metrics
);
}
}
else
{
...
...
@@ -781,9 +827,9 @@ public class FileFontStrike extends PhysicalStrike {
if
(
value
==
null
)
{
fileFont
.
getGlyphMetrics
(
pScalerContext
,
glyphCode
,
metrics
);
/* advance is currently in device space, need to convert back
* into user space
, unless getUserAdv == false
.
* into user space.
*/
if
(
invertDevTx
!=
null
&&
getUserAdv
)
{
if
(
invertDevTx
!=
null
)
{
invertDevTx
.
deltaTransform
(
metrics
,
metrics
);
}
value
=
new
Point2D
.
Float
(
metrics
.
x
,
metrics
.
y
);
...
...
test/java/awt/FontClass/LCDScale.java
0 → 100644
浏览文件 @
06a36d9d
/*
* Copyright (c) 2010, 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.
*/
/*
*
* @bug 6925760
* @summary Scaled graphics causes overlapped LCD glyphs on Windows
*/
import
java.awt.*
;
import
java.awt.font.*
;
import
java.awt.geom.*
;
public
class
LCDScale
extends
Component
{
public
static
void
main
(
String
args
[])
{
Frame
f
=
new
Frame
(
"TL TEST"
);
LCDScale
td
=
new
LCDScale
();
f
.
add
(
"Center"
,
td
);
f
.
pack
();
f
.
setVisible
(
true
);
}
public
LCDScale
()
{
super
();
}
public
Dimension
getPreferredSize
()
{
return
new
Dimension
(
500
,
500
);
}
public
void
paint
(
Graphics
g
)
{
Graphics2D
g2d
=
(
Graphics2D
)
g
;
g2d
.
setRenderingHint
(
RenderingHints
.
KEY_TEXT_ANTIALIASING
,
RenderingHints
.
VALUE_TEXT_ANTIALIAS_LCD_HRGB
);
Font
f
=
new
Font
(
"Dialog"
,
Font
.
PLAIN
,
40
);
g
.
setFont
(
f
);
FontRenderContext
frc
=
g2d
.
getFontRenderContext
();
GlyphVector
gv
=
f
.
createGlyphVector
(
frc
,
"Help"
);
g2d
.
drawGlyphVector
(
gv
,
10
f
,
50
f
);
Rectangle2D
bds1
=
gv
.
getLogicalBounds
();
f
=
new
Font
(
"Arial"
,
Font
.
PLAIN
,
25
);
g
.
setFont
(
f
);
double
s
=
2.0
;
AffineTransform
tx
=
AffineTransform
.
getScaleInstance
(
s
,
s
);
g2d
.
transform
(
tx
);
frc
=
g2d
.
getFontRenderContext
();
gv
=
f
.
createGlyphVector
(
frc
,
"Help"
);
g2d
.
drawGlyphVector
(
gv
,
10
f
,
100
f
);
Rectangle2D
bds2
=
gv
.
getLogicalBounds
();
System
.
out
.
println
(
bds1
);
System
.
out
.
println
(
bds2
);
if
(
bds2
.
getWidth
()*
s
<
bds1
.
getWidth
())
{
throw
new
RuntimeException
(
"Bounds too small"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录