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