2 * Copyright (C) 2012 Grigori Goronzy <greg@kinoho.net>
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include "hb-private.hh"
19 #include "hb-unicode-private.hh"
23 static const hb_script_t ucdn_script_translate
[] =
52 HB_SCRIPT_CANADIAN_SYLLABICS
,
80 HB_SCRIPT_NEW_TAI_LUE
,
83 HB_SCRIPT_SYLOTI_NAGRI
,
84 HB_SCRIPT_OLD_PERSIAN
,
105 HB_SCRIPT_EGYPTIAN_HIEROGLYPHS
,
110 HB_SCRIPT_MEETEI_MAYEK
,
111 HB_SCRIPT_IMPERIAL_ARAMAIC
,
112 HB_SCRIPT_OLD_SOUTH_ARABIAN
,
113 HB_SCRIPT_INSCRIPTIONAL_PARTHIAN
,
114 HB_SCRIPT_INSCRIPTIONAL_PAHLAVI
,
115 HB_SCRIPT_OLD_TURKIC
,
121 HB_SCRIPT_MEROITIC_CURSIVE
,
122 HB_SCRIPT_MEROITIC_HIEROGLYPHS
,
125 HB_SCRIPT_SORA_SOMPENG
,
129 HB_SCRIPT_CAUCASIAN_ALBANIAN
,
137 HB_SCRIPT_MANICHAEAN
,
138 HB_SCRIPT_MENDE_KIKAKUI
,
142 HB_SCRIPT_OLD_NORTH_ARABIAN
,
143 HB_SCRIPT_OLD_PERMIC
,
144 HB_SCRIPT_PAHAWH_HMONG
,
146 HB_SCRIPT_PAU_CIN_HAU
,
147 HB_SCRIPT_PSALTER_PAHLAVI
,
150 HB_SCRIPT_WARANG_CITI
,
152 HB_SCRIPT_ANATOLIAN_HIEROGLYPHS
,
155 HB_SCRIPT_OLD_HUNGARIAN
,
156 HB_SCRIPT_SIGNWRITING
,
159 static hb_unicode_combining_class_t
160 hb_ucdn_combining_class(hb_unicode_funcs_t
*ufuncs
, hb_codepoint_t unicode
,
161 void *user_data HB_UNUSED
)
163 return (hb_unicode_combining_class_t
) ucdn_get_combining_class(unicode
);
167 hb_ucdn_eastasian_width(hb_unicode_funcs_t
*ufuncs
, hb_codepoint_t unicode
,
168 void *user_data HB_UNUSED
)
170 int w
= ucdn_get_east_asian_width(unicode
);
171 return (w
== UCDN_EAST_ASIAN_F
|| w
== UCDN_EAST_ASIAN_W
) ? 2 : 1;
174 static hb_unicode_general_category_t
175 hb_ucdn_general_category(hb_unicode_funcs_t
*ufuncs
, hb_codepoint_t unicode
,
176 void *user_data HB_UNUSED
)
178 return (hb_unicode_general_category_t
)ucdn_get_general_category(unicode
);
181 static hb_codepoint_t
182 hb_ucdn_mirroring(hb_unicode_funcs_t
*ufuncs
, hb_codepoint_t unicode
,
183 void *user_data HB_UNUSED
)
185 return ucdn_mirror(unicode
);
189 hb_ucdn_script(hb_unicode_funcs_t
*ufuncs
, hb_codepoint_t unicode
,
190 void *user_data HB_UNUSED
)
192 return ucdn_script_translate
[ucdn_get_script(unicode
)];
196 hb_ucdn_compose(hb_unicode_funcs_t
*ufuncs
,
197 hb_codepoint_t a
, hb_codepoint_t b
, hb_codepoint_t
*ab
,
198 void *user_data HB_UNUSED
)
200 return ucdn_compose(ab
, a
, b
);
204 hb_ucdn_decompose(hb_unicode_funcs_t
*ufuncs
,
205 hb_codepoint_t ab
, hb_codepoint_t
*a
, hb_codepoint_t
*b
,
206 void *user_data HB_UNUSED
)
208 return ucdn_decompose(ab
, a
, b
);
212 hb_ucdn_decompose_compatibility(hb_unicode_funcs_t
*ufuncs
,
213 hb_codepoint_t u
, hb_codepoint_t
*decomposed
,
214 void *user_data HB_UNUSED
)
216 return ucdn_compat_decompose(u
, decomposed
);
219 extern "C" HB_INTERNAL
221 hb_ucdn_get_unicode_funcs (void)
223 static const hb_unicode_funcs_t _hb_ucdn_unicode_funcs
= {
224 HB_OBJECT_HEADER_STATIC
,
227 true, /* immutable */
229 #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_ucdn_##name,
230 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
231 #undef HB_UNICODE_FUNC_IMPLEMENT
235 return const_cast<hb_unicode_funcs_t
*> (&_hb_ucdn_unicode_funcs
);