Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
ff44f88d
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ff44f88d
编写于
11月 06, 2009
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle shaping in non-native direction
上级
b4b4272c
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
196 addition
and
14 deletion
+196
-14
src/hb-buffer-private.h
src/hb-buffer-private.h
+1
-0
src/hb-buffer.c
src/hb-buffer.c
+38
-4
src/hb-buffer.h
src/hb-buffer.h
+3
-7
src/hb-common.h
src/hb-common.h
+11
-0
src/hb-shape.c
src/hb-shape.c
+35
-3
src/hb-unicode-private.h
src/hb-unicode-private.h
+5
-0
src/hb-unicode.c
src/hb-unicode.c
+103
-0
未找到文件。
src/hb-buffer-private.h
浏览文件 @
ff44f88d
...
@@ -138,6 +138,7 @@ _hb_buffer_allocate_lig_id (hb_buffer_t *buffer);
...
@@ -138,6 +138,7 @@ _hb_buffer_allocate_lig_id (hb_buffer_t *buffer);
#define IN_NEXTGLYPH() (buffer->in_string[buffer->in_pos + 1].codepoint)
#define IN_NEXTGLYPH() (buffer->in_string[buffer->in_pos + 1].codepoint)
#define IN_CURINFO() (&buffer->in_string[buffer->in_pos])
#define IN_CURINFO() (&buffer->in_string[buffer->in_pos])
#define IN_MASK(pos) (buffer->in_string[(pos)].mask)
#define IN_MASK(pos) (buffer->in_string[(pos)].mask)
#define IN_CLUSTER(pos) (buffer->in_string[(pos)].cluster)
#define IN_LIGID(pos) (buffer->in_string[(pos)].lig_id)
#define IN_LIGID(pos) (buffer->in_string[(pos)].lig_id)
#define IN_COMPONENT(pos) (buffer->in_string[(pos)].component)
#define IN_COMPONENT(pos) (buffer->in_string[(pos)].component)
#define POSITION(pos) (&buffer->positions[(pos)])
#define POSITION(pos) (&buffer->positions[(pos)])
...
...
src/hb-buffer.c
浏览文件 @
ff44f88d
...
@@ -477,12 +477,14 @@ hb_buffer_get_glyph_positions (hb_buffer_t *buffer)
...
@@ -477,12 +477,14 @@ hb_buffer_get_glyph_positions (hb_buffer_t *buffer)
}
}
void
static
void
hb_buffer_reverse
(
hb_buffer_t
*
buffer
)
reverse_range
(
hb_buffer_t
*
buffer
,
unsigned
int
start
,
unsigned
int
end
)
{
{
unsigned
int
i
,
j
;
unsigned
int
i
,
j
;
for
(
i
=
0
,
j
=
buffer
->
in_length
-
1
;
i
<
buffer
->
in_length
/
2
;
i
++
,
j
--
)
{
for
(
i
=
start
,
j
=
end
-
1
;
i
<
j
;
i
++
,
j
--
)
{
hb_internal_glyph_info_t
t
;
hb_internal_glyph_info_t
t
;
t
=
buffer
->
in_string
[
i
];
t
=
buffer
->
in_string
[
i
];
...
@@ -491,7 +493,7 @@ hb_buffer_reverse (hb_buffer_t *buffer)
...
@@ -491,7 +493,7 @@ hb_buffer_reverse (hb_buffer_t *buffer)
}
}
if
(
buffer
->
positions
)
{
if
(
buffer
->
positions
)
{
for
(
i
=
0
,
j
=
buffer
->
in_length
-
1
;
i
<
buffer
->
in_length
/
2
;
i
++
,
j
--
)
{
for
(
i
=
0
,
j
=
end
-
1
;
i
<
j
;
i
++
,
j
--
)
{
hb_internal_glyph_position_t
t
;
hb_internal_glyph_position_t
t
;
t
=
buffer
->
positions
[
i
];
t
=
buffer
->
positions
[
i
];
...
@@ -501,6 +503,38 @@ hb_buffer_reverse (hb_buffer_t *buffer)
...
@@ -501,6 +503,38 @@ hb_buffer_reverse (hb_buffer_t *buffer)
}
}
}
}
void
hb_buffer_reverse
(
hb_buffer_t
*
buffer
)
{
if
(
HB_UNLIKELY
(
!
buffer
->
in_length
))
return
;
reverse_range
(
buffer
,
0
,
buffer
->
in_length
);
}
void
hb_buffer_reverse_clusters
(
hb_buffer_t
*
buffer
)
{
unsigned
int
i
,
start
,
count
,
last_cluster
;
if
(
HB_UNLIKELY
(
!
buffer
->
in_length
))
return
;
hb_buffer_reverse
(
buffer
);
count
=
buffer
->
in_length
;
start
=
0
;
last_cluster
=
buffer
->
in_string
[
0
].
cluster
;
for
(
i
=
1
;
i
<
count
;
i
++
)
{
if
(
last_cluster
!=
buffer
->
in_string
[
i
].
cluster
)
{
reverse_range
(
buffer
,
start
,
i
);
start
=
i
;
last_cluster
=
buffer
->
in_string
[
i
].
cluster
;
}
}
reverse_range
(
buffer
,
start
,
i
);
}
#define ADD_UTF(T) \
#define ADD_UTF(T) \
HB_STMT_START { \
HB_STMT_START { \
...
...
src/hb-buffer.h
浏览文件 @
ff44f88d
...
@@ -36,13 +36,6 @@ HB_BEGIN_DECLS
...
@@ -36,13 +36,6 @@ HB_BEGIN_DECLS
typedef
struct
_hb_buffer_t
hb_buffer_t
;
typedef
struct
_hb_buffer_t
hb_buffer_t
;
typedef
enum
_hb_direction_t
{
HB_DIRECTION_LTR
,
HB_DIRECTION_RTL
,
HB_DIRECTION_TTB
,
HB_DIRECTION_BTT
}
hb_direction_t
;
typedef
struct
_hb_glyph_info_t
{
typedef
struct
_hb_glyph_info_t
{
hb_codepoint_t
codepoint
;
hb_codepoint_t
codepoint
;
hb_mask_t
mask
;
hb_mask_t
mask
;
...
@@ -115,6 +108,9 @@ hb_buffer_ensure (hb_buffer_t *buffer,
...
@@ -115,6 +108,9 @@ hb_buffer_ensure (hb_buffer_t *buffer,
void
void
hb_buffer_reverse
(
hb_buffer_t
*
buffer
);
hb_buffer_reverse
(
hb_buffer_t
*
buffer
);
void
hb_buffer_reverse_clusters
(
hb_buffer_t
*
buffer
);
/* Filling the buffer in */
/* Filling the buffer in */
...
...
src/hb-common.h
浏览文件 @
ff44f88d
...
@@ -72,4 +72,15 @@ typedef uint32_t hb_mask_t;
...
@@ -72,4 +72,15 @@ typedef uint32_t hb_mask_t;
typedef
void
(
*
hb_destroy_func_t
)
(
void
*
user_data
);
typedef
void
(
*
hb_destroy_func_t
)
(
void
*
user_data
);
typedef
enum
_hb_direction_t
{
HB_DIRECTION_LTR
,
HB_DIRECTION_RTL
,
HB_DIRECTION_TTB
,
HB_DIRECTION_BTT
}
hb_direction_t
;
#define HB_DIRECTION_IS_HORIZONTAL(dir) ((dir) == HB_DIRECTION_LTR || (dir) == HB_DIRECTION_RTL)
#define HB_DIRECTION_IS_VERTICAL(dir) ((dir) == HB_DIRECTION_TTB || (dir) == HB_DIRECTION_BTT)
#endif
/* HB_COMMON_H */
#endif
/* HB_COMMON_H */
src/hb-shape.c
浏览文件 @
ff44f88d
...
@@ -37,6 +37,17 @@ is_variation_selector (hb_codepoint_t unicode)
...
@@ -37,6 +37,17 @@ is_variation_selector (hb_codepoint_t unicode)
(
unicode
>=
0xE0100
&&
unicode
<=
0xE01EF
);
(
unicode
>=
0xE0100
&&
unicode
<=
0xE01EF
);
}
}
static
void
hb_form_clusters
(
hb_buffer_t
*
buffer
)
{
unsigned
int
count
;
count
=
buffer
->
in_length
;
for
(
buffer
->
in_pos
=
1
;
buffer
->
in_pos
<
count
;
buffer
->
in_pos
++
)
if
(
buffer
->
unicode
->
get_general_category
(
IN_CURGLYPH
())
==
HB_CATEGORY_NON_SPACING_MARK
)
IN_CLUSTER
(
buffer
->
in_pos
)
=
IN_CLUSTER
(
buffer
->
in_pos
-
1
);
}
static
void
static
void
hb_map_glyphs
(
hb_font_t
*
font
,
hb_map_glyphs
(
hb_font_t
*
font
,
hb_face_t
*
face
,
hb_face_t
*
face
,
...
@@ -45,7 +56,6 @@ hb_map_glyphs (hb_font_t *font,
...
@@ -45,7 +56,6 @@ hb_map_glyphs (hb_font_t *font,
unsigned
int
count
;
unsigned
int
count
;
count
=
buffer
->
in_length
-
1
;
count
=
buffer
->
in_length
-
1
;
for
(
buffer
->
in_pos
=
0
;
buffer
->
in_pos
<
count
;
buffer
->
in_pos
++
)
{
for
(
buffer
->
in_pos
=
0
;
buffer
->
in_pos
<
count
;
buffer
->
in_pos
++
)
{
if
(
HB_UNLIKELY
(
is_variation_selector
(
IN_NEXTGLYPH
())))
{
if
(
HB_UNLIKELY
(
is_variation_selector
(
IN_NEXTGLYPH
())))
{
IN_CURGLYPH
()
=
hb_font_get_glyph
(
font
,
face
,
IN_CURGLYPH
(),
IN_NEXTGLYPH
());
IN_CURGLYPH
()
=
hb_font_get_glyph
(
font
,
face
,
IN_CURGLYPH
(),
IN_NEXTGLYPH
());
...
@@ -67,7 +77,6 @@ hb_position_default (hb_font_t *font,
...
@@ -67,7 +77,6 @@ hb_position_default (hb_font_t *font,
hb_buffer_clear_positions
(
buffer
);
hb_buffer_clear_positions
(
buffer
);
count
=
buffer
->
in_length
;
count
=
buffer
->
in_length
;
for
(
buffer
->
in_pos
=
0
;
buffer
->
in_pos
<
count
;
buffer
->
in_pos
++
)
{
for
(
buffer
->
in_pos
=
0
;
buffer
->
in_pos
<
count
;
buffer
->
in_pos
++
)
{
hb_glyph_metrics_t
metrics
;
hb_glyph_metrics_t
metrics
;
hb_font_get_glyph_metrics
(
font
,
face
,
IN_CURGLYPH
(),
&
metrics
);
hb_font_get_glyph_metrics
(
font
,
face
,
IN_CURGLYPH
(),
&
metrics
);
...
@@ -77,6 +86,23 @@ hb_position_default (hb_font_t *font,
...
@@ -77,6 +86,23 @@ hb_position_default (hb_font_t *font,
}
}
static
hb_direction_t
hb_ensure_native_direction
(
hb_buffer_t
*
buffer
)
{
hb_direction_t
original_direction
=
hb_buffer_get_direction
(
buffer
);
/* TODO vertical */
if
(
HB_DIRECTION_IS_HORIZONTAL
(
original_direction
)
&&
original_direction
!=
_hb_script_get_horizontal_direction
(
hb_buffer_get_script
(
buffer
)))
{
hb_buffer_reverse_clusters
(
buffer
);
hb_buffer_set_direction
(
buffer
,
original_direction
==
HB_DIRECTION_LTR
?
HB_DIRECTION_RTL
:
HB_DIRECTION_LTR
);
}
return
original_direction
;
}
void
void
hb_shape
(
hb_font_t
*
font
,
hb_shape
(
hb_font_t
*
font
,
hb_face_t
*
face
,
hb_face_t
*
face
,
...
@@ -84,7 +110,11 @@ hb_shape (hb_font_t *font,
...
@@ -84,7 +110,11 @@ hb_shape (hb_font_t *font,
hb_feature_t
*
features
,
hb_feature_t
*
features
,
unsigned
int
num_features
)
unsigned
int
num_features
)
{
{
/* form_clusters (buffer); */
hb_direction_t
original_direction
;
hb_form_clusters
(
buffer
);
original_direction
=
hb_ensure_native_direction
(
buffer
);
/* do_mirroring (buffer); */
/* do_mirroring (buffer); */
/* natural direction analysis */
/* natural direction analysis */
/* OT preprocess */
/* OT preprocess */
...
@@ -99,4 +129,6 @@ hb_shape (hb_font_t *font,
...
@@ -99,4 +129,6 @@ hb_shape (hb_font_t *font,
hb_position_default
(
font
,
face
,
buffer
);
hb_position_default
(
font
,
face
,
buffer
);
/* GPOS / kern */
/* GPOS / kern */
hb_buffer_set_direction
(
buffer
,
original_direction
);
}
}
src/hb-unicode-private.h
浏览文件 @
ff44f88d
...
@@ -52,6 +52,11 @@ struct _hb_unicode_funcs_t {
...
@@ -52,6 +52,11 @@ struct _hb_unicode_funcs_t {
HB_INTERNAL
hb_unicode_funcs_t
HB_INTERNAL
hb_unicode_funcs_t
_hb_unicode_funcs_nil
;
_hb_unicode_funcs_nil
;
HB_INTERNAL
hb_direction_t
_hb_script_get_horizontal_direction
(
hb_script_t
script
);
HB_END_DECLS
HB_END_DECLS
#endif
/* HB_UNICODE_PRIVATE_H */
#endif
/* HB_UNICODE_PRIVATE_H */
src/hb-unicode.c
浏览文件 @
ff44f88d
...
@@ -159,3 +159,106 @@ hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
...
@@ -159,3 +159,106 @@ hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
ufuncs
->
get_eastasian_width
=
eastasian_width_func
?
eastasian_width_func
:
hb_unicode_get_eastasian_width_nil
;
ufuncs
->
get_eastasian_width
=
eastasian_width_func
?
eastasian_width_func
:
hb_unicode_get_eastasian_width_nil
;
}
}
#define LTR HB_DIRECTION_LTR
#define RTL HB_DIRECTION_RTL
const
hb_direction_t
horiz_dir
[]
=
{
LTR
,
/* Zyyy */
LTR
,
/* Qaai */
RTL
,
/* Arab */
LTR
,
/* Armn */
LTR
,
/* Beng */
LTR
,
/* Bopo */
LTR
,
/* Cher */
LTR
,
/* Qaac */
LTR
,
/* Cyrl (Cyrs) */
LTR
,
/* Dsrt */
LTR
,
/* Deva */
LTR
,
/* Ethi */
LTR
,
/* Geor (Geon, Geoa) */
LTR
,
/* Goth */
LTR
,
/* Grek */
LTR
,
/* Gujr */
LTR
,
/* Guru */
LTR
,
/* Hani */
LTR
,
/* Hang */
RTL
,
/* Hebr */
LTR
,
/* Hira */
LTR
,
/* Knda */
LTR
,
/* Kana */
LTR
,
/* Khmr */
LTR
,
/* Laoo */
LTR
,
/* Latn (Latf, Latg) */
LTR
,
/* Mlym */
LTR
,
/* Mong */
LTR
,
/* Mymr */
LTR
,
/* Ogam */
LTR
,
/* Ital */
LTR
,
/* Orya */
LTR
,
/* Runr */
LTR
,
/* Sinh */
RTL
,
/* Syrc (Syrj, Syrn, Syre) */
LTR
,
/* Taml */
LTR
,
/* Telu */
RTL
,
/* Thaa */
LTR
,
/* Thai */
LTR
,
/* Tibt */
LTR
,
/* Cans */
LTR
,
/* Yiii */
LTR
,
/* Tglg */
LTR
,
/* Hano */
LTR
,
/* Buhd */
LTR
,
/* Tagb */
/* Unicode-4.0 additions */
LTR
,
/* Brai */
LTR
,
/* Cprt */
LTR
,
/* Limb */
LTR
,
/* Osma */
LTR
,
/* Shaw */
LTR
,
/* Linb */
LTR
,
/* Tale */
LTR
,
/* Ugar */
/* Unicode-4.1 additions */
LTR
,
/* Talu */
LTR
,
/* Bugi */
LTR
,
/* Glag */
LTR
,
/* Tfng */
LTR
,
/* Sylo */
LTR
,
/* Xpeo */
LTR
,
/* Khar */
/* Unicode-5.0 additions */
LTR
,
/* Zzzz */
LTR
,
/* Bali */
LTR
,
/* Xsux */
RTL
,
/* Phnx */
LTR
,
/* Phag */
RTL
,
/* Nkoo */
/* Unicode-5.1 additions */
LTR
,
/* Kali */
LTR
,
/* Lepc */
LTR
,
/* Rjng */
LTR
,
/* Sund */
LTR
,
/* Saur */
LTR
,
/* Cham */
LTR
,
/* Olck */
LTR
,
/* Vaii */
LTR
,
/* Cari */
LTR
,
/* Lyci */
LTR
/* Lydi */
};
#undef LTR
#undef RTL
HB_INTERNAL
hb_direction_t
_hb_script_get_horizontal_direction
(
hb_script_t
script
)
{
if
(
HB_UNLIKELY
((
unsigned
int
)
script
>=
ARRAY_LENGTH
(
horiz_dir
)))
return
HB_DIRECTION_LTR
;
return
horiz_dir
[
script
];
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录