Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
1e669f08
E
engine
项目概览
qq_34031325
/
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,发现更多精彩内容 >>
未验证
提交
1e669f08
编写于
12月 14, 2017
作者:
J
Jason Simmons
提交者:
GitHub
12月 14, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libtxt: fix the paragraph level text direction passed to the ICU bidi API (#4455)
Also includes some cleanup of the BidiRun struct
上级
e0d19e28
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
23 deletion
+23
-23
third_party/txt/src/txt/paragraph.cc
third_party/txt/src/txt/paragraph.cc
+11
-11
third_party/txt/src/txt/paragraph.h
third_party/txt/src/txt/paragraph.h
+12
-12
未找到文件。
third_party/txt/src/txt/paragraph.cc
浏览文件 @
1e669f08
...
...
@@ -257,9 +257,7 @@ bool Paragraph::ComputeLineBreaks() {
return
true
;
}
bool
Paragraph
::
ComputeBidiRuns
()
{
bidi_runs_
.
clear
();
bool
Paragraph
::
ComputeBidiRuns
(
std
::
vector
<
BidiRun
>*
result
)
{
auto
ubidi_closer
=
[](
UBiDi
*
b
)
{
ubidi_close
(
b
);
};
std
::
unique_ptr
<
UBiDi
,
decltype
(
ubidi_closer
)
>
bidi
(
ubidi_open
(),
ubidi_closer
);
...
...
@@ -267,8 +265,8 @@ bool Paragraph::ComputeBidiRuns() {
return
false
;
UBiDiLevel
paraLevel
=
(
paragraph_style_
.
text_direction
==
TextDirection
::
rtl
)
?
UBIDI_
DEFAULT_
RTL
:
UBIDI_
DEFAULT_
LTR
;
?
UBIDI_RTL
:
UBIDI_LTR
;
UErrorCode
status
=
U_ZERO_ERROR
;
ubidi_setPara
(
bidi
.
get
(),
reinterpret_cast
<
const
UChar
*>
(
text_
.
data
()),
text_
.
size
(),
paraLevel
,
nullptr
,
&
status
);
...
...
@@ -326,8 +324,8 @@ bool Paragraph::ComputeBidiRuns() {
styled_run_iter
--
;
const
StyledRuns
::
Run
&
styled_run
=
styled_run_iter
->
second
;
size_t
chunk_end
=
std
::
min
(
bidi_run_end
,
styled_run
.
end
);
bidi_runs_
.
emplace_back
(
chunk_start
,
chunk_end
,
text_direction
,
styled_run
.
style
);
result
->
emplace_back
(
chunk_start
,
chunk_end
,
text_direction
,
styled_run
.
style
);
chunk_start
=
chunk_end
;
}
}
...
...
@@ -344,10 +342,12 @@ void Paragraph::Layout(double width, bool force) {
width_
=
width
;
if
(
!
ComputeLineBreaks
())
{
if
(
!
ComputeLineBreaks
())
return
;
std
::
vector
<
BidiRun
>
bidi_runs
;
if
(
!
ComputeBidiRuns
(
&
bidi_runs
))
return
;
}
ComputeBidiRuns
();
SkPaint
paint
;
paint
.
setAntiAlias
(
true
);
...
...
@@ -389,7 +389,7 @@ 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
_
)
{
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
),
...
...
third_party/txt/src/txt/paragraph.h
浏览文件 @
1e669f08
...
...
@@ -78,16 +78,6 @@ class Paragraph {
}
};
struct
BidiRun
{
BidiRun
(
size_t
s
,
size_t
e
,
TextDirection
d
,
const
TextStyle
&
st
)
:
start
(
s
),
end
(
e
),
direction
(
d
),
style
(
st
)
{}
size_t
start
,
end
;
TextDirection
direction
;
const
TextStyle
&
style
;
bool
is_rtl
()
const
{
return
direction
==
TextDirection
::
rtl
;
}
};
// Minikin Layout doLayout() and LineBreaker addStyleRun() has an
// O(N^2) (according to benchmarks) time complexity where N is the total
// number of characters. However, this is not significant for reasonably sized
...
...
@@ -188,7 +178,6 @@ class Paragraph {
// Starting data to layout.
std
::
vector
<
uint16_t
>
text_
;
StyledRuns
runs_
;
std
::
vector
<
BidiRun
>
bidi_runs_
;
ParagraphStyle
paragraph_style_
;
std
::
shared_ptr
<
FontCollection
>
font_collection_
;
...
...
@@ -210,6 +199,17 @@ class Paragraph {
std
::
vector
<
double
>
line_baselines_
;
bool
did_exceed_max_lines_
;
struct
BidiRun
{
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
;
}
};
struct
GlyphPosition
{
Range
<
size_t
>
code_units
;
Range
<
double
>
x_pos
;
...
...
@@ -284,7 +284,7 @@ class Paragraph {
bool
ComputeLineBreaks
();
// Break the text into runs based on LTR/RTL text direction.
bool
ComputeBidiRuns
();
bool
ComputeBidiRuns
(
std
::
vector
<
BidiRun
>*
result
);
// Calculate the starting X offset of a line based on the line's width and
// alignment.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录