Mailbox support for texture layers.
[chromium-blink-merge.git] / third_party / harfbuzz-ng / src / hb-font.h
blobd796856f33c4e17bd677d25982db483d963126f9
1 /*
2 * Copyright © 2009 Red Hat, Inc.
4 * This is part of HarfBuzz, a text shaping library.
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.
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.
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.
24 * Red Hat Author(s): Behdad Esfahbod
27 #ifndef HB_H_IN
28 #error "Include <hb.h> instead."
29 #endif
31 #ifndef HB_FONT_H
32 #define HB_FONT_H
34 #include "hb-common.h"
35 #include "hb-blob.h"
37 HB_BEGIN_DECLS
40 typedef struct hb_face_t hb_face_t;
41 typedef struct hb_font_t hb_font_t;
44 * hb_face_t
47 hb_face_t *
48 hb_face_create (hb_blob_t *blob,
49 unsigned int index);
51 typedef hb_blob_t * (*hb_reference_table_func_t) (hb_face_t *face, hb_tag_t tag, void *user_data);
53 /* calls destroy() when not needing user_data anymore */
54 hb_face_t *
55 hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
56 void *user_data,
57 hb_destroy_func_t destroy);
59 hb_face_t *
60 hb_face_get_empty (void);
62 hb_face_t *
63 hb_face_reference (hb_face_t *face);
65 void
66 hb_face_destroy (hb_face_t *face);
68 hb_bool_t
69 hb_face_set_user_data (hb_face_t *face,
70 hb_user_data_key_t *key,
71 void * data,
72 hb_destroy_func_t destroy,
73 hb_bool_t replace);
76 void *
77 hb_face_get_user_data (hb_face_t *face,
78 hb_user_data_key_t *key);
80 void
81 hb_face_make_immutable (hb_face_t *face);
83 hb_bool_t
84 hb_face_is_immutable (hb_face_t *face);
87 hb_blob_t *
88 hb_face_reference_table (hb_face_t *face,
89 hb_tag_t tag);
91 hb_blob_t *
92 hb_face_reference_blob (hb_face_t *face);
94 void
95 hb_face_set_index (hb_face_t *face,
96 unsigned int index);
98 unsigned int
99 hb_face_get_index (hb_face_t *face);
101 void
102 hb_face_set_upem (hb_face_t *face,
103 unsigned int upem);
105 unsigned int
106 hb_face_get_upem (hb_face_t *face);
110 * hb_font_funcs_t
113 typedef struct hb_font_funcs_t hb_font_funcs_t;
115 hb_font_funcs_t *
116 hb_font_funcs_create (void);
118 hb_font_funcs_t *
119 hb_font_funcs_get_empty (void);
121 hb_font_funcs_t *
122 hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
124 void
125 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
127 hb_bool_t
128 hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs,
129 hb_user_data_key_t *key,
130 void * data,
131 hb_destroy_func_t destroy,
132 hb_bool_t replace);
135 void *
136 hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs,
137 hb_user_data_key_t *key);
140 void
141 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
143 hb_bool_t
144 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
147 /* glyph extents */
149 typedef struct hb_glyph_extents_t
151 hb_position_t x_bearing;
152 hb_position_t y_bearing;
153 hb_position_t width;
154 hb_position_t height;
155 } hb_glyph_extents_t;
158 /* func types */
160 typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data,
161 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
162 hb_codepoint_t *glyph,
163 void *user_data);
166 typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
167 hb_codepoint_t glyph,
168 void *user_data);
169 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
170 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
172 typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data,
173 hb_codepoint_t glyph,
174 hb_position_t *x, hb_position_t *y,
175 void *user_data);
176 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
177 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
179 typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
180 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
181 void *user_data);
182 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
183 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t;
186 typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
187 hb_codepoint_t glyph,
188 hb_glyph_extents_t *extents,
189 void *user_data);
190 typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data,
191 hb_codepoint_t glyph, unsigned int point_index,
192 hb_position_t *x, hb_position_t *y,
193 void *user_data);
196 typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data,
197 hb_codepoint_t glyph,
198 char *name, unsigned int size,
199 void *user_data);
200 typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data,
201 const char *name, int len, /* -1 means nul-terminated */
202 hb_codepoint_t *glyph,
203 void *user_data);
206 /* func setters */
208 void
209 hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
210 hb_font_get_glyph_func_t glyph_func,
211 void *user_data, hb_destroy_func_t destroy);
213 void
214 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
215 hb_font_get_glyph_h_advance_func_t func,
216 void *user_data, hb_destroy_func_t destroy);
217 void
218 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
219 hb_font_get_glyph_v_advance_func_t func,
220 void *user_data, hb_destroy_func_t destroy);
222 void
223 hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
224 hb_font_get_glyph_h_origin_func_t func,
225 void *user_data, hb_destroy_func_t destroy);
226 void
227 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
228 hb_font_get_glyph_v_origin_func_t func,
229 void *user_data, hb_destroy_func_t destroy);
231 void
232 hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
233 hb_font_get_glyph_h_kerning_func_t func,
234 void *user_data, hb_destroy_func_t destroy);
235 void
236 hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs,
237 hb_font_get_glyph_v_kerning_func_t func,
238 void *user_data, hb_destroy_func_t destroy);
240 void
241 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
242 hb_font_get_glyph_extents_func_t func,
243 void *user_data, hb_destroy_func_t destroy);
244 void
245 hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
246 hb_font_get_glyph_contour_point_func_t func,
247 void *user_data, hb_destroy_func_t destroy);
249 void
250 hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs,
251 hb_font_get_glyph_name_func_t glyph_func,
252 void *user_data, hb_destroy_func_t destroy);
253 void
254 hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
255 hb_font_get_glyph_from_name_func_t glyph_func,
256 void *user_data, hb_destroy_func_t destroy);
259 /* func dispatch */
261 hb_bool_t
262 hb_font_get_glyph (hb_font_t *font,
263 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
264 hb_codepoint_t *glyph);
266 hb_position_t
267 hb_font_get_glyph_h_advance (hb_font_t *font,
268 hb_codepoint_t glyph);
269 hb_position_t
270 hb_font_get_glyph_v_advance (hb_font_t *font,
271 hb_codepoint_t glyph);
273 hb_bool_t
274 hb_font_get_glyph_h_origin (hb_font_t *font,
275 hb_codepoint_t glyph,
276 hb_position_t *x, hb_position_t *y);
277 hb_bool_t
278 hb_font_get_glyph_v_origin (hb_font_t *font,
279 hb_codepoint_t glyph,
280 hb_position_t *x, hb_position_t *y);
282 hb_position_t
283 hb_font_get_glyph_h_kerning (hb_font_t *font,
284 hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
285 hb_position_t
286 hb_font_get_glyph_v_kerning (hb_font_t *font,
287 hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph);
289 hb_bool_t
290 hb_font_get_glyph_extents (hb_font_t *font,
291 hb_codepoint_t glyph,
292 hb_glyph_extents_t *extents);
294 hb_bool_t
295 hb_font_get_glyph_contour_point (hb_font_t *font,
296 hb_codepoint_t glyph, unsigned int point_index,
297 hb_position_t *x, hb_position_t *y);
299 hb_bool_t
300 hb_font_get_glyph_name (hb_font_t *font,
301 hb_codepoint_t glyph,
302 char *name, unsigned int size);
303 hb_bool_t
304 hb_font_get_glyph_from_name (hb_font_t *font,
305 const char *name, int len, /* -1 means nul-terminated */
306 hb_codepoint_t *glyph);
309 /* high-level funcs, with fallback */
311 void
312 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
313 hb_codepoint_t glyph,
314 hb_direction_t direction,
315 hb_position_t *x, hb_position_t *y);
316 void
317 hb_font_get_glyph_origin_for_direction (hb_font_t *font,
318 hb_codepoint_t glyph,
319 hb_direction_t direction,
320 hb_position_t *x, hb_position_t *y);
321 void
322 hb_font_add_glyph_origin_for_direction (hb_font_t *font,
323 hb_codepoint_t glyph,
324 hb_direction_t direction,
325 hb_position_t *x, hb_position_t *y);
326 void
327 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
328 hb_codepoint_t glyph,
329 hb_direction_t direction,
330 hb_position_t *x, hb_position_t *y);
332 void
333 hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
334 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
335 hb_direction_t direction,
336 hb_position_t *x, hb_position_t *y);
338 hb_bool_t
339 hb_font_get_glyph_extents_for_origin (hb_font_t *font,
340 hb_codepoint_t glyph,
341 hb_direction_t direction,
342 hb_glyph_extents_t *extents);
344 hb_bool_t
345 hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
346 hb_codepoint_t glyph, unsigned int point_index,
347 hb_direction_t direction,
348 hb_position_t *x, hb_position_t *y);
350 /* Generates gidDDD if glyph has no name. */
351 void
352 hb_font_glyph_to_string (hb_font_t *font,
353 hb_codepoint_t glyph,
354 char *s, unsigned int size);
355 /* Parses gidDDD and uniUUUU strings automatically. */
356 hb_bool_t
357 hb_font_glyph_from_string (hb_font_t *font,
358 const char *s, int len, /* -1 means nul-terminated */
359 hb_codepoint_t *glyph);
363 * hb_font_t
366 /* Fonts are very light-weight objects */
368 hb_font_t *
369 hb_font_create (hb_face_t *face);
371 hb_font_t *
372 hb_font_create_sub_font (hb_font_t *parent);
374 hb_font_t *
375 hb_font_get_empty (void);
377 hb_font_t *
378 hb_font_reference (hb_font_t *font);
380 void
381 hb_font_destroy (hb_font_t *font);
383 hb_bool_t
384 hb_font_set_user_data (hb_font_t *font,
385 hb_user_data_key_t *key,
386 void * data,
387 hb_destroy_func_t destroy,
388 hb_bool_t replace);
391 void *
392 hb_font_get_user_data (hb_font_t *font,
393 hb_user_data_key_t *key);
395 void
396 hb_font_make_immutable (hb_font_t *font);
398 hb_bool_t
399 hb_font_is_immutable (hb_font_t *font);
401 hb_font_t *
402 hb_font_get_parent (hb_font_t *font);
404 hb_face_t *
405 hb_font_get_face (hb_font_t *font);
408 void
409 hb_font_set_funcs (hb_font_t *font,
410 hb_font_funcs_t *klass,
411 void *font_data,
412 hb_destroy_func_t destroy);
414 /* Be *very* careful with this function! */
415 void
416 hb_font_set_funcs_data (hb_font_t *font,
417 void *font_data,
418 hb_destroy_func_t destroy);
421 void
422 hb_font_set_scale (hb_font_t *font,
423 int x_scale,
424 int y_scale);
426 void
427 hb_font_get_scale (hb_font_t *font,
428 int *x_scale,
429 int *y_scale);
432 * A zero value means "no hinting in that direction"
434 void
435 hb_font_set_ppem (hb_font_t *font,
436 unsigned int x_ppem,
437 unsigned int y_ppem);
439 void
440 hb_font_get_ppem (hb_font_t *font,
441 unsigned int *x_ppem,
442 unsigned int *y_ppem);
445 HB_END_DECLS
447 #endif /* HB_FONT_H */