hb-face.h (6453B)
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_or_fail_using (hb_blob_t *blob, 68 unsigned int index, 69 const char *loader_name); 70 71 HB_EXTERN hb_face_t * 72 hb_face_create_from_file_or_fail (const char *file_name, 73 unsigned int index); 74 75 HB_EXTERN hb_face_t * 76 hb_face_create_from_file_or_fail_using (const char *file_name, 77 unsigned int index, 78 const char *loader_name); 79 80 HB_EXTERN const char ** 81 hb_face_list_loaders (void); 82 83 84 /** 85 * hb_reference_table_func_t: 86 * @face: an #hb_face_t to reference table for 87 * @tag: the tag of the table to reference 88 * @user_data: User data pointer passed by the caller 89 * 90 * Callback function for hb_face_create_for_tables(). The @tag is the tag of the 91 * table to reference, and the special tag #HB_TAG_NONE is used to reference the 92 * blob of the face itself. If referencing the face blob is not possible, it is 93 * recommended to set hb_get_table_tags_func_t on the @face to allow 94 * hb_face_reference_blob() to create a face blob out of individual table blobs. 95 * 96 * Return value: (transfer full): A pointer to the @tag table within @face or 97 * `NULL` if the table is not found or cannot be referenced. 98 * 99 * Since: 0.9.2 100 */ 101 102 typedef hb_blob_t * (*hb_reference_table_func_t) (hb_face_t *face, hb_tag_t tag, void *user_data); 103 104 /* calls destroy() when not needing user_data anymore */ 105 HB_EXTERN hb_face_t * 106 hb_face_create_for_tables (hb_reference_table_func_t reference_table_func, 107 void *user_data, 108 hb_destroy_func_t destroy); 109 110 HB_EXTERN hb_face_t * 111 hb_face_get_empty (void); 112 113 HB_EXTERN hb_face_t * 114 hb_face_reference (hb_face_t *face); 115 116 HB_EXTERN void 117 hb_face_destroy (hb_face_t *face); 118 119 HB_EXTERN hb_bool_t 120 hb_face_set_user_data (hb_face_t *face, 121 hb_user_data_key_t *key, 122 void * data, 123 hb_destroy_func_t destroy, 124 hb_bool_t replace); 125 126 HB_EXTERN void * 127 hb_face_get_user_data (const hb_face_t *face, 128 hb_user_data_key_t *key); 129 130 HB_EXTERN void 131 hb_face_make_immutable (hb_face_t *face); 132 133 HB_EXTERN hb_bool_t 134 hb_face_is_immutable (hb_face_t *face); 135 136 137 HB_EXTERN hb_blob_t * 138 hb_face_reference_table (const hb_face_t *face, 139 hb_tag_t tag); 140 141 HB_EXTERN hb_blob_t * 142 hb_face_reference_blob (hb_face_t *face); 143 144 HB_EXTERN void 145 hb_face_set_index (hb_face_t *face, 146 unsigned int index); 147 148 HB_EXTERN unsigned int 149 hb_face_get_index (const hb_face_t *face); 150 151 HB_EXTERN void 152 hb_face_set_upem (hb_face_t *face, 153 unsigned int upem); 154 155 HB_EXTERN unsigned int 156 hb_face_get_upem (const hb_face_t *face); 157 158 HB_EXTERN void 159 hb_face_set_glyph_count (hb_face_t *face, 160 unsigned int glyph_count); 161 162 HB_EXTERN unsigned int 163 hb_face_get_glyph_count (const hb_face_t *face); 164 165 166 /** 167 * hb_get_table_tags_func_t: 168 * @face: A face object 169 * @start_offset: The index of first table tag to retrieve 170 * @table_count: (inout): Input = the maximum number of table tags to return; 171 * Output = the actual number of table tags returned (may be zero) 172 * @table_tags: (out) (array length=table_count): The array of table tags found 173 * @user_data: User data pointer passed by the caller 174 * 175 * Callback function for hb_face_get_table_tags(). 176 * 177 * Return value: Total number of tables, or zero if it is not possible to list 178 * 179 * Since: 10.0.0 180 */ 181 typedef unsigned int (*hb_get_table_tags_func_t) (const hb_face_t *face, 182 unsigned int start_offset, 183 unsigned int *table_count, /* IN/OUT */ 184 hb_tag_t *table_tags /* OUT */, 185 void *user_data); 186 187 HB_EXTERN void 188 hb_face_set_get_table_tags_func (hb_face_t *face, 189 hb_get_table_tags_func_t func, 190 void *user_data, 191 hb_destroy_func_t destroy); 192 193 HB_EXTERN unsigned int 194 hb_face_get_table_tags (const hb_face_t *face, 195 unsigned int start_offset, 196 unsigned int *table_count, /* IN/OUT */ 197 hb_tag_t *table_tags /* OUT */); 198 199 200 /* 201 * Character set. 202 */ 203 204 HB_EXTERN void 205 hb_face_collect_unicodes (hb_face_t *face, 206 hb_set_t *out); 207 208 HB_EXTERN void 209 hb_face_collect_nominal_glyph_mapping (hb_face_t *face, 210 hb_map_t *mapping, 211 hb_set_t *unicodes); 212 213 HB_EXTERN void 214 hb_face_collect_variation_selectors (hb_face_t *face, 215 hb_set_t *out); 216 217 HB_EXTERN void 218 hb_face_collect_variation_unicodes (hb_face_t *face, 219 hb_codepoint_t variation_selector, 220 hb_set_t *out); 221 222 223 /* 224 * Builder face. 225 */ 226 227 HB_EXTERN hb_face_t * 228 hb_face_builder_create (void); 229 230 HB_EXTERN hb_bool_t 231 hb_face_builder_add_table (hb_face_t *face, 232 hb_tag_t tag, 233 hb_blob_t *blob); 234 235 HB_EXTERN void 236 hb_face_builder_sort_tables (hb_face_t *face, 237 const hb_tag_t *tags); 238 239 240 HB_END_DECLS 241 242 #endif /* HB_FACE_H */