Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
706ab25a
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看板
提交
706ab25a
编写于
1月 28, 2008
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add script and language public getter API
上级
40a81314
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
207 addition
and
18 deletion
+207
-18
src/hb-ot-layout-open-private.h
src/hb-ot-layout-open-private.h
+25
-15
src/hb-ot-layout.cc
src/hb-ot-layout.cc
+125
-2
src/hb-ot-layout.h
src/hb-ot-layout.h
+56
-0
src/main.cc
src/main.cc
+1
-1
未找到文件。
src/hb-ot-layout-open-private.h
浏览文件 @
706ab25a
...
...
@@ -34,6 +34,8 @@
#include "hb-ot-layout-private.h"
#define NO_INDEX ((unsigned int) 0xFFFF)
/*
* Int types
*/
...
...
@@ -153,7 +155,7 @@
#define DEFINE_TAG_ARRAY_INTERFACE(Type, name) \
DEFINE_ARRAY_INTERFACE (Type, name); \
inline
hb_tag_t
get_##name##_tag (unsigned int i) const { \
inline
const Tag&
get_##name##_tag (unsigned int i) const { \
return (*this)[i].tag; \
}
#define DEFINE_TAG_LIST_INTERFACE(Type, name) \
...
...
@@ -163,16 +165,21 @@
}
#define DEFINE_TAG_FIND_INTERFACE(Type, name) \
inline const Type* find_##name (hb_tag_t tag) const { \
for (unsigned int i = 0; i < get_##name##_count (); i++) \
if (tag == get_##name##_tag (i)) \
return &get_##name (i); \
return NULL; \
inline bool find_##name##_index (hb_tag_t tag, unsigned int *name##_index) const { \
const Tag t = tag; \
for (unsigned int i = 0; i < get_##name##_count (); i++) { \
if (t == get_##name##_tag (i)) { \
if (name##_index) *name##_index = i; \
return true; \
} \
} \
if (name##_index) *name##_index = NO_INDEX; \
return false; \
} \
inline const Type& get_##name##_by_tag (hb_tag_t tag) const { \
const Type* res = find_##name (tag)
; \
if (
res
) \
return
*res
; \
unsigned int i
; \
if (
find_##name##_index (tag, &i)
) \
return
get_##name (i)
; \
else \
return Null##Type; \
}
...
...
@@ -390,7 +397,7 @@ typedef struct OffsetTable {
friend
struct
TTCHeader
;
DEFINE_TAG_ARRAY_INTERFACE
(
OpenTypeTable
,
table
);
/* get_table_count(), get_table(i), get_table_tag(i) */
DEFINE_TAG_FIND_INTERFACE
(
OpenTypeTable
,
table
);
/* find_table(tag), get_table_by_tag(tag) */
DEFINE_TAG_FIND_INTERFACE
(
OpenTypeTable
,
table
);
/* find_table
_index
(tag), get_table_by_tag(tag) */
private:
/* OpenTypeTables, in no particular order */
...
...
@@ -509,10 +516,13 @@ struct LangSys {
DEFINE_INDEX_ARRAY_INTERFACE
(
feature
);
/* Returns -1 if none */
inline
const
bool
has_required_feature
(
void
)
const
{
return
reqFeatureIndex
!=
0xffff
;
}
/* Returns NO_INDEX if none */
inline
int
get_required_feature_index
(
void
)
const
{
if
(
reqFeatureIndex
==
0xffff
)
return
-
1
;
return
NO_INDEX
;
return
reqFeatureIndex
;;
}
...
...
@@ -543,7 +553,7 @@ struct Script {
}
/* TODO bsearch */
DEFINE_TAG_FIND_INTERFACE
(
LangSys
,
lang_sys
);
/* find_lang_sys (), get_lang_sys_by_tag (tag) */
DEFINE_TAG_FIND_INTERFACE
(
LangSys
,
lang_sys
);
/* find_lang_sys
_index
(), get_lang_sys_by_tag (tag) */
inline
const
bool
has_default_lang_sys
(
void
)
const
{
return
defaultLangSys
!=
0
;
...
...
@@ -940,8 +950,8 @@ typedef struct GSUBGPOS {
DEFINE_LIST_INTERFACE
(
Lookup
,
lookup
);
/* get_lookup_count (), get_lookup (i) */
/* TODO bsearch */
DEFINE_TAG_FIND_INTERFACE
(
Script
,
script
);
/* find_script (), get_script_by_tag (tag) */
DEFINE_TAG_FIND_INTERFACE
(
Feature
,
feature
);
/* find_feature(), get_feature_by_tag(tag) */
DEFINE_TAG_FIND_INTERFACE
(
Script
,
script
);
/* find_script
_index
(), get_script_by_tag (tag) */
DEFINE_TAG_FIND_INTERFACE
(
Feature
,
feature
);
/* find_feature
_index
(), get_feature_by_tag(tag) */
private:
DEFINE_LIST_ARRAY
(
Script
,
script
);
...
...
src/hb-ot-layout.cc
浏览文件 @
706ab25a
...
...
@@ -43,7 +43,7 @@
struct
_hb_ot_layout_t
{
const
GDEF
*
gdef
;
const
GSUB
*
gsub
;
//const
GPOS *gpos;
const
/*XXX*/
GSUB
GPOS
*
gpos
;
struct
{
unsigned
char
*
klasses
;
...
...
@@ -63,7 +63,7 @@ hb_ot_layout_create_for_data (const char *font_data,
layout
->
gdef
=
&
GDEF
::
get_for_data
(
font
.
get_table_data
(
face
.
get_table_by_tag
(
GDEF
::
Tag
)));
layout
->
gsub
=
&
GSUB
::
get_for_data
(
font
.
get_table_data
(
face
.
get_table_by_tag
(
GSUB
::
Tag
)));
//layout->gpos = &GPOS::get_for_data (font.get_table_data (face.get_table_by_tag (GPOS::
Tag)));
layout
->
gpos
=
&
/*XXX*/
GSUBGPOS
::
get_for_data
(
font
.
get_table_data
(
face
.
get_table_by_tag
(
/*XXX*/
GSUBGPOS
::
GPOS
Tag
)));
return
layout
;
}
...
...
@@ -243,3 +243,126 @@ hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
for
(
i
=
0
;
i
<
count
;
i
++
)
hb_ot_layout_set_glyph_class
(
layout
,
glyphs
[
i
],
(
hb_ot_layout_glyph_class_t
)
klasses
[
i
]);
}
/*
* GSUB/GPOS
*/
static
const
GSUBGPOS
&
get_gsubgpos_table
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
)
{
switch
(
table_type
)
{
case
HB_OT_LAYOUT_TABLE_TYPE_GSUB
:
return
*
(
layout
->
gsub
);
case
HB_OT_LAYOUT_TABLE_TYPE_GPOS
:
return
*
(
layout
->
gpos
);
default:
return
NullGSUBGPOS
;
}
}
unsigned
int
hb_ot_layout_get_script_count
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
)
{
const
GSUBGPOS
&
g
=
get_gsubgpos_table
(
layout
,
table_type
);
return
g
.
get_script_count
();
}
hb_tag_t
hb_ot_layout_get_script_tag
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
,
unsigned
int
script_index
)
{
const
GSUBGPOS
&
g
=
get_gsubgpos_table
(
layout
,
table_type
);
return
g
.
get_script_tag
(
script_index
);
}
hb_bool_t
hb_ot_layout_find_script
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
,
hb_tag_t
script_tag
,
unsigned
int
*
script_index
)
{
unsigned
int
i
;
const
GSUBGPOS
&
g
=
get_gsubgpos_table
(
layout
,
table_type
);
if
(
g
.
find_script_index
(
script_tag
,
script_index
))
return
TRUE
;
/* try finding 'DFLT' */
if
(
g
.
find_script_index
(
HB_OT_LAYOUT_TAG_DEFAULT_SCRIPT
,
script_index
))
return
FALSE
;
/* try with 'dflt'; MS site has had typos and many fonts use it now :( */
if
(
g
.
find_script_index
(
HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE
,
script_index
))
return
FALSE
;
if
(
script_index
)
*
script_index
=
HB_OT_LAYOUT_NO_SCRIPT_INDEX
;
return
FALSE
;
}
unsigned
int
hb_ot_layout_get_language_count
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
,
unsigned
int
script_index
)
{
const
Script
&
s
=
get_gsubgpos_table
(
layout
,
table_type
).
get_script
(
script_index
);
return
s
.
get_lang_sys_count
();
}
hb_tag_t
hb_ot_layout_get_language_tag
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
,
unsigned
int
script_index
,
unsigned
int
language_index
)
{
const
Script
&
s
=
get_gsubgpos_table
(
layout
,
table_type
).
get_script
(
script_index
);
return
s
.
get_lang_sys_tag
(
language_index
);
}
hb_bool_t
hb_ot_layout_find_language
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
,
unsigned
int
script_index
,
hb_tag_t
language_tag
,
unsigned
int
*
language_index
,
unsigned
int
*
required_features_index
)
{
unsigned
int
i
;
const
Script
&
s
=
get_gsubgpos_table
(
layout
,
table_type
).
get_script
(
script_index
);
#if 0
if (s.find_script_index (script_tag, script_index))
return TRUE;
/* try with 'dflt'; MS site has had typos and many fonts use it now :( */
if (s.find_script_index (HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE, script_index))
return FALSE;
////////////////////////
if (script_index) *script_index = HB_OT_LAYOUT_NO_SCRIPT_INDEX;
return FALSE;
if (language_index)
*language_index = PANGO_OT_DEFAULT_LANGUAGE;
if (required_feature_index)
*required_feature_index = PANGO_OT_NO_FEATURE;
if (script_index == PANGO_OT_NO_SCRIPT)
return FALSE;
/* DefaultLangSys */
if (language_index)
*language_index = PANGO_OT_DEFAULT_LANGUAGE;
if (required_feature_index)
*required_feature_index = script->DefaultLangSys.ReqFeatureIndex;
#endif
return
FALSE
;
}
src/hb-ot-layout.h
浏览文件 @
706ab25a
...
...
@@ -78,6 +78,62 @@ hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
unsigned
char
*
klasses
,
uint16_t
count
);
/*
* GSUB/GPOS
*/
typedef
enum
{
HB_OT_LAYOUT_TABLE_TYPE_GSUB
,
HB_OT_LAYOUT_TABLE_TYPE_GPOS
,
HB_OT_LAYOUT_TABLE_TYPE_NONE
}
hb_ot_layout_table_type_t
;
#define HB_OT_LAYOUT_NO_SCRIPT_INDEX ((unsigned int) 0xFFFF)
#define HB_OT_LAYOUT_NO_FEATURE_INDEX ((unsigned int) 0xFFFF)
#define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX ((unsigned int) 0xFFFF)
#define HB_OT_LAYOUT_TAG_DEFAULT_SCRIPT HB_TAG ('D', 'F', 'L', 'T')
#define HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE HB_TAG ('d', 'f', 'l', 't')
unsigned
int
hb_ot_layout_get_script_count
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
);
hb_tag_t
hb_ot_layout_get_script_tag
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
,
unsigned
int
script_index
);
hb_bool_t
hb_ot_layout_find_script
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
,
hb_tag_t
script_tag
,
unsigned
int
*
script_index
);
unsigned
int
hb_ot_layout_get_language_count
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
,
unsigned
int
script_index
);
hb_tag_t
hb_ot_layout_get_language_tag
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
,
unsigned
int
script_index
,
unsigned
int
language_index
);
hb_bool_t
hb_ot_layout_find_language
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_table_type_t
table_type
,
unsigned
int
script_index
,
hb_tag_t
language_tag
,
unsigned
int
*
language_index
,
unsigned
int
*
required_features_index
);
/*
#define PANGO_OT_ALL_GLYPHS ((guint) 0xFFFF)
*/
HB_END_DECLS
();
#endif
/* HB_OT_LAYOUT_H */
src/main.cc
浏览文件 @
706ab25a
...
...
@@ -103,7 +103,7 @@ main (int argc, char **argv)
?
" Default Language System
\n
"
:
" Language System %2d of %2d: %.4s
\n
"
,
n_langsys
,
num_langsys
,
(
const
char
*
)
script
.
get_lang_sys_tag
(
n_langsys
));
if
(
!
langsys
.
get_required_feature_index
()
)
if
(
langsys
.
get_required_feature_index
()
==
NO_INDEX
)
printf
(
" No required feature
\n
"
);
int
num_features
=
langsys
.
get_feature_count
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录