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"
40 typedef struct hb_font_t hb_font_t
;
47 typedef struct hb_font_funcs_t hb_font_funcs_t
;
50 hb_font_funcs_create (void);
53 hb_font_funcs_get_empty (void);
56 hb_font_funcs_reference (hb_font_funcs_t
*ffuncs
);
59 hb_font_funcs_destroy (hb_font_funcs_t
*ffuncs
);
62 hb_font_funcs_set_user_data (hb_font_funcs_t
*ffuncs
,
63 hb_user_data_key_t
*key
,
65 hb_destroy_func_t destroy
,
70 hb_font_funcs_get_user_data (hb_font_funcs_t
*ffuncs
,
71 hb_user_data_key_t
*key
);
75 hb_font_funcs_make_immutable (hb_font_funcs_t
*ffuncs
);
78 hb_font_funcs_is_immutable (hb_font_funcs_t
*ffuncs
);
83 typedef struct hb_glyph_extents_t
85 hb_position_t x_bearing
;
86 hb_position_t y_bearing
;
94 typedef hb_bool_t (*hb_font_get_glyph_func_t
) (hb_font_t
*font
, void *font_data
,
95 hb_codepoint_t unicode
, hb_codepoint_t variation_selector
,
96 hb_codepoint_t
*glyph
,
100 typedef hb_position_t (*hb_font_get_glyph_advance_func_t
) (hb_font_t
*font
, void *font_data
,
101 hb_codepoint_t glyph
,
103 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t
;
104 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t
;
106 typedef hb_bool_t (*hb_font_get_glyph_origin_func_t
) (hb_font_t
*font
, void *font_data
,
107 hb_codepoint_t glyph
,
108 hb_position_t
*x
, hb_position_t
*y
,
110 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t
;
111 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t
;
113 typedef hb_position_t (*hb_font_get_glyph_kerning_func_t
) (hb_font_t
*font
, void *font_data
,
114 hb_codepoint_t first_glyph
, hb_codepoint_t second_glyph
,
116 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t
;
117 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t
;
120 typedef hb_bool_t (*hb_font_get_glyph_extents_func_t
) (hb_font_t
*font
, void *font_data
,
121 hb_codepoint_t glyph
,
122 hb_glyph_extents_t
*extents
,
124 typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t
) (hb_font_t
*font
, void *font_data
,
125 hb_codepoint_t glyph
, unsigned int point_index
,
126 hb_position_t
*x
, hb_position_t
*y
,
130 typedef hb_bool_t (*hb_font_get_glyph_name_func_t
) (hb_font_t
*font
, void *font_data
,
131 hb_codepoint_t glyph
,
132 char *name
, unsigned int size
,
134 typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t
) (hb_font_t
*font
, void *font_data
,
135 const char *name
, int len
, /* -1 means nul-terminated */
136 hb_codepoint_t
*glyph
,
143 * hb_font_funcs_set_glyph_func:
144 * @ffuncs: font functions.
145 * @func: (closure user_data) (destroy destroy) (scope notified):
154 hb_font_funcs_set_glyph_func (hb_font_funcs_t
*ffuncs
,
155 hb_font_get_glyph_func_t func
,
156 void *user_data
, hb_destroy_func_t destroy
);
159 * hb_font_funcs_set_glyph_h_advance_func:
160 * @ffuncs: font functions.
161 * @func: (closure user_data) (destroy destroy) (scope notified):
170 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t
*ffuncs
,
171 hb_font_get_glyph_h_advance_func_t func
,
172 void *user_data
, hb_destroy_func_t destroy
);
175 * hb_font_funcs_set_glyph_v_advance_func:
176 * @ffuncs: font functions.
177 * @func: (closure user_data) (destroy destroy) (scope notified):
186 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t
*ffuncs
,
187 hb_font_get_glyph_v_advance_func_t func
,
188 void *user_data
, hb_destroy_func_t destroy
);
191 * hb_font_funcs_set_glyph_h_origin_func:
192 * @ffuncs: font functions.
193 * @func: (closure user_data) (destroy destroy) (scope notified):
202 hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t
*ffuncs
,
203 hb_font_get_glyph_h_origin_func_t func
,
204 void *user_data
, hb_destroy_func_t destroy
);
207 * hb_font_funcs_set_glyph_v_origin_func:
208 * @ffuncs: font functions.
209 * @func: (closure user_data) (destroy destroy) (scope notified):
218 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t
*ffuncs
,
219 hb_font_get_glyph_v_origin_func_t func
,
220 void *user_data
, hb_destroy_func_t destroy
);
223 * hb_font_funcs_set_glyph_h_kerning_func:
224 * @ffuncs: font functions.
225 * @func: (closure user_data) (destroy destroy) (scope notified):
234 hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t
*ffuncs
,
235 hb_font_get_glyph_h_kerning_func_t func
,
236 void *user_data
, hb_destroy_func_t destroy
);
239 * hb_font_funcs_set_glyph_v_kerning_func:
240 * @ffuncs: font functions.
241 * @func: (closure user_data) (destroy destroy) (scope notified):
250 hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t
*ffuncs
,
251 hb_font_get_glyph_v_kerning_func_t func
,
252 void *user_data
, hb_destroy_func_t destroy
);
255 * hb_font_funcs_set_glyph_extents_func:
256 * @ffuncs: font functions.
257 * @func: (closure user_data) (destroy destroy) (scope notified):
266 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t
*ffuncs
,
267 hb_font_get_glyph_extents_func_t func
,
268 void *user_data
, hb_destroy_func_t destroy
);
271 * hb_font_funcs_set_glyph_contour_point_func:
272 * @ffuncs: font functions.
273 * @func: (closure user_data) (destroy destroy) (scope notified):
282 hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t
*ffuncs
,
283 hb_font_get_glyph_contour_point_func_t func
,
284 void *user_data
, hb_destroy_func_t destroy
);
287 * hb_font_funcs_set_glyph_name_func:
288 * @ffuncs: font functions.
289 * @func: (closure user_data) (destroy destroy) (scope notified):
298 hb_font_funcs_set_glyph_name_func (hb_font_funcs_t
*ffuncs
,
299 hb_font_get_glyph_name_func_t func
,
300 void *user_data
, hb_destroy_func_t destroy
);
303 * hb_font_funcs_set_glyph_from_name_func:
304 * @ffuncs: font functions.
305 * @func: (closure user_data) (destroy destroy) (scope notified):
314 hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t
*ffuncs
,
315 hb_font_get_glyph_from_name_func_t func
,
316 void *user_data
, hb_destroy_func_t destroy
);
322 hb_font_get_glyph (hb_font_t
*font
,
323 hb_codepoint_t unicode
, hb_codepoint_t variation_selector
,
324 hb_codepoint_t
*glyph
);
327 hb_font_get_glyph_h_advance (hb_font_t
*font
,
328 hb_codepoint_t glyph
);
330 hb_font_get_glyph_v_advance (hb_font_t
*font
,
331 hb_codepoint_t glyph
);
334 hb_font_get_glyph_h_origin (hb_font_t
*font
,
335 hb_codepoint_t glyph
,
336 hb_position_t
*x
, hb_position_t
*y
);
338 hb_font_get_glyph_v_origin (hb_font_t
*font
,
339 hb_codepoint_t glyph
,
340 hb_position_t
*x
, hb_position_t
*y
);
343 hb_font_get_glyph_h_kerning (hb_font_t
*font
,
344 hb_codepoint_t left_glyph
, hb_codepoint_t right_glyph
);
346 hb_font_get_glyph_v_kerning (hb_font_t
*font
,
347 hb_codepoint_t top_glyph
, hb_codepoint_t bottom_glyph
);
350 hb_font_get_glyph_extents (hb_font_t
*font
,
351 hb_codepoint_t glyph
,
352 hb_glyph_extents_t
*extents
);
355 hb_font_get_glyph_contour_point (hb_font_t
*font
,
356 hb_codepoint_t glyph
, unsigned int point_index
,
357 hb_position_t
*x
, hb_position_t
*y
);
360 hb_font_get_glyph_name (hb_font_t
*font
,
361 hb_codepoint_t glyph
,
362 char *name
, unsigned int size
);
364 hb_font_get_glyph_from_name (hb_font_t
*font
,
365 const char *name
, int len
, /* -1 means nul-terminated */
366 hb_codepoint_t
*glyph
);
369 /* high-level funcs, with fallback */
372 hb_font_get_glyph_advance_for_direction (hb_font_t
*font
,
373 hb_codepoint_t glyph
,
374 hb_direction_t direction
,
375 hb_position_t
*x
, hb_position_t
*y
);
377 hb_font_get_glyph_origin_for_direction (hb_font_t
*font
,
378 hb_codepoint_t glyph
,
379 hb_direction_t direction
,
380 hb_position_t
*x
, hb_position_t
*y
);
382 hb_font_add_glyph_origin_for_direction (hb_font_t
*font
,
383 hb_codepoint_t glyph
,
384 hb_direction_t direction
,
385 hb_position_t
*x
, hb_position_t
*y
);
387 hb_font_subtract_glyph_origin_for_direction (hb_font_t
*font
,
388 hb_codepoint_t glyph
,
389 hb_direction_t direction
,
390 hb_position_t
*x
, hb_position_t
*y
);
393 hb_font_get_glyph_kerning_for_direction (hb_font_t
*font
,
394 hb_codepoint_t first_glyph
, hb_codepoint_t second_glyph
,
395 hb_direction_t direction
,
396 hb_position_t
*x
, hb_position_t
*y
);
399 hb_font_get_glyph_extents_for_origin (hb_font_t
*font
,
400 hb_codepoint_t glyph
,
401 hb_direction_t direction
,
402 hb_glyph_extents_t
*extents
);
405 hb_font_get_glyph_contour_point_for_origin (hb_font_t
*font
,
406 hb_codepoint_t glyph
, unsigned int point_index
,
407 hb_direction_t direction
,
408 hb_position_t
*x
, hb_position_t
*y
);
410 /* Generates gidDDD if glyph has no name. */
412 hb_font_glyph_to_string (hb_font_t
*font
,
413 hb_codepoint_t glyph
,
414 char *s
, unsigned int size
);
415 /* Parses gidDDD and uniUUUU strings automatically. */
417 hb_font_glyph_from_string (hb_font_t
*font
,
418 const char *s
, int len
, /* -1 means nul-terminated */
419 hb_codepoint_t
*glyph
);
426 /* Fonts are very light-weight objects */
429 hb_font_create (hb_face_t
*face
);
432 hb_font_create_sub_font (hb_font_t
*parent
);
435 hb_font_get_empty (void);
438 hb_font_reference (hb_font_t
*font
);
441 hb_font_destroy (hb_font_t
*font
);
444 hb_font_set_user_data (hb_font_t
*font
,
445 hb_user_data_key_t
*key
,
447 hb_destroy_func_t destroy
,
452 hb_font_get_user_data (hb_font_t
*font
,
453 hb_user_data_key_t
*key
);
456 hb_font_make_immutable (hb_font_t
*font
);
459 hb_font_is_immutable (hb_font_t
*font
);
462 hb_font_get_parent (hb_font_t
*font
);
465 hb_font_get_face (hb_font_t
*font
);
469 hb_font_set_funcs (hb_font_t
*font
,
470 hb_font_funcs_t
*klass
,
472 hb_destroy_func_t destroy
);
474 /* Be *very* careful with this function! */
476 hb_font_set_funcs_data (hb_font_t
*font
,
478 hb_destroy_func_t destroy
);
482 hb_font_set_scale (hb_font_t
*font
,
487 hb_font_get_scale (hb_font_t
*font
,
492 * A zero value means "no hinting in that direction"
495 hb_font_set_ppem (hb_font_t
*font
,
497 unsigned int y_ppem
);
500 hb_font_get_ppem (hb_font_t
*font
,
501 unsigned int *x_ppem
,
502 unsigned int *y_ppem
);
507 #endif /* HB_FONT_H */