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
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
28 #error "Include <hb.h> instead."
34 #include "hb-common.h"
40 typedef struct hb_font_t hb_font_t;
47 typedef struct hb_font_funcs_t hb_font_funcs_t;
49 HB_EXTERN hb_font_funcs_t *
50 hb_font_funcs_create (void);
52 HB_EXTERN hb_font_funcs_t *
53 hb_font_funcs_get_empty (void);
55 HB_EXTERN hb_font_funcs_t *
56 hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
59 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
62 hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs,
63 hb_user_data_key_t *key,
65 hb_destroy_func_t destroy,
70 hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs,
71 hb_user_data_key_t *key);
75 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
78 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
81 /* font and glyph extents */
83 /* Note that typically ascender is positive and descender negative in coordinate systems that grow up. */
84 typedef struct hb_font_extents_t
86 hb_position_t ascender; /* typographic ascender. */
87 hb_position_t descender; /* typographic descender. */
88 hb_position_t line_gap; /* suggested line spacing gap. */
90 hb_position_t reserved9;
91 hb_position_t reserved8;
92 hb_position_t reserved7;
93 hb_position_t reserved6;
94 hb_position_t reserved5;
95 hb_position_t reserved4;
96 hb_position_t reserved3;
97 hb_position_t reserved2;
98 hb_position_t reserved1;
101 /* Note that height is negative in coordinate systems that grow up. */
102 typedef struct hb_glyph_extents_t
104 hb_position_t x_bearing; /* left side of glyph from origin. */
105 hb_position_t y_bearing; /* top side of glyph from origin. */
106 hb_position_t width; /* distance from left to right side. */
107 hb_position_t height; /* distance from top to bottom side. */
108 } hb_glyph_extents_t;
112 typedef hb_bool_t (*hb_font_get_font_extents_func_t) (hb_font_t *font, void *font_data,
113 hb_font_extents_t *extents,
115 typedef hb_font_get_font_extents_func_t hb_font_get_font_h_extents_func_t;
116 typedef hb_font_get_font_extents_func_t hb_font_get_font_v_extents_func_t;
119 typedef hb_bool_t (*hb_font_get_nominal_glyph_func_t) (hb_font_t *font, void *font_data,
120 hb_codepoint_t unicode,
121 hb_codepoint_t *glyph,
123 typedef hb_bool_t (*hb_font_get_variation_glyph_func_t) (hb_font_t *font, void *font_data,
124 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
125 hb_codepoint_t *glyph,
128 typedef unsigned int (*hb_font_get_nominal_glyphs_func_t) (hb_font_t *font, void *font_data,
130 const hb_codepoint_t *first_unicode,
131 unsigned int unicode_stride,
132 hb_codepoint_t *first_glyph,
133 unsigned int glyph_stride,
137 typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
138 hb_codepoint_t glyph,
140 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
141 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
143 typedef void (*hb_font_get_glyph_advances_func_t) (hb_font_t* font, void* font_data,
145 const hb_codepoint_t *first_glyph,
146 unsigned glyph_stride,
147 hb_position_t *first_advance,
148 unsigned advance_stride,
150 typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_h_advances_func_t;
151 typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_v_advances_func_t;
153 typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data,
154 hb_codepoint_t glyph,
155 hb_position_t *x, hb_position_t *y,
157 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
158 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
161 typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
162 hb_codepoint_t glyph,
163 hb_glyph_extents_t *extents,
165 typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data,
166 hb_codepoint_t glyph, unsigned int point_index,
167 hb_position_t *x, hb_position_t *y,
171 typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data,
172 hb_codepoint_t glyph,
173 char *name, unsigned int size,
175 typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data,
176 const char *name, int len, /* -1 means nul-terminated */
177 hb_codepoint_t *glyph,
184 * hb_font_funcs_set_font_h_extents_func:
185 * @ffuncs: font functions.
186 * @func: (closure user_data) (destroy destroy) (scope notified):
195 hb_font_funcs_set_font_h_extents_func (hb_font_funcs_t *ffuncs,
196 hb_font_get_font_h_extents_func_t func,
197 void *user_data, hb_destroy_func_t destroy);
200 * hb_font_funcs_set_font_v_extents_func:
201 * @ffuncs: font functions.
202 * @func: (closure user_data) (destroy destroy) (scope notified):
211 hb_font_funcs_set_font_v_extents_func (hb_font_funcs_t *ffuncs,
212 hb_font_get_font_v_extents_func_t func,
213 void *user_data, hb_destroy_func_t destroy);
216 * hb_font_funcs_set_nominal_glyph_func:
217 * @ffuncs: font functions.
218 * @func: (closure user_data) (destroy destroy) (scope notified):
227 hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t *ffuncs,
228 hb_font_get_nominal_glyph_func_t func,
229 void *user_data, hb_destroy_func_t destroy);
232 * hb_font_funcs_set_nominal_glyphs_func:
233 * @ffuncs: font functions.
234 * @func: (closure user_data) (destroy destroy) (scope notified):
243 hb_font_funcs_set_nominal_glyphs_func (hb_font_funcs_t *ffuncs,
244 hb_font_get_nominal_glyphs_func_t func,
245 void *user_data, hb_destroy_func_t destroy);
248 * hb_font_funcs_set_variation_glyph_func:
249 * @ffuncs: font functions.
250 * @func: (closure user_data) (destroy destroy) (scope notified):
259 hb_font_funcs_set_variation_glyph_func (hb_font_funcs_t *ffuncs,
260 hb_font_get_variation_glyph_func_t func,
261 void *user_data, hb_destroy_func_t destroy);
264 * hb_font_funcs_set_glyph_h_advance_func:
265 * @ffuncs: font functions.
266 * @func: (closure user_data) (destroy destroy) (scope notified):
275 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
276 hb_font_get_glyph_h_advance_func_t func,
277 void *user_data, hb_destroy_func_t destroy);
280 * hb_font_funcs_set_glyph_v_advance_func:
281 * @ffuncs: font functions.
282 * @func: (closure user_data) (destroy destroy) (scope notified):
291 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
292 hb_font_get_glyph_v_advance_func_t func,
293 void *user_data, hb_destroy_func_t destroy);
296 * hb_font_funcs_set_glyph_h_advances_func:
297 * @ffuncs: font functions.
298 * @func: (closure user_data) (destroy destroy) (scope notified):
307 hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t *ffuncs,
308 hb_font_get_glyph_h_advances_func_t func,
309 void *user_data, hb_destroy_func_t destroy);
312 * hb_font_funcs_set_glyph_v_advances_func:
313 * @ffuncs: font functions.
314 * @func: (closure user_data) (destroy destroy) (scope notified):
323 hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t *ffuncs,
324 hb_font_get_glyph_v_advances_func_t func,
325 void *user_data, hb_destroy_func_t destroy);
328 * hb_font_funcs_set_glyph_h_origin_func:
329 * @ffuncs: font functions.
330 * @func: (closure user_data) (destroy destroy) (scope notified):
339 hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
340 hb_font_get_glyph_h_origin_func_t func,
341 void *user_data, hb_destroy_func_t destroy);
344 * hb_font_funcs_set_glyph_v_origin_func:
345 * @ffuncs: font functions.
346 * @func: (closure user_data) (destroy destroy) (scope notified):
355 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
356 hb_font_get_glyph_v_origin_func_t func,
357 void *user_data, hb_destroy_func_t destroy);
360 * hb_font_funcs_set_glyph_extents_func:
361 * @ffuncs: font functions.
362 * @func: (closure user_data) (destroy destroy) (scope notified):
371 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
372 hb_font_get_glyph_extents_func_t func,
373 void *user_data, hb_destroy_func_t destroy);
376 * hb_font_funcs_set_glyph_contour_point_func:
377 * @ffuncs: font functions.
378 * @func: (closure user_data) (destroy destroy) (scope notified):
387 hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
388 hb_font_get_glyph_contour_point_func_t func,
389 void *user_data, hb_destroy_func_t destroy);
392 * hb_font_funcs_set_glyph_name_func:
393 * @ffuncs: font functions.
394 * @func: (closure user_data) (destroy destroy) (scope notified):
403 hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs,
404 hb_font_get_glyph_name_func_t func,
405 void *user_data, hb_destroy_func_t destroy);
408 * hb_font_funcs_set_glyph_from_name_func:
409 * @ffuncs: font functions.
410 * @func: (closure user_data) (destroy destroy) (scope notified):
419 hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
420 hb_font_get_glyph_from_name_func_t func,
421 void *user_data, hb_destroy_func_t destroy);
426 hb_font_get_h_extents (hb_font_t *font,
427 hb_font_extents_t *extents);
429 hb_font_get_v_extents (hb_font_t *font,
430 hb_font_extents_t *extents);
433 hb_font_get_nominal_glyph (hb_font_t *font,
434 hb_codepoint_t unicode,
435 hb_codepoint_t *glyph);
437 hb_font_get_variation_glyph (hb_font_t *font,
438 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
439 hb_codepoint_t *glyph);
441 HB_EXTERN hb_position_t
442 hb_font_get_glyph_h_advance (hb_font_t *font,
443 hb_codepoint_t glyph);
444 HB_EXTERN hb_position_t
445 hb_font_get_glyph_v_advance (hb_font_t *font,
446 hb_codepoint_t glyph);
449 hb_font_get_glyph_h_advances (hb_font_t* font,
451 const hb_codepoint_t *first_glyph,
452 unsigned glyph_stride,
453 hb_position_t *first_advance,
454 unsigned advance_stride);
456 hb_font_get_glyph_v_advances (hb_font_t* font,
458 const hb_codepoint_t *first_glyph,
459 unsigned glyph_stride,
460 hb_position_t *first_advance,
461 unsigned advance_stride);
464 hb_font_get_glyph_h_origin (hb_font_t *font,
465 hb_codepoint_t glyph,
466 hb_position_t *x, hb_position_t *y);
468 hb_font_get_glyph_v_origin (hb_font_t *font,
469 hb_codepoint_t glyph,
470 hb_position_t *x, hb_position_t *y);
473 hb_font_get_glyph_extents (hb_font_t *font,
474 hb_codepoint_t glyph,
475 hb_glyph_extents_t *extents);
478 hb_font_get_glyph_contour_point (hb_font_t *font,
479 hb_codepoint_t glyph, unsigned int point_index,
480 hb_position_t *x, hb_position_t *y);
483 hb_font_get_glyph_name (hb_font_t *font,
484 hb_codepoint_t glyph,
485 char *name, unsigned int size);
487 hb_font_get_glyph_from_name (hb_font_t *font,
488 const char *name, int len, /* -1 means nul-terminated */
489 hb_codepoint_t *glyph);
492 /* high-level funcs, with fallback */
494 /* Calls either hb_font_get_nominal_glyph() if variation_selector is 0,
495 * otherwise calls hb_font_get_variation_glyph(). */
497 hb_font_get_glyph (hb_font_t *font,
498 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
499 hb_codepoint_t *glyph);
502 hb_font_get_extents_for_direction (hb_font_t *font,
503 hb_direction_t direction,
504 hb_font_extents_t *extents);
506 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
507 hb_codepoint_t glyph,
508 hb_direction_t direction,
509 hb_position_t *x, hb_position_t *y);
511 hb_font_get_glyph_advances_for_direction (hb_font_t* font,
512 hb_direction_t direction,
514 const hb_codepoint_t *first_glyph,
515 unsigned glyph_stride,
516 hb_position_t *first_advance,
517 unsigned advance_stride);
519 hb_font_get_glyph_origin_for_direction (hb_font_t *font,
520 hb_codepoint_t glyph,
521 hb_direction_t direction,
522 hb_position_t *x, hb_position_t *y);
524 hb_font_add_glyph_origin_for_direction (hb_font_t *font,
525 hb_codepoint_t glyph,
526 hb_direction_t direction,
527 hb_position_t *x, hb_position_t *y);
529 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
530 hb_codepoint_t glyph,
531 hb_direction_t direction,
532 hb_position_t *x, hb_position_t *y);
535 hb_font_get_glyph_extents_for_origin (hb_font_t *font,
536 hb_codepoint_t glyph,
537 hb_direction_t direction,
538 hb_glyph_extents_t *extents);
541 hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
542 hb_codepoint_t glyph, unsigned int point_index,
543 hb_direction_t direction,
544 hb_position_t *x, hb_position_t *y);
546 /* Generates gidDDD if glyph has no name. */
548 hb_font_glyph_to_string (hb_font_t *font,
549 hb_codepoint_t glyph,
550 char *s, unsigned int size);
551 /* Parses gidDDD and uniUUUU strings automatically. */
553 hb_font_glyph_from_string (hb_font_t *font,
554 const char *s, int len, /* -1 means nul-terminated */
555 hb_codepoint_t *glyph);
562 /* Fonts are very light-weight objects */
564 HB_EXTERN hb_font_t *
565 hb_font_create (hb_face_t *face);
567 HB_EXTERN hb_font_t *
568 hb_font_create_sub_font (hb_font_t *parent);
570 HB_EXTERN hb_font_t *
571 hb_font_get_empty (void);
573 HB_EXTERN hb_font_t *
574 hb_font_reference (hb_font_t *font);
577 hb_font_destroy (hb_font_t *font);
580 hb_font_set_user_data (hb_font_t *font,
581 hb_user_data_key_t *key,
583 hb_destroy_func_t destroy,
588 hb_font_get_user_data (hb_font_t *font,
589 hb_user_data_key_t *key);
592 hb_font_make_immutable (hb_font_t *font);
595 hb_font_is_immutable (hb_font_t *font);
598 hb_font_set_parent (hb_font_t *font,
601 HB_EXTERN hb_font_t *
602 hb_font_get_parent (hb_font_t *font);
605 hb_font_set_face (hb_font_t *font,
608 HB_EXTERN hb_face_t *
609 hb_font_get_face (hb_font_t *font);
613 hb_font_set_funcs (hb_font_t *font,
614 hb_font_funcs_t *klass,
616 hb_destroy_func_t destroy);
618 /* Be *very* careful with this function! */
620 hb_font_set_funcs_data (hb_font_t *font,
622 hb_destroy_func_t destroy);
626 hb_font_set_scale (hb_font_t *font,
631 hb_font_get_scale (hb_font_t *font,
636 * A zero value means "no hinting in that direction"
639 hb_font_set_ppem (hb_font_t *font,
641 unsigned int y_ppem);
644 hb_font_get_ppem (hb_font_t *font,
645 unsigned int *x_ppem,
646 unsigned int *y_ppem);
649 * Point size per EM. Used for optical-sizing in CoreText.
650 * A value of zero means "not set".
653 hb_font_set_ptem (hb_font_t *font, float ptem);
656 hb_font_get_ptem (hb_font_t *font);
659 hb_font_set_variations (hb_font_t *font,
660 const hb_variation_t *variations,
661 unsigned int variations_length);
664 hb_font_set_var_coords_design (hb_font_t *font,
666 unsigned int coords_length);
669 hb_font_set_var_coords_normalized (hb_font_t *font,
670 const int *coords, /* 2.14 normalized */
671 unsigned int coords_length);
673 HB_EXTERN const int *
674 hb_font_get_var_coords_normalized (hb_font_t *font,
675 unsigned int *length);
679 #endif /* HB_FONT_H */