Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
000b5f31
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看板
提交
000b5f31
编写于
3月 05, 2011
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6760148: Certain fonts are not correctly soft wrapped when using JTextComponent.print()
Reviewed-by: peterz
上级
c32d33f9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
28 deletion
+11
-28
src/share/classes/javax/swing/text/Utilities.java
src/share/classes/javax/swing/text/Utilities.java
+8
-23
src/share/classes/javax/swing/text/WrappedPlainView.java
src/share/classes/javax/swing/text/WrappedPlainView.java
+3
-5
未找到文件。
src/share/classes/javax/swing/text/Utilities.java
浏览文件 @
000b5f31
...
...
@@ -390,11 +390,15 @@ public class Utilities {
}
if
((
x
>=
currX
)
&&
(
x
<
nextX
))
{
// found the hit position... return the appropriate side
if
((
round
==
false
)
||
((
x
-
currX
)
<
(
nextX
-
x
)))
{
return
i
-
txtOffset
;
}
else
{
return
i
+
1
-
txtOffset
;
int
offset
=
((
round
==
false
)
||
((
x
-
currX
)
<
(
nextX
-
x
)))
?
(
i
-
txtOffset
)
:
(
i
+
1
-
txtOffset
);
// the length of the string measured as a whole may differ from
// the sum of individual character lengths, for example if
// fractional metrics are enabled; and we must guard from this.
while
(
metrics
.
charsWidth
(
txt
,
txtOffset
,
offset
+
1
)
>
(
x
-
x0
))
{
offset
--;
}
return
(
offset
<
0
?
0
:
offset
);
}
currX
=
nextX
;
}
...
...
@@ -403,24 +407,6 @@ public class Utilities {
return
txtCount
;
}
/**
* Adjust text offset so that the length of a resulting string as a whole
* fits into the specified width.
*/
static
int
adjustOffsetForFractionalMetrics
(
Segment
s
,
FontMetrics
fm
,
int
offset
,
int
width
)
{
// Sometimes the offset returned by getTabbedTextOffset is beyond the
// available area, when fractional metrics are enabled. We should
// guard against this.
if
(
offset
<
s
.
count
)
{
while
(
offset
>
0
&&
fm
.
charsWidth
(
s
.
array
,
s
.
offset
,
offset
+
1
)
>
width
)
{
offset
--;
}
}
return
offset
;
}
/**
* Determine where to break the given text to fit
* within the given span. This tries to find a word boundary.
...
...
@@ -443,7 +429,6 @@ public class Utilities {
int
txtCount
=
s
.
count
;
int
index
=
Utilities
.
getTabbedTextOffset
(
s
,
metrics
,
x0
,
x
,
e
,
startOffset
,
false
);
index
=
adjustOffsetForFractionalMetrics
(
s
,
metrics
,
index
,
x
-
x0
);
if
(
index
>=
txtCount
-
1
)
{
return
txtCount
;
...
...
src/share/classes/javax/swing/text/WrappedPlainView.java
浏览文件 @
000b5f31
...
...
@@ -239,11 +239,9 @@ public class WrappedPlainView extends BoxView implements TabExpander {
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
);
}
else
{
int
offset
=
Utilities
.
getTabbedTextOffset
(
segment
,
metrics
,
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
,
false
);
offset
=
Utilities
.
adjustOffsetForFractionalMetrics
(
segment
,
metrics
,
offset
,
currentWidth
);
p
=
p0
+
offset
;
p
=
p0
+
Utilities
.
getTabbedTextOffset
(
segment
,
metrics
,
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
,
false
);
}
SegmentCache
.
releaseSharedSegment
(
segment
);
return
p
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录