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
30 #include "hb-common.h"
36 typedef struct _hb_face_t hb_face_t;
37 typedef struct _hb_font_t hb_font_t;
44 hb_face_create (hb_blob_t *blob,
47 typedef hb_blob_t * (*hb_get_table_func_t) (hb_face_t *face, hb_tag_t tag, void *user_data);
49 /* calls destroy() when not needing user_data anymore */
51 hb_face_create_for_tables (hb_get_table_func_t get_table,
53 hb_destroy_func_t destroy);
56 hb_face_get_empty (void);
59 hb_face_reference (hb_face_t *face);
62 hb_face_destroy (hb_face_t *face);
65 hb_face_set_user_data (hb_face_t *face,
66 hb_user_data_key_t *key,
68 hb_destroy_func_t destroy);
72 hb_face_get_user_data (hb_face_t *face,
73 hb_user_data_key_t *key);
76 hb_face_make_immutable (hb_face_t *face);
79 hb_face_is_immutable (hb_face_t *face);
83 hb_face_reference_table (hb_face_t *face,
87 hb_face_get_upem (hb_face_t *face);
94 typedef struct _hb_font_funcs_t hb_font_funcs_t;
97 hb_font_funcs_create (void);
100 hb_font_funcs_get_empty (void);
103 hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
106 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
109 hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs,
110 hb_user_data_key_t *key,
112 hb_destroy_func_t destroy);
116 hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs,
117 hb_user_data_key_t *key);
121 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
124 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
128 typedef struct _hb_glyph_extents_t
130 hb_position_t x_bearing;
131 hb_position_t y_bearing;
133 hb_position_t height;
134 } hb_glyph_extents_t;
139 typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data,
140 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
141 hb_codepoint_t *glyph,
145 typedef hb_bool_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
146 hb_codepoint_t glyph,
147 hb_position_t *x_advance, hb_position_t *y_advance,
149 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
150 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
152 typedef hb_bool_t (*hb_font_get_glyph_v_origin_func_t) (hb_font_t *font, void *font_data,
153 hb_codepoint_t glyph,
154 hb_position_t *x_origin, hb_position_t *y_origin,
157 typedef hb_bool_t (*hb_font_get_kerning_func_t) (hb_font_t *font, void *font_data,
158 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
159 hb_position_t *x_kern, hb_position_t *y_kern,
161 typedef hb_font_get_kerning_func_t hb_font_get_h_kerning_func_t;
162 typedef hb_font_get_kerning_func_t hb_font_get_v_kerning_func_t;
165 typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
166 hb_codepoint_t glyph,
168 hb_glyph_extents_t *extents,
170 typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, void *font_data,
171 hb_codepoint_t glyph, unsigned int point_index,
173 hb_position_t *x, hb_position_t *y,
180 hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
181 hb_font_get_glyph_func_t glyph_func,
182 void *user_data, hb_destroy_func_t destroy);
185 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
186 hb_font_get_glyph_h_advance_func_t glyph_advance_func,
187 void *user_data, hb_destroy_func_t destroy);
189 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
190 hb_font_get_glyph_v_advance_func_t glyph_advance_func,
191 void *user_data, hb_destroy_func_t destroy);
194 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
195 hb_font_get_glyph_v_origin_func_t glyph_advance_func,
196 void *user_data, hb_destroy_func_t destroy);
199 hb_font_funcs_set_h_kerning_func (hb_font_funcs_t *ffuncs,
200 hb_font_get_h_kerning_func_t kerning_func,
201 void *user_data, hb_destroy_func_t destroy);
203 hb_font_funcs_set_v_kerning_func (hb_font_funcs_t *ffuncs,
204 hb_font_get_v_kerning_func_t kerning_func,
205 void *user_data, hb_destroy_func_t destroy);
208 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
209 hb_font_get_glyph_extents_func_t glyph_extents_func,
210 void *user_data, hb_destroy_func_t destroy);
212 hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
213 hb_font_get_contour_point_func_t contour_point_func,
214 void *user_data, hb_destroy_func_t destroy);
220 hb_font_get_glyph (hb_font_t *font,
221 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
222 hb_codepoint_t *glyph);
225 hb_font_get_glyph_h_advance (hb_font_t *font,
226 hb_codepoint_t glyph,
227 hb_position_t *x_advance, hb_position_t *y_advance);
229 hb_font_get_glyph_v_advance (hb_font_t *font,
230 hb_codepoint_t glyph,
231 hb_position_t *x_advance, hb_position_t *y_advance);
234 hb_font_get_glyph_v_origin (hb_font_t *font,
235 hb_codepoint_t glyph,
236 hb_position_t *x_kern, hb_position_t *y_kern);
239 hb_font_get_h_kerning (hb_font_t *font,
240 hb_codepoint_t left_glyph, hb_codepoint_t right_glyph,
241 hb_position_t *x_kern, hb_position_t *y_kern);
243 hb_font_get_v_kerning (hb_font_t *font,
244 hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph,
245 hb_position_t *x_kern, hb_position_t *y_kern);
248 hb_font_get_glyph_extents (hb_font_t *font,
249 hb_codepoint_t glyph,
251 hb_glyph_extents_t *extents);
254 hb_font_get_contour_point (hb_font_t *font,
255 hb_codepoint_t glyph, unsigned int point_index,
257 hb_position_t *x, hb_position_t *y);
260 /* high-level funcs, with fallback */
263 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
264 hb_codepoint_t glyph,
265 hb_direction_t direction,
266 hb_position_t *x_advance, hb_position_t *y_advance);
269 hb_font_get_kerning_for_direction (hb_font_t *font,
270 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
271 hb_direction_t direction,
272 hb_position_t *x_kern, hb_position_t *y_kern);
275 hb_font_get_glyph_extents_for_direction (hb_font_t *font,
276 hb_codepoint_t glyph,
277 hb_direction_t direction,
278 hb_glyph_extents_t *extents);
281 hb_font_get_contour_point_for_direction (hb_font_t *font,
282 hb_codepoint_t glyph, unsigned int point_index,
283 hb_direction_t direction,
284 hb_position_t *x, hb_position_t *y);
291 /* Fonts are very light-weight objects */
294 hb_font_create (hb_face_t *face);
297 hb_font_create_sub_font (hb_font_t *parent);
300 hb_font_get_empty (void);
303 hb_font_reference (hb_font_t *font);
306 hb_font_destroy (hb_font_t *font);
309 hb_font_set_user_data (hb_font_t *font,
310 hb_user_data_key_t *key,
312 hb_destroy_func_t destroy);
316 hb_font_get_user_data (hb_font_t *font,
317 hb_user_data_key_t *key);
320 hb_font_make_immutable (hb_font_t *font);
323 hb_font_is_immutable (hb_font_t *font);
326 hb_font_get_parent (hb_font_t *font);
329 hb_font_get_face (hb_font_t *font);
333 hb_font_set_funcs (hb_font_t *font,
334 hb_font_funcs_t *klass,
336 hb_destroy_func_t destroy);
340 * We should add support for full matrices.
343 hb_font_set_scale (hb_font_t *font,
348 hb_font_get_scale (hb_font_t *font,
353 * A zero value means "no hinting in that direction"
356 hb_font_set_ppem (hb_font_t *font,
358 unsigned int y_ppem);
361 hb_font_get_ppem (hb_font_t *font,
362 unsigned int *x_ppem,
363 unsigned int *y_ppem);
368 #endif /* HB_FONT_H */