Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
2ef8e303
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,发现更多精彩内容 >>
未验证
提交
2ef8e303
编写于
4月 04, 2018
作者:
J
Jason Simmons
提交者:
GitHub
4月 04, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libtxt: render fake bold text if a bold font is not available (#4933)
Fixes
https://github.com/flutter/flutter/issues/16149
上级
48831315
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
27 addition
and
6 deletion
+27
-6
third_party/txt/src/txt/paragraph.cc
third_party/txt/src/txt/paragraph.cc
+27
-6
未找到文件。
third_party/txt/src/txt/paragraph.cc
浏览文件 @
2ef8e303
...
...
@@ -43,10 +43,31 @@
namespace
txt
{
namespace
{
const
sk_sp
<
SkTypeface
>&
GetTypefaceForGlyph
(
const
minikin
::
Layout
&
layout
,
size_t
index
)
{
class
GlyphTypeface
{
public:
GlyphTypeface
(
sk_sp
<
SkTypeface
>
typeface
,
minikin
::
FontFakery
fakery
)
:
typeface_
(
std
::
move
(
typeface
)),
fake_bold_
(
fakery
.
isFakeBold
())
{}
bool
operator
==
(
GlyphTypeface
&
other
)
{
return
other
.
typeface_
.
get
()
==
typeface_
.
get
()
&&
other
.
fake_bold_
==
fake_bold_
;
}
bool
operator
!=
(
GlyphTypeface
&
other
)
{
return
!
(
*
this
==
other
);
}
void
apply
(
SkPaint
&
paint
)
{
paint
.
setTypeface
(
typeface_
);
paint
.
setFakeBoldText
(
fake_bold_
);
}
private:
sk_sp
<
SkTypeface
>
typeface_
;
bool
fake_bold_
;
};
GlyphTypeface
GetGlyphTypeface
(
const
minikin
::
Layout
&
layout
,
size_t
index
)
{
const
FontSkia
*
font
=
static_cast
<
const
FontSkia
*>
(
layout
.
getFont
(
index
));
return
font
->
GetSkTypeface
(
);
return
GlyphTypeface
(
font
->
GetSkTypeface
(),
layout
.
getFakery
(
index
)
);
}
// Return ranges of text that have the same typeface in the layout.
...
...
@@ -56,9 +77,9 @@ std::vector<Paragraph::Range<size_t>> GetLayoutTypefaceRuns(
if
(
layout
.
nGlyphs
()
==
0
)
return
result
;
size_t
run_start
=
0
;
const
SkTypeface
*
run_typeface
=
GetTypefaceForGlyph
(
layout
,
run_start
).
get
(
);
GlyphTypeface
run_typeface
=
GetGlyphTypeface
(
layout
,
run_start
);
for
(
size_t
i
=
1
;
i
<
layout
.
nGlyphs
();
++
i
)
{
const
SkTypeface
*
typeface
=
GetTypefaceForGlyph
(
layout
,
i
).
get
(
);
GlyphTypeface
typeface
=
GetGlyphTypeface
(
layout
,
i
);
if
(
typeface
!=
run_typeface
)
{
result
.
emplace_back
(
run_start
,
i
);
run_start
=
i
;
...
...
@@ -524,7 +545,7 @@ void Paragraph::Layout(double width, bool force) {
for
(
const
Range
<
size_t
>&
glyph_blob
:
glyph_blobs
)
{
std
::
vector
<
GlyphPosition
>
glyph_positions
;
paint
.
setTypeface
(
GetTypefaceForGlyph
(
layout
,
glyph_blob
.
start
)
);
GetGlyphTypeface
(
layout
,
glyph_blob
.
start
).
apply
(
paint
);
const
SkTextBlobBuilder
::
RunBuffer
&
blob_buffer
=
builder
.
allocRunPos
(
paint
,
glyph_blob
.
end
-
glyph_blob
.
start
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录