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,
153 static hb_unicode_combining_class_t
154 hb_ucdn_combining_class(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
155 void *user_data HB_UNUSED)
157 return (hb_unicode_combining_class_t) ucdn_get_combining_class(unicode);
161 hb_ucdn_eastasian_width(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
162 void *user_data HB_UNUSED)
164 int w = ucdn_get_east_asian_width(unicode);
165 return (w == UCDN_EAST_ASIAN_F || w == UCDN_EAST_ASIAN_W) ? 2 : 1;
168 static hb_unicode_general_category_t
169 hb_ucdn_general_category(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
170 void *user_data HB_UNUSED)
172 return (hb_unicode_general_category_t)ucdn_get_general_category(unicode);
175 static hb_codepoint_t
176 hb_ucdn_mirroring(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
177 void *user_data HB_UNUSED)
179 return ucdn_mirror(unicode);
183 hb_ucdn_script(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
184 void *user_data HB_UNUSED)
186 return ucdn_script_translate[ucdn_get_script(unicode)];
190 hb_ucdn_compose(hb_unicode_funcs_t *ufuncs,
191 hb_codepoint_t a, hb_codepoint_t b, hb_codepoint_t *ab,
192 void *user_data HB_UNUSED)
194 return ucdn_compose(ab, a, b);
198 hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs,
199 hb_codepoint_t ab, hb_codepoint_t *a, hb_codepoint_t *b,
200 void *user_data HB_UNUSED)
202 return ucdn_decompose(ab, a, b);
206 hb_ucdn_decompose_compatibility(hb_unicode_funcs_t *ufuncs,
207 hb_codepoint_t u, hb_codepoint_t *decomposed,
208 void *user_data HB_UNUSED)
210 return ucdn_compat_decompose(u, decomposed);
213 extern "C" HB_INTERNAL
215 hb_ucdn_get_unicode_funcs (void)
217 static const hb_unicode_funcs_t _hb_ucdn_unicode_funcs = {
218 HB_OBJECT_HEADER_STATIC,
221 true, /* immutable */
223 #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_ucdn_##name,
224 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
225 #undef HB_UNICODE_FUNC_IMPLEMENT
229 return const_cast<hb_unicode_funcs_t *> (&_hb_ucdn_unicode_funcs);