xref: /aosp_15_r20/external/harfbuzz_ng/src/hb-face.h (revision 2d1272b857b1f7575e6e246373e1cb218663db8a)
1 /*
2  * Copyright © 2009  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): Behdad Esfahbod
25  */
26 
27 #if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
28 #error "Include <hb.h> instead."
29 #endif
30 
31 #ifndef HB_FACE_H
32 #define HB_FACE_H
33 
34 #include "hb-common.h"
35 #include "hb-blob.h"
36 #include "hb-map.h"
37 #include "hb-set.h"
38 
39 HB_BEGIN_DECLS
40 
41 
42 HB_EXTERN unsigned int
43 hb_face_count (hb_blob_t *blob);
44 
45 
46 /*
47  * hb_face_t
48  */
49 
50 /**
51  * hb_face_t:
52  *
53  * Data type for holding font faces.
54  *
55  **/
56 typedef struct hb_face_t hb_face_t;
57 
58 HB_EXTERN hb_face_t *
59 hb_face_create (hb_blob_t    *blob,
60 		unsigned int  index);
61 
62 HB_EXTERN hb_face_t *
63 hb_face_create_or_fail (hb_blob_t    *blob,
64 			unsigned int  index);
65 
66 HB_EXTERN hb_face_t *
67 hb_face_create_from_file_or_fail (const char   *file_name,
68 				  unsigned int  index);
69 
70 /**
71  * hb_reference_table_func_t:
72  * @face: an #hb_face_t to reference table for
73  * @tag: the tag of the table to reference
74  * @user_data: User data pointer passed by the caller
75  *
76  * Callback function for hb_face_create_for_tables().
77  *
78  * Return value: (transfer full): A pointer to the @tag table within @face
79  *
80  * Since: 0.9.2
81  */
82 
83 typedef hb_blob_t * (*hb_reference_table_func_t)  (hb_face_t *face, hb_tag_t tag, void *user_data);
84 
85 /* calls destroy() when not needing user_data anymore */
86 HB_EXTERN hb_face_t *
87 hb_face_create_for_tables (hb_reference_table_func_t  reference_table_func,
88 			   void                      *user_data,
89 			   hb_destroy_func_t          destroy);
90 
91 HB_EXTERN hb_face_t *
92 hb_face_get_empty (void);
93 
94 HB_EXTERN hb_face_t *
95 hb_face_reference (hb_face_t *face);
96 
97 HB_EXTERN void
98 hb_face_destroy (hb_face_t *face);
99 
100 HB_EXTERN hb_bool_t
101 hb_face_set_user_data (hb_face_t          *face,
102 		       hb_user_data_key_t *key,
103 		       void *              data,
104 		       hb_destroy_func_t   destroy,
105 		       hb_bool_t           replace);
106 
107 HB_EXTERN void *
108 hb_face_get_user_data (const hb_face_t    *face,
109 		       hb_user_data_key_t *key);
110 
111 HB_EXTERN void
112 hb_face_make_immutable (hb_face_t *face);
113 
114 HB_EXTERN hb_bool_t
115 hb_face_is_immutable (const hb_face_t *face);
116 
117 
118 HB_EXTERN hb_blob_t *
119 hb_face_reference_table (const hb_face_t *face,
120 			 hb_tag_t tag);
121 
122 HB_EXTERN hb_blob_t *
123 hb_face_reference_blob (hb_face_t *face);
124 
125 HB_EXTERN void
126 hb_face_set_index (hb_face_t    *face,
127 		   unsigned int  index);
128 
129 HB_EXTERN unsigned int
130 hb_face_get_index (const hb_face_t *face);
131 
132 HB_EXTERN void
133 hb_face_set_upem (hb_face_t    *face,
134 		  unsigned int  upem);
135 
136 HB_EXTERN unsigned int
137 hb_face_get_upem (const hb_face_t *face);
138 
139 HB_EXTERN void
140 hb_face_set_glyph_count (hb_face_t    *face,
141 			 unsigned int  glyph_count);
142 
143 HB_EXTERN unsigned int
144 hb_face_get_glyph_count (const hb_face_t *face);
145 
146 
147 /**
148  * hb_get_table_tags_func_t:
149  * @face: A face object
150  * @start_offset: The index of first table tag to retrieve
151  * @table_count: (inout): Input = the maximum number of table tags to return;
152  *                Output = the actual number of table tags returned (may be zero)
153  * @table_tags: (out) (array length=table_count): The array of table tags found
154  * @user_data: User data pointer passed by the caller
155  *
156  * Callback function for hb_face_get_table_tags().
157  *
158  * Return value: Total number of tables, or zero if it is not possible to list
159  *
160  * Since: 10.0.0
161  */
162 typedef unsigned int (*hb_get_table_tags_func_t) (const hb_face_t *face,
163 						  unsigned int  start_offset,
164 						  unsigned int *table_count, /* IN/OUT */
165 						  hb_tag_t     *table_tags /* OUT */,
166 						  void         *user_data);
167 
168 HB_EXTERN void
169 hb_face_set_get_table_tags_func (hb_face_t *face,
170 				 hb_get_table_tags_func_t func,
171 				 void                    *user_data,
172 				 hb_destroy_func_t        destroy);
173 
174 HB_EXTERN unsigned int
175 hb_face_get_table_tags (const hb_face_t *face,
176 			unsigned int  start_offset,
177 			unsigned int *table_count, /* IN/OUT */
178 			hb_tag_t     *table_tags /* OUT */);
179 
180 
181 /*
182  * Character set.
183  */
184 
185 HB_EXTERN void
186 hb_face_collect_unicodes (hb_face_t *face,
187 			  hb_set_t  *out);
188 
189 HB_EXTERN void
190 hb_face_collect_nominal_glyph_mapping (hb_face_t *face,
191 				       hb_map_t  *mapping,
192 				       hb_set_t  *unicodes);
193 
194 HB_EXTERN void
195 hb_face_collect_variation_selectors (hb_face_t *face,
196 				     hb_set_t  *out);
197 
198 HB_EXTERN void
199 hb_face_collect_variation_unicodes (hb_face_t *face,
200 				    hb_codepoint_t variation_selector,
201 				    hb_set_t  *out);
202 
203 
204 /*
205  * Builder face.
206  */
207 
208 HB_EXTERN hb_face_t *
209 hb_face_builder_create (void);
210 
211 HB_EXTERN hb_bool_t
212 hb_face_builder_add_table (hb_face_t *face,
213 			   hb_tag_t   tag,
214 			   hb_blob_t *blob);
215 
216 HB_EXTERN void
217 hb_face_builder_sort_tables (hb_face_t *face,
218                              const hb_tag_t  *tags);
219 
220 
221 HB_END_DECLS
222 
223 #endif /* HB_FACE_H */
224