Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
aac7d962
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aac7d962
编写于
2月 08, 2018
作者:
G
Garret Rieger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply per table subsetting while building the new face in hb_subset.
上级
2f941053
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
65 addition
and
41 deletion
+65
-41
src/hb-subset-glyf.cc
src/hb-subset-glyf.cc
+1
-0
src/hb-subset.cc
src/hb-subset.cc
+64
-41
未找到文件。
src/hb-subset-glyf.cc
浏览文件 @
aac7d962
...
@@ -101,6 +101,7 @@ _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
...
@@ -101,6 +101,7 @@ _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
// TODO(grieger): Subset loca simultaneously.
// TODO(grieger): Subset loca simultaneously.
// TODO(grieger): Don't fail on bad offsets, just dump them.
// TODO(grieger): Don't fail on bad offsets, just dump them.
// TODO(grieger): Support short loca output.
// TODO(grieger): Support short loca output.
// TODO(grieger): Add a extra loca entry at the end.
unsigned
int
glyf_prime_size
;
unsigned
int
glyf_prime_size
;
unsigned
int
loca_prime_size
;
unsigned
int
loca_prime_size
;
...
...
src/hb-subset.cc
浏览文件 @
aac7d962
...
@@ -253,6 +253,52 @@ hb_subset_face_add_table (hb_face_t *face, hb_tag_t tag, hb_blob_t *blob)
...
@@ -253,6 +253,52 @@ hb_subset_face_add_table (hb_face_t *face, hb_tag_t tag, hb_blob_t *blob)
return
true
;
return
true
;
}
}
bool
_subset_glyf
(
hb_subset_plan_t
*
plan
,
hb_face_t
*
source
,
hb_face_t
*
dest
)
{
hb_blob_t
*
glyf_prime
=
nullptr
;
hb_blob_t
*
loca_prime
=
nullptr
;
bool
success
=
true
;
// TODO(grieger): Migrate to subset function on the table like cmap.
if
(
hb_subset_glyf_and_loca
(
plan
,
source
,
&
glyf_prime
,
&
loca_prime
))
{
hb_subset_face_add_table
(
dest
,
HB_OT_TAG_glyf
,
glyf_prime
);
hb_subset_face_add_table
(
dest
,
HB_OT_TAG_loca
,
loca_prime
);
}
else
{
success
=
false
;
}
hb_blob_destroy
(
loca_prime
);
hb_blob_destroy
(
glyf_prime
);
return
success
;
}
bool
_subset_table
(
hb_subset_plan_t
*
plan
,
hb_face_t
*
source
,
hb_tag_t
tag
,
hb_blob_t
*
table_blob
,
hb_face_t
*
dest
)
{
// TODO (grieger): Handle updating the head table (loca format + num glyphs)
switch
(
tag
)
{
case
HB_OT_TAG_glyf
:
return
_subset_glyf
(
plan
,
source
,
dest
);
case
HB_OT_TAG_loca
:
// SKIP loca, it's handle by the glyf subsetter.
return
true
;
case
HB_OT_TAG_cmap
:
// TODO(rsheeter): remove hb_subset_face_add_table
// once cmap subsetting works.
hb_subset_face_add_table
(
dest
,
tag
,
table_blob
);
return
subset
<
const
OT
::
cmap
>
(
plan
,
source
,
dest
);
default:
// Default action, copy table as is.
hb_subset_face_add_table
(
dest
,
tag
,
table_blob
);
return
true
;
}
}
/**
/**
* hb_subset:
* hb_subset:
* @source: font face data to be subset.
* @source: font face data to be subset.
...
@@ -270,12 +316,20 @@ hb_subset (hb_face_t *source,
...
@@ -270,12 +316,20 @@ hb_subset (hb_face_t *source,
hb_subset_plan_t
*
plan
=
hb_subset_plan_create
(
source
,
profile
,
input
);
hb_subset_plan_t
*
plan
=
hb_subset_plan_create
(
source
,
profile
,
input
);
hb_face_t
*
face
=
hb_subset_face_create
();
hb_codepoint_t
old_gid
=
-
1
;
while
(
hb_set_next
(
plan
->
glyphs_to_retain
,
&
old_gid
))
{
hb_codepoint_t
new_gid
;
if
(
hb_subset_plan_new_gid_for_old_id
(
plan
,
old_gid
,
&
new_gid
))
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"Remap %d : %d"
,
old_gid
,
new_gid
);
}
else
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"Remap %d : DOOM! No new ID"
,
old_gid
);
}
}
/* Copy tables to new face. */
hb_face_t
*
dest
=
hb_subset_face_create
();
{
hb_tag_t
table_tags
[
32
];
hb_tag_t
table_tags
[
32
];
unsigned
int
offset
=
0
,
count
;
unsigned
int
offset
=
0
,
count
;
bool
success
=
true
;
do
{
do
{
count
=
ARRAY_LENGTH
(
table_tags
);
count
=
ARRAY_LENGTH
(
table_tags
);
hb_face_get_table_tags
(
source
,
offset
,
&
count
,
table_tags
);
hb_face_get_table_tags
(
source
,
offset
,
&
count
,
table_tags
);
...
@@ -283,44 +337,13 @@ hb_subset (hb_face_t *source,
...
@@ -283,44 +337,13 @@ hb_subset (hb_face_t *source,
{
{
hb_tag_t
tag
=
table_tags
[
i
];
hb_tag_t
tag
=
table_tags
[
i
];
hb_blob_t
*
blob
=
hb_face_reference_table
(
source
,
tag
);
hb_blob_t
*
blob
=
hb_face_reference_table
(
source
,
tag
);
hb_subset_face_add_table
(
face
,
tag
,
blob
);
success
=
success
&&
_subset_table
(
plan
,
source
,
tag
,
blob
,
dest
);
hb_blob_destroy
(
blob
);
hb_blob_destroy
(
blob
);
}
}
}
while
(
count
==
ARRAY_LENGTH
(
table_tags
));
}
while
(
count
==
ARRAY_LENGTH
(
table_tags
));
}
hb_codepoint_t
old_gid
=
-
1
;
while
(
hb_set_next
(
plan
->
glyphs_to_retain
,
&
old_gid
))
{
hb_codepoint_t
new_gid
;
if
(
hb_subset_plan_new_gid_for_old_id
(
plan
,
old_gid
,
&
new_gid
))
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"Remap %d : %d"
,
old_gid
,
new_gid
);
}
else
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"Remap %d : DOOM! No new ID"
,
old_gid
);
}
}
// TODO:
// - Create initial header + table directory
// - Loop through the set of tables to be kept:
// - Perform table specific subsetting if defined.
// - copy the table into the output.
// - Fix header + table directory.
bool
success
=
true
;
hb_face_t
*
dest
=
nullptr
;
// TODO allocate dest
hb_blob_t
*
glyf_prime
=
nullptr
;
hb_blob_t
*
loca_prime
=
nullptr
;
if
(
hb_subset_glyf_and_loca
(
plan
,
source
,
&
glyf_prime
,
&
loca_prime
))
{
// TODO: write new glyf and loca to new face.
}
else
{
success
=
false
;
}
hb_blob_destroy
(
glyf_prime
);
success
=
success
&&
subset
<
const
OT
::
cmap
>
(
plan
,
source
,
dest
);
hb_subset_plan_destroy
(
plan
);
return
face
;
// TODO(grieger): Remove once basic subsetting is working + tests updated.
hb_face_destroy
(
dest
);
hb_face_reference
(
source
);
return
success
?
source
:
nullptr
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录