Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
39a840ae
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看板
提交
39a840ae
编写于
4月 27, 2011
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[API] Add hb_direction_from/to_string()
And hb-view --direction argument.
上级
f1425a54
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
72 addition
and
5 deletion
+72
-5
TODO
TODO
+0
-1
src/hb-common.cc
src/hb-common.cc
+36
-0
src/hb-common.h
src/hb-common.h
+6
-0
src/hb-view.cc
src/hb-view.cc
+10
-3
test/test-common.c
test/test-common.c
+20
-1
未找到文件。
TODO
浏览文件 @
39a840ae
...
...
@@ -50,7 +50,6 @@ API to add (maybe after 1.0):
hb-view enhancements:
====================
- Add --output
- Add --format
- Add --width, --height, --auto-size, --align, etc?
- Port to GOption, --help
...
...
src/hb-common.cc
浏览文件 @
39a840ae
...
...
@@ -51,6 +51,42 @@ hb_tag_from_string (const char *s)
}
/* hb_direction_t */
const
char
direction_strings
[][
4
]
=
{
"ltr"
,
"rtl"
,
"ttb"
,
"btt"
};
hb_direction_t
hb_direction_from_string
(
const
char
*
str
)
{
if
(
unlikely
(
!
str
||
!*
str
))
return
HB_DIRECTION_INVALID
;
/* Lets match loosely: just match the first letter, such that
* all of "ltr", "left-to-right", etc work!
*/
char
c
=
TOLOWER
(
str
[
0
]);
for
(
unsigned
int
i
=
0
;
i
<
ARRAY_LENGTH
(
direction_strings
);
i
++
)
if
(
c
==
direction_strings
[
i
][
0
])
return
(
hb_direction_t
)
i
;
return
HB_DIRECTION_INVALID
;
}
const
char
*
hb_direction_to_string
(
hb_direction_t
direction
)
{
if
(
likely
((
unsigned
int
)
direction
<
ARRAY_LENGTH
(
direction_strings
)))
return
direction_strings
[
direction
];
return
"invalid"
;
}
/* hb_language_t */
struct
_hb_language_t
{
...
...
src/hb-common.h
浏览文件 @
39a840ae
...
...
@@ -92,6 +92,12 @@ typedef enum _hb_direction_t {
HB_DIRECTION_BTT
}
hb_direction_t
;
hb_direction_t
hb_direction_from_string
(
const
char
*
str
);
const
char
*
hb_direction_to_string
(
hb_direction_t
direction
);
#define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 0)
#define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 2)
#define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 0)
...
...
src/hb-view.cc
浏览文件 @
39a840ae
...
...
@@ -57,8 +57,9 @@ static const char *back = "#ffffff";
static
const
char
*
text
=
NULL
;
static
const
char
*
font_file
=
NULL
;
static
const
char
*
out_file
=
"/dev/stdout"
;
static
const
char
*
language
=
NULL
;
static
const
char
*
direction
=
NULL
;
static
const
char
*
script
=
NULL
;
static
const
char
*
language
=
NULL
;
static
hb_feature_t
*
features
=
NULL
;
static
unsigned
int
num_features
;
static
hb_bool_t
debug
=
FALSE
;
...
...
@@ -100,6 +101,7 @@ parse_opts (int argc, char **argv)
static
struct
option
long_options
[]
=
{
{
"background"
,
1
,
0
,
'B'
},
{
"debug"
,
0
,
&
debug
,
TRUE
},
{
"direction"
,
1
,
0
,
'd'
},
{
"features"
,
1
,
0
,
'f'
},
{
"font-size"
,
1
,
0
,
's'
},
{
"foreground"
,
1
,
0
,
'F'
},
...
...
@@ -152,12 +154,15 @@ parse_opts (int argc, char **argv)
case
't'
:
text
=
optarg
;
break
;
case
'
L
'
:
language
=
optarg
;
case
'
d
'
:
direction
=
optarg
;
break
;
case
'S'
:
script
=
optarg
;
break
;
case
'L'
:
language
=
optarg
;
break
;
case
'o'
:
out_file
=
optarg
;
break
;
...
...
@@ -350,6 +355,8 @@ _hb_cr_text_glyphs (cairo_t *cr,
hb_buffer
=
hb_buffer_create
(
0
);
if
(
direction
)
hb_buffer_set_direction
(
hb_buffer
,
hb_direction_from_string
(
direction
));
if
(
script
)
hb_buffer_set_script
(
hb_buffer
,
hb_script_from_string
(
script
));
if
(
language
)
...
...
test/test-common.c
浏览文件 @
39a840ae
...
...
@@ -77,6 +77,15 @@ test_types_direction (void)
g_assert_cmpint
(
HB_DIRECTION_REVERSE
(
HB_DIRECTION_RTL
),
==
,
HB_DIRECTION_LTR
);
g_assert_cmpint
(
HB_DIRECTION_REVERSE
(
HB_DIRECTION_TTB
),
==
,
HB_DIRECTION_BTT
);
g_assert_cmpint
(
HB_DIRECTION_REVERSE
(
HB_DIRECTION_BTT
),
==
,
HB_DIRECTION_TTB
);
g_assert_cmpint
(
HB_DIRECTION_INVALID
,
==
,
hb_direction_from_string
(
NULL
));
g_assert_cmpint
(
HB_DIRECTION_INVALID
,
==
,
hb_direction_from_string
(
""
));
g_assert_cmpint
(
HB_DIRECTION_INVALID
,
==
,
hb_direction_from_string
(
"x"
));
g_assert_cmpint
(
HB_DIRECTION_RTL
,
==
,
hb_direction_from_string
(
"r"
));
g_assert_cmpint
(
HB_DIRECTION_RTL
,
==
,
hb_direction_from_string
(
"rtl"
));
g_assert_cmpint
(
HB_DIRECTION_RTL
,
==
,
hb_direction_from_string
(
"RtL"
));
g_assert_cmpint
(
HB_DIRECTION_RTL
,
==
,
hb_direction_from_string
(
"right-to-left"
));
g_assert_cmpint
(
HB_DIRECTION_TTB
,
==
,
hb_direction_from_string
(
"ttb"
));
}
static
void
...
...
@@ -108,16 +117,26 @@ test_types_script (void)
hb_tag_t
x123
=
HB_TAG_CHAR4
(
"x123"
);
g_assert_cmpint
(
(
hb_tag_t
)
HB_SCRIPT_INVALID
,
==
,
HB_TAG_NONE
);
g_assert_cmpint
(
HB_SCRIPT_INVALID
,
==
,
(
hb_script_t
)
HB_TAG_NONE
);
g_assert_cmphex
(
HB_SCRIPT_ARABIC
,
!=
,
HB_SCRIPT_LATIN
);
g_assert_cmphex
(
HB_SCRIPT_INVALID
,
==
,
hb_script_from_string
(
NULL
));
g_assert_cmphex
(
HB_SCRIPT_INVALID
,
==
,
hb_script_from_string
(
""
));
g_assert_cmphex
(
HB_SCRIPT_UNKNOWN
,
==
,
hb_script_from_string
(
"x"
));
g_assert_cmphex
(
HB_SCRIPT_ARABIC
,
==
,
hb_script_from_string
(
"arab"
));
g_assert_cmphex
(
HB_SCRIPT_ARABIC
,
==
,
hb_script_from_string
(
"Arab"
));
g_assert_cmphex
(
HB_SCRIPT_ARABIC
,
==
,
hb_script_from_string
(
"ARAB"
));
g_assert_cmphex
(
HB_SCRIPT_ARABIC
,
==
,
hb_script_from_iso15924_tag
(
arab
));
g_assert_cmphex
(
HB_SCRIPT_ARABIC
,
==
,
hb_script_from_iso15924_tag
(
Arab
));
g_assert_cmphex
(
HB_SCRIPT_ARABIC
,
==
,
hb_script_from_iso15924_tag
(
ARAB
));
/* Arbitrary tags that look like may be valid ISO 15924 should be preserved. */
g_assert_cmphex
(
HB_SCRIPT_UNKNOWN
,
!=
,
hb_script_from_string
(
"wWyZ"
));
g_assert_cmphex
(
HB_SCRIPT_UNKNOWN
,
!=
,
hb_script_from_iso15924_tag
(
wWyZ
));
/* Otherwise, UNKNOWN should be returned. */
g_assert_cmphex
(
HB_SCRIPT_UNKNOWN
,
==
,
hb_script_from_string
(
"x123"
));
g_assert_cmphex
(
HB_SCRIPT_UNKNOWN
,
==
,
hb_script_from_iso15924_tag
(
x123
));
g_assert_cmphex
(
hb_script_to_iso15924_tag
(
HB_SCRIPT_ARABIC
),
==
,
Arab
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录