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,
165 static hb_unicode_combining_class_t
166 hb_ucdn_combining_class(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
167 void *user_data HB_UNUSED)
169 return (hb_unicode_combining_class_t) ucdn_get_combining_class(unicode);
173 hb_ucdn_eastasian_width(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
174 void *user_data HB_UNUSED)
176 int w = ucdn_get_east_asian_width(unicode);
177 return (w == UCDN_EAST_ASIAN_F || w == UCDN_EAST_ASIAN_W) ? 2 : 1;
180 static hb_unicode_general_category_t
181 hb_ucdn_general_category(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
182 void *user_data HB_UNUSED)
184 return (hb_unicode_general_category_t)ucdn_get_general_category(unicode);
187 static hb_codepoint_t
188 hb_ucdn_mirroring(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
189 void *user_data HB_UNUSED)
191 return ucdn_mirror(unicode);
195 hb_ucdn_script(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
196 void *user_data HB_UNUSED)
198 return ucdn_script_translate[ucdn_get_script(unicode)];
202 hb_ucdn_compose(hb_unicode_funcs_t *ufuncs,
203 hb_codepoint_t a, hb_codepoint_t b, hb_codepoint_t *ab,
204 void *user_data HB_UNUSED)
206 return ucdn_compose(ab, a, b);
210 hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs,
211 hb_codepoint_t ab, hb_codepoint_t *a, hb_codepoint_t *b,
212 void *user_data HB_UNUSED)
214 return ucdn_decompose(ab, a, b);
218 hb_ucdn_decompose_compatibility(hb_unicode_funcs_t *ufuncs,
219 hb_codepoint_t u, hb_codepoint_t *decomposed,
220 void *user_data HB_UNUSED)
222 return ucdn_compat_decompose(u, decomposed);
225 extern "C" HB_INTERNAL
227 hb_ucdn_get_unicode_funcs (void)
229 static const hb_unicode_funcs_t _hb_ucdn_unicode_funcs = {
230 HB_OBJECT_HEADER_STATIC,
233 true, /* immutable */
235 #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_ucdn_##name,
236 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
237 #undef HB_UNICODE_FUNC_IMPLEMENT
241 return const_cast<hb_unicode_funcs_t *> (&_hb_ucdn_unicode_funcs);