Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
53a95407
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,发现更多精彩内容 >>
未验证
提交
53a95407
编写于
1月 19, 2018
作者:
J
Jason Simmons
提交者:
GitHub
1月 19, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libtxt: insert styled runs in reverse order if a bidi run is RTL (#4573)
上级
e45eb692
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
27 deletion
+42
-27
third_party/txt/src/txt/paragraph.cc
third_party/txt/src/txt/paragraph.cc
+28
-19
third_party/txt/src/txt/paragraph.h
third_party/txt/src/txt/paragraph.h
+14
-8
未找到文件。
third_party/txt/src/txt/paragraph.cc
浏览文件 @
53a95407
...
...
@@ -331,16 +331,23 @@ bool Paragraph::ComputeBidiRuns(std::vector<BidiRun>* result) {
direction
==
UBIDI_RTL
?
TextDirection
::
rtl
:
TextDirection
::
ltr
;
// Break this bidi run into chunks based on text style.
std
::
vector
<
BidiRun
>
chunks
;
size_t
chunk_start
=
bidi_run_start
;
while
(
chunk_start
<
bidi_run_end
)
{
auto
styled_run_iter
=
styled_run_map
.
upper_bound
(
chunk_start
);
styled_run_iter
--
;
const
StyledRuns
::
Run
&
styled_run
=
styled_run_iter
->
second
;
size_t
chunk_end
=
std
::
min
(
bidi_run_end
,
styled_run
.
end
);
result
->
emplace_back
(
chunk_start
,
chunk_end
,
text_direction
,
styled_run
.
style
);
chunks
.
emplace_back
(
chunk_start
,
chunk_end
,
text_direction
,
styled_run
.
style
);
chunk_start
=
chunk_end
;
}
if
(
text_direction
==
TextDirection
::
ltr
)
{
result
->
insert
(
result
->
end
(),
chunks
.
begin
(),
chunks
.
end
());
}
else
{
result
->
insert
(
result
->
end
(),
chunks
.
rbegin
(),
chunks
.
rend
());
}
}
return
true
;
...
...
@@ -411,10 +418,11 @@ void Paragraph::Layout(double width, bool force) {
// Find the runs comprising this line.
std
::
vector
<
BidiRun
>
line_runs
;
for
(
const
BidiRun
&
bidi_run
:
bidi_runs
)
{
if
(
bidi_run
.
start
<
line_range
.
end
&&
bidi_run
.
end
>
line_range
.
start
)
{
line_runs
.
emplace_back
(
std
::
max
(
bidi_run
.
start
,
line_range
.
start
),
std
::
min
(
bidi_run
.
end
,
line_range
.
end
),
bidi_run
.
direction
,
bidi_run
.
style
);
if
(
bidi_run
.
start
()
<
line_range
.
end
&&
bidi_run
.
end
()
>
line_range
.
start
)
{
line_runs
.
emplace_back
(
std
::
max
(
bidi_run
.
start
(),
line_range
.
start
),
std
::
min
(
bidi_run
.
end
(),
line_range
.
end
),
bidi_run
.
direction
(),
bidi_run
.
style
());
}
}
...
...
@@ -426,17 +434,17 @@ void Paragraph::Layout(double width, bool force) {
for
(
const
BidiRun
&
run
:
line_runs
)
{
minikin
::
FontStyle
font
;
minikin
::
MinikinPaint
minikin_paint
;
GetFontAndMinikinPaint
(
run
.
style
,
&
font
,
&
minikin_paint
);
paint
.
setTextSize
(
run
.
style
.
font_size
);
GetFontAndMinikinPaint
(
run
.
style
()
,
&
font
,
&
minikin_paint
);
paint
.
setTextSize
(
run
.
style
()
.
font_size
);
std
::
shared_ptr
<
minikin
::
FontCollection
>
minikin_font_collection
=
font_collection_
->
GetMinikinFontCollectionForFamily
(
run
.
style
.
font_family
);
run
.
style
()
.
font_family
);
// Lay out this run.
uint16_t
*
text_ptr
=
text_
.
data
();
size_t
text_start
=
run
.
start
;
size_t
text_count
=
run
.
end
-
run
.
start
;
size_t
text_start
=
run
.
start
()
;
size_t
text_count
=
run
.
end
()
-
run
.
start
()
;
// Apply ellipsizing if the run was not completely laid out and this
// is the last line (or lines are unlimited).
...
...
@@ -466,8 +474,8 @@ void Paragraph::Layout(double width, bool force) {
ellipsized_text
.
reserve
(
text_count
-
truncate_count
+
ellipsis
.
length
());
ellipsized_text
.
insert
(
ellipsized_text
.
begin
(),
text_
.
begin
()
+
run
.
start
,
text_
.
begin
()
+
run
.
end
-
truncate_count
);
text_
.
begin
()
+
run
.
start
()
,
text_
.
begin
()
+
run
.
end
()
-
truncate_count
);
ellipsized_text
.
insert
(
ellipsized_text
.
end
(),
ellipsis
.
begin
(),
ellipsis
.
end
());
text_ptr
=
ellipsized_text
.
data
();
...
...
@@ -524,7 +532,7 @@ void Paragraph::Layout(double width, bool force) {
int32_t
current_grapheme
=
grapheme_breaker_
->
current
();
if
(
word_index
<
words
.
size
()
&&
words
[
word_index
].
start
==
run
.
start
+
current_grapheme
)
{
words
[
word_index
].
start
==
run
.
start
()
+
current_grapheme
)
{
word_start_position
=
run_x_offset
+
glyph_x_offset
;
}
...
...
@@ -556,7 +564,7 @@ void Paragraph::Layout(double width, bool force) {
glyph_positions
.
emplace_back
(
run_x_offset
+
glyph_x_offset
,
subglyph_advance
,
run
.
start
+
current_grapheme
,
subglyph_code_unit_counts
[
0
]);
run
.
start
()
+
current_grapheme
,
subglyph_code_unit_counts
[
0
]);
// Compute positions for the additional characters in the ligature.
for
(
size_t
i
=
1
;
i
<
subglyph_code_unit_counts
.
size
();
++
i
)
{
...
...
@@ -568,7 +576,7 @@ void Paragraph::Layout(double width, bool force) {
}
if
(
word_index
<
words
.
size
()
&&
words
[
word_index
].
end
==
run
.
start
+
next_grapheme
)
{
words
[
word_index
].
end
==
run
.
start
()
+
next_grapheme
)
{
if
(
justify_line
)
justify_x_offset
+=
word_gap_width
;
word_index
++
;
...
...
@@ -584,7 +592,7 @@ void Paragraph::Layout(double width, bool force) {
SkPaint
::
FontMetrics
metrics
;
paint
.
getFontMetrics
(
&
metrics
);
paint_records
.
emplace_back
(
run
.
style
,
SkPoint
::
Make
(
run_x_offset
,
0
),
paint_records
.
emplace_back
(
run
.
style
()
,
SkPoint
::
Make
(
run_x_offset
,
0
),
builder
.
make
(),
metrics
,
line_number
,
layout
.
getAdvance
());
...
...
@@ -599,10 +607,11 @@ void Paragraph::Layout(double width, bool force) {
return
a
.
code_units
.
start
<
b
.
code_units
.
start
;
});
code_unit_runs_
.
emplace_back
(
std
::
move
(
code_unit_positions
),
Range
<
size_t
>
(
run
.
start
,
run
.
end
),
std
::
move
(
code_unit_positions
),
Range
<
size_t
>
(
run
.
start
(),
run
.
end
()),
Range
<
double
>
(
glyph_positions
.
front
().
x_pos
.
start
,
glyph_positions
.
back
().
x_pos
.
end
),
line_number
,
metrics
,
run
.
direction
);
line_number
,
metrics
,
run
.
direction
()
);
}
run_x_offset
+=
layout
.
getAdvance
();
...
...
third_party/txt/src/txt/paragraph.h
浏览文件 @
53a95407
...
...
@@ -200,15 +200,21 @@ class Paragraph {
std
::
vector
<
double
>
line_baselines_
;
bool
did_exceed_max_lines_
;
struct
BidiRun
{
class
BidiRun
{
public:
BidiRun
(
size_t
s
,
size_t
e
,
TextDirection
d
,
const
TextStyle
&
st
)
:
start
(
s
),
end
(
e
),
direction
(
d
),
style
(
st
)
{}
const
size_t
start
,
end
;
const
TextDirection
direction
;
const
TextStyle
&
style
;
bool
is_rtl
()
const
{
return
direction
==
TextDirection
::
rtl
;
}
:
start_
(
s
),
end_
(
e
),
direction_
(
d
),
style_
(
&
st
)
{}
size_t
start
()
const
{
return
start_
;
}
size_t
end
()
const
{
return
end_
;
}
TextDirection
direction
()
const
{
return
direction_
;
}
const
TextStyle
&
style
()
const
{
return
*
style_
;
}
bool
is_rtl
()
const
{
return
direction_
==
TextDirection
::
rtl
;
}
private:
size_t
start_
,
end_
;
TextDirection
direction_
;
const
TextStyle
*
style_
;
};
struct
GlyphPosition
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录