hb-unicode.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. /*
  2. * Copyright © 2009 Red Hat, Inc.
  3. * Copyright © 2011 Codethink Limited
  4. * Copyright © 2011,2012 Google, Inc.
  5. *
  6. * This is part of HarfBuzz, a text shaping library.
  7. *
  8. * Permission is hereby granted, without written agreement and without
  9. * license or royalty fees, to use, copy, modify, and distribute this
  10. * software and its documentation for any purpose, provided that the
  11. * above copyright notice and the following two paragraphs appear in
  12. * all copies of this software.
  13. *
  14. * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
  15. * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  16. * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
  17. * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  18. * DAMAGE.
  19. *
  20. * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  21. * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  22. * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
  23. * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  24. * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  25. *
  26. * Red Hat Author(s): Behdad Esfahbod
  27. * Codethink Author(s): Ryan Lortie
  28. * Google Author(s): Behdad Esfahbod
  29. */
  30. #ifndef HB_H_IN
  31. #error "Include <hb.h> instead."
  32. #endif
  33. #ifndef HB_UNICODE_H
  34. #define HB_UNICODE_H
  35. #include "hb-common.h"
  36. HB_BEGIN_DECLS
  37. /**
  38. * HB_UNICODE_MAX
  39. *
  40. * Since: 1.9.0
  41. **/
  42. #define HB_UNICODE_MAX 0x10FFFFu
  43. /* hb_unicode_general_category_t */
  44. /* Unicode Character Database property: General_Category (gc) */
  45. typedef enum
  46. {
  47. HB_UNICODE_GENERAL_CATEGORY_CONTROL, /* Cc */
  48. HB_UNICODE_GENERAL_CATEGORY_FORMAT, /* Cf */
  49. HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED, /* Cn */
  50. HB_UNICODE_GENERAL_CATEGORY_PRIVATE_USE, /* Co */
  51. HB_UNICODE_GENERAL_CATEGORY_SURROGATE, /* Cs */
  52. HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER, /* Ll */
  53. HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER, /* Lm */
  54. HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER, /* Lo */
  55. HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER, /* Lt */
  56. HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER, /* Lu */
  57. HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK, /* Mc */
  58. HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK, /* Me */
  59. HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK, /* Mn */
  60. HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER, /* Nd */
  61. HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER, /* Nl */
  62. HB_UNICODE_GENERAL_CATEGORY_OTHER_NUMBER, /* No */
  63. HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION, /* Pc */
  64. HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION, /* Pd */
  65. HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION, /* Pe */
  66. HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION, /* Pf */
  67. HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION, /* Pi */
  68. HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION, /* Po */
  69. HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION, /* Ps */
  70. HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL, /* Sc */
  71. HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL, /* Sk */
  72. HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL, /* Sm */
  73. HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL, /* So */
  74. HB_UNICODE_GENERAL_CATEGORY_LINE_SEPARATOR, /* Zl */
  75. HB_UNICODE_GENERAL_CATEGORY_PARAGRAPH_SEPARATOR, /* Zp */
  76. HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR /* Zs */
  77. } hb_unicode_general_category_t;
  78. /* hb_unicode_combining_class_t */
  79. /* Note: newer versions of Unicode may add new values. Clients should be ready to handle
  80. * any value in the 0..254 range being returned from hb_unicode_combining_class().
  81. */
  82. /* Unicode Character Database property: Canonical_Combining_Class (ccc) */
  83. typedef enum
  84. {
  85. HB_UNICODE_COMBINING_CLASS_NOT_REORDERED = 0,
  86. HB_UNICODE_COMBINING_CLASS_OVERLAY = 1,
  87. HB_UNICODE_COMBINING_CLASS_NUKTA = 7,
  88. HB_UNICODE_COMBINING_CLASS_KANA_VOICING = 8,
  89. HB_UNICODE_COMBINING_CLASS_VIRAMA = 9,
  90. /* Hebrew */
  91. HB_UNICODE_COMBINING_CLASS_CCC10 = 10,
  92. HB_UNICODE_COMBINING_CLASS_CCC11 = 11,
  93. HB_UNICODE_COMBINING_CLASS_CCC12 = 12,
  94. HB_UNICODE_COMBINING_CLASS_CCC13 = 13,
  95. HB_UNICODE_COMBINING_CLASS_CCC14 = 14,
  96. HB_UNICODE_COMBINING_CLASS_CCC15 = 15,
  97. HB_UNICODE_COMBINING_CLASS_CCC16 = 16,
  98. HB_UNICODE_COMBINING_CLASS_CCC17 = 17,
  99. HB_UNICODE_COMBINING_CLASS_CCC18 = 18,
  100. HB_UNICODE_COMBINING_CLASS_CCC19 = 19,
  101. HB_UNICODE_COMBINING_CLASS_CCC20 = 20,
  102. HB_UNICODE_COMBINING_CLASS_CCC21 = 21,
  103. HB_UNICODE_COMBINING_CLASS_CCC22 = 22,
  104. HB_UNICODE_COMBINING_CLASS_CCC23 = 23,
  105. HB_UNICODE_COMBINING_CLASS_CCC24 = 24,
  106. HB_UNICODE_COMBINING_CLASS_CCC25 = 25,
  107. HB_UNICODE_COMBINING_CLASS_CCC26 = 26,
  108. /* Arabic */
  109. HB_UNICODE_COMBINING_CLASS_CCC27 = 27,
  110. HB_UNICODE_COMBINING_CLASS_CCC28 = 28,
  111. HB_UNICODE_COMBINING_CLASS_CCC29 = 29,
  112. HB_UNICODE_COMBINING_CLASS_CCC30 = 30,
  113. HB_UNICODE_COMBINING_CLASS_CCC31 = 31,
  114. HB_UNICODE_COMBINING_CLASS_CCC32 = 32,
  115. HB_UNICODE_COMBINING_CLASS_CCC33 = 33,
  116. HB_UNICODE_COMBINING_CLASS_CCC34 = 34,
  117. HB_UNICODE_COMBINING_CLASS_CCC35 = 35,
  118. /* Syriac */
  119. HB_UNICODE_COMBINING_CLASS_CCC36 = 36,
  120. /* Telugu */
  121. HB_UNICODE_COMBINING_CLASS_CCC84 = 84,
  122. HB_UNICODE_COMBINING_CLASS_CCC91 = 91,
  123. /* Thai */
  124. HB_UNICODE_COMBINING_CLASS_CCC103 = 103,
  125. HB_UNICODE_COMBINING_CLASS_CCC107 = 107,
  126. /* Lao */
  127. HB_UNICODE_COMBINING_CLASS_CCC118 = 118,
  128. HB_UNICODE_COMBINING_CLASS_CCC122 = 122,
  129. /* Tibetan */
  130. HB_UNICODE_COMBINING_CLASS_CCC129 = 129,
  131. HB_UNICODE_COMBINING_CLASS_CCC130 = 130,
  132. HB_UNICODE_COMBINING_CLASS_CCC133 = 132,
  133. HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW_LEFT = 200,
  134. HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW = 202,
  135. HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE = 214,
  136. HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE_RIGHT = 216,
  137. HB_UNICODE_COMBINING_CLASS_BELOW_LEFT = 218,
  138. HB_UNICODE_COMBINING_CLASS_BELOW = 220,
  139. HB_UNICODE_COMBINING_CLASS_BELOW_RIGHT = 222,
  140. HB_UNICODE_COMBINING_CLASS_LEFT = 224,
  141. HB_UNICODE_COMBINING_CLASS_RIGHT = 226,
  142. HB_UNICODE_COMBINING_CLASS_ABOVE_LEFT = 228,
  143. HB_UNICODE_COMBINING_CLASS_ABOVE = 230,
  144. HB_UNICODE_COMBINING_CLASS_ABOVE_RIGHT = 232,
  145. HB_UNICODE_COMBINING_CLASS_DOUBLE_BELOW = 233,
  146. HB_UNICODE_COMBINING_CLASS_DOUBLE_ABOVE = 234,
  147. HB_UNICODE_COMBINING_CLASS_IOTA_SUBSCRIPT = 240,
  148. HB_UNICODE_COMBINING_CLASS_INVALID = 255
  149. } hb_unicode_combining_class_t;
  150. /*
  151. * hb_unicode_funcs_t
  152. */
  153. typedef struct hb_unicode_funcs_t hb_unicode_funcs_t;
  154. /*
  155. * just give me the best implementation you've got there.
  156. */
  157. HB_EXTERN hb_unicode_funcs_t *
  158. hb_unicode_funcs_get_default (void);
  159. HB_EXTERN hb_unicode_funcs_t *
  160. hb_unicode_funcs_create (hb_unicode_funcs_t *parent);
  161. HB_EXTERN hb_unicode_funcs_t *
  162. hb_unicode_funcs_get_empty (void);
  163. HB_EXTERN hb_unicode_funcs_t *
  164. hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs);
  165. HB_EXTERN void
  166. hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs);
  167. HB_EXTERN hb_bool_t
  168. hb_unicode_funcs_set_user_data (hb_unicode_funcs_t *ufuncs,
  169. hb_user_data_key_t *key,
  170. void * data,
  171. hb_destroy_func_t destroy,
  172. hb_bool_t replace);
  173. HB_EXTERN void *
  174. hb_unicode_funcs_get_user_data (hb_unicode_funcs_t *ufuncs,
  175. hb_user_data_key_t *key);
  176. HB_EXTERN void
  177. hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs);
  178. HB_EXTERN hb_bool_t
  179. hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs);
  180. HB_EXTERN hb_unicode_funcs_t *
  181. hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs);
  182. /*
  183. * funcs
  184. */
  185. /* typedefs */
  186. typedef hb_unicode_combining_class_t (*hb_unicode_combining_class_func_t) (hb_unicode_funcs_t *ufuncs,
  187. hb_codepoint_t unicode,
  188. void *user_data);
  189. typedef hb_unicode_general_category_t (*hb_unicode_general_category_func_t) (hb_unicode_funcs_t *ufuncs,
  190. hb_codepoint_t unicode,
  191. void *user_data);
  192. typedef hb_codepoint_t (*hb_unicode_mirroring_func_t) (hb_unicode_funcs_t *ufuncs,
  193. hb_codepoint_t unicode,
  194. void *user_data);
  195. typedef hb_script_t (*hb_unicode_script_func_t) (hb_unicode_funcs_t *ufuncs,
  196. hb_codepoint_t unicode,
  197. void *user_data);
  198. typedef hb_bool_t (*hb_unicode_compose_func_t) (hb_unicode_funcs_t *ufuncs,
  199. hb_codepoint_t a,
  200. hb_codepoint_t b,
  201. hb_codepoint_t *ab,
  202. void *user_data);
  203. typedef hb_bool_t (*hb_unicode_decompose_func_t) (hb_unicode_funcs_t *ufuncs,
  204. hb_codepoint_t ab,
  205. hb_codepoint_t *a,
  206. hb_codepoint_t *b,
  207. void *user_data);
  208. /* setters */
  209. /**
  210. * hb_unicode_funcs_set_combining_class_func:
  211. * @ufuncs: a Unicode function structure
  212. * @func: (closure user_data) (destroy destroy) (scope notified):
  213. * @user_data:
  214. * @destroy:
  215. *
  216. *
  217. *
  218. * Since: 0.9.2
  219. **/
  220. HB_EXTERN void
  221. hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
  222. hb_unicode_combining_class_func_t func,
  223. void *user_data, hb_destroy_func_t destroy);
  224. /**
  225. * hb_unicode_funcs_set_general_category_func:
  226. * @ufuncs: a Unicode function structure
  227. * @func: (closure user_data) (destroy destroy) (scope notified):
  228. * @user_data:
  229. * @destroy:
  230. *
  231. *
  232. *
  233. * Since: 0.9.2
  234. **/
  235. HB_EXTERN void
  236. hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,
  237. hb_unicode_general_category_func_t func,
  238. void *user_data, hb_destroy_func_t destroy);
  239. /**
  240. * hb_unicode_funcs_set_mirroring_func:
  241. * @ufuncs: a Unicode function structure
  242. * @func: (closure user_data) (destroy destroy) (scope notified):
  243. * @user_data:
  244. * @destroy:
  245. *
  246. *
  247. *
  248. * Since: 0.9.2
  249. **/
  250. HB_EXTERN void
  251. hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs,
  252. hb_unicode_mirroring_func_t func,
  253. void *user_data, hb_destroy_func_t destroy);
  254. /**
  255. * hb_unicode_funcs_set_script_func:
  256. * @ufuncs: a Unicode function structure
  257. * @func: (closure user_data) (destroy destroy) (scope notified):
  258. * @user_data:
  259. * @destroy:
  260. *
  261. *
  262. *
  263. * Since: 0.9.2
  264. **/
  265. HB_EXTERN void
  266. hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs,
  267. hb_unicode_script_func_t func,
  268. void *user_data, hb_destroy_func_t destroy);
  269. /**
  270. * hb_unicode_funcs_set_compose_func:
  271. * @ufuncs: a Unicode function structure
  272. * @func: (closure user_data) (destroy destroy) (scope notified):
  273. * @user_data:
  274. * @destroy:
  275. *
  276. *
  277. *
  278. * Since: 0.9.2
  279. **/
  280. HB_EXTERN void
  281. hb_unicode_funcs_set_compose_func (hb_unicode_funcs_t *ufuncs,
  282. hb_unicode_compose_func_t func,
  283. void *user_data, hb_destroy_func_t destroy);
  284. /**
  285. * hb_unicode_funcs_set_decompose_func:
  286. * @ufuncs: a Unicode function structure
  287. * @func: (closure user_data) (destroy destroy) (scope notified):
  288. * @user_data:
  289. * @destroy:
  290. *
  291. *
  292. *
  293. * Since: 0.9.2
  294. **/
  295. HB_EXTERN void
  296. hb_unicode_funcs_set_decompose_func (hb_unicode_funcs_t *ufuncs,
  297. hb_unicode_decompose_func_t func,
  298. void *user_data, hb_destroy_func_t destroy);
  299. /* accessors */
  300. /**
  301. * hb_unicode_combining_class:
  302. *
  303. * Since: 0.9.2
  304. **/
  305. HB_EXTERN hb_unicode_combining_class_t
  306. hb_unicode_combining_class (hb_unicode_funcs_t *ufuncs,
  307. hb_codepoint_t unicode);
  308. /**
  309. * hb_unicode_general_category:
  310. *
  311. * Since: 0.9.2
  312. **/
  313. HB_EXTERN hb_unicode_general_category_t
  314. hb_unicode_general_category (hb_unicode_funcs_t *ufuncs,
  315. hb_codepoint_t unicode);
  316. /**
  317. * hb_unicode_mirroring:
  318. *
  319. * Since: 0.9.2
  320. **/
  321. HB_EXTERN hb_codepoint_t
  322. hb_unicode_mirroring (hb_unicode_funcs_t *ufuncs,
  323. hb_codepoint_t unicode);
  324. /**
  325. * hb_unicode_script:
  326. *
  327. * Since: 0.9.2
  328. **/
  329. HB_EXTERN hb_script_t
  330. hb_unicode_script (hb_unicode_funcs_t *ufuncs,
  331. hb_codepoint_t unicode);
  332. HB_EXTERN hb_bool_t
  333. hb_unicode_compose (hb_unicode_funcs_t *ufuncs,
  334. hb_codepoint_t a,
  335. hb_codepoint_t b,
  336. hb_codepoint_t *ab);
  337. HB_EXTERN hb_bool_t
  338. hb_unicode_decompose (hb_unicode_funcs_t *ufuncs,
  339. hb_codepoint_t ab,
  340. hb_codepoint_t *a,
  341. hb_codepoint_t *b);
  342. HB_END_DECLS
  343. #endif /* HB_UNICODE_H */