Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
e9f28a38
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看板
提交
e9f28a38
编写于
8月 11, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[OT] Add shape_plan to Arabic shaper
上级
344cc566
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
29 deletion
+53
-29
src/hb-ot-shape-complex-arabic.cc
src/hb-ot-shape-complex-arabic.cc
+53
-29
未找到文件。
src/hb-ot-shape-complex-arabic.cc
浏览文件 @
e9f28a38
/*
* Copyright © 2010 Google, Inc.
* Copyright © 2010
,2012
Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
...
...
@@ -99,7 +99,7 @@ static uint16_t get_ligature (hb_codepoint_t first, hb_codepoint_t second)
return
0
;
}
static
const
hb_tag_t
arabic_
syriac_
features
[]
=
static
const
hb_tag_t
arabic_features
[]
=
{
HB_TAG
(
'i'
,
'n'
,
'i'
,
't'
),
HB_TAG
(
'm'
,
'e'
,
'd'
,
'i'
),
...
...
@@ -127,9 +127,7 @@ enum {
NONE
,
COMMON_NUM_FEATURES
=
4
,
SYRIAC_NUM_FEATURES
=
7
,
TOTAL_NUM_FEATURES
=
NONE
ARABIC_NUM_FEATURES
=
NONE
};
static
const
struct
arabic_state_table_entry
{
...
...
@@ -184,9 +182,8 @@ collect_features_arabic (hb_ot_shape_planner_t *plan)
map
->
add_gsub_pause
(
NULL
);
unsigned
int
num_features
=
plan
->
props
.
script
==
HB_SCRIPT_SYRIAC
?
SYRIAC_NUM_FEATURES
:
COMMON_NUM_FEATURES
;
for
(
unsigned
int
i
=
0
;
i
<
num_features
;
i
++
)
map
->
add_bool_feature
(
arabic_syriac_features
[
i
],
false
);
for
(
unsigned
int
i
=
0
;
i
<
ARABIC_NUM_FEATURES
;
i
++
)
map
->
add_bool_feature
(
arabic_features
[
i
],
false
);
map
->
add_gsub_pause
(
NULL
);
...
...
@@ -200,10 +197,51 @@ collect_features_arabic (hb_ot_shape_planner_t *plan)
map
->
add_bool_feature
(
HB_TAG
(
'c'
,
's'
,
'w'
,
'h'
));
}
struct
arabic_shape_plan_t
{
ASSERT_POD
();
bool
do_fallback
;
hb_mask_t
mask_array
[
ARABIC_NUM_FEATURES
];
};
static
void
*
data_create_arabic
(
const
hb_ot_shape_plan_t
*
plan
)
{
arabic_shape_plan_t
*
arabic_plan
=
(
arabic_shape_plan_t
*
)
calloc
(
1
,
sizeof
(
arabic_shape_plan_t
));
if
(
unlikely
(
!
arabic_plan
))
return
NULL
;
hb_mask_t
total_masks
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
ARABIC_NUM_FEATURES
;
i
++
)
{
arabic_plan
->
mask_array
[
i
]
=
plan
->
map
.
get_1_mask
(
arabic_features
[
i
]);
total_masks
|=
arabic_plan
->
mask_array
[
i
];
}
/* Pitfalls:
* - This path fires if user force-set init/medi/fina/isol off,
* - If font does not declare script 'arab', well, what to do?
* Most probably it's safe to assume that init/medi/fina/isol
* still mean Arabic shaping, although they do not have to.
*/
arabic_plan
->
do_fallback
=
0
==
total_masks
;
return
arabic_plan
;
}
static
void
data_destroy_arabic
(
void
*
data
)
{
free
(
data
);
}
static
void
arabic_fallback_shape
(
hb_font_t
*
font
,
hb_buffer_t
*
buffer
)
{
/* Only Arabic has presentation forms encoded in Unicode. */
if
(
buffer
->
props
.
script
!=
HB_SCRIPT_ARABIC
)
return
;
unsigned
int
count
=
buffer
->
len
;
hb_codepoint_t
glyph
;
...
...
@@ -240,6 +278,8 @@ setup_masks_arabic (const hb_ot_shape_plan_t *plan,
hb_buffer_t
*
buffer
,
hb_font_t
*
font
)
{
const
arabic_shape_plan_t
*
arabic_plan
=
(
const
arabic_shape_plan_t
*
)
plan
->
data
;
unsigned
int
count
=
buffer
->
len
;
unsigned
int
prev
=
0
,
state
=
0
;
...
...
@@ -265,28 +305,12 @@ setup_masks_arabic (const hb_ot_shape_plan_t *plan,
state
=
entry
->
next_state
;
}
hb_mask_t
mask_array
[
TOTAL_NUM_FEATURES
+
1
]
=
{
0
};
hb_mask_t
total_masks
=
0
;
unsigned
int
num_masks
=
buffer
->
props
.
script
==
HB_SCRIPT_SYRIAC
?
SYRIAC_NUM_FEATURES
:
COMMON_NUM_FEATURES
;
for
(
unsigned
int
i
=
0
;
i
<
num_masks
;
i
++
)
{
mask_array
[
i
]
=
plan
->
map
.
get_1_mask
(
arabic_syriac_features
[
i
]);
total_masks
|=
mask_array
[
i
];
}
if
(
total_masks
)
{
if
(
likely
(
!
arabic_plan
->
do_fallback
))
{
/* Has OpenType tables */
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
buffer
->
info
[
i
].
mask
|=
mask_array
[
buffer
->
info
[
i
].
arabic_shaping_action
()];
}
else
if
(
buffer
->
props
.
script
==
HB_SCRIPT_ARABIC
)
{
/* Fallback Arabic shaping to Presentation Forms */
/* Pitfalls:
* - This path fires if user force-set init/medi/fina/isol off,
* - If font does not declare script 'arab', well, what to do?
* Most probably it's safe to assume that init/medi/fina/isol
* still mean Arabic shaping, although they do not have to.
*/
buffer
->
info
[
i
].
mask
|=
arabic_plan
->
mask_array
[
buffer
->
info
[
i
].
arabic_shaping_action
()];
}
else
arabic_fallback_shape
(
font
,
buffer
);
}
HB_BUFFER_DEALLOCATE_VAR
(
buffer
,
arabic_shaping_action
);
}
...
...
@@ -296,8 +320,8 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic =
"arabic"
,
collect_features_arabic
,
NULL
,
/* override_features */
NULL
,
/* data_create */
NULL
,
/* data_destroy */
data_create_arabic
,
data_destroy_arabic
,
NULL
,
/* normalization_preference */
setup_masks_arabic
,
true
,
/* zero_width_attached_marks */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录