Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
ea84ed26
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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,发现更多精彩内容 >>
提交
ea84ed26
编写于
12月 16, 2014
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8065373: [macosx] jdk8, jdk7u60 Regression in Graphics2D drawing of derived Fonts
Reviewed-by: bae, prr
上级
14eb2d41
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
165 addition
and
6 deletion
+165
-6
src/macosx/native/sun/font/AWTStrike.m
src/macosx/native/sun/font/AWTStrike.m
+3
-6
test/java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java
...phics2D/DrawString/DrawRotatedStringUsingRotatedFont.java
+162
-0
未找到文件。
src/macosx/native/sun/font/AWTStrike.m
浏览文件 @
ea84ed26
/*
/*
* Copyright (c) 2011, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 201
4
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -25,14 +25,11 @@
...
@@ -25,14 +25,11 @@
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import "java_awt_geom_PathIterator.h"
#import "java_awt_geom_PathIterator.h"
#import "sun_awt_SunHints.h"
#import "sun_font_CStrike.h"
#import "sun_font_CStrike.h"
#import "sun_font_CStrikeDisposer.h"
#import "sun_font_CStrikeDisposer.h"
#import "CGGlyphImages.h"
#import "CGGlyphImages.h"
#import "CGGlyphOutlines.h"
#import "CGGlyphOutlines.h"
#import "AWTStrike.h"
#import "CoreTextSupport.h"
#import "CoreTextSupport.h"
//#import "jni_util.h"
#include "fontscalerdefs.h"
#include "fontscalerdefs.h"
/* Use THIS_FILE when it is available. */
/* Use THIS_FILE when it is available. */
...
@@ -65,10 +62,10 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
...
@@ -65,10 +62,10 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
invDevTx
.
b
*=
-
1
;
invDevTx
.
b
*=
-
1
;
invDevTx
.
c
*=
-
1
;
invDevTx
.
c
*=
-
1
;
fFontTx
=
CGAffineTransformConcat
(
CGAffineTransformConcat
(
tx
,
invDevTx
),
sInverseTX
);
fFontTx
=
CGAffineTransformConcat
(
CGAffineTransformConcat
(
tx
,
invDevTx
),
sInverseTX
);
fDevTx
=
CGAffineTransformInvert
(
invDevTx
);
fDevTx
=
CGAffineTransformInvert
(
CGAffineTransformConcat
(
invDevTx
,
sInverseTX
)
);
// the "font size" is the square root of the determinant of the matrix
// the "font size" is the square root of the determinant of the matrix
fSize
=
sqrt
(
abs
(
fFontTx
.
a
*
fFontTx
.
d
-
fFontTx
.
b
*
fFontTx
.
c
));
fSize
=
sqrt
(
f
abs
(
fFontTx
.
a
*
fFontTx
.
d
-
fFontTx
.
b
*
fFontTx
.
c
));
}
}
return
self
;
return
self
;
}
}
...
...
test/java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java
0 → 100644
浏览文件 @
ea84ed26
/*
* Copyright (c) 2014, 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
java.awt.Color
;
import
java.awt.Font
;
import
java.awt.Graphics2D
;
import
java.awt.RenderingHints
;
import
java.awt.geom.AffineTransform
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
javax.imageio.ImageIO
;
import
static
java
.
awt
.
image
.
BufferedImage
.
TYPE_INT_RGB
;
import
static
java
.
lang
.
Math
.
toRadians
;
/**
* @test
* @bug 8065373
* @summary Verifies that we get correct direction, when draw rotated string.
* @author Sergey Bylokhov
* @run main DrawRotatedStringUsingRotatedFont
*/
public
final
class
DrawRotatedStringUsingRotatedFont
{
private
static
final
int
SIZE
=
500
;
private
static
final
String
STR
=
"MMMMMMMMMMMMMMMM"
;
private
static
AffineTransform
[]
txs
=
{
AffineTransform
.
getRotateInstance
(
toRadians
(
00
)),
AffineTransform
.
getRotateInstance
(
toRadians
(
45
)),
AffineTransform
.
getRotateInstance
(
toRadians
(-
45
)),
AffineTransform
.
getRotateInstance
(
toRadians
(
90
)),
AffineTransform
.
getRotateInstance
(
toRadians
(-
90
)),
AffineTransform
.
getRotateInstance
(
toRadians
(
135
)),
AffineTransform
.
getRotateInstance
(
toRadians
(-
135
)),
AffineTransform
.
getRotateInstance
(
toRadians
(
180
)),
AffineTransform
.
getRotateInstance
(
toRadians
(-
180
)),
AffineTransform
.
getRotateInstance
(
toRadians
(
225
)),
AffineTransform
.
getRotateInstance
(
toRadians
(-
225
)),
AffineTransform
.
getRotateInstance
(
toRadians
(
270
)),
AffineTransform
.
getRotateInstance
(
toRadians
(-
270
)),
AffineTransform
.
getRotateInstance
(
toRadians
(
315
)),
AffineTransform
.
getRotateInstance
(
toRadians
(-
315
)),
AffineTransform
.
getRotateInstance
(
toRadians
(
360
)),
AffineTransform
.
getRotateInstance
(
toRadians
(-
360
))
};
public
static
void
main
(
final
String
[]
args
)
throws
IOException
{
for
(
final
AffineTransform
tx2
:
txs
)
{
for
(
final
AffineTransform
tx1
:
txs
)
{
for
(
final
boolean
aa
:
new
boolean
[]{
true
,
false
})
{
final
BufferedImage
bi1
=
createImage
(
aa
,
tx1
,
tx2
);
final
BufferedImage
bi2
=
createImage
(
aa
,
tx2
,
tx1
);
compareImage
(
bi1
,
bi2
);
fillTextArea
(
bi1
,
tx1
,
tx2
);
fillTextArea
(
bi2
,
tx2
,
tx1
);
checkColors
(
bi1
,
bi2
);
}
}
}
System
.
out
.
println
(
"Passed"
);
}
/**
* Compares two images.
*/
private
static
void
compareImage
(
final
BufferedImage
bi1
,
final
BufferedImage
bi2
)
throws
IOException
{
for
(
int
i
=
0
;
i
<
SIZE
;
++
i
)
{
for
(
int
j
=
0
;
j
<
SIZE
;
++
j
)
{
if
(
bi1
.
getRGB
(
i
,
j
)
!=
bi2
.
getRGB
(
i
,
j
))
{
ImageIO
.
write
(
bi1
,
"png"
,
new
File
(
"image1.png"
));
ImageIO
.
write
(
bi2
,
"png"
,
new
File
(
"image2.png"
));
throw
new
RuntimeException
(
"Failed: wrong text location"
);
}
}
}
}
/**
* Checks an image color. RED and GREEN are allowed only.
*/
private
static
void
checkColors
(
final
BufferedImage
bi1
,
final
BufferedImage
bi2
)
throws
IOException
{
for
(
int
i
=
0
;
i
<
SIZE
;
++
i
)
{
for
(
int
j
=
0
;
j
<
SIZE
;
++
j
)
{
final
int
rgb1
=
bi1
.
getRGB
(
i
,
j
);
final
int
rgb2
=
bi2
.
getRGB
(
i
,
j
);
if
(
rgb1
!=
rgb2
||
rgb1
!=
0xFFFF0000
&&
rgb1
!=
0xFF00FF00
)
{
ImageIO
.
write
(
bi1
,
"png"
,
new
File
(
"image1.png"
));
ImageIO
.
write
(
bi2
,
"png"
,
new
File
(
"image2.png"
));
throw
new
RuntimeException
(
"Failed: wrong text location"
);
}
}
}
}
/**
* Creates an BufferedImage and draws a text, using two transformations,
* one for graphics and one for font.
*/
private
static
BufferedImage
createImage
(
final
boolean
aa
,
final
AffineTransform
gtx
,
final
AffineTransform
ftx
)
{
final
BufferedImage
bi
=
new
BufferedImage
(
SIZE
,
SIZE
,
TYPE_INT_RGB
);
final
Graphics2D
bg
=
bi
.
createGraphics
();
bg
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
aa
?
RenderingHints
.
VALUE_ANTIALIAS_ON
:
RenderingHints
.
VALUE_ANTIALIAS_OFF
);
bg
.
setColor
(
Color
.
RED
);
bg
.
fillRect
(
0
,
0
,
SIZE
,
SIZE
);
bg
.
translate
(
100
,
100
);
bg
.
transform
(
gtx
);
bg
.
setColor
(
Color
.
BLACK
);
bg
.
setFont
(
bg
.
getFont
().
deriveFont
(
20.0f
).
deriveFont
(
ftx
));
bg
.
drawString
(
STR
,
0
,
0
);
bg
.
dispose
();
return
bi
;
}
/**
* Fills the area of text using green solid color.
*/
private
static
void
fillTextArea
(
final
BufferedImage
bi
,
final
AffineTransform
tx1
,
final
AffineTransform
tx2
)
{
final
Graphics2D
bg
=
bi
.
createGraphics
();
bg
.
translate
(
100
,
100
);
bg
.
transform
(
tx1
);
bg
.
transform
(
tx2
);
bg
.
setColor
(
Color
.
GREEN
);
final
Font
font
=
bg
.
getFont
().
deriveFont
(
20.0f
);
bg
.
setFont
(
font
);
bg
.
fill
(
font
.
getStringBounds
(
STR
,
bg
.
getFontRenderContext
()));
bg
.
dispose
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录