Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
4009a05c
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看板
提交
4009a05c
编写于
11月 17, 2018
作者:
E
Ebrahim Byagowi
提交者:
Behdad Esfahbod
11月 25, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[feat] Address Behdad comments
上级
19b60255
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
423 addition
and
466 deletion
+423
-466
src/hb-aat-layout-feat-table.hh
src/hb-aat-layout-feat-table.hh
+77
-37
src/hb-aat-layout.cc
src/hb-aat-layout.cc
+12
-2
src/hb-aat.h
src/hb-aat.h
+289
-384
test/api/test-aat-layout.c
test/api/test-aat-layout.c
+45
-43
未找到文件。
src/hb-aat-layout-feat-table.hh
浏览文件 @
4009a05c
...
...
@@ -45,6 +45,13 @@ struct SettingName
return_trace
(
likely
(
c
->
check_struct
(
this
)));
}
inline
hb_aat_layout_feature_setting_t
get_setting
()
const
{
return
(
hb_aat_layout_feature_setting_t
)
(
unsigned
int
)
setting
;
}
inline
hb_ot_name_id_t
get_name_id
()
const
{
return
(
hb_ot_name_id_t
)
nameIndex
;
}
protected:
HBUINT16
setting
;
/* The setting. */
NameID
nameIndex
;
/* The name table index for the setting's name. */
public:
...
...
@@ -57,10 +64,10 @@ struct FeatureName
{
static
int
cmp
(
const
void
*
key_
,
const
void
*
entry_
)
{
hb_aat_
feature_type_t
key
=
*
(
hb_aat_feature_type
_t
*
)
key_
;
hb_aat_
layout_feature_setting_t
key
=
*
(
hb_aat_layout_feature_setting
_t
*
)
key_
;
const
FeatureName
*
entry
=
(
const
FeatureName
*
)
entry_
;
return
key
<
entry
->
feature
?
-
1
:
key
>
entry
->
feature
?
1
:
key
>
entry
->
feature
?
+
1
:
0
;
}
...
...
@@ -78,48 +85,59 @@ struct FeatureName
* as the default. */
};
inline
unsigned
int
get_settings
(
const
feat
*
feat
,
hb_
bool_t
*
is_exclusive
,
unsigned
int
start_offset
,
unsigned
int
*
records_
count
,
hb_aat_
feature_option_record_t
*
records_buffer
)
const
inline
unsigned
int
get_settings
(
const
feat
*
feat
,
hb_
aat_layout_feature_setting_t
*
default_setting
,
unsigned
int
start_offset
,
unsigned
int
*
count
,
hb_aat_
layout_feature_setting_t
*
settings
)
const
{
bool
exclusive
=
featureFlags
&
Exclusive
;
bool
not_default
=
featureFlags
&
NotDefault
;
if
(
is_exclusive
)
*
is_exclusive
=
exclusive
;
const
UnsizedArrayOf
<
SettingName
>&
settings
=
feat
+
settingTable
;
unsigned
int
len
=
0
;
const
UnsizedArrayOf
<
SettingName
>&
settings_table
=
feat
+
settingTableZ
;
unsigned
int
settings_count
=
nSettings
;
if
(
records_count
&&
records_buffer
)
if
(
count
&&
*
count
)
{
len
=
MIN
(
settings_count
-
start_offset
,
*
records_
count
);
unsigned
int
len
=
MIN
(
settings_count
-
start_offset
,
*
count
);
for
(
unsigned
int
i
=
0
;
i
<
len
;
i
++
)
{
records_buffer
[
i
].
is_default
=
exclusive
&&
not_default
&&
i
+
start_offset
==
(
featureFlags
&
IndexMask
);
records_buffer
[
i
].
name_id
=
settings
[
start_offset
+
i
].
nameIndex
;
records_buffer
[
i
].
setting
=
settings
[
start_offset
+
i
].
setting
;
}
if
(
exclusive
&&
!
not_default
&&
start_offset
==
0
&&
len
!=
0
)
records_buffer
[
0
].
is_default
=
true
;
settings
[
i
]
=
settings_table
[
start_offset
+
i
].
get_setting
();
*
count
=
len
;
}
if
(
default_setting
)
{
unsigned
int
index
=
(
featureFlags
&
NotDefault
)
?
featureFlags
&
IndexMask
:
0
;
*
default_setting
=
((
featureFlags
&
Exclusive
)
&&
index
<
settings_count
)
?
settings_table
[
index
].
get_setting
()
:
HB_AAT_LAYOUT_SELECTOR_INVALID
;
}
if
(
is_exclusive
)
*
is_exclusive
=
exclusive
;
if
(
records_count
)
*
records_count
=
len
;
return
settings_count
;
}
inline
hb_aat_layout_feature_type_t
get_feature_type
()
const
{
return
(
hb_aat_layout_feature_type_t
)
(
unsigned
int
)
feature
;
}
inline
hb_ot_name_id_t
get_feature_name_id
()
const
{
return
(
hb_ot_name_id_t
)
nameIndex
;
}
inline
hb_ot_name_id_t
get_feature_setting_name_id
(
const
feat
*
feat
,
hb_aat_layout_feature_setting_t
setting
)
const
{
const
UnsizedArrayOf
<
SettingName
>&
settings_table
=
feat
+
settingTableZ
;
for
(
unsigned
int
i
=
0
;
i
<
nSettings
;
i
++
)
if
(
settings_table
[
i
].
get_setting
()
==
setting
)
return
settings_table
[
i
].
get_name_id
();
return
HB_OT_NAME_ID_INVALID
;
}
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
,
const
void
*
base
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)
&&
(
base
+
settingTable
).
sanitize
(
c
,
nSettings
)));
(
base
+
settingTable
Z
).
sanitize
(
c
,
nSettings
)));
}
protected:
HBUINT16
feature
;
/* Feature type. */
HBUINT16
nSettings
;
/* The number of records in the setting name array. */
LOffsetTo
<
UnsizedArrayOf
<
SettingName
>
,
false
>
settingTable
;
/* Offset in bytes from the beginning of this table to
settingTable
Z
;
/* Offset in bytes from the beginning of this table to
* this feature's setting name array. The actual type of
* record this offset refers to will depend on the
* exclusivity value, as described below. */
...
...
@@ -135,9 +153,24 @@ struct feat
{
static
const
hb_tag_t
tableTag
=
HB_AAT_TAG_feat
;
inline
const
FeatureName
&
get_feature
(
hb_aat_feature_type_t
key
)
const
inline
unsigned
int
get_features
(
unsigned
int
start_offset
,
unsigned
int
*
count
,
hb_aat_layout_feature_type_t
*
features
)
const
{
const
FeatureName
*
feature
=
(
FeatureName
*
)
hb_bsearch
(
&
key
,
&
names
,
unsigned
int
feature_count
=
featureNameCount
;
if
(
count
&&
*
count
)
{
unsigned
int
len
=
MIN
(
feature_count
-
start_offset
,
*
count
);
for
(
unsigned
int
i
=
0
;
i
<
len
;
i
++
)
features
[
i
]
=
namesZ
[
i
+
start_offset
].
get_feature_type
();
*
count
=
len
;
}
return
featureNameCount
;
}
inline
const
FeatureName
&
get_feature
(
hb_aat_layout_feature_type_t
key
)
const
{
const
FeatureName
*
feature
=
(
FeatureName
*
)
hb_bsearch
(
&
key
,
&
namesZ
,
FeatureName
::
static_size
,
sizeof
(
FeatureName
),
FeatureName
::
cmp
);
...
...
@@ -145,21 +178,28 @@ struct feat
return
feature
?
*
feature
:
Null
(
FeatureName
);
}
inline
unsigned
int
get_settings
(
hb_aat_feature_type_t
key
,
hb_bool_t
*
is_exclusive
,
unsigned
int
start_offset
,
unsigned
int
*
records_count
,
hb_aat_feature_option_record_t
*
records_buffer
)
const
inline
hb_ot_name_id_t
get_feature_name_id
(
hb_aat_layout_feature_type_t
feature
)
const
{
return
get_feature
(
feature
).
get_feature_name_id
();
}
inline
hb_ot_name_id_t
get_feature_setting_name_id
(
hb_aat_layout_feature_type_t
feature
,
hb_aat_layout_feature_setting_t
setting
)
const
{
return
get_feature
(
feature
).
get_feature_setting_name_id
(
this
,
setting
);
}
inline
unsigned
int
get_settings
(
hb_aat_layout_feature_type_t
key
,
hb_aat_layout_feature_setting_t
*
default_setting
,
unsigned
int
start_offset
,
unsigned
int
*
count
,
hb_aat_layout_feature_setting_t
*
settings
)
const
{
return
get_feature
(
key
).
get_settings
(
this
,
is_exclusive
,
start_offset
,
records_count
,
records_buffer
);
return
get_feature
(
key
).
get_settings
(
this
,
default_setting
,
start_offset
,
count
,
settings
);
}
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)
&&
names
.
sanitize
(
c
,
featureNameCount
,
this
)));
names
Z
.
sanitize
(
c
,
featureNameCount
,
this
)));
}
protected:
...
...
@@ -170,7 +210,7 @@ struct feat
HBUINT16
reserved1
;
/* Reserved (set to zero). */
HBUINT32
reserved2
;
/* Reserved (set to zero). */
UnsizedArrayOf
<
FeatureName
>
names
;
/* The feature name array. */
names
Z
;
/* The feature name array. */
public:
DEFINE_SIZE_STATIC
(
24
);
};
...
...
src/hb-aat-layout.cc
浏览文件 @
4009a05c
...
...
@@ -314,10 +314,15 @@ hb_aat_layout_get_features (hb_face_t *face,
return
face
->
table
.
feat
->
get_features
(
start_offset
,
count
,
features
);
}
/**
* hb_aat_layout_get_feature_name_id:
*
* Since: REPLACEME
*/
hb_ot_name_id_t
hb_aat_layout_get_feature_name_id
(
hb_face_t
*
face
,
hb_aat_layout_feature_type_t
feature
)
{
return
HB_OT_NAME_ID_INVALID
;
}
{
return
face
->
table
.
feat
->
get_feature_name_id
(
feature
)
;
}
/**
* hb_aat_layout_get_feature_settings:
...
...
@@ -336,8 +341,13 @@ hb_aat_layout_get_feature_settings (hb_face_t *face,
start_offset
,
count
,
settings
);
}
/**
* hb_aat_layout_get_feature_setting_name_id:
*
* Since: REPLACEME
*/
hb_ot_name_id_t
hb_aat_layout_get_feature_setting_name_id
(
hb_face_t
*
face
,
hb_aat_layout_feature_type_t
feature
,
hb_aat_layout_feature_setting_t
setting
)
{
return
HB_OT_NAME_ID_INVALID
;
}
{
return
face
->
table
.
feat
->
get_feature_setting_name_id
(
feature
,
setting
)
;
}
src/hb-aat.h
浏览文件 @
4009a05c
此差异已折叠。
点击以展开。
test/api/test-aat-layout.c
浏览文件 @
4009a05c
...
...
@@ -36,65 +36,67 @@ static hb_face_t *sbix;
static
void
test_aat_get_features
(
void
)
{
// hb_aat_layout_feature_record_t records[3];
// unsigned int record_count = 3;
// g_assert_cmpuint (11, ==, hb_aat_layout_get_features (face, 0, &record_count, records));
// g_assert_cmpuint (1, ==, records[0].feature);
// g_assert_cmpuint (258, ==, records[0].name_id);
// g_assert_cmpuint (3, ==, records[1].feature);
// g_assert_cmpuint (261, ==, records[1].name_id);
// g_assert_cmpuint (6, ==, records[2].feature);
// g_assert_cmpuint (265, ==, records[2].name_id);
hb_aat_layout_feature_type_t
features
[
3
];
unsigned
int
count
=
3
;
g_assert_cmpuint
(
11
,
==
,
hb_aat_layout_get_features
(
face
,
0
,
&
count
,
features
));
g_assert_cmpuint
(
1
,
==
,
features
[
0
]);
g_assert_cmpuint
(
3
,
==
,
features
[
1
]);
g_assert_cmpuint
(
6
,
==
,
features
[
2
]);
g_assert_cmpuint
(
258
,
==
,
hb_aat_layout_get_feature_name_id
(
face
,
features
[
0
]));
g_assert_cmpuint
(
261
,
==
,
hb_aat_layout_get_feature_name_id
(
face
,
features
[
1
]));
g_assert_cmpuint
(
265
,
==
,
hb_aat_layout_get_feature_name_id
(
face
,
features
[
2
]));
}
static
void
test_aat_get_feature_settings
(
void
)
{
// hb_aat_layout_feature_setting_t default_setting;
// hb_aat_layout_feature_type_selector_t records[3];
// unsigned int count = 3;
// g_assert_cmpuint (4, ==, hb_aat_layout_get_feature_settings (face, (hb_aat_layout_feature_type_t) 18,
// &default_setting, 0, &count, records));
// g_assert_cmpuint (3, ==, count);
// g_assert_cmpuint (0, ==, default_setting);
hb_aat_layout_feature_setting_t
default_setting
;
hb_aat_layout_feature_setting_t
settings
[
3
];
unsigned
int
count
=
3
;
// g_assert_cmpuint (0, ==, records[0].setting);
// g_assert_cmpuint (294, ==, records[0].name_id);
g_assert_cmpuint
(
4
,
==
,
hb_aat_layout_get_feature_settings
(
face
,
HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
,
&
default_setting
,
0
,
&
count
,
settings
));
g_assert_cmpuint
(
3
,
==
,
count
);
g_assert_cmpuint
(
0
,
==
,
default_setting
);
// g_assert_cmpuint (1, ==, records[1].setting
);
// g_assert_cmpuint (295, ==, records[1].name_id
);
g_assert_cmpuint
(
0
,
==
,
settings
[
0
]
);
g_assert_cmpuint
(
294
,
==
,
hb_aat_layout_get_feature_setting_name_id
(
face
,
HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
,
settings
[
0
])
);
// g_assert_cmpuint (2, ==, records[2].setting
);
// g_assert_cmpuint (296, ==, records[2].name_id
);
g_assert_cmpuint
(
1
,
==
,
settings
[
1
]
);
g_assert_cmpuint
(
295
,
==
,
hb_aat_layout_get_feature_setting_name_id
(
face
,
HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
,
settings
[
1
])
);
// count = 3;
// g_assert_cmpuint (4, ==, hb_aat_layout_get_feature_settings (face, (hb_aat_layout_feature_type_t) 18,
// &default_setting, 3, &count, records));
// g_assert_cmpuint (1, ==, count);
// g_assert_cmpuint (0, ==, default_setting);
g_assert_cmpuint
(
2
,
==
,
settings
[
2
]);
g_assert_cmpuint
(
296
,
==
,
hb_aat_layout_get_feature_setting_name_id
(
face
,
HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
,
settings
[
2
]));
// g_assert_cmpuint (3, ==, records[0].setting);
// g_assert_cmpuint (297, ==, records[0].name_id);
g_assert_cmpuint
(
HB_OT_NAME_ID_INVALID
,
==
,
hb_aat_layout_get_feature_setting_name_id
(
face
,
HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
,
HB_AAT_LAYOUT_SELECTOR_INVALID
));
count
=
3
;
g_assert_cmpuint
(
4
,
==
,
hb_aat_layout_get_feature_settings
(
face
,
HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
,
&
default_setting
,
3
,
&
count
,
settings
));
g_assert_cmpuint
(
1
,
==
,
count
);
g_assert_cmpuint
(
0
,
==
,
default_setting
);
// count = 1;
// g_assert_cmpuint (1, ==, hb_aat_layout_get_feature_settings (face, HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS,
// &default_setting, 0, &count, records));
// g_assert_cmpuint (1, ==, count);
// g_assert_cmpuint (HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED, ==, default_setting);
g_assert_cmpuint
(
3
,
==
,
settings
[
0
]);
g_assert_cmpuint
(
297
,
==
,
hb_aat_layout_get_feature_setting_name_id
(
face
,
HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE
,
settings
[
0
]));
// g_assert_cmpuint (8, ==, records[0].setting);
// g_assert_cmpuint (308, ==, records[0].name_id);
count
=
1
;
g_assert_cmpuint
(
1
,
==
,
hb_aat_layout_get_feature_settings
(
face
,
HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
,
&
default_setting
,
0
,
&
count
,
settings
));
g_assert_cmpuint
(
1
,
==
,
count
);
g_assert_cmpuint
(
HB_AAT_LAYOUT_FEATURE_TYPE_INVALID
,
==
,
default_setting
);
g_assert_cmpuint
(
8
,
==
,
settings
[
0
]);
g_assert_cmpuint
(
308
,
==
,
hb_aat_layout_get_feature_setting_name_id
(
face
,
HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS
,
settings
[
0
]));
//
count = 100;
// g_assert_cmpuint (0, ==, hb_aat_layout_get_feature_settings (face, HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINE
D,
// NULL, 0, &count, record
s));
//
g_assert_cmpuint (0, ==, count);
count
=
100
;
g_assert_cmpuint
(
0
,
==
,
hb_aat_layout_get_feature_settings
(
face
,
HB_AAT_LAYOUT_FEATURE_TYPE_INVALI
D
,
NULL
,
0
,
&
count
,
setting
s
));
g_assert_cmpuint
(
0
,
==
,
count
);
// g_assert_cmpuint (0, ==, hb_aat_layout_get_feature_settings (sbix, HB_AAT_LAYOUT_FEATURE_TYPE_UNDEFINED, NULL
,
// 0, &count, records
));
g_assert_cmpuint
(
HB_OT_NAME_ID_INVALID
,
==
,
hb_aat_layout_get_feature_setting_name_id
(
sbix
,
HB_AAT_LAYOUT_FEATURE_TYPE_INVALID
,
(
hb_aat_layout_feature_setting_t
)
0
));
}
int
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录