Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
53a783bb
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,发现更多精彩内容 >>
未验证
提交
53a783bb
编写于
2月 09, 2021
作者:
J
Jason Simmons
提交者:
GitHub
2月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libtxt: apply the justify offset to glyph positions instead of paint records (#24219)
上级
a9dd80f0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
6 deletion
+57
-6
third_party/txt/src/txt/paragraph_txt.cc
third_party/txt/src/txt/paragraph_txt.cc
+8
-6
third_party/txt/tests/paragraph_unittests.cc
third_party/txt/tests/paragraph_unittests.cc
+49
-0
未找到文件。
third_party/txt/src/txt/paragraph_txt.cc
浏览文件 @
53a783bb
...
...
@@ -909,8 +909,9 @@ void ParagraphTxt::Layout(double width) {
blob_buffer
.
glyphs
[
blob_index
]
=
layout
.
getGlyphId
(
glyph_index
);
size_t
pos_index
=
blob_index
*
2
;
blob_buffer
.
pos
[
pos_index
]
=
layout
.
getX
(
glyph_index
)
+
justify_x_offset_delta
;
blob_buffer
.
pos
[
pos_index
]
=
layout
.
getX
(
glyph_index
)
+
justify_x_offset
+
justify_x_offset_delta
;
blob_buffer
.
pos
[
pos_index
+
1
]
=
layout
.
getY
(
glyph_index
);
if
(
glyph_index
==
cluster_start_glyph_index
)
...
...
@@ -1028,10 +1029,11 @@ void ParagraphTxt::Layout(double width) {
Range
<
double
>
record_x_pos
(
glyph_positions
.
front
().
x_pos
.
start
-
run_x_offset
,
glyph_positions
.
back
().
x_pos
.
end
-
run_x_offset
);
paint_records
.
emplace_back
(
run
.
style
(),
SkPoint
::
Make
(
run_x_offset
+
justify_x_offset
,
0
),
builder
.
make
(),
*
metrics
,
line_number
,
record_x_pos
.
start
,
record_x_pos
.
end
,
run
.
is_ghost
(),
run
.
placeholder_run
());
paint_records
.
emplace_back
(
run
.
style
(),
SkPoint
::
Make
(
run_x_offset
,
0
),
builder
.
make
(),
*
metrics
,
line_number
,
record_x_pos
.
start
,
record_x_pos
.
end
,
run
.
is_ghost
(),
run
.
placeholder_run
());
justify_x_offset
+=
justify_x_offset_delta
;
line_glyph_positions
.
insert
(
line_glyph_positions
.
end
(),
...
...
third_party/txt/tests/paragraph_unittests.cc
浏览文件 @
53a783bb
...
...
@@ -2461,6 +2461,55 @@ TEST_F(ParagraphTest, LINUX_ONLY(JustifyRTLNewLine)) {
}
}
TEST_F
(
ParagraphTest
,
DISABLE_ON_WINDOWS
(
JustifyPlaceholder
))
{
const
char
*
text1
=
"A "
;
auto
icu_text1
=
icu
::
UnicodeString
::
fromUTF8
(
text1
);
std
::
u16string
u16_text1
(
icu_text1
.
getBuffer
(),
icu_text1
.
getBuffer
()
+
icu_text1
.
length
());
txt
::
PlaceholderRun
placeholder_run
(
60
,
60
,
PlaceholderAlignment
::
kBaseline
,
TextBaseline
::
kAlphabetic
,
0
);
const
char
*
text2
=
" B CCCCC"
;
auto
icu_text2
=
icu
::
UnicodeString
::
fromUTF8
(
text2
);
std
::
u16string
u16_text2
(
icu_text2
.
getBuffer
(),
icu_text2
.
getBuffer
()
+
icu_text2
.
length
());
txt
::
ParagraphStyle
paragraph_style
;
paragraph_style
.
text_align
=
TextAlign
::
justify
;
txt
::
ParagraphBuilderTxt
builder
(
paragraph_style
,
GetTestFontCollection
());
txt
::
TextStyle
text_style
;
text_style
.
font_families
=
std
::
vector
<
std
::
string
>
(
1
,
"Ahem"
);
text_style
.
font_size
=
20
;
text_style
.
decoration_color
=
SK_ColorBLACK
;
builder
.
PushStyle
(
text_style
);
builder
.
AddText
(
u16_text1
);
builder
.
AddPlaceholder
(
placeholder_run
);
builder
.
AddText
(
u16_text2
);
builder
.
Pop
();
auto
paragraph
=
BuildParagraph
(
builder
);
paragraph
->
Layout
(
200
);
Paragraph
::
RectHeightStyle
rect_height_style
=
Paragraph
::
RectHeightStyle
::
kTight
;
Paragraph
::
RectWidthStyle
rect_width_style
=
Paragraph
::
RectWidthStyle
::
kTight
;
// Check location of placeholder at the center of the line.
std
::
vector
<
txt
::
Paragraph
::
TextBox
>
boxes
=
paragraph
->
GetRectsForRange
(
2
,
3
,
rect_height_style
,
rect_width_style
);
EXPECT_FLOAT_EQ
(
boxes
[
0
].
rect
.
left
(),
70
);
// Check location of character B at the end of the line.
boxes
=
paragraph
->
GetRectsForRange
(
4
,
5
,
rect_height_style
,
rect_width_style
);
EXPECT_FLOAT_EQ
(
boxes
[
0
].
rect
.
left
(),
180
);
}
TEST_F
(
ParagraphTest
,
DISABLE_ON_WINDOWS
(
LeadingSpaceRTL
))
{
const
char
*
text
=
" leading space"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录