Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
302e2e9d
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
302e2e9d
编写于
3月 01, 2019
作者:
C
Core
提交者:
Gary Qian
2月 28, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix cursor jumping when typing some special characters. (#7964)
上级
fe15149d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
96 addition
and
0 deletion
+96
-0
third_party/txt/src/txt/paragraph.cc
third_party/txt/src/txt/paragraph.cc
+10
-0
third_party/txt/tests/paragraph_unittests.cc
third_party/txt/tests/paragraph_unittests.cc
+86
-0
未找到文件。
third_party/txt/src/txt/paragraph.cc
浏览文件 @
302e2e9d
...
@@ -1248,6 +1248,7 @@ std::vector<Paragraph::TextBox> Paragraph::GetRectsForRange(
...
@@ -1248,6 +1248,7 @@ std::vector<Paragraph::TextBox> Paragraph::GetRectsForRange(
// Lines that are actually in the requested range.
// Lines that are actually in the requested range.
size_t
max_line
=
0
;
size_t
max_line
=
0
;
size_t
min_line
=
INT_MAX
;
size_t
min_line
=
INT_MAX
;
size_t
glyph_length
=
0
;
// Generate initial boxes and calculate metrics.
// Generate initial boxes and calculate metrics.
for
(
const
CodeUnitRun
&
run
:
code_unit_runs_
)
{
for
(
const
CodeUnitRun
&
run
:
code_unit_runs_
)
{
...
@@ -1276,6 +1277,15 @@ std::vector<Paragraph::TextBox> Paragraph::GetRectsForRange(
...
@@ -1276,6 +1277,15 @@ std::vector<Paragraph::TextBox> Paragraph::GetRectsForRange(
if
(
gp
.
code_units
.
start
>=
start
&&
gp
.
code_units
.
end
<=
end
)
{
if
(
gp
.
code_units
.
start
>=
start
&&
gp
.
code_units
.
end
<=
end
)
{
left
=
std
::
min
(
left
,
static_cast
<
SkScalar
>
(
gp
.
x_pos
.
start
));
left
=
std
::
min
(
left
,
static_cast
<
SkScalar
>
(
gp
.
x_pos
.
start
));
right
=
std
::
max
(
right
,
static_cast
<
SkScalar
>
(
gp
.
x_pos
.
end
));
right
=
std
::
max
(
right
,
static_cast
<
SkScalar
>
(
gp
.
x_pos
.
end
));
}
else
if
(
gp
.
code_units
.
end
==
end
)
{
// Calculate left and right when we are at
// the last position of a combining character.
glyph_length
=
(
gp
.
code_units
.
end
-
gp
.
code_units
.
start
)
-
1
;
if
(
gp
.
code_units
.
start
==
std
::
max
<
size_t
>
(
0
,
(
start
-
glyph_length
)))
{
left
=
std
::
min
(
left
,
static_cast
<
SkScalar
>
(
gp
.
x_pos
.
start
));
right
=
std
::
max
(
right
,
static_cast
<
SkScalar
>
(
gp
.
x_pos
.
end
));
}
}
}
}
}
if
(
left
==
SK_ScalarMax
||
right
==
SK_ScalarMin
)
if
(
left
==
SK_ScalarMax
||
right
==
SK_ScalarMin
)
...
...
third_party/txt/tests/paragraph_unittests.cc
浏览文件 @
302e2e9d
...
@@ -1673,6 +1673,92 @@ TEST_F(ParagraphTest,
...
@@ -1673,6 +1673,92 @@ TEST_F(ParagraphTest,
ASSERT_TRUE
(
Snapshot
());
ASSERT_TRUE
(
Snapshot
());
}
}
TEST_F
(
ParagraphTest
,
GetRectsForRangeIncludeCombiningCharacter
)
{
const
char
*
text
=
"ดีสวัสดีชาวโลกที่น่ารัก"
;
auto
icu_text
=
icu
::
UnicodeString
::
fromUTF8
(
text
);
std
::
u16string
u16_text
(
icu_text
.
getBuffer
(),
icu_text
.
getBuffer
()
+
icu_text
.
length
());
txt
::
ParagraphStyle
paragraph_style
;
paragraph_style
.
max_lines
=
10
;
paragraph_style
.
text_align
=
TextAlign
::
left
;
txt
::
ParagraphBuilder
builder
(
paragraph_style
,
GetTestFontCollection
());
txt
::
TextStyle
text_style
;
text_style
.
font_families
=
std
::
vector
<
std
::
string
>
(
1
,
"Roboto"
);
text_style
.
font_size
=
50
;
text_style
.
letter_spacing
=
1
;
text_style
.
word_spacing
=
5
;
text_style
.
color
=
SK_ColorBLACK
;
text_style
.
height
=
1
;
builder
.
PushStyle
(
text_style
);
builder
.
AddText
(
u16_text
);
builder
.
Pop
();
auto
paragraph
=
builder
.
Build
();
paragraph
->
Layout
(
GetTestCanvasWidth
()
-
100
);
paragraph
->
Paint
(
GetCanvas
(),
0
,
0
);
Paragraph
::
RectHeightStyle
rect_height_style
=
Paragraph
::
RectHeightStyle
::
kTight
;
Paragraph
::
RectWidthStyle
rect_width_style
=
Paragraph
::
RectWidthStyle
::
kTight
;
std
::
vector
<
txt
::
Paragraph
::
TextBox
>
boxes
=
paragraph
->
GetRectsForRange
(
0
,
0
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
0ull
);
// Case when the sentence starts with a combining character
// We should get 0 box for ด because it's already been combined to ดี
boxes
=
paragraph
->
GetRectsForRange
(
0
,
1
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
0ull
);
boxes
=
paragraph
->
GetRectsForRange
(
1
,
2
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
1ull
);
boxes
=
paragraph
->
GetRectsForRange
(
0
,
2
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
1ull
);
// Case when the sentence contains a combining character
// We should get 0 box for ว because it's already been combined to วั
boxes
=
paragraph
->
GetRectsForRange
(
3
,
4
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
0ull
);
boxes
=
paragraph
->
GetRectsForRange
(
4
,
5
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
1ull
);
boxes
=
paragraph
->
GetRectsForRange
(
3
,
5
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
1ull
);
// Case when the sentence contains a combining character that contain 3
// characters We should get 0 box for ท and ที because it's already been
// combined to ที่
boxes
=
paragraph
->
GetRectsForRange
(
14
,
15
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
0ull
);
boxes
=
paragraph
->
GetRectsForRange
(
15
,
16
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
0ull
);
boxes
=
paragraph
->
GetRectsForRange
(
16
,
17
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
1ull
);
boxes
=
paragraph
->
GetRectsForRange
(
14
,
17
,
rect_height_style
,
rect_width_style
);
EXPECT_EQ
(
boxes
.
size
(),
1ull
);
}
TEST_F
(
ParagraphTest
,
DISABLE_ON_WINDOWS
(
GetRectsForRangeCenterParagraph
))
{
TEST_F
(
ParagraphTest
,
DISABLE_ON_WINDOWS
(
GetRectsForRangeCenterParagraph
))
{
const
char
*
text
=
"01234 "
;
// includes ideographic space
const
char
*
text
=
"01234 "
;
// includes ideographic space
// and english space.
// and english space.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录