Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
1330edc4
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,发现更多精彩内容 >>
提交
1330edc4
编写于
2月 12, 2018
作者:
R
Rod Sheeter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use functions to get new gids. Avoid 0; fonttools drops it from cmap.
上级
1639bdd3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
12 deletion
+44
-12
src/hb-ot-cmap-table.hh
src/hb-ot-cmap-table.hh
+18
-6
src/hb-subset-plan.cc
src/hb-subset-plan.cc
+20
-5
src/hb-subset-plan.hh
src/hb-subset-plan.hh
+5
-0
src/hb-subset.cc
src/hb-subset.cc
+1
-1
未找到文件。
src/hb-ot-cmap-table.hh
浏览文件 @
1330edc4
...
@@ -522,18 +522,25 @@ struct cmap
...
@@ -522,18 +522,25 @@ struct cmap
encodingRecord
.
sanitize
(
c
,
this
));
encodingRecord
.
sanitize
(
c
,
this
));
}
}
inline
void
populate_groups
(
hb_prealloced_array_t
<
hb_codepoint_t
>
&
codepoints
,
inline
hb_bool_t
populate_groups
(
hb_subset_plan_t
*
plan
,
hb_prealloced_array_t
<
CmapSubtableLongGroup
>
*
groups
)
const
hb_prealloced_array_t
<
CmapSubtableLongGroup
>
*
groups
)
const
{
{
CmapSubtableLongGroup
*
group
=
nullptr
;
CmapSubtableLongGroup
*
group
=
nullptr
;
for
(
unsigned
int
i
=
0
;
i
<
codepoints
.
len
;
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
plan
->
codepoints
.
len
;
i
++
)
{
hb_codepoint_t
cp
=
codepoints
[
i
];
hb_codepoint_t
cp
=
plan
->
codepoints
[
i
];
if
(
!
group
||
cp
-
1
!=
group
->
endCharCode
)
if
(
!
group
||
cp
-
1
!=
group
->
endCharCode
)
{
{
group
=
groups
->
push
();
group
=
groups
->
push
();
group
->
startCharCode
.
set
(
cp
);
group
->
startCharCode
.
set
(
cp
);
group
->
endCharCode
.
set
(
cp
);
group
->
endCharCode
.
set
(
cp
);
group
->
glyphID
.
set
(
i
);
// index in codepoints is new gid
hb_codepoint_t
new_gid
;
if
(
unlikely
(
!
hb_subset_plan_new_gid_for_codepoint
(
plan
,
cp
,
&
new_gid
)))
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"Unable to find new gid for %04x"
,
cp
);
return
false
;
}
group
->
glyphID
.
set
(
new_gid
);
}
else
}
else
{
{
group
->
endCharCode
.
set
(
cp
);
group
->
endCharCode
.
set
(
cp
);
...
@@ -545,6 +552,8 @@ struct cmap
...
@@ -545,6 +552,8 @@ struct cmap
CmapSubtableLongGroup
&
group
=
(
*
groups
)[
i
];
CmapSubtableLongGroup
&
group
=
(
*
groups
)[
i
];
DEBUG_MSG
(
SUBSET
,
nullptr
,
" %d: U+%04X-U+%04X, gid %d-%d"
,
i
,
(
uint32_t
)
group
.
startCharCode
,
(
uint32_t
)
group
.
endCharCode
,
(
uint32_t
)
group
.
glyphID
,
(
uint32_t
)
group
.
glyphID
+
((
uint32_t
)
group
.
endCharCode
-
(
uint32_t
)
group
.
startCharCode
));
DEBUG_MSG
(
SUBSET
,
nullptr
,
" %d: U+%04X-U+%04X, gid %d-%d"
,
i
,
(
uint32_t
)
group
.
startCharCode
,
(
uint32_t
)
group
.
endCharCode
,
(
uint32_t
)
group
.
glyphID
,
(
uint32_t
)
group
.
glyphID
+
((
uint32_t
)
group
.
endCharCode
-
(
uint32_t
)
group
.
startCharCode
));
}
}
return
true
;
}
}
hb_bool_t
_subset
(
hb_prealloced_array_t
<
CmapSubtableLongGroup
>
&
groups
,
hb_bool_t
_subset
(
hb_prealloced_array_t
<
CmapSubtableLongGroup
>
&
groups
,
...
@@ -600,7 +609,10 @@ struct cmap
...
@@ -600,7 +609,10 @@ struct cmap
{
{
hb_auto_array_t
<
CmapSubtableLongGroup
>
groups
;
hb_auto_array_t
<
CmapSubtableLongGroup
>
groups
;
populate_groups
(
plan
->
codepoints
,
&
groups
);
if
(
unlikely
(
!
populate_groups
(
plan
,
&
groups
)))
{
return
nullptr
;
}
// We now know how big our blob needs to be
// We now know how big our blob needs to be
// TODO use APIs from the structs to get size?
// TODO use APIs from the structs to get size?
...
...
src/hb-subset-plan.cc
浏览文件 @
1330edc4
...
@@ -38,6 +38,24 @@ _hb_codepoint_t_cmp (const void *pa, const void *pb)
...
@@ -38,6 +38,24 @@ _hb_codepoint_t_cmp (const void *pa, const void *pb)
return
a
<
b
?
-
1
:
a
>
b
?
+
1
:
0
;
return
a
<
b
?
-
1
:
a
>
b
?
+
1
:
0
;
}
}
hb_bool_t
hb_subset_plan_new_gid_for_codepoint
(
hb_subset_plan_t
*
plan
,
hb_codepoint_t
codepoint
,
hb_codepoint_t
*
new_gid
)
{
// TODO actual map, delete this garbage.
for
(
unsigned
int
i
=
0
;
i
<
plan
->
codepoints
.
len
;
i
++
)
{
if
(
plan
->
codepoints
[
i
]
!=
codepoint
)
continue
;
if
(
!
hb_subset_plan_new_gid_for_old_id
(
plan
,
plan
->
gids_to_retain
[
i
],
new_gid
))
{
return
false
;
}
return
true
;
}
return
false
;
}
hb_bool_t
hb_bool_t
hb_subset_plan_new_gid_for_old_id
(
hb_subset_plan_t
*
plan
,
hb_subset_plan_new_gid_for_old_id
(
hb_subset_plan_t
*
plan
,
hb_codepoint_t
old_gid
,
hb_codepoint_t
old_gid
,
...
@@ -46,7 +64,8 @@ hb_subset_plan_new_gid_for_old_id (hb_subset_plan_t *plan,
...
@@ -46,7 +64,8 @@ hb_subset_plan_new_gid_for_old_id (hb_subset_plan_t *plan,
// the index in old_gids is the new gid; only up to codepoints.len are valid
// the index in old_gids is the new gid; only up to codepoints.len are valid
for
(
unsigned
int
i
=
0
;
i
<
plan
->
gids_to_retain_sorted
.
len
;
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
plan
->
gids_to_retain_sorted
.
len
;
i
++
)
{
if
(
plan
->
gids_to_retain_sorted
[
i
]
==
old_gid
)
{
if
(
plan
->
gids_to_retain_sorted
[
i
]
==
old_gid
)
{
*
new_gid
=
i
;
// +1: assign new gids from 1..N; 0 is special
*
new_gid
=
i
+
1
;
return
true
;
return
true
;
}
}
}
}
...
@@ -109,10 +128,6 @@ _populate_gids_to_retain (hb_face_t *face,
...
@@ -109,10 +128,6 @@ _populate_gids_to_retain (hb_face_t *face,
*
(
old_gids_sorted
.
push
())
=
0
;
*
(
old_gids_sorted
.
push
())
=
0
;
old_gids_sorted
.
qsort
(
_hb_codepoint_t_cmp
);
old_gids_sorted
.
qsort
(
_hb_codepoint_t_cmp
);
for
(
unsigned
int
i
=
0
;
i
<
codepoints
.
len
;
i
++
)
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
" U+%04X, old_gid %d, new_gid %d"
,
codepoints
[
i
],
old_gids
[
i
],
i
);
}
// TODO(Q1) expand with glyphs that make up complex glyphs
// TODO(Q1) expand with glyphs that make up complex glyphs
// TODO expand with glyphs reached by G*
// TODO expand with glyphs reached by G*
//
//
...
...
src/hb-subset-plan.hh
浏览文件 @
1330edc4
...
@@ -55,6 +55,11 @@ hb_subset_plan_new_gid_for_old_id(hb_subset_plan_t *plan,
...
@@ -55,6 +55,11 @@ hb_subset_plan_new_gid_for_old_id(hb_subset_plan_t *plan,
hb_codepoint_t
old_gid
,
hb_codepoint_t
old_gid
,
hb_codepoint_t
*
new_gid
/* OUT */
);
hb_codepoint_t
*
new_gid
/* OUT */
);
HB_INTERNAL
hb_bool_t
hb_subset_plan_new_gid_for_codepoint
(
hb_subset_plan_t
*
plan
,
hb_codepoint_t
codepont
,
hb_codepoint_t
*
new_gid
/* OUT */
);
HB_INTERNAL
void
HB_INTERNAL
void
hb_subset_plan_destroy
(
hb_subset_plan_t
*
plan
);
hb_subset_plan_destroy
(
hb_subset_plan_t
*
plan
);
...
...
src/hb-subset.cc
浏览文件 @
1330edc4
...
@@ -124,7 +124,7 @@ _subset (hb_subset_plan_t *plan, hb_face_t *source)
...
@@ -124,7 +124,7 @@ _subset (hb_subset_plan_t *plan, hb_face_t *source)
hb_blob_destroy
(
source_blob
);
hb_blob_destroy
(
source_blob
);
hb_tag_t
tag
=
TableType
::
tableTag
;
hb_tag_t
tag
=
TableType
::
tableTag
;
DEBUG_MSG
(
SUBSET
,
nullptr
,
"
Subset %c%c%c%c
%s"
,
HB_UNTAG
(
tag
),
result
?
"success"
:
"FAILED!"
);
DEBUG_MSG
(
SUBSET
,
nullptr
,
"
OT::%c%c%c%c::subset
%s"
,
HB_UNTAG
(
tag
),
result
?
"success"
:
"FAILED!"
);
return
result
;
return
result
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录