[Indic] Define indic_position_t
[profile/ivi/org.tizen.video-player.git] / src / hb-font.h
1 /*
2  * Copyright © 2009  Red Hat, Inc.
3  *
4  *  This is part of HarfBuzz, a text shaping library.
5  *
6  * Permission is hereby granted, without written agreement and without
7  * license or royalty fees, to use, copy, modify, and distribute this
8  * software and its documentation for any purpose, provided that the
9  * above copyright notice and the following two paragraphs appear in
10  * all copies of this software.
11  *
12  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16  * DAMAGE.
17  *
18  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
21  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23  *
24  * Red Hat Author(s): Behdad Esfahbod
25  */
26
27 #ifndef HB_FONT_H
28 #define HB_FONT_H
29
30 #include "hb-common.h"
31 #include "hb-blob.h"
32
33 HB_BEGIN_DECLS
34
35
36 typedef struct _hb_face_t hb_face_t;
37 typedef struct _hb_font_t hb_font_t;
38
39 /*
40  * hb_face_t
41  */
42
43 hb_face_t *
44 hb_face_create (hb_blob_t    *blob,
45                 unsigned int  index);
46
47 typedef hb_blob_t * (*hb_get_table_func_t)  (hb_face_t *face, hb_tag_t tag, void *user_data);
48
49 /* calls destroy() when not needing user_data anymore */
50 hb_face_t *
51 hb_face_create_for_tables (hb_get_table_func_t  get_table,
52                            void                *user_data,
53                            hb_destroy_func_t    destroy);
54
55 hb_face_t *
56 hb_face_get_empty (void);
57
58 hb_face_t *
59 hb_face_reference (hb_face_t *face);
60
61 void
62 hb_face_destroy (hb_face_t *face);
63
64 hb_bool_t
65 hb_face_set_user_data (hb_face_t          *face,
66                        hb_user_data_key_t *key,
67                        void *              data,
68                        hb_destroy_func_t   destroy);
69
70
71 void *
72 hb_face_get_user_data (hb_face_t          *face,
73                        hb_user_data_key_t *key);
74
75 void
76 hb_face_make_immutable (hb_face_t *face);
77
78 hb_bool_t
79 hb_face_is_immutable (hb_face_t *face);
80
81
82 hb_blob_t *
83 hb_face_reference_table (hb_face_t *face,
84                          hb_tag_t   tag);
85
86 unsigned int
87 hb_face_get_upem (hb_face_t *face);
88
89
90 /*
91  * hb_font_funcs_t
92  */
93
94 typedef struct _hb_font_funcs_t hb_font_funcs_t;
95
96 hb_font_funcs_t *
97 hb_font_funcs_create (void);
98
99 hb_font_funcs_t *
100 hb_font_funcs_get_empty (void);
101
102 hb_font_funcs_t *
103 hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
104
105 void
106 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
107
108 hb_bool_t
109 hb_font_funcs_set_user_data (hb_font_funcs_t    *ffuncs,
110                              hb_user_data_key_t *key,
111                              void *              data,
112                              hb_destroy_func_t   destroy);
113
114
115 void *
116 hb_font_funcs_get_user_data (hb_font_funcs_t    *ffuncs,
117                              hb_user_data_key_t *key);
118
119
120 void
121 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
122
123 hb_bool_t
124 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
125
126 /* funcs */
127
128 typedef struct _hb_glyph_extents_t
129 {
130   hb_position_t x_bearing;
131   hb_position_t y_bearing;
132   hb_position_t width;
133   hb_position_t height;
134 } hb_glyph_extents_t;
135
136
137 /* func types */
138
139 typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data,
140                                                hb_codepoint_t unicode, hb_codepoint_t variation_selector,
141                                                hb_codepoint_t *glyph,
142                                                void *user_data);
143
144
145 typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
146                                                            hb_codepoint_t glyph,
147                                                            void *user_data);
148 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
149 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
150
151 typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data,
152                                                       hb_codepoint_t glyph,
153                                                       hb_position_t *x, hb_position_t *y,
154                                                       void *user_data);
155 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
156 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
157
158 typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
159                                                            hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
160                                                            void *user_data);
161 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
162 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t;
163
164
165 typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
166                                                        hb_codepoint_t glyph,
167                                                        hb_glyph_extents_t *extents,
168                                                        void *user_data);
169 typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data,
170                                                              hb_codepoint_t glyph, unsigned int point_index,
171                                                              hb_position_t *x, hb_position_t *y,
172                                                              void *user_data);
173
174
175 /* func setters */
176
177 void
178 hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
179                               hb_font_get_glyph_func_t glyph_func,
180                               void *user_data, hb_destroy_func_t destroy);
181
182 void
183 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
184                                         hb_font_get_glyph_h_advance_func_t func,
185                                         void *user_data, hb_destroy_func_t destroy);
186 void
187 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
188                                         hb_font_get_glyph_v_advance_func_t func,
189                                         void *user_data, hb_destroy_func_t destroy);
190
191 void
192 hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
193                                        hb_font_get_glyph_h_origin_func_t func,
194                                        void *user_data, hb_destroy_func_t destroy);
195 void
196 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
197                                        hb_font_get_glyph_v_origin_func_t func,
198                                        void *user_data, hb_destroy_func_t destroy);
199
200 void
201 hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
202                                         hb_font_get_glyph_h_kerning_func_t func,
203                                         void *user_data, hb_destroy_func_t destroy);
204 void
205 hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs,
206                                         hb_font_get_glyph_v_kerning_func_t func,
207                                         void *user_data, hb_destroy_func_t destroy);
208
209 void
210 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
211                                       hb_font_get_glyph_extents_func_t func,
212                                       void *user_data, hb_destroy_func_t destroy);
213 void
214 hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
215                                             hb_font_get_glyph_contour_point_func_t func,
216                                             void *user_data, hb_destroy_func_t destroy);
217
218
219 /* func dispatch */
220
221 hb_bool_t
222 hb_font_get_glyph (hb_font_t *font,
223                    hb_codepoint_t unicode, hb_codepoint_t variation_selector,
224                    hb_codepoint_t *glyph);
225
226 hb_position_t
227 hb_font_get_glyph_h_advance (hb_font_t *font,
228                              hb_codepoint_t glyph);
229 hb_position_t
230 hb_font_get_glyph_v_advance (hb_font_t *font,
231                              hb_codepoint_t glyph);
232
233 hb_bool_t
234 hb_font_get_glyph_h_origin (hb_font_t *font,
235                             hb_codepoint_t glyph,
236                             hb_position_t *x, hb_position_t *y);
237 hb_bool_t
238 hb_font_get_glyph_v_origin (hb_font_t *font,
239                             hb_codepoint_t glyph,
240                             hb_position_t *x, hb_position_t *y);
241
242 hb_position_t
243 hb_font_get_glyph_h_kerning (hb_font_t *font,
244                              hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
245 hb_position_t
246 hb_font_get_glyph_v_kerning (hb_font_t *font,
247                              hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph);
248
249 hb_bool_t
250 hb_font_get_glyph_extents (hb_font_t *font,
251                            hb_codepoint_t glyph,
252                            hb_glyph_extents_t *extents);
253
254 hb_bool_t
255 hb_font_get_glyph_contour_point (hb_font_t *font,
256                                  hb_codepoint_t glyph, unsigned int point_index,
257                                  hb_position_t *x, hb_position_t *y);
258
259
260 /* high-level funcs, with fallback */
261
262 void
263 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
264                                          hb_codepoint_t glyph,
265                                          hb_direction_t direction,
266                                          hb_position_t *x, hb_position_t *y);
267 void
268 hb_font_get_glyph_origin_for_direction (hb_font_t *font,
269                                         hb_codepoint_t glyph,
270                                         hb_direction_t direction,
271                                         hb_position_t *x, hb_position_t *y);
272 void
273 hb_font_add_glyph_origin_for_direction (hb_font_t *font,
274                                         hb_codepoint_t glyph,
275                                         hb_direction_t direction,
276                                         hb_position_t *x, hb_position_t *y);
277 void
278 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
279                                              hb_codepoint_t glyph,
280                                              hb_direction_t direction,
281                                              hb_position_t *x, hb_position_t *y);
282
283 void
284 hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
285                                          hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
286                                          hb_direction_t direction,
287                                          hb_position_t *x, hb_position_t *y);
288
289 hb_bool_t
290 hb_font_get_glyph_extents_for_origin (hb_font_t *font,
291                                       hb_codepoint_t glyph,
292                                       hb_direction_t direction,
293                                       hb_glyph_extents_t *extents);
294
295 hb_bool_t
296 hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
297                                             hb_codepoint_t glyph, unsigned int point_index,
298                                             hb_direction_t direction,
299                                             hb_position_t *x, hb_position_t *y);
300
301
302 /*
303  * hb_font_t
304  */
305
306 /* Fonts are very light-weight objects */
307
308 hb_font_t *
309 hb_font_create (hb_face_t *face);
310
311 hb_font_t *
312 hb_font_create_sub_font (hb_font_t *parent);
313
314 hb_font_t *
315 hb_font_get_empty (void);
316
317 hb_font_t *
318 hb_font_reference (hb_font_t *font);
319
320 void
321 hb_font_destroy (hb_font_t *font);
322
323 hb_bool_t
324 hb_font_set_user_data (hb_font_t          *font,
325                        hb_user_data_key_t *key,
326                        void *              data,
327                        hb_destroy_func_t   destroy);
328
329
330 void *
331 hb_font_get_user_data (hb_font_t          *font,
332                        hb_user_data_key_t *key);
333
334 void
335 hb_font_make_immutable (hb_font_t *font);
336
337 hb_bool_t
338 hb_font_is_immutable (hb_font_t *font);
339
340 hb_font_t *
341 hb_font_get_parent (hb_font_t *font);
342
343 hb_face_t *
344 hb_font_get_face (hb_font_t *font);
345
346
347 void
348 hb_font_set_funcs (hb_font_t         *font,
349                    hb_font_funcs_t   *klass,
350                    void              *font_data,
351                    hb_destroy_func_t  destroy);
352
353
354 void
355 hb_font_set_scale (hb_font_t *font,
356                    int x_scale,
357                    int y_scale);
358
359 void
360 hb_font_get_scale (hb_font_t *font,
361                    int *x_scale,
362                    int *y_scale);
363
364 /*
365  * A zero value means "no hinting in that direction"
366  */
367 void
368 hb_font_set_ppem (hb_font_t *font,
369                   unsigned int x_ppem,
370                   unsigned int y_ppem);
371
372 void
373 hb_font_get_ppem (hb_font_t *font,
374                   unsigned int *x_ppem,
375                   unsigned int *y_ppem);
376
377
378 HB_END_DECLS
379
380 #endif /* HB_FONT_H */