Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
af02812f
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
接近 2 年 前同步成功
通知
1
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看板
提交
af02812f
编写于
2月 07, 2018
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[subset] Change hb_subset API to remove hb_subset_face_t
上级
2da0d87e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
36 addition
and
86 deletion
+36
-86
src/hb-subset-plan.cc
src/hb-subset-plan.cc
+9
-3
src/hb-subset-plan.hh
src/hb-subset-plan.hh
+1
-1
src/hb-subset-private.hh
src/hb-subset-private.hh
+0
-10
src/hb-subset.cc
src/hb-subset.cc
+8
-44
src/hb-subset.h
src/hb-subset.h
+6
-19
test/api/test-subset.c
test/api/test-subset.c
+5
-4
util/hb-subset.cc
util/hb-subset.cc
+7
-5
未找到文件。
src/hb-subset-plan.cc
浏览文件 @
af02812f
...
...
@@ -27,6 +27,8 @@
#include "hb-subset-plan.hh"
#include "hb-subset-private.hh"
#include "hb-ot-cmap-table.hh"
hb_bool_t
hb_subset_plan_new_gid_for_old_id
(
hb_subset_plan_t
*
plan
,
hb_codepoint_t
old_gid
,
...
...
@@ -46,14 +48,16 @@ hb_subset_plan_new_gid_for_old_id(hb_subset_plan_t *plan,
}
hb_set_t
*
glyph_ids_to_retain
(
hb_
subset_
face_t
*
face
,
glyph_ids_to_retain
(
hb_face_t
*
face
,
hb_set_t
*
codepoints
)
{
OT
::
cmap
::
accelerator_t
cmap
;
cmap
.
init
(
face
);
hb_codepoint_t
cp
=
-
1
;
hb_set_t
*
gids
=
hb_set_create
();
while
(
hb_set_next
(
codepoints
,
&
cp
))
{
hb_codepoint_t
gid
;
if
(
face
->
cmap
.
get_nominal_glyph
(
cp
,
&
gid
))
{
if
(
cmap
.
get_nominal_glyph
(
cp
,
&
gid
))
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"gid for U+%04X is %d"
,
cp
,
gid
);
hb_set_add
(
gids
,
gid
);
}
else
{
...
...
@@ -63,6 +67,8 @@ glyph_ids_to_retain (hb_subset_face_t *face,
// TODO(Q1) expand with glyphs that make up complex glyphs
// TODO expand with glyphs reached by G*
//
cmap
.
fini
();
return
gids
;
}
...
...
@@ -77,7 +83,7 @@ glyph_ids_to_retain (hb_subset_face_t *face,
* Since: 1.7.5
**/
hb_subset_plan_t
*
hb_subset_plan_create
(
hb_
subset_face_t
*
face
,
hb_subset_plan_create
(
hb_
face_t
*
face
,
hb_subset_profile_t
*
profile
,
hb_subset_input_t
*
input
)
{
...
...
src/hb-subset-plan.hh
浏览文件 @
af02812f
...
...
@@ -40,7 +40,7 @@ struct hb_subset_plan_t {
typedef
struct
hb_subset_plan_t
hb_subset_plan_t
;
hb_subset_plan_t
*
hb_subset_plan_create
(
hb_
subset_face_t
*
face
,
hb_subset_plan_create
(
hb_
face_t
*
face
,
hb_subset_profile_t
*
profile
,
hb_subset_input_t
*
input
);
...
...
src/hb-subset-private.hh
浏览文件 @
af02812f
...
...
@@ -34,8 +34,6 @@
#include "hb-font-private.hh"
#include "hb-ot-cmap-table.hh"
struct
hb_subset_input_t
{
hb_object_header_t
header
;
ASSERT_POD
();
...
...
@@ -43,12 +41,4 @@ struct hb_subset_input_t {
hb_set_t
*
codepoints
;
};
struct
hb_subset_face_t
{
hb_object_header_t
header
;
ASSERT_POD
();
hb_face_t
*
face
;
OT
::
cmap
::
accelerator_t
cmap
;
};
#endif
/* HB_SUBSET_PRIVATE_HH */
src/hb-subset.cc
浏览文件 @
af02812f
...
...
@@ -101,40 +101,6 @@ hb_subset_input_destroy(hb_subset_input_t *subset_input)
free
(
subset_input
);
}
/**
* hb_subset_face_create:
*
* Return value: New subset face.
*
* Since: 1.7.5
**/
hb_subset_face_t
*
hb_subset_face_create
(
hb_face_t
*
face
)
{
if
(
unlikely
(
!
face
))
face
=
hb_face_get_empty
();
hb_subset_face_t
*
subset_face
=
hb_object_create
<
hb_subset_face_t
>
();
subset_face
->
face
=
hb_face_reference
(
face
);
subset_face
->
cmap
.
init
(
face
);
return
subset_face
;
}
/**
* hb_subset_face_destroy:
*
* Since: 1.7.5
**/
void
hb_subset_face_destroy
(
hb_subset_face_t
*
subset_face
)
{
if
(
!
hb_object_destroy
(
subset_face
))
return
;
subset_face
->
cmap
.
fini
();
hb_face_destroy
(
subset_face
->
face
);
free
(
subset_face
);
}
/**
* hb_subset:
...
...
@@ -145,15 +111,14 @@ hb_subset_face_destroy (hb_subset_face_t *subset_face)
*
* Subsets a font according to provided profile and input.
**/
hb_bool_t
hb_subset
(
hb_subset_profile_t
*
profile
,
hb_subset_input_t
*
input
,
hb_subset_face_t
*
face
,
hb_blob_t
**
result
/* OUT */
)
hb_face_t
*
hb_subset
(
hb_face_t
*
source
,
hb_subset_profile_t
*
profile
,
hb_subset_input_t
*
input
)
{
if
(
!
profile
||
!
input
||
!
face
)
return
false
;
if
(
unlikely
(
!
profile
||
!
input
||
!
source
))
return
nullptr
;
hb_subset_plan_t
*
plan
=
hb_subset_plan_create
(
fa
ce
,
profile
,
input
);
hb_subset_plan_t
*
plan
=
hb_subset_plan_create
(
sour
ce
,
profile
,
input
);
hb_codepoint_t
old_gid
=
-
1
;
while
(
hb_set_next
(
plan
->
glyphs_to_retain
,
&
old_gid
))
{
...
...
@@ -174,14 +139,13 @@ hb_subset (hb_subset_profile_t *profile,
bool
success
=
true
;
hb_blob_t
*
glyf_prime
=
nullptr
;
if
(
hb_subset_glyf
(
plan
,
face
->
fa
ce
,
&
glyf_prime
))
{
if
(
hb_subset_glyf
(
plan
,
sour
ce
,
&
glyf_prime
))
{
// TODO: write new glyf to new face.
}
else
{
success
=
false
;
}
hb_blob_destroy
(
glyf_prime
);
*
result
=
hb_face_reference_blob
(
face
->
face
);
hb_subset_plan_destroy
(
plan
);
return
success
;
return
success
?
hb_face_reference
(
source
)
:
nullptr
;
}
src/hb-subset.h
浏览文件 @
af02812f
...
...
@@ -40,7 +40,7 @@ HB_BEGIN_DECLS
typedef
struct
hb_subset_profile_t
hb_subset_profile_t
;
HB_EXTERN
hb_subset_profile_t
*
hb_subset_profile_create
();
hb_subset_profile_create
(
void
);
HB_EXTERN
void
hb_subset_profile_destroy
(
hb_subset_profile_t
*
profile
);
...
...
@@ -58,26 +58,13 @@ hb_subset_input_create (hb_set_t *codepoints);
HB_EXTERN
void
hb_subset_input_destroy
(
hb_subset_input_t
*
subset_input
);
/*
* hb_subset_face_t
* Reusable subset-ready plan for a given face. Threadsafe for multiple
* concurrent subset operations.
*/
typedef
struct
hb_subset_face_t
hb_subset_face_t
;
HB_EXTERN
hb_subset_face_t
*
hb_subset_face_create
(
hb_face_t
*
face
);
HB_EXTERN
void
hb_subset_face_destroy
(
hb_subset_face_t
*
face
);
/* hb_subset() */
HB_EXTERN
hb_bool_t
hb_subset
(
hb_subset_profile_t
*
profile
,
hb_subset_input_t
*
input
,
hb_subset_face_t
*
face
,
hb_blob_t
**
result
/* OUT */
);
HB_EXTERN
hb_face_t
*
hb_subset
(
hb_face_t
*
source
,
hb_subset_profile_t
*
profile
,
hb_subset_input_t
*
input
);
HB_END_DECLS
...
...
test/api/test-subset.c
浏览文件 @
af02812f
...
...
@@ -43,19 +43,20 @@ test_subset (void)
hb_subset_profile_t
*
profile
=
hb_subset_profile_create
();
hb_subset_input_t
*
input
=
hb_subset_input_create
(
hb_set_get_empty
());
hb_subset_face_t
*
subset_face
=
hb_subset_face_create
(
face
);
hb_blob_t
*
output
;
g_assert
(
hb_subset
(
profile
,
input
,
subset_face
,
&
output
));
hb_face_t
*
out_face
=
hb_subset
(
face
,
profile
,
input
);
g_assert
(
out_face
);
g_assert
(
out_face
!=
hb_face_get_empty
());
hb_blob_t
*
output
=
hb_face_reference_blob
(
out_face
);
unsigned
int
output_length
;
const
char
*
output_data
=
hb_blob_get_data
(
output
,
&
output_length
);
g_assert_cmpmem
(
test_data
,
4
,
output_data
,
output_length
);
hb_blob_destroy
(
output
);
hb_subset_face_destroy
(
subset_face
);
hb_subset_input_destroy
(
input
);
hb_subset_profile_destroy
(
profile
);
hb_face_destroy
(
out_face
);
hb_face_destroy
(
face
);
hb_blob_destroy
(
font_blob
);
}
...
...
util/hb-subset.cc
浏览文件 @
af02812f
...
...
@@ -93,19 +93,21 @@ struct subset_consumer_t
hb_subset_profile_t
*
subset_profile
=
hb_subset_profile_create
();
hb_subset_input_t
*
subset_input
=
hb_subset_input_create
(
codepoints
);
hb_face_t
*
face
=
hb_font_get_face
(
font
);
hb_subset_face_t
*
subset_face
=
hb_subset_face_create
(
face
);
hb_blob_t
*
result
=
nullptr
;
failed
=
!
(
hb_subset
(
subset_profile
,
subset_input
,
subset_face
,
&
result
)
&&
write_file
(
options
.
output_file
,
result
));
hb_face_t
*
new_face
=
hb_subset
(
face
,
subset_profile
,
subset_input
);
hb_blob_t
*
result
=
hb_face_reference_blob
(
new_face
);
failed
=
!
hb_blob_get_length
(
result
);
if
(
!
failed
)
write_file
(
options
.
output_file
,
result
);
hb_subset_profile_destroy
(
subset_profile
);
hb_subset_input_destroy
(
subset_input
);
hb_set_destroy
(
codepoints
);
hb_subset_face_destroy
(
subset_face
);
hb_blob_destroy
(
result
);
hb_face_destroy
(
new_face
);
hb_font_destroy
(
font
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录