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
,
130 static hb_unicode_combining_class_t
131 hb_ucdn_combining_class(hb_unicode_funcs_t
*ufuncs
, hb_codepoint_t unicode
,
132 void *user_data HB_UNUSED
)
134 return (hb_unicode_combining_class_t
) ucdn_get_combining_class(unicode
);
138 hb_ucdn_eastasian_width(hb_unicode_funcs_t
*ufuncs
, hb_codepoint_t unicode
,
139 void *user_data HB_UNUSED
)
141 int w
= ucdn_get_east_asian_width(unicode
);
142 return (w
== UCDN_EAST_ASIAN_F
|| w
== UCDN_EAST_ASIAN_W
) ? 2 : 1;
145 static hb_unicode_general_category_t
146 hb_ucdn_general_category(hb_unicode_funcs_t
*ufuncs
, hb_codepoint_t unicode
,
147 void *user_data HB_UNUSED
)
149 return (hb_unicode_general_category_t
)ucdn_get_general_category(unicode
);
152 static hb_codepoint_t
153 hb_ucdn_mirroring(hb_unicode_funcs_t
*ufuncs
, hb_codepoint_t unicode
,
154 void *user_data HB_UNUSED
)
156 return ucdn_mirror(unicode
);
160 hb_ucdn_script(hb_unicode_funcs_t
*ufuncs
, hb_codepoint_t unicode
,
161 void *user_data HB_UNUSED
)
163 return ucdn_script_translate
[ucdn_get_script(unicode
)];
167 hb_ucdn_compose(hb_unicode_funcs_t
*ufuncs
,
168 hb_codepoint_t a
, hb_codepoint_t b
, hb_codepoint_t
*ab
,
169 void *user_data HB_UNUSED
)
171 return ucdn_compose(ab
, a
, b
);
175 hb_ucdn_decompose(hb_unicode_funcs_t
*ufuncs
,
176 hb_codepoint_t ab
, hb_codepoint_t
*a
, hb_codepoint_t
*b
,
177 void *user_data HB_UNUSED
)
179 return ucdn_decompose(ab
, a
, b
);
183 hb_ucdn_decompose_compatibility(hb_unicode_funcs_t
*ufuncs
,
184 hb_codepoint_t u
, hb_codepoint_t
*decomposed
,
185 void *user_data HB_UNUSED
)
187 return ucdn_compat_decompose(u
, decomposed
);
190 extern "C" HB_INTERNAL
192 hb_ucdn_get_unicode_funcs (void)
194 static const hb_unicode_funcs_t _hb_ucdn_unicode_funcs
= {
195 HB_OBJECT_HEADER_STATIC
,
198 true, /* immutable */
200 #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_ucdn_##name,
201 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
202 #undef HB_UNICODE_FUNC_IMPLEMENT
206 return const_cast<hb_unicode_funcs_t
*> (&_hb_ucdn_unicode_funcs
);