[API] Add hb_font_create_sub_font() and hb_font_get_parent()
[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_for_data (hb_blob_t    *blob,
45                          unsigned int  index);
46
47 typedef hb_blob_t * (*hb_get_table_func_t)  (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_reference (hb_face_t *face);
57
58 void
59 hb_face_destroy (hb_face_t *face);
60
61 hb_bool_t
62 hb_face_set_user_data (hb_face_t          *face,
63                        hb_user_data_key_t *key,
64                        void *              data,
65                        hb_destroy_func_t   destroy);
66
67
68 void *
69 hb_face_get_user_data (hb_face_t          *face,
70                        hb_user_data_key_t *key);
71
72
73 hb_blob_t *
74 hb_face_reference_table (hb_face_t *face,
75                          hb_tag_t   tag);
76
77 unsigned int
78 hb_face_get_upem (hb_face_t *face);
79
80
81 /*
82  * hb_font_funcs_t
83  */
84
85 typedef struct _hb_font_funcs_t hb_font_funcs_t;
86
87 hb_font_funcs_t *
88 hb_font_funcs_create (void);
89
90 hb_font_funcs_t *
91 hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
92
93 void
94 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
95
96 hb_bool_t
97 hb_font_funcs_set_user_data (hb_font_funcs_t    *ffuncs,
98                              hb_user_data_key_t *key,
99                              void *              data,
100                              hb_destroy_func_t   destroy);
101
102
103 void *
104 hb_font_funcs_get_user_data (hb_font_funcs_t    *ffuncs,
105                              hb_user_data_key_t *key);
106
107
108 void
109 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
110
111 hb_bool_t
112 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
113
114 /* funcs */
115
116 typedef struct _hb_glyph_extents_t
117 {
118     hb_position_t x_bearing;
119     hb_position_t y_bearing;
120     hb_position_t width;
121     hb_position_t height;
122 } hb_glyph_extents_t;
123
124 typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, const void *user_data,
125                                                     hb_codepoint_t unicode, hb_codepoint_t variation_selector);
126 typedef void (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, const void *user_data,
127                                                   hb_codepoint_t glyph,
128                                                   hb_position_t *x_advance, hb_position_t *y_advance);
129 typedef void (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, const void *user_data,
130                                                   hb_codepoint_t glyph,
131                                                   hb_glyph_extents_t *extents);
132 typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, const void *user_data,
133                                                        unsigned int point_index, hb_codepoint_t glyph,
134                                                        hb_position_t *x, hb_position_t *y);
135 typedef hb_position_t (*hb_font_get_kerning_func_t) (hb_font_t *font, const void *user_data,
136                                                      hb_codepoint_t first_glyph, hb_codepoint_t second_glyph);
137
138
139 void
140 hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
141                               hb_font_get_glyph_func_t glyph_func);
142
143 void
144 hb_font_funcs_set_glyph_advance_func (hb_font_funcs_t *ffuncs,
145                                       hb_font_get_glyph_advance_func_t glyph_advance_func);
146
147 void
148 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
149                                       hb_font_get_glyph_extents_func_t glyph_extents_func);
150
151 void
152 hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
153                                       hb_font_get_contour_point_func_t contour_point_func);
154
155 void
156 hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
157                                 hb_font_get_kerning_func_t kerning_func);
158
159
160 /* These never return NULL.  Return fallback defaults instead. */
161
162 hb_font_get_glyph_func_t
163 hb_font_funcs_get_glyph_func (hb_font_funcs_t *ffuncs);
164
165 hb_font_get_glyph_advance_func_t
166 hb_font_funcs_get_glyph_advance_func (hb_font_funcs_t *ffuncs);
167
168 hb_font_get_glyph_extents_func_t
169 hb_font_funcs_get_glyph_extents_func (hb_font_funcs_t *ffuncs);
170
171 hb_font_get_contour_point_func_t
172 hb_font_funcs_get_contour_point_func (hb_font_funcs_t *ffuncs);
173
174 hb_font_get_kerning_func_t
175 hb_font_funcs_get_kerning_func (hb_font_funcs_t *ffuncs);
176
177
178 hb_codepoint_t
179 hb_font_get_glyph (hb_font_t *font,
180                    hb_codepoint_t unicode, hb_codepoint_t variation_selector);
181
182 void
183 hb_font_get_glyph_advance (hb_font_t *font,
184                            hb_codepoint_t glyph,
185                            hb_position_t *x_advance, hb_position_t *y_advance);
186
187 void
188 hb_font_get_glyph_extents (hb_font_t *font,
189                            hb_codepoint_t glyph,
190                            hb_glyph_extents_t *extents);
191
192 hb_bool_t
193 hb_font_get_contour_point (hb_font_t *font,
194                            unsigned int point_index, hb_codepoint_t glyph,
195                            hb_position_t *x, hb_position_t *y);
196
197 hb_position_t
198 hb_font_get_kerning (hb_font_t *font,
199                      hb_codepoint_t first_glyph, hb_codepoint_t second_glyph);
200
201
202 /*
203  * hb_font_t
204  */
205
206 /* Fonts are very light-weight objects */
207
208 hb_font_t *
209 hb_font_create (hb_face_t *face);
210
211 hb_font_t *
212 hb_font_create_sub_font (hb_font_t *parent);
213
214 hb_font_t *
215 hb_font_reference (hb_font_t *font);
216
217 void
218 hb_font_destroy (hb_font_t *font);
219
220 hb_bool_t
221 hb_font_set_user_data (hb_font_t          *font,
222                        hb_user_data_key_t *key,
223                        void *              data,
224                        hb_destroy_func_t   destroy);
225
226
227 void *
228 hb_font_get_user_data (hb_font_t          *font,
229                        hb_user_data_key_t *key);
230
231 void
232 hb_font_make_immutable (hb_font_t *font);
233
234 hb_bool_t
235 hb_font_is_immutable (hb_font_t *font);
236
237 hb_font_t *
238 hb_font_get_parent (hb_font_t *font);
239
240 hb_face_t *
241 hb_font_get_face (hb_font_t *font);
242
243
244 void
245 hb_font_set_funcs (hb_font_t         *font,
246                    hb_font_funcs_t   *klass,
247                    void              *user_data,
248                    hb_destroy_func_t  destroy);
249
250
251 /*
252  * We should add support for full matrices.
253  */
254 void
255 hb_font_set_scale (hb_font_t *font,
256                    int x_scale,
257                    int y_scale);
258
259 void
260 hb_font_get_scale (hb_font_t *font,
261                    int *x_scale,
262                    int *y_scale);
263
264 /*
265  * A zero value means "no hinting in that direction"
266  */
267 void
268 hb_font_set_ppem (hb_font_t *font,
269                   unsigned int x_ppem,
270                   unsigned int y_ppem);
271
272 void
273 hb_font_get_ppem (hb_font_t *font,
274                   unsigned int *x_ppem,
275                   unsigned int *y_ppem);
276
277
278 HB_END_DECLS
279
280 #endif /* HB_FONT_H */