9aa97a6b1c4bded7ccb0b78b4da6aee12ad65a40
[framework/uifw/harfbuzz.git] / src / hb-unicode.h
1 /*
2  * Copyright © 2009  Red Hat, Inc.
3  * Copyright © 2011  Codethink Limited
4  * Copyright © 2011  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
31 #ifndef HB_UNICODE_H
32 #define HB_UNICODE_H
33
34 #include "hb-common.h"
35
36 HB_BEGIN_DECLS
37
38
39 /*
40  * hb_unicode_funcs_t
41  */
42
43 typedef struct _hb_unicode_funcs_t hb_unicode_funcs_t;
44
45
46 /*
47  * just give me the best implementation you've got there.
48  */
49 hb_unicode_funcs_t *
50 hb_unicode_funcs_get_default (void);
51
52
53 hb_unicode_funcs_t *
54 hb_unicode_funcs_create (hb_unicode_funcs_t *parent);
55
56 hb_unicode_funcs_t *
57 hb_unicode_funcs_get_empty (void);
58
59 hb_unicode_funcs_t *
60 hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs);
61
62 void
63 hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs);
64
65 hb_bool_t
66 hb_unicode_funcs_set_user_data (hb_unicode_funcs_t *ufuncs,
67                                 hb_user_data_key_t *key,
68                                 void *              data,
69                                 hb_destroy_func_t   destroy);
70
71
72 void *
73 hb_unicode_funcs_get_user_data (hb_unicode_funcs_t *ufuncs,
74                                 hb_user_data_key_t *key);
75
76
77 void
78 hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs);
79
80 hb_bool_t
81 hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs);
82
83 hb_unicode_funcs_t *
84 hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs);
85
86
87 /*
88  * funcs
89  */
90
91 /* typedefs */
92
93 typedef unsigned int                    (*hb_unicode_combining_class_func_t)    (hb_unicode_funcs_t *ufuncs,
94                                                                                  hb_codepoint_t      unicode,
95                                                                                  void               *user_data);
96 typedef unsigned int                    (*hb_unicode_eastasian_width_func_t)    (hb_unicode_funcs_t *ufuncs,
97                                                                                  hb_codepoint_t      unicode,
98                                                                                  void               *user_data);
99 typedef hb_unicode_general_category_t   (*hb_unicode_general_category_func_t)   (hb_unicode_funcs_t *ufuncs,
100                                                                                  hb_codepoint_t      unicode,
101                                                                                  void               *user_data);
102 typedef hb_codepoint_t                  (*hb_unicode_mirroring_func_t)          (hb_unicode_funcs_t *ufuncs,
103                                                                                  hb_codepoint_t      unicode,
104                                                                                  void               *user_data);
105 typedef hb_script_t                     (*hb_unicode_script_func_t)             (hb_unicode_funcs_t *ufuncs,
106                                                                                  hb_codepoint_t      unicode,
107                                                                                  void               *user_data);
108
109 typedef hb_bool_t                       (*hb_unicode_compose_func_t)            (hb_unicode_funcs_t *ufuncs,
110                                                                                  hb_codepoint_t      a,
111                                                                                  hb_codepoint_t      b,
112                                                                                  hb_codepoint_t     *ab,
113                                                                                  void               *user_data);
114 typedef hb_bool_t                       (*hb_unicode_decompose_func_t)          (hb_unicode_funcs_t *ufuncs,
115                                                                                  hb_codepoint_t      ab,
116                                                                                  hb_codepoint_t     *a,
117                                                                                  hb_codepoint_t     *b,
118                                                                                  void               *user_data);
119
120 /* setters */
121
122 void
123 hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
124                                            hb_unicode_combining_class_func_t combining_class_func,
125                                            void *user_data, hb_destroy_func_t destroy);
126
127 void
128 hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
129                                            hb_unicode_eastasian_width_func_t eastasian_width_func,
130                                            void *user_data, hb_destroy_func_t destroy);
131
132 void
133 hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,
134                                             hb_unicode_general_category_func_t general_category_func,
135                                             void *user_data, hb_destroy_func_t destroy);
136
137 void
138 hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs,
139                                      hb_unicode_mirroring_func_t mirroring_func,
140                                      void *user_data, hb_destroy_func_t destroy);
141
142 void
143 hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs,
144                                   hb_unicode_script_func_t script_func,
145                                   void *user_data, hb_destroy_func_t destroy);
146
147 void
148 hb_unicode_funcs_set_compose_func (hb_unicode_funcs_t *ufuncs,
149                                    hb_unicode_compose_func_t compose_func,
150                                    void *user_data, hb_destroy_func_t destroy);
151
152 void
153 hb_unicode_funcs_set_decompose_func (hb_unicode_funcs_t *ufuncs,
154                                      hb_unicode_decompose_func_t decompose_func,
155                                      void *user_data, hb_destroy_func_t destroy);
156
157
158 /* accessors */
159
160 unsigned int
161 hb_unicode_combining_class (hb_unicode_funcs_t *ufuncs,
162                             hb_codepoint_t unicode);
163
164 unsigned int
165 hb_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs,
166                             hb_codepoint_t unicode);
167
168 hb_unicode_general_category_t
169 hb_unicode_general_category (hb_unicode_funcs_t *ufuncs,
170                              hb_codepoint_t unicode);
171
172 hb_codepoint_t
173 hb_unicode_mirroring (hb_unicode_funcs_t *ufuncs,
174                       hb_codepoint_t unicode);
175
176 hb_script_t
177 hb_unicode_script (hb_unicode_funcs_t *ufuncs,
178                    hb_codepoint_t unicode);
179
180 hb_bool_t
181 hb_unicode_compose (hb_unicode_funcs_t *ufuncs,
182                     hb_codepoint_t      a,
183                     hb_codepoint_t      b,
184                     hb_codepoint_t     *ab);
185 hb_bool_t
186 hb_unicode_decompose (hb_unicode_funcs_t *ufuncs,
187                       hb_codepoint_t      ab,
188                       hb_codepoint_t     *a,
189                       hb_codepoint_t     *b);
190
191 HB_END_DECLS
192
193 #endif /* HB_UNICODE_H */