Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
e8ef0e62
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e8ef0e62
编写于
5月 07, 2019
作者:
G
Garret Rieger
提交者:
Behdad Esfahbod
5月 08, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[subset] WIP convert hdmx subsetting to use iterators.
上级
d5decf9b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
93 deletion
+51
-93
src/hb-ot-hdmx-table.hh
src/hb-ot-hdmx-table.hh
+51
-70
test/api/test-subset-hdmx.c
test/api/test-subset-hdmx.c
+0
-23
未找到文件。
src/hb-ot-hdmx-table.hh
浏览文件 @
e8ef0e62
...
...
@@ -41,71 +41,30 @@ namespace OT {
struct
DeviceRecord
{
struct
SubsetView
{
const
DeviceRecord
*
source_device_record
;
unsigned
int
sizeDeviceRecord
;
hb_subset_plan_t
*
subset_plan
;
void
init
(
const
DeviceRecord
*
source_device_record
,
unsigned
int
sizeDeviceRecord
,
hb_subset_plan_t
*
subset_plan
)
{
this
->
source_device_record
=
source_device_record
;
this
->
sizeDeviceRecord
=
sizeDeviceRecord
;
this
->
subset_plan
=
subset_plan
;
}
unsigned
int
len
()
const
{
return
this
->
subset_plan
->
num_output_glyphs
();
}
const
HBUINT8
*
operator
[]
(
unsigned
int
new_gid
)
const
{
if
(
unlikely
(
new_gid
>=
len
()))
return
nullptr
;
hb_codepoint_t
old_gid
;
if
(
!
this
->
subset_plan
->
old_gid_for_new_gid
(
new_gid
,
&
old_gid
))
return
&
Null
(
HBUINT8
);
if
(
old_gid
>=
sizeDeviceRecord
-
DeviceRecord
::
min_size
)
return
nullptr
;
return
&
(
this
->
source_device_record
->
widthsZ
[
old_gid
]);
}
};
static
unsigned
int
get_size
(
unsigned
int
count
)
static
unsigned
int
get_size
(
unsigned
count
)
{
return
hb_ceil_to_4
(
min_size
+
count
*
HBUINT8
::
static_size
);
}
bool
serialize
(
hb_serialize_context_t
*
c
,
const
SubsetView
&
subset_view
)
template
<
typename
Iterator
>
bool
serialize
(
hb_serialize_context_t
*
c
,
unsigned
pixelSize
,
Iterator
it
)
{
TRACE_SERIALIZE
(
this
);
unsigned
int
size
=
get_size
(
subset_view
.
len
());
if
(
unlikely
(
!
c
->
allocate_size
<
DeviceRecord
>
(
size
)))
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"Couldn't allocate enough space for DeviceRecord: %d."
,
size
);
return_trace
(
false
);
}
this
->
pixelSize
=
subset_view
.
source_device_record
->
pixelSize
;
this
->
maxWidth
=
subset_view
.
source_device_record
->
maxWidth
;
for
(
unsigned
int
i
=
0
;
i
<
subset_view
.
len
();
i
++
)
{
const
HBUINT8
*
width
=
subset_view
[
i
];
if
(
!
width
)
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"HDMX width for new gid %d is missing."
,
i
);
return_trace
(
false
);
}
widthsZ
[
i
]
=
*
width
;
}
unsigned
length
=
it
.
len
();
if
(
unlikely
(
!
c
->
extend
(
*
this
,
length
)))
return_trace
(
false
);
this
->
pixelSize
=
pixelSize
;
this
->
maxWidth
=
+
it
|
hb_reduce
(
hb_max
,
0u
);
+
it
|
hb_sink
(
widthsZ
.
as_array
(
length
));
return_trace
(
true
);
}
bool
sanitize
(
hb_sanitize_context_t
*
c
,
unsigned
int
sizeDeviceRecord
)
const
bool
sanitize
(
hb_sanitize_context_t
*
c
,
unsigned
sizeDeviceRecord
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)
&&
...
...
@@ -135,26 +94,25 @@ struct hdmx
return
StructAtOffset
<
DeviceRecord
>
(
&
this
->
firstDeviceRecord
,
i
*
sizeDeviceRecord
);
}
bool
serialize
(
hb_serialize_context_t
*
c
,
const
hdmx
*
source_hdmx
,
hb_subset_plan_t
*
plan
)
template
<
typename
Iterator
>
bool
serialize
(
hb_serialize_context_t
*
c
,
unsigned
version
,
Iterator
it
)
{
TRACE_SERIALIZE
(
this
);
if
(
unlikely
(
!
c
->
extend_min
((
*
this
))))
return_trace
(
false
);
this
->
version
=
source_hdmx
->
version
;
this
->
numRecords
=
source_hdmx
->
numRecords
;
this
->
sizeDeviceRecord
=
DeviceRecord
::
get_size
(
plan
->
num_output_glyphs
());
for
(
unsigned
int
i
=
0
;
i
<
source_hdmx
->
numRecords
;
i
++
)
{
DeviceRecord
::
SubsetView
subset_view
;
subset_view
.
init
(
&
(
*
source_hdmx
)[
i
],
source_hdmx
->
sizeDeviceRecord
,
plan
);
this
->
version
=
version
;
this
->
numRecords
=
it
.
len
();
this
->
sizeDeviceRecord
=
it
?
DeviceRecord
::
get_size
((
*
it
).
second
.
len
())
:
DeviceRecord
::
get_size
(
0
);
if
(
!
c
->
start_embed
<
DeviceRecord
>
()
->
serialize
(
c
,
subset_view
))
return_trace
(
false
);
}
using
pair_t
=
decltype
(
*
it
);
+
it
|
hb_apply
([
&
]
(
const
pair_t
&
_
)
{
c
->
start_embed
<
DeviceRecord
>
()
->
serialize
(
c
,
_
.
first
,
_
.
second
);
});
return_trace
(
true
);
return_trace
(
c
->
successful
);
}
...
...
@@ -165,10 +123,33 @@ struct hdmx
hdmx
*
hdmx_prime
=
c
->
serializer
->
start_embed
<
hdmx
>
();
if
(
unlikely
(
!
hdmx_prime
))
return_trace
(
false
);
hdmx_prime
->
serialize
(
c
->
serializer
,
this
,
c
->
plan
);
auto
it
=
+
hb_iota
((
unsigned
)
numRecords
)
|
hb_map
([
&
]
(
unsigned
_
)
{
const
DeviceRecord
*
device_record
=
&
StructAtOffset
<
DeviceRecord
>
(
&
firstDeviceRecord
,
_
*
sizeDeviceRecord
);
auto
row
=
+
hb_iota
(
c
->
plan
->
num_output_glyphs
())
|
hb_map
(
c
->
plan
->
reverse_glyph_map
)
|
hb_map
([
=
]
(
hb_codepoint_t
_
)
{
if
(
c
->
plan
->
is_empty_glyph
(
_
))
return
Null
(
HBUINT8
);
return
device_record
->
widthsZ
.
as_array
(
get_num_glyphs
())
[
_
];
})
;
return
hb_pair
((
unsigned
)
device_record
->
pixelSize
,
+
row
);
});
hdmx_prime
->
serialize
(
c
->
serializer
,
version
,
it
);
return_trace
(
true
);
}
unsigned
get_num_glyphs
()
const
{
return
sizeDeviceRecord
-
DeviceRecord
::
min_size
;
}
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
...
...
test/api/test-subset-hdmx.c
浏览文件 @
e8ef0e62
...
...
@@ -91,28 +91,6 @@ test_subset_hdmx_invalid (void)
hb_face_destroy
(
face
);
}
static
void
test_subset_hdmx_fails_sanitize
(
void
)
{
hb_face_t
*
face
=
hb_test_open_font_file
(
"../fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5609911946838016"
);
hb_subset_input_t
*
input
=
hb_subset_input_create_or_fail
();
hb_set_t
*
codepoints
=
hb_subset_input_unicode_set
(
input
);
hb_face_t
*
subset
;
hb_set_add
(
codepoints
,
'a'
);
hb_set_add
(
codepoints
,
'b'
);
hb_set_add
(
codepoints
,
'c'
);
subset
=
hb_subset
(
face
,
input
);
g_assert
(
subset
);
g_assert
(
subset
==
hb_face_get_empty
());
hb_subset_input_destroy
(
input
);
hb_face_destroy
(
subset
);
hb_face_destroy
(
face
);
}
static
void
test_subset_hdmx_noop
(
void
)
{
...
...
@@ -140,7 +118,6 @@ main (int argc, char **argv)
hb_test_add
(
test_subset_hdmx_simple_subset
);
hb_test_add
(
test_subset_hdmx_multiple_device_records
);
hb_test_add
(
test_subset_hdmx_invalid
);
hb_test_add
(
test_subset_hdmx_fails_sanitize
);
hb_test_add
(
test_subset_hdmx_noop
);
return
hb_test_run
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录