Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
43f04a74
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看板
提交
43f04a74
编写于
11月 14, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move Thai shaper into a separate file
上级
ba82325b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
143 addition
and
115 deletion
+143
-115
src/Makefile.am
src/Makefile.am
+2
-1
src/hb-ot-shape-complex-default.cc
src/hb-ot-shape-complex-default.cc
+0
-114
src/hb-ot-shape-complex-thai.cc
src/hb-ot-shape-complex-thai.cc
+141
-0
未找到文件。
src/Makefile.am
浏览文件 @
43f04a74
...
@@ -81,11 +81,12 @@ HBSOURCES += \
...
@@ -81,11 +81,12 @@ HBSOURCES += \
hb-ot-shape-complex-arabic.cc
\
hb-ot-shape-complex-arabic.cc
\
hb-ot-shape-complex-arabic-fallback.hh
\
hb-ot-shape-complex-arabic-fallback.hh
\
hb-ot-shape-complex-arabic-table.hh
\
hb-ot-shape-complex-arabic-table.hh
\
hb-ot-shape-complex-default.cc
\
hb-ot-shape-complex-indic.cc
\
hb-ot-shape-complex-indic.cc
\
hb-ot-shape-complex-indic-machine.hh
\
hb-ot-shape-complex-indic-machine.hh
\
hb-ot-shape-complex-indic-private.hh
\
hb-ot-shape-complex-indic-private.hh
\
hb-ot-shape-complex-indic-table.hh
\
hb-ot-shape-complex-indic-table.hh
\
hb-ot-shape-complex-
misc
.cc
\
hb-ot-shape-complex-
thai
.cc
\
hb-ot-shape-complex-private.hh
\
hb-ot-shape-complex-private.hh
\
hb-ot-shape-normalize-private.hh
\
hb-ot-shape-normalize-private.hh
\
hb-ot-shape-normalize.cc
\
hb-ot-shape-normalize.cc
\
...
...
src/hb-ot-shape-complex-
misc
.cc
→
src/hb-ot-shape-complex-
default
.cc
浏览文件 @
43f04a74
...
@@ -223,117 +223,3 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default =
...
@@ -223,117 +223,3 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default =
true
,
/* zero_width_attached_marks */
true
,
/* zero_width_attached_marks */
true
,
/* fallback_position */
true
,
/* fallback_position */
};
};
/* Thai / Lao shaper */
static
void
preprocess_text_thai
(
const
hb_ot_shape_plan_t
*
plan
HB_UNUSED
,
hb_buffer_t
*
buffer
,
hb_font_t
*
font
HB_UNUSED
)
{
/* The following is NOT specified in the MS OT Thai spec, however, it seems
* to be what Uniscribe and other engines implement. According to Eric Muller:
*
* When you have a SARA AM, decompose it in NIKHAHIT + SARA AA, *and* move the
* NIKHAHIT backwards over any tone mark (0E48-0E4B).
*
* <0E14, 0E4B, 0E33> -> <0E14, 0E4D, 0E4B, 0E32>
*
* This reordering is legit only when the NIKHAHIT comes from a SARA AM, not
* when it's there to start with. The string <0E14, 0E4B, 0E4D> is probably
* not what a user wanted, but the rendering is nevertheless nikhahit above
* chattawa.
*
* Same for Lao.
*
* Note:
*
* Uniscribe also does so below-marks reordering. Namely, it positions U+0E3A
* after U+0E38 and U+0E39. We do that by modifying the ccc for U+0E3A.
* See unicode->modified_combining_class (). Lao does NOT have a U+0E3A
* equivalent.
*/
/*
* Here are the characters of significance:
*
* Thai Lao
* SARA AM: U+0E33 U+0EB3
* SARA AA: U+0E32 U+0EB2
* Nikhahit: U+0E4D U+0ECD
*
* Testing shows that Uniscribe reorder the following marks:
* Thai: <0E31,0E34..0E37,0E47..0E4E>
* Lao: <0EB1,0EB4..0EB7,0EC7..0ECE>
*
* Note how the Lao versions are the same as Thai + 0x80.
*/
/* We only get one script at a time, so a script-agnostic implementation
* is adequate here. */
#define IS_SARA_AM(x) (((x) & ~0x0080) == 0x0E33)
#define NIKHAHIT_FROM_SARA_AM(x) ((x) - 0xE33 + 0xE4D)
#define SARA_AA_FROM_SARA_AM(x) ((x) - 1)
#define IS_TONE_MARK(x) (hb_in_ranges<hb_codepoint_t> ((x) & ~0x0080, 0x0E34, 0x0E37, 0x0E47, 0x0E4E, 0x0E31, 0x0E31))
buffer
->
clear_output
();
unsigned
int
count
=
buffer
->
len
;
for
(
buffer
->
idx
=
0
;
buffer
->
idx
<
count
;)
{
hb_codepoint_t
u
=
buffer
->
cur
().
codepoint
;
if
(
likely
(
!
IS_SARA_AM
(
u
)))
{
buffer
->
next_glyph
();
continue
;
}
/* Is SARA AM. Decompose and reorder. */
hb_codepoint_t
decomposed
[
2
]
=
{
hb_codepoint_t
(
NIKHAHIT_FROM_SARA_AM
(
u
)),
hb_codepoint_t
(
SARA_AA_FROM_SARA_AM
(
u
))};
buffer
->
replace_glyphs
(
1
,
2
,
decomposed
);
if
(
unlikely
(
buffer
->
in_error
))
return
;
/* Ok, let's see... */
unsigned
int
end
=
buffer
->
out_len
;
unsigned
int
start
=
end
-
2
;
while
(
start
>
0
&&
IS_TONE_MARK
(
buffer
->
out_info
[
start
-
1
].
codepoint
))
start
--
;
if
(
start
+
2
<
end
)
{
/* Move Nikhahit (end-2) to the beginning */
buffer
->
merge_out_clusters
(
start
,
end
);
hb_glyph_info_t
t
=
buffer
->
out_info
[
end
-
2
];
memmove
(
buffer
->
out_info
+
start
+
1
,
buffer
->
out_info
+
start
,
sizeof
(
buffer
->
out_info
[
0
])
*
(
end
-
start
-
2
));
buffer
->
out_info
[
start
]
=
t
;
}
else
{
/* Since we decomposed, and NIKHAHIT is combining, merge clusters with the
* previous cluster. */
if
(
start
)
buffer
->
merge_out_clusters
(
start
-
1
,
end
);
}
}
buffer
->
swap_buffers
();
}
const
hb_ot_complex_shaper_t
_hb_ot_complex_shaper_thai
=
{
"thai"
,
NULL
,
/* collect_features */
NULL
,
/* override_features */
NULL
,
/* data_create */
NULL
,
/* data_destroy */
preprocess_text_thai
,
NULL
,
/* normalization_preference */
NULL
,
/* decompose */
NULL
,
/* compose */
NULL
,
/* setup_masks */
true
,
/* zero_width_attached_marks */
false
,
/* fallback_position */
};
src/hb-ot-shape-complex-thai.cc
0 → 100644
浏览文件 @
43f04a74
/*
* Copyright © 2010,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Google Author(s): Behdad Esfahbod
*/
#include "hb-ot-shape-complex-private.hh"
/* Thai / Lao shaper */
static
void
preprocess_text_thai
(
const
hb_ot_shape_plan_t
*
plan
HB_UNUSED
,
hb_buffer_t
*
buffer
,
hb_font_t
*
font
HB_UNUSED
)
{
/* The following is NOT specified in the MS OT Thai spec, however, it seems
* to be what Uniscribe and other engines implement. According to Eric Muller:
*
* When you have a SARA AM, decompose it in NIKHAHIT + SARA AA, *and* move the
* NIKHAHIT backwards over any tone mark (0E48-0E4B).
*
* <0E14, 0E4B, 0E33> -> <0E14, 0E4D, 0E4B, 0E32>
*
* This reordering is legit only when the NIKHAHIT comes from a SARA AM, not
* when it's there to start with. The string <0E14, 0E4B, 0E4D> is probably
* not what a user wanted, but the rendering is nevertheless nikhahit above
* chattawa.
*
* Same for Lao.
*
* Note:
*
* Uniscribe also does some below-marks reordering. Namely, it positions U+0E3A
* after U+0E38 and U+0E39. We do that by modifying the ccc for U+0E3A.
* See unicode->modified_combining_class (). Lao does NOT have a U+0E3A
* equivalent.
*/
/*
* Here are the characters of significance:
*
* Thai Lao
* SARA AM: U+0E33 U+0EB3
* SARA AA: U+0E32 U+0EB2
* Nikhahit: U+0E4D U+0ECD
*
* Testing shows that Uniscribe reorder the following marks:
* Thai: <0E31,0E34..0E37,0E47..0E4E>
* Lao: <0EB1,0EB4..0EB7,0EC7..0ECE>
*
* Note how the Lao versions are the same as Thai + 0x80.
*/
/* We only get one script at a time, so a script-agnostic implementation
* is adequate here. */
#define IS_SARA_AM(x) (((x) & ~0x0080) == 0x0E33)
#define NIKHAHIT_FROM_SARA_AM(x) ((x) - 0xE33 + 0xE4D)
#define SARA_AA_FROM_SARA_AM(x) ((x) - 1)
#define IS_TONE_MARK(x) (hb_in_ranges<hb_codepoint_t> ((x) & ~0x0080, 0x0E34, 0x0E37, 0x0E47, 0x0E4E, 0x0E31, 0x0E31))
buffer
->
clear_output
();
unsigned
int
count
=
buffer
->
len
;
for
(
buffer
->
idx
=
0
;
buffer
->
idx
<
count
;)
{
hb_codepoint_t
u
=
buffer
->
cur
().
codepoint
;
if
(
likely
(
!
IS_SARA_AM
(
u
)))
{
buffer
->
next_glyph
();
continue
;
}
/* Is SARA AM. Decompose and reorder. */
hb_codepoint_t
decomposed
[
2
]
=
{
hb_codepoint_t
(
NIKHAHIT_FROM_SARA_AM
(
u
)),
hb_codepoint_t
(
SARA_AA_FROM_SARA_AM
(
u
))};
buffer
->
replace_glyphs
(
1
,
2
,
decomposed
);
if
(
unlikely
(
buffer
->
in_error
))
return
;
/* Ok, let's see... */
unsigned
int
end
=
buffer
->
out_len
;
unsigned
int
start
=
end
-
2
;
while
(
start
>
0
&&
IS_TONE_MARK
(
buffer
->
out_info
[
start
-
1
].
codepoint
))
start
--
;
if
(
start
+
2
<
end
)
{
/* Move Nikhahit (end-2) to the beginning */
buffer
->
merge_out_clusters
(
start
,
end
);
hb_glyph_info_t
t
=
buffer
->
out_info
[
end
-
2
];
memmove
(
buffer
->
out_info
+
start
+
1
,
buffer
->
out_info
+
start
,
sizeof
(
buffer
->
out_info
[
0
])
*
(
end
-
start
-
2
));
buffer
->
out_info
[
start
]
=
t
;
}
else
{
/* Since we decomposed, and NIKHAHIT is combining, merge clusters with the
* previous cluster. */
if
(
start
)
buffer
->
merge_out_clusters
(
start
-
1
,
end
);
}
}
buffer
->
swap_buffers
();
}
const
hb_ot_complex_shaper_t
_hb_ot_complex_shaper_thai
=
{
"thai"
,
NULL
,
/* collect_features */
NULL
,
/* override_features */
NULL
,
/* data_create */
NULL
,
/* data_destroy */
preprocess_text_thai
,
NULL
,
/* normalization_preference */
NULL
,
/* decompose */
NULL
,
/* compose */
NULL
,
/* setup_masks */
true
,
/* zero_width_attached_marks */
false
,
/* fallback_position */
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录