Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
8a3e9a2b
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,发现更多精彩内容 >>
未验证
提交
8a3e9a2b
编写于
12月 17, 2020
作者:
L
liguisheng
提交者:
GitHub
12月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix crash in FontCollection::init() when FontFamily is empty (#23019)
上级
c608b07d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
39 addition
and
24 deletion
+39
-24
third_party/txt/src/minikin/FontCollection.cpp
third_party/txt/src/minikin/FontCollection.cpp
+26
-20
third_party/txt/src/minikin/FontCollection.h
third_party/txt/src/minikin/FontCollection.h
+5
-3
third_party/txt/src/txt/font_collection.cc
third_party/txt/src/txt/font_collection.cc
+5
-1
third_party/txt/src/txt/paragraph_txt.cc
third_party/txt/src/txt/paragraph_txt.cc
+3
-0
未找到文件。
third_party/txt/src/minikin/FontCollection.cpp
浏览文件 @
8a3e9a2b
...
...
@@ -51,21 +51,20 @@ std::string GetFontLocale(uint32_t langListId) {
return
langs
.
size
()
?
langs
[
0
].
getString
()
:
""
;
}
FontCollection
::
FontCollection
(
std
::
shared_ptr
<
FontFamily
>&&
typeface
)
:
mMaxChar
(
0
)
{
std
::
vector
<
std
::
shared_ptr
<
FontFamily
>>
typefaces
;
typefaces
.
push_back
(
typeface
);
init
(
typefaces
);
std
::
shared_ptr
<
minikin
::
FontCollection
>
FontCollection
::
Create
(
const
std
::
vector
<
std
::
shared_ptr
<
FontFamily
>>&
typefaces
)
{
std
::
shared_ptr
<
minikin
::
FontCollection
>
font_collection
(
new
minikin
::
FontCollection
());
if
(
!
font_collection
||
!
font_collection
->
init
(
typefaces
))
{
return
nullptr
;
}
return
font_collection
;
}
FontCollection
::
FontCollection
(
const
vector
<
std
::
shared_ptr
<
FontFamily
>>&
typefaces
)
:
mMaxChar
(
0
)
{
init
(
typefaces
);
}
FontCollection
::
FontCollection
()
:
mMaxChar
(
0
)
{}
void
FontCollection
::
init
(
const
vector
<
std
::
shared_ptr
<
FontFamily
>>&
typefaces
)
{
bool
FontCollection
::
init
(
const
std
::
vector
<
std
::
shared_ptr
<
FontFamily
>>&
typefaces
)
{
std
::
scoped_lock
_l
(
gMinikinLock
);
mId
=
sNextId
++
;
vector
<
uint32_t
>
lastChar
;
...
...
@@ -91,10 +90,14 @@ void FontCollection::init(
mSupportedAxes
.
insert
(
supportedAxes
.
begin
(),
supportedAxes
.
end
());
}
nTypefaces
=
mFamilies
.
size
();
LOG_ALWAYS_FATAL_IF
(
nTypefaces
==
0
,
"Font collection must have at least one valid typeface"
);
LOG_ALWAYS_FATAL_IF
(
nTypefaces
>
254
,
"Font collection may only have up to 254 font families."
);
if
(
nTypefaces
==
0
)
{
ALOGE
(
"Font collection must have at least one valid typeface."
);
return
false
;
}
if
(
nTypefaces
>
254
)
{
ALOGE
(
"Font collection may only have up to 254 font families."
);
return
false
;
}
size_t
nPages
=
(
mMaxChar
+
kPageMask
)
>>
kLogCharsPerPage
;
// TODO: Use variation selector map for mRanges construction.
// A font can have a glyph for a base code point and variation selector pair
...
...
@@ -122,9 +125,12 @@ void FontCollection::init(
}
range
->
end
=
mFamilyVec
.
size
();
}
// See the comment in Range for more details.
LOG_ALWAYS_FATAL_IF
(
mFamilyVec
.
size
()
>=
0xFFFF
,
"Exceeded the maximum indexable cmap coverage."
);
if
(
mFamilyVec
.
size
()
>=
0xFFFF
)
{
ALOGE
(
"Exceeded the maximum indexable cmap coverage."
);
return
false
;
}
return
true
;
}
// Special scores for the font fallback.
...
...
@@ -566,7 +572,7 @@ std::shared_ptr<FontCollection> FontCollection::createCollectionWithVariation(
}
}
return
std
::
shared_ptr
<
FontCollection
>
(
new
FontCollection
(
families
));
return
FontCollection
::
Create
(
std
::
move
(
families
));
}
uint32_t
FontCollection
::
getId
()
const
{
...
...
third_party/txt/src/minikin/FontCollection.h
浏览文件 @
8a3e9a2b
...
...
@@ -28,10 +28,12 @@
namespace
minikin
{
class
FontCollection
{
private:
explicit
FontCollection
();
public:
explicit
FontCollection
(
static
std
::
shared_ptr
<
minikin
::
FontCollection
>
Create
(
const
std
::
vector
<
std
::
shared_ptr
<
FontFamily
>>&
typefaces
);
explicit
FontCollection
(
std
::
shared_ptr
<
FontFamily
>&&
typeface
);
// libtxt extension: an interface for looking up fallback fonts for characters
// that do not match this collection's font families.
...
...
@@ -94,7 +96,7 @@ class FontCollection {
};
// Initialize the FontCollection.
void
init
(
const
std
::
vector
<
std
::
shared_ptr
<
FontFamily
>>&
typefaces
);
bool
init
(
const
std
::
vector
<
std
::
shared_ptr
<
FontFamily
>>&
typefaces
);
const
std
::
shared_ptr
<
FontFamily
>&
getFamilyForChar
(
uint32_t
ch
,
uint32_t
vs
,
...
...
third_party/txt/src/txt/font_collection.cc
浏览文件 @
8a3e9a2b
...
...
@@ -207,7 +207,11 @@ FontCollection::GetMinikinFontCollectionForFamilies(
}
// Create the minikin font collection.
auto
font_collection
=
std
::
make_shared
<
minikin
::
FontCollection
>
(
std
::
move
(
minikin_families
));
minikin
::
FontCollection
::
Create
(
std
::
move
(
minikin_families
));
if
(
!
font_collection
)
{
font_collections_cache_
[
family_key
]
=
nullptr
;
return
nullptr
;
}
if
(
enable_font_fallback_
)
{
font_collection
->
set_fallback_font_provider
(
std
::
make_unique
<
TxtFallbackFontProvider
>
(
shared_from_this
()));
...
...
third_party/txt/src/txt/paragraph_txt.cc
浏览文件 @
8a3e9a2b
...
...
@@ -807,6 +807,9 @@ void ParagraphTxt::Layout(double width) {
std
::
shared_ptr
<
minikin
::
FontCollection
>
minikin_font_collection
=
GetMinikinFontCollectionForStyle
(
run
.
style
());
if
(
!
minikin_font_collection
)
{
return
;
}
// Lay out this run.
uint16_t
*
text_ptr
=
text_
.
data
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录