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;
160 typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
161 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
163 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
166 typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
167 hb_codepoint_t glyph,
168 hb_glyph_extents_t *extents,
170 typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data,
171 hb_codepoint_t glyph, unsigned int point_index,
172 hb_position_t *x, hb_position_t *y,
176 typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data,
177 hb_codepoint_t glyph,
178 char *name, unsigned int size,
180 typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data,
181 const char *name, int len, /* -1 means nul-terminated */
182 hb_codepoint_t *glyph,
189 * hb_font_funcs_set_font_h_extents_func:
190 * @ffuncs: font functions.
191 * @func: (closure user_data) (destroy destroy) (scope notified):
200 hb_font_funcs_set_font_h_extents_func (hb_font_funcs_t *ffuncs,
201 hb_font_get_font_h_extents_func_t func,
202 void *user_data, hb_destroy_func_t destroy);
205 * hb_font_funcs_set_font_v_extents_func:
206 * @ffuncs: font functions.
207 * @func: (closure user_data) (destroy destroy) (scope notified):
216 hb_font_funcs_set_font_v_extents_func (hb_font_funcs_t *ffuncs,
217 hb_font_get_font_v_extents_func_t func,
218 void *user_data, hb_destroy_func_t destroy);
221 * hb_font_funcs_set_nominal_glyph_func:
222 * @ffuncs: font functions.
223 * @func: (closure user_data) (destroy destroy) (scope notified):
232 hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t *ffuncs,
233 hb_font_get_nominal_glyph_func_t func,
234 void *user_data, hb_destroy_func_t destroy);
237 * hb_font_funcs_set_nominal_glyphs_func:
238 * @ffuncs: font functions.
239 * @func: (closure user_data) (destroy destroy) (scope notified):
248 hb_font_funcs_set_nominal_glyphs_func (hb_font_funcs_t *ffuncs,
249 hb_font_get_nominal_glyphs_func_t func,
250 void *user_data, hb_destroy_func_t destroy);
253 * hb_font_funcs_set_variation_glyph_func:
254 * @ffuncs: font functions.
255 * @func: (closure user_data) (destroy destroy) (scope notified):
264 hb_font_funcs_set_variation_glyph_func (hb_font_funcs_t *ffuncs,
265 hb_font_get_variation_glyph_func_t func,
266 void *user_data, hb_destroy_func_t destroy);
269 * hb_font_funcs_set_glyph_h_advance_func:
270 * @ffuncs: font functions.
271 * @func: (closure user_data) (destroy destroy) (scope notified):
280 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
281 hb_font_get_glyph_h_advance_func_t func,
282 void *user_data, hb_destroy_func_t destroy);
285 * hb_font_funcs_set_glyph_v_advance_func:
286 * @ffuncs: font functions.
287 * @func: (closure user_data) (destroy destroy) (scope notified):
296 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
297 hb_font_get_glyph_v_advance_func_t func,
298 void *user_data, hb_destroy_func_t destroy);
301 * hb_font_funcs_set_glyph_h_advances_func:
302 * @ffuncs: font functions.
303 * @func: (closure user_data) (destroy destroy) (scope notified):
312 hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t *ffuncs,
313 hb_font_get_glyph_h_advances_func_t func,
314 void *user_data, hb_destroy_func_t destroy);
317 * hb_font_funcs_set_glyph_v_advances_func:
318 * @ffuncs: font functions.
319 * @func: (closure user_data) (destroy destroy) (scope notified):
328 hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t *ffuncs,
329 hb_font_get_glyph_v_advances_func_t func,
330 void *user_data, hb_destroy_func_t destroy);
333 * hb_font_funcs_set_glyph_h_origin_func:
334 * @ffuncs: font functions.
335 * @func: (closure user_data) (destroy destroy) (scope notified):
344 hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
345 hb_font_get_glyph_h_origin_func_t func,
346 void *user_data, hb_destroy_func_t destroy);
349 * hb_font_funcs_set_glyph_v_origin_func:
350 * @ffuncs: font functions.
351 * @func: (closure user_data) (destroy destroy) (scope notified):
360 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
361 hb_font_get_glyph_v_origin_func_t func,
362 void *user_data, hb_destroy_func_t destroy);
365 * hb_font_funcs_set_glyph_h_kerning_func:
366 * @ffuncs: font functions.
367 * @func: (closure user_data) (destroy destroy) (scope notified):
376 hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
377 hb_font_get_glyph_h_kerning_func_t func,
378 void *user_data, hb_destroy_func_t destroy);
381 * hb_font_funcs_set_glyph_extents_func:
382 * @ffuncs: font functions.
383 * @func: (closure user_data) (destroy destroy) (scope notified):
392 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
393 hb_font_get_glyph_extents_func_t func,
394 void *user_data, hb_destroy_func_t destroy);
397 * hb_font_funcs_set_glyph_contour_point_func:
398 * @ffuncs: font functions.
399 * @func: (closure user_data) (destroy destroy) (scope notified):
408 hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
409 hb_font_get_glyph_contour_point_func_t func,
410 void *user_data, hb_destroy_func_t destroy);
413 * hb_font_funcs_set_glyph_name_func:
414 * @ffuncs: font functions.
415 * @func: (closure user_data) (destroy destroy) (scope notified):
424 hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs,
425 hb_font_get_glyph_name_func_t func,
426 void *user_data, hb_destroy_func_t destroy);
429 * hb_font_funcs_set_glyph_from_name_func:
430 * @ffuncs: font functions.
431 * @func: (closure user_data) (destroy destroy) (scope notified):
440 hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
441 hb_font_get_glyph_from_name_func_t func,
442 void *user_data, hb_destroy_func_t destroy);
447 hb_font_get_h_extents (hb_font_t *font,
448 hb_font_extents_t *extents);
450 hb_font_get_v_extents (hb_font_t *font,
451 hb_font_extents_t *extents);
454 hb_font_get_nominal_glyph (hb_font_t *font,
455 hb_codepoint_t unicode,
456 hb_codepoint_t *glyph);
458 hb_font_get_variation_glyph (hb_font_t *font,
459 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
460 hb_codepoint_t *glyph);
462 HB_EXTERN unsigned int
463 hb_font_get_nominal_glyphs (hb_font_t *font,
465 const hb_codepoint_t *first_unicode,
466 unsigned int unicode_stride,
467 hb_codepoint_t *first_glyph,
468 unsigned int glyph_stride);
470 HB_EXTERN hb_position_t
471 hb_font_get_glyph_h_advance (hb_font_t *font,
472 hb_codepoint_t glyph);
473 HB_EXTERN hb_position_t
474 hb_font_get_glyph_v_advance (hb_font_t *font,
475 hb_codepoint_t glyph);
478 hb_font_get_glyph_h_advances (hb_font_t* font,
480 const hb_codepoint_t *first_glyph,
481 unsigned glyph_stride,
482 hb_position_t *first_advance,
483 unsigned advance_stride);
485 hb_font_get_glyph_v_advances (hb_font_t* font,
487 const hb_codepoint_t *first_glyph,
488 unsigned glyph_stride,
489 hb_position_t *first_advance,
490 unsigned advance_stride);
493 hb_font_get_glyph_h_origin (hb_font_t *font,
494 hb_codepoint_t glyph,
495 hb_position_t *x, hb_position_t *y);
497 hb_font_get_glyph_v_origin (hb_font_t *font,
498 hb_codepoint_t glyph,
499 hb_position_t *x, hb_position_t *y);
501 HB_EXTERN hb_position_t
502 hb_font_get_glyph_h_kerning (hb_font_t *font,
503 hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
506 hb_font_get_glyph_extents (hb_font_t *font,
507 hb_codepoint_t glyph,
508 hb_glyph_extents_t *extents);
511 hb_font_get_glyph_contour_point (hb_font_t *font,
512 hb_codepoint_t glyph, unsigned int point_index,
513 hb_position_t *x, hb_position_t *y);
516 hb_font_get_glyph_name (hb_font_t *font,
517 hb_codepoint_t glyph,
518 char *name, unsigned int size);
520 hb_font_get_glyph_from_name (hb_font_t *font,
521 const char *name, int len, /* -1 means nul-terminated */
522 hb_codepoint_t *glyph);
525 /* high-level funcs, with fallback */
527 /* Calls either hb_font_get_nominal_glyph() if variation_selector is 0,
528 * otherwise calls hb_font_get_variation_glyph(). */
530 hb_font_get_glyph (hb_font_t *font,
531 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
532 hb_codepoint_t *glyph);
535 hb_font_get_extents_for_direction (hb_font_t *font,
536 hb_direction_t direction,
537 hb_font_extents_t *extents);
539 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
540 hb_codepoint_t glyph,
541 hb_direction_t direction,
542 hb_position_t *x, hb_position_t *y);
544 hb_font_get_glyph_advances_for_direction (hb_font_t* font,
545 hb_direction_t direction,
547 const hb_codepoint_t *first_glyph,
548 unsigned glyph_stride,
549 hb_position_t *first_advance,
550 unsigned advance_stride);
552 hb_font_get_glyph_origin_for_direction (hb_font_t *font,
553 hb_codepoint_t glyph,
554 hb_direction_t direction,
555 hb_position_t *x, hb_position_t *y);
557 hb_font_add_glyph_origin_for_direction (hb_font_t *font,
558 hb_codepoint_t glyph,
559 hb_direction_t direction,
560 hb_position_t *x, hb_position_t *y);
562 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
563 hb_codepoint_t glyph,
564 hb_direction_t direction,
565 hb_position_t *x, hb_position_t *y);
568 hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
569 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
570 hb_direction_t direction,
571 hb_position_t *x, hb_position_t *y);
574 hb_font_get_glyph_extents_for_origin (hb_font_t *font,
575 hb_codepoint_t glyph,
576 hb_direction_t direction,
577 hb_glyph_extents_t *extents);
580 hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
581 hb_codepoint_t glyph, unsigned int point_index,
582 hb_direction_t direction,
583 hb_position_t *x, hb_position_t *y);
585 /* Generates gidDDD if glyph has no name. */
587 hb_font_glyph_to_string (hb_font_t *font,
588 hb_codepoint_t glyph,
589 char *s, unsigned int size);
590 /* Parses gidDDD and uniUUUU strings automatically. */
592 hb_font_glyph_from_string (hb_font_t *font,
593 const char *s, int len, /* -1 means nul-terminated */
594 hb_codepoint_t *glyph);
601 /* Fonts are very light-weight objects */
603 HB_EXTERN hb_font_t *
604 hb_font_create (hb_face_t *face);
606 HB_EXTERN hb_font_t *
607 hb_font_create_sub_font (hb_font_t *parent);
609 HB_EXTERN hb_font_t *
610 hb_font_get_empty (void);
612 HB_EXTERN hb_font_t *
613 hb_font_reference (hb_font_t *font);
616 hb_font_destroy (hb_font_t *font);
619 hb_font_set_user_data (hb_font_t *font,
620 hb_user_data_key_t *key,
622 hb_destroy_func_t destroy,
627 hb_font_get_user_data (hb_font_t *font,
628 hb_user_data_key_t *key);
631 hb_font_make_immutable (hb_font_t *font);
634 hb_font_is_immutable (hb_font_t *font);
637 hb_font_set_parent (hb_font_t *font,
640 HB_EXTERN hb_font_t *
641 hb_font_get_parent (hb_font_t *font);
644 hb_font_set_face (hb_font_t *font,
647 HB_EXTERN hb_face_t *
648 hb_font_get_face (hb_font_t *font);
652 hb_font_set_funcs (hb_font_t *font,
653 hb_font_funcs_t *klass,
655 hb_destroy_func_t destroy);
657 /* Be *very* careful with this function! */
659 hb_font_set_funcs_data (hb_font_t *font,
661 hb_destroy_func_t destroy);
665 hb_font_set_scale (hb_font_t *font,
670 hb_font_get_scale (hb_font_t *font,
675 * A zero value means "no hinting in that direction"
678 hb_font_set_ppem (hb_font_t *font,
680 unsigned int y_ppem);
683 hb_font_get_ppem (hb_font_t *font,
684 unsigned int *x_ppem,
685 unsigned int *y_ppem);
688 * Point size per EM. Used for optical-sizing in CoreText.
689 * A value of zero means "not set".
692 hb_font_set_ptem (hb_font_t *font, float ptem);
695 hb_font_get_ptem (hb_font_t *font);
698 hb_font_set_variations (hb_font_t *font,
699 const hb_variation_t *variations,
700 unsigned int variations_length);
703 hb_font_set_var_coords_design (hb_font_t *font,
705 unsigned int coords_length);
708 hb_font_set_var_coords_normalized (hb_font_t *font,
709 const int *coords, /* 2.14 normalized */
710 unsigned int coords_length);
712 HB_EXTERN const int *
713 hb_font_get_var_coords_normalized (hb_font_t *font,
714 unsigned int *length);
717 hb_font_set_var_named_instance (hb_font_t *font,
718 unsigned instance_index);
722 #endif /* HB_FONT_H */