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
;
49 HB_EXTERN hb_font_funcs_t
*
50 hb_font_funcs_create (void);
52 HB_EXTERN hb_font_funcs_t
*
53 hb_font_funcs_get_empty (void);
55 HB_EXTERN hb_font_funcs_t
*
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 /* Note that height is negative in coordinate systems that grow up. */
84 typedef struct hb_glyph_extents_t
86 hb_position_t x_bearing
; /* left side of glyph from origin. */
87 hb_position_t y_bearing
; /* top side of glyph from origin. */
88 hb_position_t width
; /* distance from left to right side. */
89 hb_position_t height
; /* distance from top to bottom side. */
95 typedef hb_bool_t (*hb_font_get_glyph_func_t
) (hb_font_t
*font
, void *font_data
,
96 hb_codepoint_t unicode
, hb_codepoint_t variation_selector
,
97 hb_codepoint_t
*glyph
,
101 typedef hb_position_t (*hb_font_get_glyph_advance_func_t
) (hb_font_t
*font
, void *font_data
,
102 hb_codepoint_t glyph
,
104 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t
;
105 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t
;
107 typedef hb_bool_t (*hb_font_get_glyph_origin_func_t
) (hb_font_t
*font
, void *font_data
,
108 hb_codepoint_t glyph
,
109 hb_position_t
*x
, hb_position_t
*y
,
111 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t
;
112 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t
;
114 typedef hb_position_t (*hb_font_get_glyph_kerning_func_t
) (hb_font_t
*font
, void *font_data
,
115 hb_codepoint_t first_glyph
, hb_codepoint_t second_glyph
,
117 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t
;
118 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t
;
121 typedef hb_bool_t (*hb_font_get_glyph_extents_func_t
) (hb_font_t
*font
, void *font_data
,
122 hb_codepoint_t glyph
,
123 hb_glyph_extents_t
*extents
,
125 typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t
) (hb_font_t
*font
, void *font_data
,
126 hb_codepoint_t glyph
, unsigned int point_index
,
127 hb_position_t
*x
, hb_position_t
*y
,
131 typedef hb_bool_t (*hb_font_get_glyph_name_func_t
) (hb_font_t
*font
, void *font_data
,
132 hb_codepoint_t glyph
,
133 char *name
, unsigned int size
,
135 typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t
) (hb_font_t
*font
, void *font_data
,
136 const char *name
, int len
, /* -1 means nul-terminated */
137 hb_codepoint_t
*glyph
,
144 * hb_font_funcs_set_glyph_func:
145 * @ffuncs: font functions.
146 * @func: (closure user_data) (destroy destroy) (scope notified):
155 hb_font_funcs_set_glyph_func (hb_font_funcs_t
*ffuncs
,
156 hb_font_get_glyph_func_t func
,
157 void *user_data
, hb_destroy_func_t destroy
);
160 * hb_font_funcs_set_glyph_h_advance_func:
161 * @ffuncs: font functions.
162 * @func: (closure user_data) (destroy destroy) (scope notified):
171 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t
*ffuncs
,
172 hb_font_get_glyph_h_advance_func_t func
,
173 void *user_data
, hb_destroy_func_t destroy
);
176 * hb_font_funcs_set_glyph_v_advance_func:
177 * @ffuncs: font functions.
178 * @func: (closure user_data) (destroy destroy) (scope notified):
187 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t
*ffuncs
,
188 hb_font_get_glyph_v_advance_func_t func
,
189 void *user_data
, hb_destroy_func_t destroy
);
192 * hb_font_funcs_set_glyph_h_origin_func:
193 * @ffuncs: font functions.
194 * @func: (closure user_data) (destroy destroy) (scope notified):
203 hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t
*ffuncs
,
204 hb_font_get_glyph_h_origin_func_t func
,
205 void *user_data
, hb_destroy_func_t destroy
);
208 * hb_font_funcs_set_glyph_v_origin_func:
209 * @ffuncs: font functions.
210 * @func: (closure user_data) (destroy destroy) (scope notified):
219 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t
*ffuncs
,
220 hb_font_get_glyph_v_origin_func_t func
,
221 void *user_data
, hb_destroy_func_t destroy
);
224 * hb_font_funcs_set_glyph_h_kerning_func:
225 * @ffuncs: font functions.
226 * @func: (closure user_data) (destroy destroy) (scope notified):
235 hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t
*ffuncs
,
236 hb_font_get_glyph_h_kerning_func_t func
,
237 void *user_data
, hb_destroy_func_t destroy
);
240 * hb_font_funcs_set_glyph_v_kerning_func:
241 * @ffuncs: font functions.
242 * @func: (closure user_data) (destroy destroy) (scope notified):
251 hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t
*ffuncs
,
252 hb_font_get_glyph_v_kerning_func_t func
,
253 void *user_data
, hb_destroy_func_t destroy
);
256 * hb_font_funcs_set_glyph_extents_func:
257 * @ffuncs: font functions.
258 * @func: (closure user_data) (destroy destroy) (scope notified):
267 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t
*ffuncs
,
268 hb_font_get_glyph_extents_func_t func
,
269 void *user_data
, hb_destroy_func_t destroy
);
272 * hb_font_funcs_set_glyph_contour_point_func:
273 * @ffuncs: font functions.
274 * @func: (closure user_data) (destroy destroy) (scope notified):
283 hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t
*ffuncs
,
284 hb_font_get_glyph_contour_point_func_t func
,
285 void *user_data
, hb_destroy_func_t destroy
);
288 * hb_font_funcs_set_glyph_name_func:
289 * @ffuncs: font functions.
290 * @func: (closure user_data) (destroy destroy) (scope notified):
299 hb_font_funcs_set_glyph_name_func (hb_font_funcs_t
*ffuncs
,
300 hb_font_get_glyph_name_func_t func
,
301 void *user_data
, hb_destroy_func_t destroy
);
304 * hb_font_funcs_set_glyph_from_name_func:
305 * @ffuncs: font functions.
306 * @func: (closure user_data) (destroy destroy) (scope notified):
315 hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t
*ffuncs
,
316 hb_font_get_glyph_from_name_func_t func
,
317 void *user_data
, hb_destroy_func_t destroy
);
323 hb_font_get_glyph (hb_font_t
*font
,
324 hb_codepoint_t unicode
, hb_codepoint_t variation_selector
,
325 hb_codepoint_t
*glyph
);
327 HB_EXTERN hb_position_t
328 hb_font_get_glyph_h_advance (hb_font_t
*font
,
329 hb_codepoint_t glyph
);
330 HB_EXTERN hb_position_t
331 hb_font_get_glyph_v_advance (hb_font_t
*font
,
332 hb_codepoint_t glyph
);
335 hb_font_get_glyph_h_origin (hb_font_t
*font
,
336 hb_codepoint_t glyph
,
337 hb_position_t
*x
, hb_position_t
*y
);
339 hb_font_get_glyph_v_origin (hb_font_t
*font
,
340 hb_codepoint_t glyph
,
341 hb_position_t
*x
, hb_position_t
*y
);
343 HB_EXTERN hb_position_t
344 hb_font_get_glyph_h_kerning (hb_font_t
*font
,
345 hb_codepoint_t left_glyph
, hb_codepoint_t right_glyph
);
346 HB_EXTERN hb_position_t
347 hb_font_get_glyph_v_kerning (hb_font_t
*font
,
348 hb_codepoint_t top_glyph
, hb_codepoint_t bottom_glyph
);
351 hb_font_get_glyph_extents (hb_font_t
*font
,
352 hb_codepoint_t glyph
,
353 hb_glyph_extents_t
*extents
);
356 hb_font_get_glyph_contour_point (hb_font_t
*font
,
357 hb_codepoint_t glyph
, unsigned int point_index
,
358 hb_position_t
*x
, hb_position_t
*y
);
361 hb_font_get_glyph_name (hb_font_t
*font
,
362 hb_codepoint_t glyph
,
363 char *name
, unsigned int size
);
365 hb_font_get_glyph_from_name (hb_font_t
*font
,
366 const char *name
, int len
, /* -1 means nul-terminated */
367 hb_codepoint_t
*glyph
);
370 /* high-level funcs, with fallback */
373 hb_font_get_glyph_advance_for_direction (hb_font_t
*font
,
374 hb_codepoint_t glyph
,
375 hb_direction_t direction
,
376 hb_position_t
*x
, hb_position_t
*y
);
378 hb_font_get_glyph_origin_for_direction (hb_font_t
*font
,
379 hb_codepoint_t glyph
,
380 hb_direction_t direction
,
381 hb_position_t
*x
, hb_position_t
*y
);
383 hb_font_add_glyph_origin_for_direction (hb_font_t
*font
,
384 hb_codepoint_t glyph
,
385 hb_direction_t direction
,
386 hb_position_t
*x
, hb_position_t
*y
);
388 hb_font_subtract_glyph_origin_for_direction (hb_font_t
*font
,
389 hb_codepoint_t glyph
,
390 hb_direction_t direction
,
391 hb_position_t
*x
, hb_position_t
*y
);
394 hb_font_get_glyph_kerning_for_direction (hb_font_t
*font
,
395 hb_codepoint_t first_glyph
, hb_codepoint_t second_glyph
,
396 hb_direction_t direction
,
397 hb_position_t
*x
, hb_position_t
*y
);
400 hb_font_get_glyph_extents_for_origin (hb_font_t
*font
,
401 hb_codepoint_t glyph
,
402 hb_direction_t direction
,
403 hb_glyph_extents_t
*extents
);
406 hb_font_get_glyph_contour_point_for_origin (hb_font_t
*font
,
407 hb_codepoint_t glyph
, unsigned int point_index
,
408 hb_direction_t direction
,
409 hb_position_t
*x
, hb_position_t
*y
);
411 /* Generates gidDDD if glyph has no name. */
413 hb_font_glyph_to_string (hb_font_t
*font
,
414 hb_codepoint_t glyph
,
415 char *s
, unsigned int size
);
416 /* Parses gidDDD and uniUUUU strings automatically. */
418 hb_font_glyph_from_string (hb_font_t
*font
,
419 const char *s
, int len
, /* -1 means nul-terminated */
420 hb_codepoint_t
*glyph
);
427 /* Fonts are very light-weight objects */
429 HB_EXTERN hb_font_t
*
430 hb_font_create (hb_face_t
*face
);
432 HB_EXTERN hb_font_t
*
433 hb_font_create_sub_font (hb_font_t
*parent
);
435 HB_EXTERN hb_font_t
*
436 hb_font_get_empty (void);
438 HB_EXTERN hb_font_t
*
439 hb_font_reference (hb_font_t
*font
);
442 hb_font_destroy (hb_font_t
*font
);
445 hb_font_set_user_data (hb_font_t
*font
,
446 hb_user_data_key_t
*key
,
448 hb_destroy_func_t destroy
,
453 hb_font_get_user_data (hb_font_t
*font
,
454 hb_user_data_key_t
*key
);
457 hb_font_make_immutable (hb_font_t
*font
);
460 hb_font_is_immutable (hb_font_t
*font
);
463 hb_font_set_parent (hb_font_t
*font
,
466 HB_EXTERN hb_font_t
*
467 hb_font_get_parent (hb_font_t
*font
);
469 HB_EXTERN hb_face_t
*
470 hb_font_get_face (hb_font_t
*font
);
474 hb_font_set_funcs (hb_font_t
*font
,
475 hb_font_funcs_t
*klass
,
477 hb_destroy_func_t destroy
);
479 /* Be *very* careful with this function! */
481 hb_font_set_funcs_data (hb_font_t
*font
,
483 hb_destroy_func_t destroy
);
487 hb_font_set_scale (hb_font_t
*font
,
492 hb_font_get_scale (hb_font_t
*font
,
497 * A zero value means "no hinting in that direction"
500 hb_font_set_ppem (hb_font_t
*font
,
502 unsigned int y_ppem
);
505 hb_font_get_ppem (hb_font_t
*font
,
506 unsigned int *x_ppem
,
507 unsigned int *y_ppem
);
512 #endif /* HB_FONT_H */