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"
41 typedef struct hb_font_t hb_font_t;
48 typedef struct hb_font_funcs_t hb_font_funcs_t;
50 HB_EXTERN hb_font_funcs_t *
51 hb_font_funcs_create (void);
53 HB_EXTERN hb_font_funcs_t *
54 hb_font_funcs_get_empty (void);
56 HB_EXTERN hb_font_funcs_t *
57 hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
60 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
63 hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs,
64 hb_user_data_key_t *key,
66 hb_destroy_func_t destroy,
71 hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs,
72 hb_user_data_key_t *key);
76 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
79 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
82 /* font and glyph extents */
84 /* Note that typically ascender is positive and descender negative in coordinate systems that grow up. */
85 typedef struct hb_font_extents_t
87 hb_position_t ascender; /* typographic ascender. */
88 hb_position_t descender; /* typographic descender. */
89 hb_position_t line_gap; /* suggested line spacing gap. */
91 hb_position_t reserved9;
92 hb_position_t reserved8;
93 hb_position_t reserved7;
94 hb_position_t reserved6;
95 hb_position_t reserved5;
96 hb_position_t reserved4;
97 hb_position_t reserved3;
98 hb_position_t reserved2;
99 hb_position_t reserved1;
102 /* Note that height is negative in coordinate systems that grow up. */
103 typedef struct hb_glyph_extents_t
105 hb_position_t x_bearing; /* left side of glyph from origin. */
106 hb_position_t y_bearing; /* top side of glyph from origin. */
107 hb_position_t width; /* distance from left to right side. */
108 hb_position_t height; /* distance from top to bottom side. */
109 } hb_glyph_extents_t;
113 typedef hb_bool_t (*hb_font_get_font_extents_func_t) (hb_font_t *font, void *font_data,
114 hb_font_extents_t *extents,
116 typedef hb_font_get_font_extents_func_t hb_font_get_font_h_extents_func_t;
117 typedef hb_font_get_font_extents_func_t hb_font_get_font_v_extents_func_t;
120 typedef hb_bool_t (*hb_font_get_nominal_glyph_func_t) (hb_font_t *font, void *font_data,
121 hb_codepoint_t unicode,
122 hb_codepoint_t *glyph,
124 typedef hb_bool_t (*hb_font_get_variation_glyph_func_t) (hb_font_t *font, void *font_data,
125 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
126 hb_codepoint_t *glyph,
129 typedef unsigned int (*hb_font_get_nominal_glyphs_func_t) (hb_font_t *font, void *font_data,
131 const hb_codepoint_t *first_unicode,
132 unsigned int unicode_stride,
133 hb_codepoint_t *first_glyph,
134 unsigned int glyph_stride,
138 typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
139 hb_codepoint_t glyph,
141 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
142 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
144 typedef void (*hb_font_get_glyph_advances_func_t) (hb_font_t* font, void* font_data,
146 const hb_codepoint_t *first_glyph,
147 unsigned glyph_stride,
148 hb_position_t *first_advance,
149 unsigned advance_stride,
151 typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_h_advances_func_t;
152 typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_v_advances_func_t;
154 typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data,
155 hb_codepoint_t glyph,
156 hb_position_t *x, hb_position_t *y,
158 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
159 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
161 typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
162 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
164 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
167 typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
168 hb_codepoint_t glyph,
169 hb_glyph_extents_t *extents,
171 typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data,
172 hb_codepoint_t glyph, unsigned int point_index,
173 hb_position_t *x, hb_position_t *y,
177 typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data,
178 hb_codepoint_t glyph,
179 char *name, unsigned int size,
181 typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data,
182 const char *name, int len, /* -1 means nul-terminated */
183 hb_codepoint_t *glyph,
190 * hb_font_funcs_set_font_h_extents_func:
191 * @ffuncs: font functions.
192 * @func: (closure user_data) (destroy destroy) (scope notified):
201 hb_font_funcs_set_font_h_extents_func (hb_font_funcs_t *ffuncs,
202 hb_font_get_font_h_extents_func_t func,
203 void *user_data, hb_destroy_func_t destroy);
206 * hb_font_funcs_set_font_v_extents_func:
207 * @ffuncs: font functions.
208 * @func: (closure user_data) (destroy destroy) (scope notified):
217 hb_font_funcs_set_font_v_extents_func (hb_font_funcs_t *ffuncs,
218 hb_font_get_font_v_extents_func_t func,
219 void *user_data, hb_destroy_func_t destroy);
222 * hb_font_funcs_set_nominal_glyph_func:
223 * @ffuncs: font functions.
224 * @func: (closure user_data) (destroy destroy) (scope notified):
233 hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t *ffuncs,
234 hb_font_get_nominal_glyph_func_t func,
235 void *user_data, hb_destroy_func_t destroy);
238 * hb_font_funcs_set_nominal_glyphs_func:
239 * @ffuncs: font functions.
240 * @func: (closure user_data) (destroy destroy) (scope notified):
249 hb_font_funcs_set_nominal_glyphs_func (hb_font_funcs_t *ffuncs,
250 hb_font_get_nominal_glyphs_func_t func,
251 void *user_data, hb_destroy_func_t destroy);
254 * hb_font_funcs_set_variation_glyph_func:
255 * @ffuncs: font functions.
256 * @func: (closure user_data) (destroy destroy) (scope notified):
265 hb_font_funcs_set_variation_glyph_func (hb_font_funcs_t *ffuncs,
266 hb_font_get_variation_glyph_func_t func,
267 void *user_data, hb_destroy_func_t destroy);
270 * hb_font_funcs_set_glyph_h_advance_func:
271 * @ffuncs: font functions.
272 * @func: (closure user_data) (destroy destroy) (scope notified):
281 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
282 hb_font_get_glyph_h_advance_func_t func,
283 void *user_data, hb_destroy_func_t destroy);
286 * hb_font_funcs_set_glyph_v_advance_func:
287 * @ffuncs: font functions.
288 * @func: (closure user_data) (destroy destroy) (scope notified):
297 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
298 hb_font_get_glyph_v_advance_func_t func,
299 void *user_data, hb_destroy_func_t destroy);
302 * hb_font_funcs_set_glyph_h_advances_func:
303 * @ffuncs: font functions.
304 * @func: (closure user_data) (destroy destroy) (scope notified):
313 hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t *ffuncs,
314 hb_font_get_glyph_h_advances_func_t func,
315 void *user_data, hb_destroy_func_t destroy);
318 * hb_font_funcs_set_glyph_v_advances_func:
319 * @ffuncs: font functions.
320 * @func: (closure user_data) (destroy destroy) (scope notified):
329 hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t *ffuncs,
330 hb_font_get_glyph_v_advances_func_t func,
331 void *user_data, hb_destroy_func_t destroy);
334 * hb_font_funcs_set_glyph_h_origin_func:
335 * @ffuncs: font functions.
336 * @func: (closure user_data) (destroy destroy) (scope notified):
345 hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
346 hb_font_get_glyph_h_origin_func_t func,
347 void *user_data, hb_destroy_func_t destroy);
350 * hb_font_funcs_set_glyph_v_origin_func:
351 * @ffuncs: font functions.
352 * @func: (closure user_data) (destroy destroy) (scope notified):
361 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
362 hb_font_get_glyph_v_origin_func_t func,
363 void *user_data, hb_destroy_func_t destroy);
366 * hb_font_funcs_set_glyph_h_kerning_func:
367 * @ffuncs: font functions.
368 * @func: (closure user_data) (destroy destroy) (scope notified):
377 hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
378 hb_font_get_glyph_h_kerning_func_t func,
379 void *user_data, hb_destroy_func_t destroy);
382 * hb_font_funcs_set_glyph_extents_func:
383 * @ffuncs: font functions.
384 * @func: (closure user_data) (destroy destroy) (scope notified):
393 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
394 hb_font_get_glyph_extents_func_t func,
395 void *user_data, hb_destroy_func_t destroy);
398 * hb_font_funcs_set_glyph_contour_point_func:
399 * @ffuncs: font functions.
400 * @func: (closure user_data) (destroy destroy) (scope notified):
409 hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
410 hb_font_get_glyph_contour_point_func_t func,
411 void *user_data, hb_destroy_func_t destroy);
414 * hb_font_funcs_set_glyph_name_func:
415 * @ffuncs: font functions.
416 * @func: (closure user_data) (destroy destroy) (scope notified):
425 hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs,
426 hb_font_get_glyph_name_func_t func,
427 void *user_data, hb_destroy_func_t destroy);
430 * hb_font_funcs_set_glyph_from_name_func:
431 * @ffuncs: font functions.
432 * @func: (closure user_data) (destroy destroy) (scope notified):
441 hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
442 hb_font_get_glyph_from_name_func_t func,
443 void *user_data, hb_destroy_func_t destroy);
448 hb_font_get_h_extents (hb_font_t *font,
449 hb_font_extents_t *extents);
451 hb_font_get_v_extents (hb_font_t *font,
452 hb_font_extents_t *extents);
455 hb_font_get_nominal_glyph (hb_font_t *font,
456 hb_codepoint_t unicode,
457 hb_codepoint_t *glyph);
459 hb_font_get_variation_glyph (hb_font_t *font,
460 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
461 hb_codepoint_t *glyph);
463 HB_EXTERN unsigned int
464 hb_font_get_nominal_glyphs (hb_font_t *font,
466 const hb_codepoint_t *first_unicode,
467 unsigned int unicode_stride,
468 hb_codepoint_t *first_glyph,
469 unsigned int glyph_stride);
471 HB_EXTERN hb_position_t
472 hb_font_get_glyph_h_advance (hb_font_t *font,
473 hb_codepoint_t glyph);
474 HB_EXTERN hb_position_t
475 hb_font_get_glyph_v_advance (hb_font_t *font,
476 hb_codepoint_t glyph);
479 hb_font_get_glyph_h_advances (hb_font_t* font,
481 const hb_codepoint_t *first_glyph,
482 unsigned glyph_stride,
483 hb_position_t *first_advance,
484 unsigned advance_stride);
486 hb_font_get_glyph_v_advances (hb_font_t* font,
488 const hb_codepoint_t *first_glyph,
489 unsigned glyph_stride,
490 hb_position_t *first_advance,
491 unsigned advance_stride);
494 hb_font_get_glyph_h_origin (hb_font_t *font,
495 hb_codepoint_t glyph,
496 hb_position_t *x, hb_position_t *y);
498 hb_font_get_glyph_v_origin (hb_font_t *font,
499 hb_codepoint_t glyph,
500 hb_position_t *x, hb_position_t *y);
502 HB_EXTERN hb_position_t
503 hb_font_get_glyph_h_kerning (hb_font_t *font,
504 hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
507 hb_font_get_glyph_extents (hb_font_t *font,
508 hb_codepoint_t glyph,
509 hb_glyph_extents_t *extents);
512 hb_font_get_glyph_contour_point (hb_font_t *font,
513 hb_codepoint_t glyph, unsigned int point_index,
514 hb_position_t *x, hb_position_t *y);
517 hb_font_get_glyph_name (hb_font_t *font,
518 hb_codepoint_t glyph,
519 char *name, unsigned int size);
521 hb_font_get_glyph_from_name (hb_font_t *font,
522 const char *name, int len, /* -1 means nul-terminated */
523 hb_codepoint_t *glyph);
526 /* high-level funcs, with fallback */
528 /* Calls either hb_font_get_nominal_glyph() if variation_selector is 0,
529 * otherwise calls hb_font_get_variation_glyph(). */
531 hb_font_get_glyph (hb_font_t *font,
532 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
533 hb_codepoint_t *glyph);
536 hb_font_get_extents_for_direction (hb_font_t *font,
537 hb_direction_t direction,
538 hb_font_extents_t *extents);
540 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
541 hb_codepoint_t glyph,
542 hb_direction_t direction,
543 hb_position_t *x, hb_position_t *y);
545 hb_font_get_glyph_advances_for_direction (hb_font_t* font,
546 hb_direction_t direction,
548 const hb_codepoint_t *first_glyph,
549 unsigned glyph_stride,
550 hb_position_t *first_advance,
551 unsigned advance_stride);
553 hb_font_get_glyph_origin_for_direction (hb_font_t *font,
554 hb_codepoint_t glyph,
555 hb_direction_t direction,
556 hb_position_t *x, hb_position_t *y);
558 hb_font_add_glyph_origin_for_direction (hb_font_t *font,
559 hb_codepoint_t glyph,
560 hb_direction_t direction,
561 hb_position_t *x, hb_position_t *y);
563 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
564 hb_codepoint_t glyph,
565 hb_direction_t direction,
566 hb_position_t *x, hb_position_t *y);
569 hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
570 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
571 hb_direction_t direction,
572 hb_position_t *x, hb_position_t *y);
575 hb_font_get_glyph_extents_for_origin (hb_font_t *font,
576 hb_codepoint_t glyph,
577 hb_direction_t direction,
578 hb_glyph_extents_t *extents);
581 hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
582 hb_codepoint_t glyph, unsigned int point_index,
583 hb_direction_t direction,
584 hb_position_t *x, hb_position_t *y);
586 /* Generates gidDDD if glyph has no name. */
588 hb_font_glyph_to_string (hb_font_t *font,
589 hb_codepoint_t glyph,
590 char *s, unsigned int size);
591 /* Parses gidDDD and uniUUUU strings automatically. */
593 hb_font_glyph_from_string (hb_font_t *font,
594 const char *s, int len, /* -1 means nul-terminated */
595 hb_codepoint_t *glyph);
602 /* Fonts are very light-weight objects */
604 HB_EXTERN hb_font_t *
605 hb_font_create (hb_face_t *face);
607 HB_EXTERN hb_font_t *
608 hb_font_create_sub_font (hb_font_t *parent);
610 HB_EXTERN hb_font_t *
611 hb_font_get_empty (void);
613 HB_EXTERN hb_font_t *
614 hb_font_reference (hb_font_t *font);
617 hb_font_destroy (hb_font_t *font);
620 hb_font_set_user_data (hb_font_t *font,
621 hb_user_data_key_t *key,
623 hb_destroy_func_t destroy,
628 hb_font_get_user_data (hb_font_t *font,
629 hb_user_data_key_t *key);
632 hb_font_make_immutable (hb_font_t *font);
635 hb_font_is_immutable (hb_font_t *font);
638 hb_font_set_parent (hb_font_t *font,
641 HB_EXTERN hb_font_t *
642 hb_font_get_parent (hb_font_t *font);
645 hb_font_set_face (hb_font_t *font,
648 HB_EXTERN hb_face_t *
649 hb_font_get_face (hb_font_t *font);
653 hb_font_set_funcs (hb_font_t *font,
654 hb_font_funcs_t *klass,
656 hb_destroy_func_t destroy);
658 /* Be *very* careful with this function! */
660 hb_font_set_funcs_data (hb_font_t *font,
662 hb_destroy_func_t destroy);
666 hb_font_set_scale (hb_font_t *font,
671 hb_font_get_scale (hb_font_t *font,
676 * A zero value means "no hinting in that direction"
679 hb_font_set_ppem (hb_font_t *font,
681 unsigned int y_ppem);
684 hb_font_get_ppem (hb_font_t *font,
685 unsigned int *x_ppem,
686 unsigned int *y_ppem);
689 * Point size per EM. Used for optical-sizing in CoreText.
690 * A value of zero means "not set".
693 hb_font_set_ptem (hb_font_t *font, float ptem);
696 hb_font_get_ptem (hb_font_t *font);
699 hb_font_set_variations (hb_font_t *font,
700 const hb_variation_t *variations,
701 unsigned int variations_length);
704 hb_font_set_var_coords_design (hb_font_t *font,
706 unsigned int coords_length);
708 #ifdef HB_EXPERIMENTAL_API
709 HB_EXTERN const float *
710 hb_font_get_var_coords_design (hb_font_t *font,
711 unsigned int *length);
715 hb_font_set_var_coords_normalized (hb_font_t *font,
716 const int *coords, /* 2.14 normalized */
717 unsigned int coords_length);
719 HB_EXTERN const int *
720 hb_font_get_var_coords_normalized (hb_font_t *font,
721 unsigned int *length);
724 hb_font_set_var_named_instance (hb_font_t *font,
725 unsigned instance_index);
727 #ifdef HB_EXPERIMENTAL_API
729 hb_font_draw_glyph (hb_font_t *font, hb_codepoint_t glyph,
730 const hb_draw_funcs_t *funcs, void *user_data);
735 #endif /* HB_FONT_H */