143 HB_SCRIPT_OLD_PERMIC, 144 HB_SCRIPT_PAHAWH_HMONG, 145 HB_SCRIPT_PALMYRENE, 146 HB_SCRIPT_PAU_CIN_HAU, 147 HB_SCRIPT_PSALTER_PAHLAVI, 148 HB_SCRIPT_SIDDHAM, 149 HB_SCRIPT_TIRHUTA, 150 HB_SCRIPT_WARANG_CITI, 151 HB_SCRIPT_AHOM, 152 HB_SCRIPT_ANATOLIAN_HIEROGLYPHS, 153 HB_SCRIPT_HATRAN, 154 HB_SCRIPT_MULTANI, 155 HB_SCRIPT_OLD_HUNGARIAN, 156 HB_SCRIPT_SIGNWRITING, 157 HB_SCRIPT_ADLAM, 158 HB_SCRIPT_BHAIKSUKI, 159 HB_SCRIPT_MARCHEN, 160 HB_SCRIPT_NEWA, 161 HB_SCRIPT_OSAGE, 162 HB_SCRIPT_TANGUT, 163 }; 164 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) 168 { 169 return (hb_unicode_combining_class_t) ucdn_get_combining_class(unicode); 170 } 171 172 static unsigned int 173 hb_ucdn_eastasian_width(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode, 174 void *user_data HB_UNUSED) 175 { 176 int w = ucdn_get_east_asian_width(unicode); 177 return (w == UCDN_EAST_ASIAN_F || w == UCDN_EAST_ASIAN_W) ? 2 : 1; 178 } 179 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) 183 { 184 return (hb_unicode_general_category_t)ucdn_get_general_category(unicode); 185 } 186 187 static hb_codepoint_t 188 hb_ucdn_mirroring(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode, 189 void *user_data HB_UNUSED) 190 { 191 return ucdn_mirror(unicode); 192 } 193 194 static hb_script_t 195 hb_ucdn_script(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode, 196 void *user_data HB_UNUSED) 197 { 198 return ucdn_script_translate[ucdn_get_script(unicode)]; 199 } 200 201 static hb_bool_t 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) 205 { 206 return ucdn_compose(ab, a, b); 207 } 208 209 static hb_bool_t 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) 213 { 214 return ucdn_decompose(ab, a, b); 215 } 216 217 static unsigned int 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) 221 { 222 return ucdn_compat_decompose(u, decomposed); 223 } 224 225 extern "C" HB_INTERNAL 226 hb_unicode_funcs_t * 227 hb_ucdn_get_unicode_funcs (void) 228 { 229 static const hb_unicode_funcs_t _hb_ucdn_unicode_funcs = { 230 HB_OBJECT_HEADER_STATIC, 231 232 NULL, /* parent */ 233 true, /* immutable */ 234 { 235 #define HB_UNICODE_FUNC_IMPLEMENT(name) hb_ucdn_##name, 236 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS 237 #undef HB_UNICODE_FUNC_IMPLEMENT 238 } 239 }; 240 241 return const_cast<hb_unicode_funcs_t *> (&_hb_ucdn_unicode_funcs); 242 } 243 | 143 HB_SCRIPT_OLD_PERMIC, 144 HB_SCRIPT_PAHAWH_HMONG, 145 HB_SCRIPT_PALMYRENE, 146 HB_SCRIPT_PAU_CIN_HAU, 147 HB_SCRIPT_PSALTER_PAHLAVI, 148 HB_SCRIPT_SIDDHAM, 149 HB_SCRIPT_TIRHUTA, 150 HB_SCRIPT_WARANG_CITI, 151 HB_SCRIPT_AHOM, 152 HB_SCRIPT_ANATOLIAN_HIEROGLYPHS, 153 HB_SCRIPT_HATRAN, 154 HB_SCRIPT_MULTANI, 155 HB_SCRIPT_OLD_HUNGARIAN, 156 HB_SCRIPT_SIGNWRITING, 157 HB_SCRIPT_ADLAM, 158 HB_SCRIPT_BHAIKSUKI, 159 HB_SCRIPT_MARCHEN, 160 HB_SCRIPT_NEWA, 161 HB_SCRIPT_OSAGE, 162 HB_SCRIPT_TANGUT, 163 HB_SCRIPT_MASARAM_GONDI, 164 HB_SCRIPT_NUSHU, 165 HB_SCRIPT_SOYOMBO, 166 HB_SCRIPT_ZANABAZAR_SQUARE, 167 }; 168 169 static hb_unicode_combining_class_t 170 hb_ucdn_combining_class(hb_unicode_funcs_t *ufuncs HB_UNUSED, 171 hb_codepoint_t unicode, 172 void *user_data HB_UNUSED) 173 { 174 return (hb_unicode_combining_class_t) ucdn_get_combining_class(unicode); 175 } 176 177 static unsigned int 178 hb_ucdn_eastasian_width(hb_unicode_funcs_t *ufuncs HB_UNUSED, 179 hb_codepoint_t unicode, 180 void *user_data HB_UNUSED) 181 { 182 int w = ucdn_get_east_asian_width(unicode); 183 return (w == UCDN_EAST_ASIAN_F || w == UCDN_EAST_ASIAN_W) ? 2 : 1; 184 } 185 186 static hb_unicode_general_category_t 187 hb_ucdn_general_category(hb_unicode_funcs_t *ufuncs HB_UNUSED, 188 hb_codepoint_t unicode, 189 void *user_data HB_UNUSED) 190 { 191 return (hb_unicode_general_category_t)ucdn_get_general_category(unicode); 192 } 193 194 static hb_codepoint_t 195 hb_ucdn_mirroring(hb_unicode_funcs_t *ufuncs HB_UNUSED, 196 hb_codepoint_t unicode, 197 void *user_data HB_UNUSED) 198 { 199 return ucdn_mirror(unicode); 200 } 201 202 static hb_script_t 203 hb_ucdn_script(hb_unicode_funcs_t *ufuncs HB_UNUSED, 204 hb_codepoint_t unicode, 205 void *user_data HB_UNUSED) 206 { 207 return ucdn_script_translate[ucdn_get_script(unicode)]; 208 } 209 210 static hb_bool_t 211 hb_ucdn_compose(hb_unicode_funcs_t *ufuncs HB_UNUSED, 212 hb_codepoint_t a, hb_codepoint_t b, hb_codepoint_t *ab, 213 void *user_data HB_UNUSED) 214 { 215 return ucdn_compose(ab, a, b); 216 } 217 218 static hb_bool_t 219 hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs HB_UNUSED, 220 hb_codepoint_t ab, hb_codepoint_t *a, hb_codepoint_t *b, 221 void *user_data HB_UNUSED) 222 { 223 return ucdn_decompose(ab, a, b); 224 } 225 226 static unsigned int 227 hb_ucdn_decompose_compatibility(hb_unicode_funcs_t *ufuncs HB_UNUSED, 228 hb_codepoint_t u, hb_codepoint_t *decomposed, 229 void *user_data HB_UNUSED) 230 { 231 return ucdn_compat_decompose(u, decomposed); 232 } 233 234 static hb_unicode_funcs_t *static_ucdn_funcs = nullptr; 235 236 #ifdef HB_USE_ATEXIT 237 static 238 void free_static_ucdn_funcs (void) 239 { 240 hb_unicode_funcs_destroy (static_ucdn_funcs); 241 } 242 #endif 243 244 extern "C" HB_INTERNAL 245 hb_unicode_funcs_t * 246 hb_ucdn_get_unicode_funcs (void) 247 { 248 retry: 249 hb_unicode_funcs_t *funcs = (hb_unicode_funcs_t *) hb_atomic_ptr_get (&static_ucdn_funcs); 250 251 if (unlikely (!funcs)) 252 { 253 funcs = hb_unicode_funcs_create (nullptr); 254 255 #define HB_UNICODE_FUNC_IMPLEMENT(name) \ 256 hb_unicode_funcs_set_##name##_func (funcs, hb_ucdn_##name, nullptr, nullptr); 257 HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS 258 #undef HB_UNICODE_FUNC_IMPLEMENT 259 260 hb_unicode_funcs_make_immutable (funcs); 261 262 if (!hb_atomic_ptr_cmpexch (&static_ucdn_funcs, nullptr, funcs)) { 263 hb_unicode_funcs_destroy (funcs); 264 goto retry; 265 } 266 267 #ifdef HB_USE_ATEXIT 268 atexit (free_static_ucdn_funcs); /* First person registers atexit() callback. */ 269 #endif 270 }; 271 272 return hb_unicode_funcs_reference (funcs); 273 } |