Restore variadic macros in DevToolsEmbedderMessageDispatcher
[chromium-blink-merge.git] / third_party / harfbuzz-ng / src / hb-font.h
blobcf22589ec65531c816840f841a4ccbfd5f2e3237
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-face.h"
37 HB_BEGIN_DECLS
40 typedef struct hb_font_t hb_font_t;
44 * hb_font_funcs_t
47 typedef struct hb_font_funcs_t hb_font_funcs_t;
49 hb_font_funcs_t *
50 hb_font_funcs_create (void);
52 hb_font_funcs_t *
53 hb_font_funcs_get_empty (void);
55 hb_font_funcs_t *
56 hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
58 void
59 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
61 hb_bool_t
62 hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs,
63 hb_user_data_key_t *key,
64 void * data,
65 hb_destroy_func_t destroy,
66 hb_bool_t replace);
69 void *
70 hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs,
71 hb_user_data_key_t *key);
74 void
75 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
77 hb_bool_t
78 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
81 /* glyph extents */
83 typedef struct hb_glyph_extents_t
85 hb_position_t x_bearing;
86 hb_position_t y_bearing;
87 hb_position_t width;
88 hb_position_t height;
89 } hb_glyph_extents_t;
92 /* func types */
94 typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data,
95 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
96 hb_codepoint_t *glyph,
97 void *user_data);
100 typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
101 hb_codepoint_t glyph,
102 void *user_data);
103 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
104 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
106 typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data,
107 hb_codepoint_t glyph,
108 hb_position_t *x, hb_position_t *y,
109 void *user_data);
110 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
111 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
113 typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
114 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
115 void *user_data);
116 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
117 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t;
120 typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
121 hb_codepoint_t glyph,
122 hb_glyph_extents_t *extents,
123 void *user_data);
124 typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data,
125 hb_codepoint_t glyph, unsigned int point_index,
126 hb_position_t *x, hb_position_t *y,
127 void *user_data);
130 typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data,
131 hb_codepoint_t glyph,
132 char *name, unsigned int size,
133 void *user_data);
134 typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data,
135 const char *name, int len, /* -1 means nul-terminated */
136 hb_codepoint_t *glyph,
137 void *user_data);
140 /* func setters */
143 * hb_font_funcs_set_glyph_func:
144 * @ffuncs: font functions.
145 * @func: (closure user_data) (destroy destroy) (scope notified):
146 * @user_data:
147 * @destroy:
151 * Since: 1.0
153 void
154 hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
155 hb_font_get_glyph_func_t func,
156 void *user_data, hb_destroy_func_t destroy);
159 * hb_font_funcs_set_glyph_h_advance_func:
160 * @ffuncs: font functions.
161 * @func: (closure user_data) (destroy destroy) (scope notified):
162 * @user_data:
163 * @destroy:
167 * Since: 1.0
169 void
170 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
171 hb_font_get_glyph_h_advance_func_t func,
172 void *user_data, hb_destroy_func_t destroy);
175 * hb_font_funcs_set_glyph_v_advance_func:
176 * @ffuncs: font functions.
177 * @func: (closure user_data) (destroy destroy) (scope notified):
178 * @user_data:
179 * @destroy:
183 * Since: 1.0
185 void
186 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
187 hb_font_get_glyph_v_advance_func_t func,
188 void *user_data, hb_destroy_func_t destroy);
191 * hb_font_funcs_set_glyph_h_origin_func:
192 * @ffuncs: font functions.
193 * @func: (closure user_data) (destroy destroy) (scope notified):
194 * @user_data:
195 * @destroy:
199 * Since: 1.0
201 void
202 hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
203 hb_font_get_glyph_h_origin_func_t func,
204 void *user_data, hb_destroy_func_t destroy);
207 * hb_font_funcs_set_glyph_v_origin_func:
208 * @ffuncs: font functions.
209 * @func: (closure user_data) (destroy destroy) (scope notified):
210 * @user_data:
211 * @destroy:
215 * Since: 1.0
217 void
218 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
219 hb_font_get_glyph_v_origin_func_t func,
220 void *user_data, hb_destroy_func_t destroy);
223 * hb_font_funcs_set_glyph_h_kerning_func:
224 * @ffuncs: font functions.
225 * @func: (closure user_data) (destroy destroy) (scope notified):
226 * @user_data:
227 * @destroy:
231 * Since: 1.0
233 void
234 hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
235 hb_font_get_glyph_h_kerning_func_t func,
236 void *user_data, hb_destroy_func_t destroy);
239 * hb_font_funcs_set_glyph_v_kerning_func:
240 * @ffuncs: font functions.
241 * @func: (closure user_data) (destroy destroy) (scope notified):
242 * @user_data:
243 * @destroy:
247 * Since: 1.0
249 void
250 hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs,
251 hb_font_get_glyph_v_kerning_func_t func,
252 void *user_data, hb_destroy_func_t destroy);
255 * hb_font_funcs_set_glyph_extents_func:
256 * @ffuncs: font functions.
257 * @func: (closure user_data) (destroy destroy) (scope notified):
258 * @user_data:
259 * @destroy:
263 * Since: 1.0
265 void
266 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
267 hb_font_get_glyph_extents_func_t func,
268 void *user_data, hb_destroy_func_t destroy);
271 * hb_font_funcs_set_glyph_contour_point_func:
272 * @ffuncs: font functions.
273 * @func: (closure user_data) (destroy destroy) (scope notified):
274 * @user_data:
275 * @destroy:
279 * Since: 1.0
281 void
282 hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
283 hb_font_get_glyph_contour_point_func_t func,
284 void *user_data, hb_destroy_func_t destroy);
287 * hb_font_funcs_set_glyph_name_func:
288 * @ffuncs: font functions.
289 * @func: (closure user_data) (destroy destroy) (scope notified):
290 * @user_data:
291 * @destroy:
295 * Since: 0.9.2
297 void
298 hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs,
299 hb_font_get_glyph_name_func_t func,
300 void *user_data, hb_destroy_func_t destroy);
303 * hb_font_funcs_set_glyph_from_name_func:
304 * @ffuncs: font functions.
305 * @func: (closure user_data) (destroy destroy) (scope notified):
306 * @user_data:
307 * @destroy:
311 * Since: 0.9.2
313 void
314 hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
315 hb_font_get_glyph_from_name_func_t func,
316 void *user_data, hb_destroy_func_t destroy);
319 /* func dispatch */
321 hb_bool_t
322 hb_font_get_glyph (hb_font_t *font,
323 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
324 hb_codepoint_t *glyph);
326 hb_position_t
327 hb_font_get_glyph_h_advance (hb_font_t *font,
328 hb_codepoint_t glyph);
329 hb_position_t
330 hb_font_get_glyph_v_advance (hb_font_t *font,
331 hb_codepoint_t glyph);
333 hb_bool_t
334 hb_font_get_glyph_h_origin (hb_font_t *font,
335 hb_codepoint_t glyph,
336 hb_position_t *x, hb_position_t *y);
337 hb_bool_t
338 hb_font_get_glyph_v_origin (hb_font_t *font,
339 hb_codepoint_t glyph,
340 hb_position_t *x, hb_position_t *y);
342 hb_position_t
343 hb_font_get_glyph_h_kerning (hb_font_t *font,
344 hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
345 hb_position_t
346 hb_font_get_glyph_v_kerning (hb_font_t *font,
347 hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph);
349 hb_bool_t
350 hb_font_get_glyph_extents (hb_font_t *font,
351 hb_codepoint_t glyph,
352 hb_glyph_extents_t *extents);
354 hb_bool_t
355 hb_font_get_glyph_contour_point (hb_font_t *font,
356 hb_codepoint_t glyph, unsigned int point_index,
357 hb_position_t *x, hb_position_t *y);
359 hb_bool_t
360 hb_font_get_glyph_name (hb_font_t *font,
361 hb_codepoint_t glyph,
362 char *name, unsigned int size);
363 hb_bool_t
364 hb_font_get_glyph_from_name (hb_font_t *font,
365 const char *name, int len, /* -1 means nul-terminated */
366 hb_codepoint_t *glyph);
369 /* high-level funcs, with fallback */
371 void
372 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
373 hb_codepoint_t glyph,
374 hb_direction_t direction,
375 hb_position_t *x, hb_position_t *y);
376 void
377 hb_font_get_glyph_origin_for_direction (hb_font_t *font,
378 hb_codepoint_t glyph,
379 hb_direction_t direction,
380 hb_position_t *x, hb_position_t *y);
381 void
382 hb_font_add_glyph_origin_for_direction (hb_font_t *font,
383 hb_codepoint_t glyph,
384 hb_direction_t direction,
385 hb_position_t *x, hb_position_t *y);
386 void
387 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
388 hb_codepoint_t glyph,
389 hb_direction_t direction,
390 hb_position_t *x, hb_position_t *y);
392 void
393 hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
394 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
395 hb_direction_t direction,
396 hb_position_t *x, hb_position_t *y);
398 hb_bool_t
399 hb_font_get_glyph_extents_for_origin (hb_font_t *font,
400 hb_codepoint_t glyph,
401 hb_direction_t direction,
402 hb_glyph_extents_t *extents);
404 hb_bool_t
405 hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
406 hb_codepoint_t glyph, unsigned int point_index,
407 hb_direction_t direction,
408 hb_position_t *x, hb_position_t *y);
410 /* Generates gidDDD if glyph has no name. */
411 void
412 hb_font_glyph_to_string (hb_font_t *font,
413 hb_codepoint_t glyph,
414 char *s, unsigned int size);
415 /* Parses gidDDD and uniUUUU strings automatically. */
416 hb_bool_t
417 hb_font_glyph_from_string (hb_font_t *font,
418 const char *s, int len, /* -1 means nul-terminated */
419 hb_codepoint_t *glyph);
423 * hb_font_t
426 /* Fonts are very light-weight objects */
428 hb_font_t *
429 hb_font_create (hb_face_t *face);
431 hb_font_t *
432 hb_font_create_sub_font (hb_font_t *parent);
434 hb_font_t *
435 hb_font_get_empty (void);
437 hb_font_t *
438 hb_font_reference (hb_font_t *font);
440 void
441 hb_font_destroy (hb_font_t *font);
443 hb_bool_t
444 hb_font_set_user_data (hb_font_t *font,
445 hb_user_data_key_t *key,
446 void * data,
447 hb_destroy_func_t destroy,
448 hb_bool_t replace);
451 void *
452 hb_font_get_user_data (hb_font_t *font,
453 hb_user_data_key_t *key);
455 void
456 hb_font_make_immutable (hb_font_t *font);
458 hb_bool_t
459 hb_font_is_immutable (hb_font_t *font);
461 hb_font_t *
462 hb_font_get_parent (hb_font_t *font);
464 hb_face_t *
465 hb_font_get_face (hb_font_t *font);
468 void
469 hb_font_set_funcs (hb_font_t *font,
470 hb_font_funcs_t *klass,
471 void *font_data,
472 hb_destroy_func_t destroy);
474 /* Be *very* careful with this function! */
475 void
476 hb_font_set_funcs_data (hb_font_t *font,
477 void *font_data,
478 hb_destroy_func_t destroy);
481 void
482 hb_font_set_scale (hb_font_t *font,
483 int x_scale,
484 int y_scale);
486 void
487 hb_font_get_scale (hb_font_t *font,
488 int *x_scale,
489 int *y_scale);
492 * A zero value means "no hinting in that direction"
494 void
495 hb_font_set_ppem (hb_font_t *font,
496 unsigned int x_ppem,
497 unsigned int y_ppem);
499 void
500 hb_font_get_ppem (hb_font_t *font,
501 unsigned int *x_ppem,
502 unsigned int *y_ppem);
505 HB_END_DECLS
507 #endif /* HB_FONT_H */