Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
d5b33f2f
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
d5b33f2f
编写于
2月 13, 2018
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[subset] hb_subset_input_t changes
上级
28e63a12
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
153 addition
and
63 deletion
+153
-63
src/Makefile.sources
src/Makefile.sources
+1
-0
src/hb-face.h
src/hb-face.h
+0
-1
src/hb-set.cc
src/hb-set.cc
+7
-7
src/hb-subset-input.cc
src/hb-subset-input.cc
+109
-0
src/hb-subset-plan.cc
src/hb-subset-plan.cc
+1
-1
src/hb-subset-private.hh
src/hb-subset-private.hh
+10
-1
src/hb-subset.cc
src/hb-subset.cc
+3
-37
src/hb-subset.h
src/hb-subset.h
+11
-1
test/api/test-subset-glyf.c
test/api/test-subset-glyf.c
+2
-2
test/api/test-subset.c
test/api/test-subset.c
+1
-1
util/hb-subset.cc
util/hb-subset.cc
+8
-12
未找到文件。
src/Makefile.sources
浏览文件 @
d5b33f2f
...
...
@@ -185,6 +185,7 @@ HB_ICU_headers = hb-icu.h
HB_SUBSET_sources
=
\
hb-subset.cc
\
hb-subset-glyf.cc
\
hb-subset-input.cc
\
hb-subset-plan.cc
\
$(NULL)
...
...
src/hb-face.h
浏览文件 @
d5b33f2f
...
...
@@ -71,7 +71,6 @@ hb_face_set_user_data (hb_face_t *face,
hb_destroy_func_t
destroy
,
hb_bool_t
replace
);
HB_EXTERN
void
*
hb_face_get_user_data
(
hb_face_t
*
face
,
hb_user_data_key_t
*
key
);
...
...
src/hb-set.cc
浏览文件 @
d5b33f2f
...
...
@@ -50,6 +50,13 @@ hb_set_create (void)
return
set
;
}
static
const
hb_set_t
_hb_set_nil
=
{
HB_OBJECT_HEADER_STATIC
,
true
,
/* in_error */
{
0
}
/* elts */
};
/**
* hb_set_get_empty:
*
...
...
@@ -60,13 +67,6 @@ hb_set_create (void)
hb_set_t
*
hb_set_get_empty
(
void
)
{
static
const
hb_set_t
_hb_set_nil
=
{
HB_OBJECT_HEADER_STATIC
,
true
,
/* in_error */
{
0
}
/* elts */
};
return
const_cast
<
hb_set_t
*>
(
&
_hb_set_nil
);
}
...
...
src/hb-subset-input.cc
0 → 100644
浏览文件 @
d5b33f2f
/*
* Copyright © 2018 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Google Author(s): Garret Rieger, Rod Sheeter, Behdad Esfahbod
*/
#include "hb-object-private.hh"
#include "hb-subset-private.hh"
#include "hb-set-private.hh"
/**
* hb_subset_input_create:
*
* Return value: New subset input.
*
* Since: 1.8.0
**/
hb_subset_input_t
*
hb_subset_input_create
(
void
)
{
hb_subset_input_t
*
input
=
hb_object_create
<
hb_subset_input_t
>
();
/* Unlike libharfbuzz, in this lib we return nullptr
* in case of allocation failure. */
if
(
unlikely
(
!
input
))
return
nullptr
;
input
->
unicodes
=
hb_set_create
();
input
->
glyphs
=
hb_set_create
();
return
input
;
}
/**
* hb_subset_input_reference: (skip)
* @subset_input: a subset_input.
*
*
*
* Return value:
*
* Since: 1.8.0
**/
hb_subset_input_t
*
hb_subset_input_reference
(
hb_subset_input_t
*
subset_input
)
{
return
hb_object_reference
(
subset_input
);
}
/**
* hb_subset_input_destroy:
* @subset_input: a subset_input.
*
* Since: 1.8.0
**/
void
hb_subset_input_destroy
(
hb_subset_input_t
*
subset_input
)
{
if
(
!
hb_object_destroy
(
subset_input
))
return
;
hb_set_destroy
(
subset_input
->
unicodes
);
hb_set_destroy
(
subset_input
->
glyphs
);
free
(
subset_input
);
}
/**
* hb_subset_input_unicode_set:
* @subset_input: a subset_input.
*
* Since: 1.8.0
**/
HB_EXTERN
hb_set_t
*
hb_subset_input_unicode_set
(
hb_subset_input_t
*
subset_input
)
{
return
subset_input
->
unicodes
;
}
/**
* hb_subset_input_glyph_set:
* @subset_input: a subset_input.
*
* Since: 1.8.0
**/
HB_EXTERN
hb_set_t
*
hb_subset_input_glyph_set
(
hb_subset_input_t
*
subset_input
)
{
return
subset_input
->
glyphs
;
}
src/hb-subset-plan.cc
浏览文件 @
d5b33f2f
...
...
@@ -140,7 +140,7 @@ hb_subset_plan_create (hb_face_t *face,
plan
->
gids_to_retain
.
init
();
plan
->
gids_to_retain_sorted
.
init
();
_populate_codepoints
(
input
->
codepoint
s
,
plan
->
codepoints
);
_populate_codepoints
(
input
->
unicode
s
,
plan
->
codepoints
);
_populate_gids_to_retain
(
face
,
plan
->
codepoints
,
plan
->
gids_to_retain
,
...
...
src/hb-subset-private.hh
浏览文件 @
d5b33f2f
...
...
@@ -38,7 +38,16 @@ struct hb_subset_input_t {
hb_object_header_t
header
;
ASSERT_POD
();
hb_set_t
*
codepoints
;
hb_set_t
*
unicodes
;
hb_set_t
*
glyphs
;
/* TODO
*
* features
* lookups
* nameIDs
* ...
*/
};
#endif
/* HB_SUBSET_PRIVATE_HH */
src/hb-subset.cc
浏览文件 @
d5b33f2f
...
...
@@ -21,14 +21,12 @@
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Google Author(s): Garret Rieger, Rod Sheeter
* Google Author(s): Garret Rieger, Rod Sheeter
, Behdad Esfahbod
*/
#include "hb-object-private.hh"
#include "hb-open-type-private.hh"
#include "hb-private.hh"
#include "hb-subset-glyf.hh"
#include "hb-subset-private.hh"
#include "hb-subset-plan.hh"
...
...
@@ -53,7 +51,7 @@ struct hb_subset_profile_t {
*
* Return value: New profile with default settings.
*
* Since: 1.
7.5
* Since: 1.
8.0
**/
hb_subset_profile_t
*
hb_subset_profile_create
()
...
...
@@ -64,7 +62,7 @@ hb_subset_profile_create ()
/**
* hb_subset_profile_destroy:
*
* Since: 1.
7.5
* Since: 1.
8.0
**/
void
hb_subset_profile_destroy
(
hb_subset_profile_t
*
profile
)
...
...
@@ -74,38 +72,6 @@ hb_subset_profile_destroy (hb_subset_profile_t *profile)
free
(
profile
);
}
/**
* hb_subset_input_create:
*
* Return value: New subset input.
*
* Since: 1.7.5
**/
hb_subset_input_t
*
hb_subset_input_create
(
hb_set_t
*
codepoints
)
{
if
(
unlikely
(
!
codepoints
))
codepoints
=
hb_set_get_empty
();
hb_subset_input_t
*
input
=
hb_object_create
<
hb_subset_input_t
>
();
input
->
codepoints
=
hb_set_reference
(
codepoints
);
return
input
;
}
/**
* hb_subset_input_destroy:
*
* Since: 1.7.5
**/
void
hb_subset_input_destroy
(
hb_subset_input_t
*
subset_input
)
{
if
(
!
hb_object_destroy
(
subset_input
))
return
;
hb_set_destroy
(
subset_input
->
codepoints
);
free
(
subset_input
);
}
template
<
typename
TableType
>
static
hb_blob_t
*
_subset
(
hb_subset_plan_t
*
plan
,
hb_face_t
*
source
)
...
...
src/hb-subset.h
浏览文件 @
d5b33f2f
...
...
@@ -47,17 +47,27 @@ hb_subset_profile_destroy (hb_subset_profile_t *profile);
/*
* hb_subset_input_t
*
* Things that change based on the input. Characters to keep, etc.
*/
typedef
struct
hb_subset_input_t
hb_subset_input_t
;
HB_EXTERN
hb_subset_input_t
*
hb_subset_input_create
(
hb_set_t
*
codepoints
);
hb_subset_input_create
(
void
);
HB_EXTERN
hb_subset_input_t
*
hb_subset_input_reference
(
hb_subset_input_t
*
subset_input
);
HB_EXTERN
void
hb_subset_input_destroy
(
hb_subset_input_t
*
subset_input
);
HB_EXTERN
hb_set_t
*
hb_subset_input_unicode_set
(
hb_subset_input_t
*
subset_input
);
HB_EXTERN
hb_set_t
*
hb_subset_input_glyph_set
(
hb_subset_input_t
*
subset_input
);
/* hb_subset() */
...
...
test/api/test-subset-glyf.c
浏览文件 @
d5b33f2f
...
...
@@ -94,9 +94,9 @@ test_subset_glyf (void)
hb_face_t
*
face_abc_subset
;
hb_blob_t
*
glyf_expected_blob
;
hb_blob_t
*
glyf_actual_blob
;
hb_set_t
*
codepoints
=
hb_set_create
();
hb_subset_profile_t
*
profile
=
hb_subset_profile_create
();
hb_subset_input_t
*
input
=
hb_subset_input_create
(
codepoints
);
hb_subset_input_t
*
input
=
hb_subset_input_create
();
hb_set_t
*
codepoints
=
hb_set_reference
(
hb_subset_input_unicode_set
(
input
));
g_assert
(
face_abc
);
g_assert
(
face_ac
);
...
...
test/api/test-subset.c
浏览文件 @
d5b33f2f
...
...
@@ -43,7 +43,7 @@ test_subset (void)
hb_face_t
*
face
=
hb_face_create
(
font_blob
,
0
);
hb_subset_profile_t
*
profile
=
hb_subset_profile_create
();
hb_subset_input_t
*
input
=
hb_subset_input_create
(
hb_set_get_empty
()
);
hb_subset_input_t
*
input
=
hb_subset_input_create
();
hb_face_t
*
out_face
=
hb_subset
(
face
,
profile
,
input
);
g_assert
(
out_face
);
...
...
util/hb-subset.cc
浏览文件 @
d5b33f2f
...
...
@@ -37,13 +37,13 @@
struct
subset_consumer_t
{
subset_consumer_t
(
option_parser_t
*
parser
)
:
failed
(
false
),
options
(
parser
),
font
(
nullptr
),
codepoints
(
nullptr
)
{}
:
failed
(
false
),
options
(
parser
),
font
(
nullptr
),
input
(
nullptr
)
{}
void
init
(
hb_buffer_t
*
buffer_
,
const
font_options_t
*
font_opts
)
{
font
=
hb_font_reference
(
font_opts
->
get_font
());
codepoints
=
hb_set_create
();
input
=
hb_subset_input_create
();
}
void
consume_line
(
const
char
*
text
,
...
...
@@ -51,14 +51,13 @@ struct subset_consumer_t
const
char
*
text_before
,
const
char
*
text_after
)
{
// text appears to be a g_string when set by --unicodes
// TODO(Q1) are gunichar and hbcodepoint_t interchangeable?
// TODO(Q1) does this only get called with at least 1 codepoint?
hb_set_t
*
codepoints
=
hb_subset_input_unicode_set
(
input
);
gchar
*
c
=
(
gchar
*
)
text
;
do
{
gunichar
cp
=
g_utf8_get_char
(
c
);
hb_codepoint_t
hb_cp
=
cp
;
// TODO(Q1) is this safe?
hb_set_add
(
codepoints
,
hb_cp
);
hb_codepoint_t
hb_cp
=
cp
;
hb_set_add
(
codepoints
,
hb_cp
);
}
while
((
c
=
g_utf8_find_next_char
(
c
,
text
+
text_len
))
!=
nullptr
);
}
...
...
@@ -90,12 +89,10 @@ struct subset_consumer_t
void
finish
(
const
font_options_t
*
font_opts
)
{
// TODO(Q1) check for errors from creates and such
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_face_t
*
new_face
=
hb_subset
(
face
,
subset_profile
,
subset_
input
);
hb_face_t
*
new_face
=
hb_subset
(
face
,
subset_profile
,
input
);
hb_blob_t
*
result
=
hb_face_reference_blob
(
new_face
);
failed
=
!
hb_blob_get_length
(
result
);
...
...
@@ -103,8 +100,7 @@ struct subset_consumer_t
write_file
(
options
.
output_file
,
result
);
hb_subset_profile_destroy
(
subset_profile
);
hb_subset_input_destroy
(
subset_input
);
hb_set_destroy
(
codepoints
);
hb_subset_input_destroy
(
input
);
hb_blob_destroy
(
result
);
hb_face_destroy
(
new_face
);
hb_font_destroy
(
font
);
...
...
@@ -116,7 +112,7 @@ struct subset_consumer_t
private:
output_options_t
options
;
hb_font_t
*
font
;
hb_s
et_t
*
codepoints
;
hb_s
ubset_input_t
*
input
;
};
int
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录