1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/harfbuzz/src/hb-unicode.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,445 @@ 1.4 +/* 1.5 + * Copyright © 2009 Red Hat, Inc. 1.6 + * Copyright © 2011 Codethink Limited 1.7 + * Copyright © 2011,2012 Google, Inc. 1.8 + * 1.9 + * This is part of HarfBuzz, a text shaping library. 1.10 + * 1.11 + * Permission is hereby granted, without written agreement and without 1.12 + * license or royalty fees, to use, copy, modify, and distribute this 1.13 + * software and its documentation for any purpose, provided that the 1.14 + * above copyright notice and the following two paragraphs appear in 1.15 + * all copies of this software. 1.16 + * 1.17 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 1.18 + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 1.19 + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 1.20 + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 1.21 + * DAMAGE. 1.22 + * 1.23 + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 1.24 + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 1.25 + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 1.26 + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 1.27 + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 1.28 + * 1.29 + * Red Hat Author(s): Behdad Esfahbod 1.30 + * Codethink Author(s): Ryan Lortie 1.31 + * Google Author(s): Behdad Esfahbod 1.32 + */ 1.33 + 1.34 +#ifndef HB_H_IN 1.35 +#error "Include <hb.h> instead." 1.36 +#endif 1.37 + 1.38 +#ifndef HB_UNICODE_H 1.39 +#define HB_UNICODE_H 1.40 + 1.41 +#include "hb-common.h" 1.42 + 1.43 +HB_BEGIN_DECLS 1.44 + 1.45 + 1.46 +/* hb_unicode_general_category_t */ 1.47 + 1.48 +/* Unicode Character Database property: General_Category (gc) */ 1.49 +typedef enum 1.50 +{ 1.51 + HB_UNICODE_GENERAL_CATEGORY_CONTROL, /* Cc */ 1.52 + HB_UNICODE_GENERAL_CATEGORY_FORMAT, /* Cf */ 1.53 + HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED, /* Cn */ 1.54 + HB_UNICODE_GENERAL_CATEGORY_PRIVATE_USE, /* Co */ 1.55 + HB_UNICODE_GENERAL_CATEGORY_SURROGATE, /* Cs */ 1.56 + HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER, /* Ll */ 1.57 + HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER, /* Lm */ 1.58 + HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER, /* Lo */ 1.59 + HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER, /* Lt */ 1.60 + HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER, /* Lu */ 1.61 + HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK, /* Mc */ 1.62 + HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK, /* Me */ 1.63 + HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK, /* Mn */ 1.64 + HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER, /* Nd */ 1.65 + HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER, /* Nl */ 1.66 + HB_UNICODE_GENERAL_CATEGORY_OTHER_NUMBER, /* No */ 1.67 + HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION, /* Pc */ 1.68 + HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION, /* Pd */ 1.69 + HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION, /* Pe */ 1.70 + HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION, /* Pf */ 1.71 + HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION, /* Pi */ 1.72 + HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION, /* Po */ 1.73 + HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION, /* Ps */ 1.74 + HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL, /* Sc */ 1.75 + HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL, /* Sk */ 1.76 + HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL, /* Sm */ 1.77 + HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL, /* So */ 1.78 + HB_UNICODE_GENERAL_CATEGORY_LINE_SEPARATOR, /* Zl */ 1.79 + HB_UNICODE_GENERAL_CATEGORY_PARAGRAPH_SEPARATOR, /* Zp */ 1.80 + HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR /* Zs */ 1.81 +} hb_unicode_general_category_t; 1.82 + 1.83 +/* hb_unicode_combining_class_t */ 1.84 + 1.85 +/* Note: newer versions of Unicode may add new values. Clients should be ready to handle 1.86 + * any value in the 0..254 range being returned from hb_unicode_combining_class(). 1.87 + */ 1.88 + 1.89 +/* Unicode Character Database property: Canonical_Combining_Class (ccc) */ 1.90 +typedef enum 1.91 +{ 1.92 + HB_UNICODE_COMBINING_CLASS_NOT_REORDERED = 0, 1.93 + HB_UNICODE_COMBINING_CLASS_OVERLAY = 1, 1.94 + HB_UNICODE_COMBINING_CLASS_NUKTA = 7, 1.95 + HB_UNICODE_COMBINING_CLASS_KANA_VOICING = 8, 1.96 + HB_UNICODE_COMBINING_CLASS_VIRAMA = 9, 1.97 + 1.98 + /* Hebrew */ 1.99 + HB_UNICODE_COMBINING_CLASS_CCC10 = 10, 1.100 + HB_UNICODE_COMBINING_CLASS_CCC11 = 11, 1.101 + HB_UNICODE_COMBINING_CLASS_CCC12 = 12, 1.102 + HB_UNICODE_COMBINING_CLASS_CCC13 = 13, 1.103 + HB_UNICODE_COMBINING_CLASS_CCC14 = 14, 1.104 + HB_UNICODE_COMBINING_CLASS_CCC15 = 15, 1.105 + HB_UNICODE_COMBINING_CLASS_CCC16 = 16, 1.106 + HB_UNICODE_COMBINING_CLASS_CCC17 = 17, 1.107 + HB_UNICODE_COMBINING_CLASS_CCC18 = 18, 1.108 + HB_UNICODE_COMBINING_CLASS_CCC19 = 19, 1.109 + HB_UNICODE_COMBINING_CLASS_CCC20 = 20, 1.110 + HB_UNICODE_COMBINING_CLASS_CCC21 = 21, 1.111 + HB_UNICODE_COMBINING_CLASS_CCC22 = 22, 1.112 + HB_UNICODE_COMBINING_CLASS_CCC23 = 23, 1.113 + HB_UNICODE_COMBINING_CLASS_CCC24 = 24, 1.114 + HB_UNICODE_COMBINING_CLASS_CCC25 = 25, 1.115 + HB_UNICODE_COMBINING_CLASS_CCC26 = 26, 1.116 + 1.117 + /* Arabic */ 1.118 + HB_UNICODE_COMBINING_CLASS_CCC27 = 27, 1.119 + HB_UNICODE_COMBINING_CLASS_CCC28 = 28, 1.120 + HB_UNICODE_COMBINING_CLASS_CCC29 = 29, 1.121 + HB_UNICODE_COMBINING_CLASS_CCC30 = 30, 1.122 + HB_UNICODE_COMBINING_CLASS_CCC31 = 31, 1.123 + HB_UNICODE_COMBINING_CLASS_CCC32 = 32, 1.124 + HB_UNICODE_COMBINING_CLASS_CCC33 = 33, 1.125 + HB_UNICODE_COMBINING_CLASS_CCC34 = 34, 1.126 + HB_UNICODE_COMBINING_CLASS_CCC35 = 35, 1.127 + 1.128 + /* Syriac */ 1.129 + HB_UNICODE_COMBINING_CLASS_CCC36 = 36, 1.130 + 1.131 + /* Telugu */ 1.132 + HB_UNICODE_COMBINING_CLASS_CCC84 = 84, 1.133 + HB_UNICODE_COMBINING_CLASS_CCC91 = 91, 1.134 + 1.135 + /* Thai */ 1.136 + HB_UNICODE_COMBINING_CLASS_CCC103 = 103, 1.137 + HB_UNICODE_COMBINING_CLASS_CCC107 = 107, 1.138 + 1.139 + /* Lao */ 1.140 + HB_UNICODE_COMBINING_CLASS_CCC118 = 118, 1.141 + HB_UNICODE_COMBINING_CLASS_CCC122 = 122, 1.142 + 1.143 + /* Tibetan */ 1.144 + HB_UNICODE_COMBINING_CLASS_CCC129 = 129, 1.145 + HB_UNICODE_COMBINING_CLASS_CCC130 = 130, 1.146 + HB_UNICODE_COMBINING_CLASS_CCC133 = 132, 1.147 + 1.148 + 1.149 + HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW_LEFT = 200, 1.150 + HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW = 202, 1.151 + HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE = 214, 1.152 + HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE_RIGHT = 216, 1.153 + HB_UNICODE_COMBINING_CLASS_BELOW_LEFT = 218, 1.154 + HB_UNICODE_COMBINING_CLASS_BELOW = 220, 1.155 + HB_UNICODE_COMBINING_CLASS_BELOW_RIGHT = 222, 1.156 + HB_UNICODE_COMBINING_CLASS_LEFT = 224, 1.157 + HB_UNICODE_COMBINING_CLASS_RIGHT = 226, 1.158 + HB_UNICODE_COMBINING_CLASS_ABOVE_LEFT = 228, 1.159 + HB_UNICODE_COMBINING_CLASS_ABOVE = 230, 1.160 + HB_UNICODE_COMBINING_CLASS_ABOVE_RIGHT = 232, 1.161 + HB_UNICODE_COMBINING_CLASS_DOUBLE_BELOW = 233, 1.162 + HB_UNICODE_COMBINING_CLASS_DOUBLE_ABOVE = 234, 1.163 + 1.164 + HB_UNICODE_COMBINING_CLASS_IOTA_SUBSCRIPT = 240, 1.165 + 1.166 + HB_UNICODE_COMBINING_CLASS_INVALID = 255 1.167 +} hb_unicode_combining_class_t; 1.168 + 1.169 + 1.170 +/* 1.171 + * hb_unicode_funcs_t 1.172 + */ 1.173 + 1.174 +typedef struct hb_unicode_funcs_t hb_unicode_funcs_t; 1.175 + 1.176 + 1.177 +/* 1.178 + * just give me the best implementation you've got there. 1.179 + */ 1.180 +hb_unicode_funcs_t * 1.181 +hb_unicode_funcs_get_default (void); 1.182 + 1.183 + 1.184 +hb_unicode_funcs_t * 1.185 +hb_unicode_funcs_create (hb_unicode_funcs_t *parent); 1.186 + 1.187 +hb_unicode_funcs_t * 1.188 +hb_unicode_funcs_get_empty (void); 1.189 + 1.190 +hb_unicode_funcs_t * 1.191 +hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs); 1.192 + 1.193 +void 1.194 +hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs); 1.195 + 1.196 +hb_bool_t 1.197 +hb_unicode_funcs_set_user_data (hb_unicode_funcs_t *ufuncs, 1.198 + hb_user_data_key_t *key, 1.199 + void * data, 1.200 + hb_destroy_func_t destroy, 1.201 + hb_bool_t replace); 1.202 + 1.203 + 1.204 +void * 1.205 +hb_unicode_funcs_get_user_data (hb_unicode_funcs_t *ufuncs, 1.206 + hb_user_data_key_t *key); 1.207 + 1.208 + 1.209 +void 1.210 +hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs); 1.211 + 1.212 +hb_bool_t 1.213 +hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs); 1.214 + 1.215 +hb_unicode_funcs_t * 1.216 +hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs); 1.217 + 1.218 + 1.219 +/* 1.220 + * funcs 1.221 + */ 1.222 + 1.223 +/* typedefs */ 1.224 + 1.225 +typedef hb_unicode_combining_class_t (*hb_unicode_combining_class_func_t) (hb_unicode_funcs_t *ufuncs, 1.226 + hb_codepoint_t unicode, 1.227 + void *user_data); 1.228 +typedef unsigned int (*hb_unicode_eastasian_width_func_t) (hb_unicode_funcs_t *ufuncs, 1.229 + hb_codepoint_t unicode, 1.230 + void *user_data); 1.231 +typedef hb_unicode_general_category_t (*hb_unicode_general_category_func_t) (hb_unicode_funcs_t *ufuncs, 1.232 + hb_codepoint_t unicode, 1.233 + void *user_data); 1.234 +typedef hb_codepoint_t (*hb_unicode_mirroring_func_t) (hb_unicode_funcs_t *ufuncs, 1.235 + hb_codepoint_t unicode, 1.236 + void *user_data); 1.237 +typedef hb_script_t (*hb_unicode_script_func_t) (hb_unicode_funcs_t *ufuncs, 1.238 + hb_codepoint_t unicode, 1.239 + void *user_data); 1.240 + 1.241 +typedef hb_bool_t (*hb_unicode_compose_func_t) (hb_unicode_funcs_t *ufuncs, 1.242 + hb_codepoint_t a, 1.243 + hb_codepoint_t b, 1.244 + hb_codepoint_t *ab, 1.245 + void *user_data); 1.246 +typedef hb_bool_t (*hb_unicode_decompose_func_t) (hb_unicode_funcs_t *ufuncs, 1.247 + hb_codepoint_t ab, 1.248 + hb_codepoint_t *a, 1.249 + hb_codepoint_t *b, 1.250 + void *user_data); 1.251 + 1.252 +/** 1.253 + * hb_unicode_decompose_compatibility_func_t: 1.254 + * @ufuncs: a Unicode function structure 1.255 + * @u: codepoint to decompose 1.256 + * @decomposed: address of codepoint array (of length %HB_UNICODE_MAX_DECOMPOSITION_LEN) to write decomposition into 1.257 + * @user_data: user data pointer as passed to hb_unicode_funcs_set_decompose_compatibility_func() 1.258 + * 1.259 + * Fully decompose @u to its Unicode compatibility decomposition. The codepoints of the decomposition will be written to @decomposed. 1.260 + * The complete length of the decomposition will be returned. 1.261 + * 1.262 + * If @u has no compatibility decomposition, zero should be returned. 1.263 + * 1.264 + * The Unicode standard guarantees that a buffer of length %HB_UNICODE_MAX_DECOMPOSITION_LEN codepoints will always be sufficient for any 1.265 + * compatibility decomposition plus an terminating value of 0. Consequently, @decompose must be allocated by the caller to be at least this length. Implementations 1.266 + * of this function type must ensure that they do not write past the provided array. 1.267 + * 1.268 + * Return value: number of codepoints in the full compatibility decomposition of @u, or 0 if no decomposition available. 1.269 + */ 1.270 +typedef unsigned int (*hb_unicode_decompose_compatibility_func_t) (hb_unicode_funcs_t *ufuncs, 1.271 + hb_codepoint_t u, 1.272 + hb_codepoint_t *decomposed, 1.273 + void *user_data); 1.274 + 1.275 +/* See Unicode 6.1 for details on the maximum decomposition length. */ 1.276 +#define HB_UNICODE_MAX_DECOMPOSITION_LEN (18+1) /* codepoints */ 1.277 + 1.278 +/* setters */ 1.279 + 1.280 +/** 1.281 + * hb_unicode_funcs_set_combining_class_func: 1.282 + * @ufuncs: a Unicode function structure 1.283 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.284 + * @user_data: 1.285 + * @destroy: 1.286 + * 1.287 + * 1.288 + * 1.289 + * Since: 1.0 1.290 + **/ 1.291 +void 1.292 +hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs, 1.293 + hb_unicode_combining_class_func_t func, 1.294 + void *user_data, hb_destroy_func_t destroy); 1.295 + 1.296 +/** 1.297 + * hb_unicode_funcs_set_eastasian_width_func: 1.298 + * @ufuncs: a Unicode function structure 1.299 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.300 + * @user_data: 1.301 + * @destroy: 1.302 + * 1.303 + * 1.304 + * 1.305 + * Since: 1.0 1.306 + **/ 1.307 +void 1.308 +hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs, 1.309 + hb_unicode_eastasian_width_func_t func, 1.310 + void *user_data, hb_destroy_func_t destroy); 1.311 + 1.312 +/** 1.313 + * hb_unicode_funcs_set_general_category_func: 1.314 + * @ufuncs: a Unicode function structure 1.315 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.316 + * @user_data: 1.317 + * @destroy: 1.318 + * 1.319 + * 1.320 + * 1.321 + * Since: 1.0 1.322 + **/ 1.323 +void 1.324 +hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs, 1.325 + hb_unicode_general_category_func_t func, 1.326 + void *user_data, hb_destroy_func_t destroy); 1.327 + 1.328 +/** 1.329 + * hb_unicode_funcs_set_mirroring_func: 1.330 + * @ufuncs: a Unicode function structure 1.331 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.332 + * @user_data: 1.333 + * @destroy: 1.334 + * 1.335 + * 1.336 + * 1.337 + * Since: 1.0 1.338 + **/ 1.339 +void 1.340 +hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs, 1.341 + hb_unicode_mirroring_func_t func, 1.342 + void *user_data, hb_destroy_func_t destroy); 1.343 + 1.344 +/** 1.345 + * hb_unicode_funcs_set_script_func: 1.346 + * @ufuncs: a Unicode function structure 1.347 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.348 + * @user_data: 1.349 + * @destroy: 1.350 + * 1.351 + * 1.352 + * 1.353 + * Since: 1.0 1.354 + **/ 1.355 +void 1.356 +hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs, 1.357 + hb_unicode_script_func_t func, 1.358 + void *user_data, hb_destroy_func_t destroy); 1.359 + 1.360 +/** 1.361 + * hb_unicode_funcs_set_compose_func: 1.362 + * @ufuncs: a Unicode function structure 1.363 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.364 + * @user_data: 1.365 + * @destroy: 1.366 + * 1.367 + * 1.368 + * 1.369 + * Since: 1.0 1.370 + **/ 1.371 +void 1.372 +hb_unicode_funcs_set_compose_func (hb_unicode_funcs_t *ufuncs, 1.373 + hb_unicode_compose_func_t func, 1.374 + void *user_data, hb_destroy_func_t destroy); 1.375 + 1.376 +/** 1.377 + * hb_unicode_funcs_set_decompose_func: 1.378 + * @ufuncs: a Unicode function structure 1.379 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.380 + * @user_data: 1.381 + * @destroy: 1.382 + * 1.383 + * 1.384 + * 1.385 + * Since: 1.0 1.386 + **/ 1.387 +void 1.388 +hb_unicode_funcs_set_decompose_func (hb_unicode_funcs_t *ufuncs, 1.389 + hb_unicode_decompose_func_t func, 1.390 + void *user_data, hb_destroy_func_t destroy); 1.391 + 1.392 +/** 1.393 + * hb_unicode_funcs_set_decompose_compatibility_func: 1.394 + * @ufuncs: a Unicode function structure 1.395 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.396 + * @user_data: 1.397 + * @destroy: 1.398 + * 1.399 + * 1.400 + * 1.401 + * Since: 1.0 1.402 + **/ 1.403 +void 1.404 +hb_unicode_funcs_set_decompose_compatibility_func (hb_unicode_funcs_t *ufuncs, 1.405 + hb_unicode_decompose_compatibility_func_t func, 1.406 + void *user_data, hb_destroy_func_t destroy); 1.407 + 1.408 +/* accessors */ 1.409 + 1.410 +hb_unicode_combining_class_t 1.411 +hb_unicode_combining_class (hb_unicode_funcs_t *ufuncs, 1.412 + hb_codepoint_t unicode); 1.413 + 1.414 +unsigned int 1.415 +hb_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs, 1.416 + hb_codepoint_t unicode); 1.417 + 1.418 +hb_unicode_general_category_t 1.419 +hb_unicode_general_category (hb_unicode_funcs_t *ufuncs, 1.420 + hb_codepoint_t unicode); 1.421 + 1.422 +hb_codepoint_t 1.423 +hb_unicode_mirroring (hb_unicode_funcs_t *ufuncs, 1.424 + hb_codepoint_t unicode); 1.425 + 1.426 +hb_script_t 1.427 +hb_unicode_script (hb_unicode_funcs_t *ufuncs, 1.428 + hb_codepoint_t unicode); 1.429 + 1.430 +hb_bool_t 1.431 +hb_unicode_compose (hb_unicode_funcs_t *ufuncs, 1.432 + hb_codepoint_t a, 1.433 + hb_codepoint_t b, 1.434 + hb_codepoint_t *ab); 1.435 +hb_bool_t 1.436 +hb_unicode_decompose (hb_unicode_funcs_t *ufuncs, 1.437 + hb_codepoint_t ab, 1.438 + hb_codepoint_t *a, 1.439 + hb_codepoint_t *b); 1.440 + 1.441 +unsigned int 1.442 +hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs, 1.443 + hb_codepoint_t u, 1.444 + hb_codepoint_t *decomposed); 1.445 + 1.446 +HB_END_DECLS 1.447 + 1.448 +#endif /* HB_UNICODE_H */