Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
fb194b87
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看板
提交
fb194b87
编写于
4月 20, 2011
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unicode: Cleanup implementation
上级
ecfb7738
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
237 addition
and
244 deletion
+237
-244
src/Makefile.am
src/Makefile.am
+4
-4
src/hb-buffer-private.hh
src/hb-buffer-private.hh
+1
-1
src/hb-glib.cc
src/hb-glib.cc
+33
-32
src/hb-icu.cc
src/hb-icu.cc
+15
-15
src/hb-ot-shape.cc
src/hb-ot-shape.cc
+5
-9
src/hb-shape.cc
src/hb-shape.cc
+2
-2
src/hb-unicode-private.hh
src/hb-unicode-private.hh
+42
-23
src/hb-unicode.cc
src/hb-unicode.cc
+90
-123
src/hb-unicode.h
src/hb-unicode.h
+29
-28
test/test-unicode.c
test/test-unicode.c
+16
-7
未找到文件。
src/Makefile.am
浏览文件 @
fb194b87
...
...
@@ -24,8 +24,8 @@ HBSOURCES = \
hb-ot-head-private.hh
\
hb-private.h
\
hb-shape.cc
\
hb-unicode.c
\
hb-unicode-private.h
\
hb-unicode.c
c
\
hb-unicode-private.h
h
\
$(NULL)
HBHEADERS
=
\
hb.h
\
...
...
@@ -65,7 +65,7 @@ if HAVE_GLIB
HBCFLAGS
+=
$(GLIB_CFLAGS)
HBLIBS
+=
$(GLIB_LIBS)
HBSOURCES
+=
\
hb-glib.c
\
hb-glib.c
c
\
$(NULL)
HBHEADERS
+=
\
hb-glib.h
\
...
...
@@ -76,7 +76,7 @@ if HAVE_ICU
HBCFLAGS
+=
$(ICU_CFLAGS)
HBLIBS
+=
$(ICU_LIBS)
HBSOURCES
+=
\
hb-icu.c
\
hb-icu.c
c
\
$(NULL)
HBHEADERS
+=
\
hb-icu.h
\
...
...
src/hb-buffer-private.hh
浏览文件 @
fb194b87
...
...
@@ -30,7 +30,7 @@
#include "hb-private.h"
#include "hb-buffer.h"
#include "hb-unicode-private.h"
#include "hb-unicode-private.h
h
"
HB_BEGIN_DECLS
...
...
src/hb-glib.c
→
src/hb-glib.c
c
浏览文件 @
fb194b87
...
...
@@ -28,20 +28,28 @@
#include "hb-glib.h"
#include "hb-unicode-private.h"
#include "hb-unicode-private.h
h
"
#include <glib.h>
HB_BEGIN_DECLS
static
hb_codepoint_t
hb_glib_get_mirroring
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
)
static
unsigned
int
hb_glib_get_combining_class
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
)
{
g_unichar_get_mirror_char
(
unicode
,
&
unicode
);
return
unicode
;
return
g_unichar_combining_class
(
unicode
);
}
static
unsigned
int
hb_glib_get_eastasian_width
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
)
{
return
g_unichar_iswide
(
unicode
)
?
2
:
1
;
}
static
hb_unicode_general_category_t
...
...
@@ -50,7 +58,17 @@ hb_glib_get_general_category (hb_unicode_funcs_t *ufuncs,
void
*
user_data
)
{
return
g_unichar_type
(
unicode
);
/* hb_unicode_general_category_t and GUnicodeType are identical */
return
(
hb_unicode_general_category_t
)
g_unichar_type
(
unicode
);
}
static
hb_codepoint_t
hb_glib_get_mirroring
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
)
{
g_unichar_get_mirror_char
(
unicode
,
&
unicode
);
return
unicode
;
}
static
hb_script_t
...
...
@@ -167,7 +185,7 @@ hb_glib_get_script (hb_unicode_funcs_t *ufuncs,
MATCH_SCRIPT
(
LISU
);
/* Lisu */
MATCH_SCRIPT
(
MEETEI_MAYEK
);
/* Mtei */
MATCH_SCRIPT
(
OLD_SOUTH_ARABIAN
);
/* Sarb */
#if GLIB_CHECK_VERSION(2,2
8,0
)
#if GLIB_CHECK_VERSION(2,2
7,92
)
MATCH_SCRIPT
(
OLD_TURKIC
);
/* Orkh */
#else
MATCH_SCRIPT2
(
OLD_TURKISH
,
OLD_TURKIC
);
/* Orkh */
...
...
@@ -190,33 +208,16 @@ hb_glib_get_script (hb_unicode_funcs_t *ufuncs,
return
HB_SCRIPT_UNKNOWN
;
}
static
unsigned
int
hb_glib_get_combining_class
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
)
{
return
g_unichar_combining_class
(
unicode
);
}
static
unsigned
int
hb_glib_get_eastasian_width
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
)
{
return
g_unichar_iswide
(
unicode
)
?
2
:
1
;
}
static
hb_unicode_funcs_t
glib_ufuncs
=
{
HB_REFERENCE_COUNT_INVALID
,
/* ref_count */
NULL
,
NULL
,
/* parent */
TRUE
,
/* immutable */
{
hb_glib_get_
general_category
,
NULL
,
NULL
,
hb_glib_get_
combining_class
,
NULL
,
NULL
,
hb_glib_get_
mirroring
,
NULL
,
NULL
,
hb_glib_get_
script
,
NULL
,
NULL
,
hb_glib_get_
eastasian_width
,
NULL
,
NULL
hb_glib_get_
combining_class
,
hb_glib_get_
eastasian_width
,
hb_glib_get_
general_category
,
hb_glib_get_
mirroring
,
hb_glib_get_
script
}
};
...
...
src/hb-icu.c
→
src/hb-icu.c
c
浏览文件 @
fb194b87
...
...
@@ -29,7 +29,7 @@
#include "hb-icu.h"
#include "hb-unicode-private.h"
#include "hb-unicode-private.h
h
"
#include <unicode/uversion.h>
#include <unicode/uchar.h>
...
...
@@ -38,14 +38,6 @@
HB_BEGIN_DECLS
static
hb_codepoint_t
hb_icu_get_mirroring
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
)
{
return
u_charMirror
(
unicode
);
}
static
unsigned
int
hb_icu_get_combining_class
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
...
...
@@ -125,6 +117,14 @@ hb_icu_get_general_category (hb_unicode_funcs_t *ufuncs,
return
HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED
;
}
static
hb_codepoint_t
hb_icu_get_mirroring
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
)
{
return
u_charMirror
(
unicode
);
}
static
hb_script_t
hb_icu_get_script
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
...
...
@@ -264,14 +264,14 @@ hb_icu_get_script (hb_unicode_funcs_t *ufuncs,
static
hb_unicode_funcs_t
icu_ufuncs
=
{
HB_REFERENCE_COUNT_INVALID
,
/* ref_count */
NULL
,
NULL
,
/* parent */
TRUE
,
/* immutable */
{
hb_icu_get_
general_category
,
NULL
,
NULL
,
hb_icu_get_
combining_class
,
NULL
,
NULL
,
hb_icu_get_
mirroring
,
NULL
,
NULL
,
hb_icu_get_
script
,
NULL
,
NULL
,
hb_icu_get_
eastasian_width
,
NULL
,
NULL
hb_icu_get_
combining_class
,
hb_icu_get_
eastasian_width
,
hb_icu_get_
general_category
,
hb_icu_get_
mirroring
,
hb_icu_get_
script
}
};
...
...
src/hb-ot-shape.cc
浏览文件 @
fb194b87
...
...
@@ -143,16 +143,13 @@ is_variation_selector (hb_codepoint_t unicode)
static
void
hb_set_unicode_props
(
hb_ot_shape_context_t
*
c
)
{
hb_unicode_get_general_category_func_t
get_general_category
=
c
->
buffer
->
unicode
->
v
.
get_general_category
;
hb_unicode_get_combining_class_func_t
get_combining_class
=
c
->
buffer
->
unicode
->
v
.
get_combining_class
;
hb_unicode_funcs_t
*
unicode
=
c
->
buffer
->
unicode
;
hb_glyph_info_t
*
info
=
c
->
buffer
->
info
;
unsigned
int
count
=
c
->
buffer
->
len
;
for
(
unsigned
int
i
=
1
;
i
<
count
;
i
++
)
{
info
[
i
].
general_category
()
=
get_general_category
(
c
->
buffer
->
unicode
,
info
[
i
].
codepoint
,
c
->
buffer
->
unicode
->
v
.
get_general_category_data
);
info
[
i
].
combining_class
()
=
get_combining_class
(
c
->
buffer
->
unicode
,
info
[
i
].
codepoint
,
c
->
buffer
->
unicode
->
v
.
get_combining_class_data
);
info
[
i
].
general_category
()
=
unicode
->
get_general_category
(
info
[
i
].
codepoint
);
info
[
i
].
combining_class
()
=
unicode
->
get_combining_class
(
info
[
i
].
codepoint
);
}
}
...
...
@@ -193,7 +190,7 @@ hb_reset_glyph_infos (hb_ot_shape_context_t *c)
static
void
hb_mirror_chars
(
hb_ot_shape_context_t
*
c
)
{
hb_unicode_
get_mirroring_func_t
get_mirroring
=
c
->
buffer
->
unicode
->
v
.
get_mirroring
;
hb_unicode_
funcs_t
*
unicode
=
c
->
buffer
->
unicode
;
if
(
HB_DIRECTION_IS_FORWARD
(
c
->
target_direction
))
return
;
...
...
@@ -202,8 +199,7 @@ hb_mirror_chars (hb_ot_shape_context_t *c)
unsigned
int
count
=
c
->
buffer
->
len
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
{
hb_codepoint_t
codepoint
=
get_mirroring
(
c
->
buffer
->
unicode
,
c
->
buffer
->
info
[
i
].
codepoint
,
c
->
buffer
->
unicode
->
v
.
get_mirroring_data
);
hb_codepoint_t
codepoint
=
unicode
->
get_mirroring
(
c
->
buffer
->
info
[
i
].
codepoint
);
if
(
likely
(
codepoint
==
c
->
buffer
->
info
[
i
].
codepoint
))
c
->
buffer
->
info
[
i
].
mask
|=
rtlm_mask
;
/* XXX this should be moved to before setting user-feature masks */
else
...
...
src/hb-shape.cc
浏览文件 @
fb194b87
...
...
@@ -74,10 +74,10 @@ hb_shape (hb_font_t *font,
/* If script is set to INVALID, guess from buffer contents */
if
(
buffer
->
props
.
script
==
HB_SCRIPT_INVALID
)
{
hb_unicode_
get_script_func_t
get_script
=
buffer
->
unicode
->
v
.
get_script
;
hb_unicode_
funcs_t
*
unicode
=
buffer
->
unicode
;
unsigned
int
count
=
buffer
->
len
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
{
hb_script_t
script
=
get_script
(
buffer
->
unicode
,
buffer
->
info
[
i
].
codepoint
,
buffer
->
unicode
->
v
.
get_script_data
);
hb_script_t
script
=
unicode
->
get_script
(
buffer
->
info
[
i
].
codepoint
);
if
(
likely
(
script
!=
HB_SCRIPT_COMMON
&&
script
!=
HB_SCRIPT_INHERITED
&&
script
!=
HB_SCRIPT_UNKNOWN
))
{
...
...
src/hb-unicode-private.h
→
src/hb-unicode-private.h
h
浏览文件 @
fb194b87
/*
* Copyright (C) 2009 Red Hat, Inc.
* Copyright © 2011 Codethink Limited
* Copyright (C) 2010 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
...
...
@@ -24,10 +25,11 @@
*
* Red Hat Author(s): Behdad Esfahbod
* Codethink Author(s): Ryan Lortie
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_UNICODE_PRIVATE_H
#define HB_UNICODE_PRIVATE_H
#ifndef HB_UNICODE_PRIVATE_H
H
#define HB_UNICODE_PRIVATE_H
H
#include "hb-private.h"
...
...
@@ -46,27 +48,44 @@ struct _hb_unicode_funcs_t {
hb_bool_t
immutable
;
#define IMPLEMENT(return_type, name) \
inline return_type \
get_##name (hb_codepoint_t unicode) \
{ return this->get.name (this, unicode, this->user_data.name); }
IMPLEMENT
(
unsigned
int
,
combining_class
)
IMPLEMENT
(
unsigned
int
,
eastasian_width
)
IMPLEMENT
(
hb_unicode_general_category_t
,
general_category
)
IMPLEMENT
(
hb_codepoint_t
,
mirroring
)
IMPLEMENT
(
hb_script_t
,
script
)
#undef IMPLEMENT
/* Don't access these directly. Call get_*() instead. */
struct
{
hb_unicode_get_combining_class_func_t
combining_class
;
hb_unicode_get_eastasian_width_func_t
eastasian_width
;
hb_unicode_get_general_category_func_t
general_category
;
hb_unicode_get_mirroring_func_t
mirroring
;
hb_unicode_get_script_func_t
script
;
}
get
;
struct
{
void
*
combining_class
;
void
*
eastasian_width
;
void
*
general_category
;
void
*
mirroring
;
void
*
script
;
}
user_data
;
struct
{
hb_unicode_get_general_category_func_t
get_general_category
;
void
*
get_general_category_data
;
hb_destroy_func_t
get_general_category_destroy
;
hb_unicode_get_combining_class_func_t
get_combining_class
;
void
*
get_combining_class_data
;
hb_destroy_func_t
get_combining_class_destroy
;
hb_unicode_get_mirroring_func_t
get_mirroring
;
void
*
get_mirroring_data
;
hb_destroy_func_t
get_mirroring_destroy
;
hb_unicode_get_script_func_t
get_script
;
void
*
get_script_data
;
hb_destroy_func_t
get_script_destroy
;
hb_unicode_get_eastasian_width_func_t
get_eastasian_width
;
void
*
get_eastasian_width_data
;
hb_destroy_func_t
get_eastasian_width_destroy
;
}
v
;
hb_destroy_func_t
combining_class
;
hb_destroy_func_t
eastasian_width
;
hb_destroy_func_t
general_category
;
hb_destroy_func_t
mirroring
;
hb_destroy_func_t
script
;
}
destroy
;
};
extern
HB_INTERNAL
hb_unicode_funcs_t
_hb_unicode_funcs_nil
;
...
...
@@ -74,4 +93,4 @@ extern HB_INTERNAL hb_unicode_funcs_t _hb_unicode_funcs_nil;
HB_END_DECLS
#endif
/* HB_UNICODE_PRIVATE_H */
#endif
/* HB_UNICODE_PRIVATE_H
H
*/
src/hb-unicode.c
→
src/hb-unicode.c
c
浏览文件 @
fb194b87
/*
* Copyright (C) 2009 Red Hat, Inc.
* Copyright © 2011 Codethink Limited
* Copyright (C) 2010 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
...
...
@@ -24,11 +25,12 @@
*
* Red Hat Author(s): Behdad Esfahbod
* Codethink Author(s): Ryan Lortie
* Google Author(s): Behdad Esfahbod
*/
#include "hb-private.h"
#include "hb-unicode-private.h"
#include "hb-unicode-private.h
h
"
HB_BEGIN_DECLS
...
...
@@ -37,59 +39,61 @@ HB_BEGIN_DECLS
* hb_unicode_funcs_t
*/
static
hb_codepoint_
t
hb_unicode_get_
mirroring
_nil
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_codepoint_t
unicode
HB_UNUSED
,
void
*
user_data
HB_UNUSED
)
static
unsigned
in
t
hb_unicode_get_
combining_class
_nil
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_codepoint_t
unicode
HB_UNUSED
,
void
*
user_data
HB_UNUSED
)
{
return
unicode
;
return
0
;
}
static
unsigned
int
hb_unicode_get_eastasian_width_nil
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_codepoint_t
unicode
HB_UNUSED
,
void
*
user_data
HB_UNUSED
)
{
return
1
;
}
static
hb_unicode_general_category_t
hb_unicode_get_general_category_nil
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_codepoint_t
unicode
HB_UNUSED
,
void
*
user_data
HB_UNUSED
)
hb_codepoint_t
unicode
HB_UNUSED
,
void
*
user_data
HB_UNUSED
)
{
return
HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER
;
}
static
hb_
scrip
t_t
hb_unicode_get_
script
_nil
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_codepoint_t
unicode
HB_UNUSED
,
void
*
user_data
HB_UNUSED
)
static
hb_
codepoin
t_t
hb_unicode_get_
mirroring
_nil
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_codepoint_t
unicode
HB_UNUSED
,
void
*
user_data
HB_UNUSED
)
{
return
HB_SCRIPT_UNKNOWN
;
return
unicode
;
}
static
unsigned
in
t
hb_unicode_get_
combining_class
_nil
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_codepoint_t
unicode
HB_UNUSED
,
void
*
user_data
HB_UNUSED
)
static
hb_script_
t
hb_unicode_get_
script
_nil
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_codepoint_t
unicode
HB_UNUSED
,
void
*
user_data
HB_UNUSED
)
{
return
0
;
return
HB_SCRIPT_UNKNOWN
;
}
static
unsigned
int
hb_unicode_get_eastasian_width_nil
(
hb_unicode_funcs_t
*
ufuncs
HB_UNUSED
,
hb_codepoint_t
unicode
HB_UNUSED
,
void
*
user_data
HB_UNUSED
)
{
return
1
;
}
hb_unicode_funcs_t
_hb_unicode_funcs_nil
=
{
HB_REFERENCE_COUNT_INVALID
,
/* ref_count */
NULL
,
/* parent */
TRUE
,
/* immutable */
{
hb_unicode_get_
general_category_nil
,
NULL
,
NULL
,
hb_unicode_get_
combining_class_nil
,
NULL
,
NULL
,
hb_unicode_get_
mirroring_nil
,
NULL
,
NULL
,
hb_unicode_get_
script_nil
,
NULL
,
NULL
,
hb_unicode_get_
eastasian_width_nil
,
NULL
,
NULL
hb_unicode_get_
combining_class_nil
,
hb_unicode_get_
eastasian_width_nil
,
hb_unicode_get_
general_category_nil
,
hb_unicode_get_
mirroring_nil
,
hb_unicode_get_
script_nil
,
}
};
hb_unicode_funcs_t
*
hb_unicode_funcs_create
(
hb_unicode_funcs_t
*
parent
)
{
...
...
@@ -98,24 +102,21 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent)
if
(
!
HB_OBJECT_DO_CREATE
(
hb_unicode_funcs_t
,
ufuncs
))
return
&
_hb_unicode_funcs_nil
;
if
(
parent
!=
NULL
)
{
ufuncs
->
parent
=
hb_unicode_funcs_reference
(
parent
);
if
(
parent
!=
NULL
)
{
hb_unicode_funcs_make_immutable
(
parent
);
ufuncs
->
v
=
parent
->
v
;
/* Clear out the destroy notifies from our parent.
*
* We don't want to destroy the user_data twice and since we hold a
* reference on our parent then we know that the user_data will
* survive for at least as long as we do anyway.
*/
ufuncs
->
v
.
get_general_category_destroy
=
NULL
;
ufuncs
->
v
.
get_combining_class_destroy
=
NULL
;
ufuncs
->
v
.
get_mirroring_destroy
=
NULL
;
ufuncs
->
v
.
get_script_destroy
=
NULL
;
ufuncs
->
v
.
get_eastasian_width_destroy
=
NULL
;
}
else
{
ufuncs
->
v
=
_hb_unicode_funcs_nil
.
v
;
ufuncs
->
parent
=
hb_unicode_funcs_reference
(
parent
);
ufuncs
->
get
=
parent
->
get
;
/* We can safely copy user_data from parent since we hold a reference
* onto it and it's immutable. We should not copy the destroy notifiers
* though. */
ufuncs
->
user_data
=
parent
->
user_data
;
}
else
{
ufuncs
->
get
=
_hb_unicode_funcs_nil
.
get
;
}
return
ufuncs
;
...
...
@@ -138,33 +139,20 @@ hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
{
HB_OBJECT_DO_DESTROY
(
ufuncs
);
#define DESTROY(name) if (ufuncs->destroy.name) ufuncs->destroy.name (ufuncs->user_data.name)
DESTROY
(
combining_class
);
DESTROY
(
eastasian_width
);
DESTROY
(
general_category
);
DESTROY
(
mirroring
);
DESTROY
(
script
);
#undef DESTROY
if
(
ufuncs
->
parent
!=
NULL
)
hb_unicode_funcs_destroy
(
ufuncs
->
parent
);
if
(
ufuncs
->
v
.
get_general_category_destroy
!=
NULL
)
ufuncs
->
v
.
get_general_category_destroy
(
ufuncs
->
v
.
get_general_category_data
);
if
(
ufuncs
->
v
.
get_combining_class_destroy
!=
NULL
)
ufuncs
->
v
.
get_combining_class_destroy
(
ufuncs
->
v
.
get_combining_class_data
);
if
(
ufuncs
->
v
.
get_mirroring_destroy
!=
NULL
)
ufuncs
->
v
.
get_mirroring_destroy
(
ufuncs
->
v
.
get_mirroring_data
);
if
(
ufuncs
->
v
.
get_script_destroy
!=
NULL
)
ufuncs
->
v
.
get_script_destroy
(
ufuncs
->
v
.
get_script_data
);
if
(
ufuncs
->
v
.
get_eastasian_width_destroy
!=
NULL
)
ufuncs
->
v
.
get_eastasian_width_destroy
(
ufuncs
->
v
.
get_eastasian_width_data
);
free
(
ufuncs
);
}
hb_unicode_funcs_t
*
hb_unicode_funcs_get_parent
(
hb_unicode_funcs_t
*
ufuncs
)
{
return
ufuncs
->
parent
;
}
void
hb_unicode_funcs_make_immutable
(
hb_unicode_funcs_t
*
ufuncs
)
{
...
...
@@ -180,8 +168,15 @@ hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs)
return
ufuncs
->
immutable
;
}
hb_unicode_funcs_t
*
hb_unicode_funcs_get_parent
(
hb_unicode_funcs_t
*
ufuncs
)
{
return
ufuncs
->
parent
;
}
#define SETTER(name) \
#define IMPLEMENT(return_type, name) \
\
void \
hb_unicode_funcs_set_##name##_func (hb_unicode_funcs_t *ufuncs, \
hb_unicode_get_##name##_func_t func, \
...
...
@@ -191,66 +186,38 @@ hb_unicode_funcs_set_##name##_func (hb_unicode_funcs_t *ufuncs, \
if (ufuncs->immutable) \
return; \
\
if (func != NULL) { \
ufuncs->v.get_##name = func; \
ufuncs->v.get_##name##_data = user_data; \
ufuncs->v.get_##name##_destroy = destroy; \
if (ufuncs->destroy.name) \
ufuncs->destroy.name (ufuncs->user_data.name); \
\
if (func) { \
ufuncs->get.name = func; \
ufuncs->user_data.name = user_data; \
ufuncs->destroy.name = destroy; \
} else if (ufuncs->parent != NULL) { \
ufuncs->
v.get_##name = ufuncs->parent->v.get_##name;
\
ufuncs->
v.get_##name##_data = ufuncs->parent->v.get_##name##_data;;
\
ufuncs->
v.get_##name##_destroy = NULL;
\
ufuncs->
get.name = ufuncs->parent->get.name;
\
ufuncs->
user_data.name = ufuncs->parent->user_data.name;
\
ufuncs->
destroy.name = NULL;
\
} else { \
ufuncs->
v.get_##name = hb_unicode_get_##name##_nil;
\
ufuncs->
v.get_##name##_data = NULL;
\
ufuncs->
v.get_##name##_destroy = NULL;
\
ufuncs->
get.name = hb_unicode_get_##name##_nil;
\
ufuncs->
user_data.name = NULL;
\
ufuncs->
destroy.name = NULL;
\
} \
} \
\
return_type \
hb_unicode_get_##name (hb_unicode_funcs_t *ufuncs, \
hb_codepoint_t unicode) \
{ \
return ufuncs->get.name (ufuncs, unicode, ufuncs->user_data.name); \
}
SETTER
(
mirroring
)
SETTER
(
general_category
)
SETTER
(
script
)
SETTER
(
combining_class
)
SETTER
(
eastasian_width
)
hb_codepoint_t
hb_unicode_get_mirroring
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
)
{
return
ufuncs
->
v
.
get_mirroring
(
ufuncs
,
unicode
,
ufuncs
->
v
.
get_mirroring_data
);
}
hb_unicode_general_category_t
hb_unicode_get_general_category
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
)
{
return
ufuncs
->
v
.
get_general_category
(
ufuncs
,
unicode
,
ufuncs
->
v
.
get_general_category_data
);
}
hb_script_t
hb_unicode_get_script
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
)
{
return
ufuncs
->
v
.
get_script
(
ufuncs
,
unicode
,
ufuncs
->
v
.
get_script_data
);
}
unsigned
int
hb_unicode_get_combining_class
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
)
{
return
ufuncs
->
v
.
get_combining_class
(
ufuncs
,
unicode
,
ufuncs
->
v
.
get_combining_class_data
);
}
IMPLEMENT
(
unsigned
int
,
combining_class
)
IMPLEMENT
(
unsigned
int
,
eastasian_width
)
IMPLEMENT
(
hb_unicode_general_category_t
,
general_category
)
IMPLEMENT
(
hb_codepoint_t
,
mirroring
)
IMPLEMENT
(
hb_script_t
,
script
)
unsigned
int
hb_unicode_get_eastasian_width
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
)
{
return
ufuncs
->
v
.
get_eastasian_width
(
ufuncs
,
unicode
,
ufuncs
->
v
.
get_eastasian_width_data
);
}
#undef IMPLEMENT
HB_END_DECLS
src/hb-unicode.h
浏览文件 @
fb194b87
...
...
@@ -68,72 +68,73 @@ hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs);
/* typedefs */
typedef
hb_codepoint_t
(
*
hb_unicode_get_mirroring_func_t
)
(
hb_unicode_funcs_t
*
ufuncs
,
typedef
unsigned
int
(
*
hb_unicode_get_combining_class_func_t
)
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
);
typedef
hb_unicode_general_category_t
(
*
hb_unicode_get_general_category_func_t
)
(
hb_unicode_funcs_t
*
ufuncs
,
typedef
unsigned
int
(
*
hb_unicode_get_eastasian_width_func_t
)
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
);
typedef
hb_
script_t
(
*
hb_unicode_get_script_func_t
)
(
hb_unicode_funcs_t
*
ufuncs
,
typedef
hb_
unicode_general_category_t
(
*
hb_unicode_get_general_category_func_t
)
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
);
typedef
unsigned
int
(
*
hb_unicode_get_combining_class_func_t
)
(
hb_unicode_funcs_t
*
ufuncs
,
typedef
hb_codepoint_t
(
*
hb_unicode_get_mirroring_func_t
)
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
);
typedef
unsigned
int
(
*
hb_unicode_get_eastasian_width_func_t
)
(
hb_unicode_funcs_t
*
ufuncs
,
typedef
hb_script_t
(
*
hb_unicode_get_script_func_t
)
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
,
void
*
user_data
);
/* setters */
void
hb_unicode_funcs_set_mirroring_func
(
hb_unicode_funcs_t
*
ufuncs
,
hb_unicode_get_mirroring_func_t
mirroring_func
,
void
*
user_data
,
hb_destroy_func_t
destroy
);
hb_unicode_funcs_set_combining_class_func
(
hb_unicode_funcs_t
*
ufuncs
,
hb_unicode_get_combining_class_func_t
combining_class_func
,
void
*
user_data
,
hb_destroy_func_t
destroy
);
void
hb_unicode_funcs_set_eastasian_width_func
(
hb_unicode_funcs_t
*
ufuncs
,
hb_unicode_get_eastasian_width_func_t
eastasian_width_func
,
void
*
user_data
,
hb_destroy_func_t
destroy
);
void
hb_unicode_funcs_set_general_category_func
(
hb_unicode_funcs_t
*
ufuncs
,
hb_unicode_get_general_category_func_t
general_category_func
,
void
*
user_data
,
hb_destroy_func_t
destroy
);
void
hb_unicode_funcs_set_mirroring_func
(
hb_unicode_funcs_t
*
ufuncs
,
hb_unicode_get_mirroring_func_t
mirroring_func
,
void
*
user_data
,
hb_destroy_func_t
destroy
);
void
hb_unicode_funcs_set_script_func
(
hb_unicode_funcs_t
*
ufuncs
,
hb_unicode_get_script_func_t
script_func
,
void
*
user_data
,
hb_destroy_func_t
destroy
);
void
hb_unicode_funcs_set_combining_class_func
(
hb_unicode_funcs_t
*
ufuncs
,
hb_unicode_get_combining_class_func_t
combining_class_func
,
void
*
user_data
,
hb_destroy_func_t
destroy
);
void
hb_unicode_funcs_set_eastasian_width_func
(
hb_unicode_funcs_t
*
ufuncs
,
hb_unicode_get_eastasian_width_func_t
eastasian_width_func
,
void
*
user_data
,
hb_destroy_func_t
destroy
);
/* accessors */
hb_codepoint_t
hb_unicode_get_mirroring
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
);
unsigned
int
hb_unicode_get_combining_class
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
);
unsigned
int
hb_unicode_get_eastasian_width
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
);
hb_unicode_general_category_t
hb_unicode_get_general_category
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
);
hb_codepoint_t
hb_unicode_get_mirroring
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
);
hb_script_t
hb_unicode_get_script
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
);
unsigned
int
hb_unicode_get_combining_class
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
);
unsigned
int
hb_unicode_get_eastasian_width
(
hb_unicode_funcs_t
*
ufuncs
,
hb_codepoint_t
unicode
);
HB_END_DECLS
...
...
test/test-unicode.c
浏览文件 @
fb194b87
...
...
@@ -120,10 +120,14 @@ a_is_for_arabic_get_script (hb_unicode_funcs_t *ufuncs,
static
void
test_subclassing_nil
(
void
)
{
hb_unicode_funcs_t
*
uf
=
hb_unicode_funcs_create
(
NULL
);
hb_unicode_funcs_t
*
uf
,
*
aa
;
uf
=
hb_unicode_funcs_create
(
NULL
);
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
uf
),
==
,
1
);
hb_unicode_funcs_t
*
aa
=
hb_unicode_funcs_create
(
uf
);
aa
=
hb_unicode_funcs_create
(
uf
);
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
uf
),
==
,
2
);
hb_unicode_funcs_destroy
(
uf
);
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
uf
),
==
,
1
);
...
...
@@ -133,7 +137,6 @@ test_subclassing_nil (void)
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'a'
),
==
,
HB_SCRIPT_ARABIC
);
g_assert_cmpint
(
hb_unicode_get_script
(
aa
,
'b'
),
==
,
HB_SCRIPT_UNKNOWN
);
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
aa
),
==
,
1
);
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
uf
),
==
,
1
);
g_assert
(
!
freed0
&&
!
freed1
);
...
...
@@ -145,10 +148,14 @@ test_subclassing_nil (void)
static
void
test_subclassing_glib
(
void
)
{
hb_unicode_funcs_t
*
uf
=
hb_glib_get_unicode_funcs
();
hb_unicode_funcs_t
*
uf
,
*
aa
;
uf
=
hb_glib_get_unicode_funcs
();
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
uf
),
==
,
0
);
hb_unicode_funcs_t
*
aa
=
hb_unicode_funcs_create
(
uf
);
aa
=
hb_unicode_funcs_create
(
uf
);
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
uf
),
==
,
0
);
hb_unicode_funcs_destroy
(
uf
);
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
uf
),
==
,
0
);
...
...
@@ -168,13 +175,15 @@ test_subclassing_glib (void)
static
void
test_subclassing_deep
(
void
)
{
hb_unicode_funcs_t
*
uf
=
hb_unicode_funcs_create
(
NULL
);
hb_unicode_funcs_t
*
uf
,
*
aa
;
uf
=
hb_unicode_funcs_create
(
NULL
);
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
uf
),
==
,
1
);
hb_unicode_funcs_set_script_func
(
uf
,
simple_get_script
,
unique_pointer0
,
free_up
);
hb_unicode_funcs_t
*
aa
=
hb_unicode_funcs_create
(
uf
);
aa
=
hb_unicode_funcs_create
(
uf
);
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
aa
),
==
,
1
);
g_assert_cmpint
(
hb_unicode_funcs_get_reference_count
(
uf
),
==
,
2
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录