Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
2ed1ca37
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
2ed1ca37
编写于
8月 07, 2017
作者:
G
Gary Qian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Break on hyphens without minikin::Hyphenator, tests.
Change-Id: I42e449134ac8c007ffa07d7f56a8c56a26ec47a5
上级
c52d193a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
1 deletion
+49
-1
libs/minikin/WordBreaker.cpp
libs/minikin/WordBreaker.cpp
+2
-1
src/paragraph.h
src/paragraph.h
+1
-0
src/styled_runs.h
src/styled_runs.h
+1
-0
tests/txt/paragraph_unittests.cc
tests/txt/paragraph_unittests.cc
+45
-0
未找到文件。
libs/minikin/WordBreaker.cpp
浏览文件 @
2ed1ca37
...
...
@@ -70,7 +70,8 @@ static bool isBreakValid(const uint16_t* buf, size_t bufEnd, size_t i) {
U16_PREV
(
buf
,
0
,
prev_offset
,
codePoint
);
// Do not break on hard or soft hyphens. These are handled by automatic hyphenation.
if
(
Hyphenator
::
isLineBreakingHyphen
(
codePoint
)
||
codePoint
==
CHAR_SOFT_HYPHEN
)
{
return
false
;
// txt addition: Temporarily always break on hyphen. Changed from false to true.
return
true
;
}
// For Myanmar kinzi sequences, created by <consonant, ASAT, VIRAMA, consonant>. This is to go
// around a bug in ICU line breaking: http://bugs.icu-project.org/trac/ticket/12561. To avoid
...
...
src/paragraph.h
浏览文件 @
2ed1ca37
...
...
@@ -162,6 +162,7 @@ class Paragraph {
FRIEND_TEST
(
RenderTest
,
KernScaleParagraph
);
FRIEND_TEST
(
RenderTest
,
NewlineParagraph
);
FRIEND_TEST
(
RenderTest
,
EmojiParagraph
);
FRIEND_TEST
(
RenderTest
,
HyphenBreakParagraph
);
// Starting data to layout.
std
::
vector
<
uint16_t
>
text_
;
...
...
src/styled_runs.h
浏览文件 @
2ed1ca37
...
...
@@ -76,6 +76,7 @@ class StyledRuns {
FRIEND_TEST
(
RenderTest
,
DISABLED_ArabicParagraph
);
FRIEND_TEST
(
RenderTest
,
LongWordParagraph
);
FRIEND_TEST
(
RenderTest
,
KernParagraph
);
FRIEND_TEST
(
RenderTest
,
HyphenBreakParagraph
);
struct
IndexedRun
{
size_t
style_index
=
0
;
...
...
tests/txt/paragraph_unittests.cc
浏览文件 @
2ed1ca37
...
...
@@ -1439,4 +1439,49 @@ TEST_F(RenderTest, EmojiParagraph) {
ASSERT_TRUE
(
Snapshot
());
}
TEST_F
(
RenderTest
,
HyphenBreakParagraph
)
{
const
char
*
text
=
"A "
"very-very-long-Hyphen-word-to-see-where-this-will-wrap-or-if-it-will-at-"
"all-and-if-it-does-thent-hat-"
"would-be-a-good-thing-because-the-breaking."
;
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
.
break_strategy
=
minikin
::
kBreakStrategy_HighQuality
;
auto
font_collection
=
FontCollection
::
GetFontCollection
(
txt
::
GetFontDir
());
txt
::
ParagraphBuilder
builder
(
paragraph_style
,
&
font_collection
);
txt
::
TextStyle
text_style
;
text_style
.
font_family
=
"Roboto"
;
text_style
.
font_size
=
31
;
text_style
.
letter_spacing
=
0
;
text_style
.
word_spacing
=
0
;
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
()
/
2
);
paragraph
->
Paint
(
GetCanvas
(),
0
,
0
);
ASSERT_TRUE
(
Snapshot
());
ASSERT_EQ
(
paragraph
->
text_
.
size
(),
std
::
string
{
text
}.
length
());
for
(
size_t
i
=
0
;
i
<
u16_text
.
length
();
i
++
)
{
ASSERT_EQ
(
paragraph
->
text_
[
i
],
u16_text
[
i
]);
}
ASSERT_EQ
(
paragraph
->
runs_
.
runs_
.
size
(),
1ull
);
ASSERT_EQ
(
paragraph
->
runs_
.
styles_
.
size
(),
1ull
);
ASSERT_TRUE
(
paragraph
->
runs_
.
styles_
[
0
].
equals
(
text_style
));
ASSERT_EQ
(
paragraph
->
records_
[
0
].
style
().
color
,
text_style
.
color
);
ASSERT_EQ
(
paragraph
->
GetLineCount
(),
5
);
ASSERT_TRUE
(
Snapshot
());
}
}
// namespace txt
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录