xref: /aosp_15_r20/external/harfbuzz_ng/src/hb-cairo.h (revision 2d1272b857b1f7575e6e246373e1cb218663db8a)
1 /*
2  * Copyright © 2022 Red Hat, Inc.
3  *
4  *  This is part of HarfBuzz, a text shaping library.
5  *
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.
11  *
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.
17  *
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.
23  *
24  * Red Hat Author(s): Matthias Clasen
25  */
26 
27 #ifndef HB_CAIRO_H
28 #define HB_CAIRO_H
29 
30 #include "hb.h"
31 
32 #include <cairo.h>
33 
34 HB_BEGIN_DECLS
35 
36 HB_EXTERN cairo_font_face_t *
37 hb_cairo_font_face_create_for_font (hb_font_t *font);
38 
39 HB_EXTERN hb_font_t *
40 hb_cairo_font_face_get_font (cairo_font_face_t *font_face);
41 
42 HB_EXTERN cairo_font_face_t *
43 hb_cairo_font_face_create_for_face (hb_face_t *face);
44 
45 HB_EXTERN hb_face_t *
46 hb_cairo_font_face_get_face (cairo_font_face_t *font_face);
47 
48 /**
49  * hb_cairo_font_init_func_t:
50  * @font: The #hb_font_t being created
51  * @scaled_font: The respective #cairo_scaled_font_t
52  * @user_data: User data accompanying this method
53  *
54  * The type of a virtual method to be called when a cairo
55  * face created using hb_cairo_font_face_create_for_face()
56  * creates an #hb_font_t for a #cairo_scaled_font_t.
57  *
58  * Return value: the #hb_font_t value to use; in most cases same as @font
59  *
60  * Since: 7.0.0
61  */
62 typedef hb_font_t * (*hb_cairo_font_init_func_t) (hb_font_t *font,
63 						  cairo_scaled_font_t *scaled_font,
64 						  void *user_data);
65 
66 HB_EXTERN void
67 hb_cairo_font_face_set_font_init_func (cairo_font_face_t *font_face,
68 				       hb_cairo_font_init_func_t func,
69 				       void *user_data,
70 				       hb_destroy_func_t destroy);
71 
72 HB_EXTERN hb_font_t *
73 hb_cairo_scaled_font_get_font (cairo_scaled_font_t *scaled_font);
74 
75 HB_EXTERN void
76 hb_cairo_font_face_set_scale_factor (cairo_font_face_t *font_face,
77 				     unsigned int scale_factor);
78 
79 HB_EXTERN unsigned int
80 hb_cairo_font_face_get_scale_factor (cairo_font_face_t *font_face);
81 
82 HB_EXTERN void
83 hb_cairo_glyphs_from_buffer (hb_buffer_t *buffer,
84 			     hb_bool_t utf8_clusters,
85 			     double x_scale_factor,
86 			     double y_scale_factor,
87 			     double x,
88 			     double y,
89 			     const char *utf8,
90 			     int utf8_len,
91 			     cairo_glyph_t **glyphs,
92 			     unsigned int *num_glyphs,
93 			     cairo_text_cluster_t **clusters,
94 			     unsigned int *num_clusters,
95 			     cairo_text_cluster_flags_t *cluster_flags);
96 
97 HB_END_DECLS
98 
99 #endif /* HB_CAIRO_H */
100