• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FONT_H
32 #define HB_FONT_H
33 
34 #include "hb-common.h"
35 #include "hb-face.h"
36 #include "hb-draw.h"
37 
38 HB_BEGIN_DECLS
39 
40 /**
41  * hb_font_t:
42  *
43  * Data type for holding fonts.
44  *
45  */
46 typedef struct hb_font_t hb_font_t;
47 
48 
49 /*
50  * hb_font_funcs_t
51  */
52 
53 /**
54  * hb_font_funcs_t:
55  *
56  * Data type containing a set of virtual methods used for
57  * working on #hb_font_t font objects.
58  *
59  * HarfBuzz provides a lightweight default function for each of
60  * the methods in #hb_font_funcs_t. Client programs can implement
61  * their own replacements for the individual font functions, as
62  * needed, and replace the default by calling the setter for a
63  * method.
64  *
65  **/
66 typedef struct hb_font_funcs_t hb_font_funcs_t;
67 
68 HB_EXTERN hb_font_funcs_t *
69 hb_font_funcs_create (void);
70 
71 HB_EXTERN hb_font_funcs_t *
72 hb_font_funcs_get_empty (void);
73 
74 HB_EXTERN hb_font_funcs_t *
75 hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
76 
77 HB_EXTERN void
78 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
79 
80 HB_EXTERN hb_bool_t
81 hb_font_funcs_set_user_data (hb_font_funcs_t    *ffuncs,
82 			     hb_user_data_key_t *key,
83 			     void *              data,
84 			     hb_destroy_func_t   destroy,
85 			     hb_bool_t           replace);
86 
87 
88 HB_EXTERN void *
89 hb_font_funcs_get_user_data (const hb_font_funcs_t *ffuncs,
90 			     hb_user_data_key_t    *key);
91 
92 
93 HB_EXTERN void
94 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
95 
96 HB_EXTERN hb_bool_t
97 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
98 
99 
100 /* font and glyph extents */
101 
102 /**
103  * hb_font_extents_t:
104  * @ascender: The height of typographic ascenders.
105  * @descender: The depth of typographic descenders.
106  * @line_gap: The suggested line-spacing gap.
107  *
108  * Font-wide extent values, measured in font units.
109  *
110  * Note that typically @ascender is positive and @descender
111  * negative, in coordinate systems that grow up.
112  **/
113 typedef struct hb_font_extents_t {
114   hb_position_t ascender;
115   hb_position_t descender;
116   hb_position_t line_gap;
117   /*< private >*/
118   hb_position_t reserved9;
119   hb_position_t reserved8;
120   hb_position_t reserved7;
121   hb_position_t reserved6;
122   hb_position_t reserved5;
123   hb_position_t reserved4;
124   hb_position_t reserved3;
125   hb_position_t reserved2;
126   hb_position_t reserved1;
127 } hb_font_extents_t;
128 
129 /**
130  * hb_glyph_extents_t:
131  * @x_bearing: Distance from the x-origin to the left extremum of the glyph.
132  * @y_bearing: Distance from the top extremum of the glyph to the y-origin.
133  * @width: Distance from the left extremum of the glyph to the right extremum.
134  * @height: Distance from the top extremum of the glyph to the bottom extremum.
135  *
136  * Glyph extent values, measured in font units.
137  *
138  * Note that @height is negative, in coordinate systems that grow up.
139  **/
140 typedef struct hb_glyph_extents_t {
141   hb_position_t x_bearing;
142   hb_position_t y_bearing;
143   hb_position_t width;
144   hb_position_t height;
145 } hb_glyph_extents_t;
146 
147 /* func types */
148 
149 /**
150  * hb_font_get_font_extents_func_t:
151  * @font: #hb_font_t to work upon
152  * @font_data: @font user data pointer
153  * @extents: (out): The font extents retrieved
154  * @user_data: User data pointer passed by the caller
155  *
156  * This method should retrieve the extents for a font.
157  *
158  **/
159 typedef hb_bool_t (*hb_font_get_font_extents_func_t) (hb_font_t *font, void *font_data,
160 						       hb_font_extents_t *extents,
161 						       void *user_data);
162 
163 /**
164  * hb_font_get_font_h_extents_func_t:
165  *
166  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
167  *
168  * This method should retrieve the extents for a font, for horizontal-direction
169  * text segments. Extents must be returned in an #hb_glyph_extents output
170  * parameter.
171  *
172  **/
173 typedef hb_font_get_font_extents_func_t hb_font_get_font_h_extents_func_t;
174 
175 /**
176  * hb_font_get_font_v_extents_func_t:
177  *
178  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
179  *
180  * This method should retrieve the extents for a font, for vertical-direction
181  * text segments. Extents must be returned in an #hb_glyph_extents output
182  * parameter.
183  *
184  **/
185 typedef hb_font_get_font_extents_func_t hb_font_get_font_v_extents_func_t;
186 
187 
188 /**
189  * hb_font_get_nominal_glyph_func_t:
190  * @font: #hb_font_t to work upon
191  * @font_data: @font user data pointer
192  * @unicode: The Unicode code point to query
193  * @glyph: (out): The glyph ID retrieved
194  * @user_data: User data pointer passed by the caller
195  *
196  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
197  *
198  * This method should retrieve the nominal glyph ID for a specified Unicode code
199  * point. Glyph IDs must be returned in a #hb_codepoint_t output parameter.
200  *
201  * Return value: `true` if data found, `false` otherwise
202  *
203  **/
204 typedef hb_bool_t (*hb_font_get_nominal_glyph_func_t) (hb_font_t *font, void *font_data,
205 						       hb_codepoint_t unicode,
206 						       hb_codepoint_t *glyph,
207 						       void *user_data);
208 
209 /**
210  * hb_font_get_variation_glyph_func_t:
211  * @font: #hb_font_t to work upon
212  * @font_data: @font user data pointer
213  * @unicode: The Unicode code point to query
214  * @variation_selector: The  variation-selector code point to query
215  * @glyph: (out): The glyph ID retrieved
216  * @user_data: User data pointer passed by the caller
217  *
218  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
219  *
220  * This method should retrieve the glyph ID for a specified Unicode code point
221  * followed by a specified Variation Selector code point. Glyph IDs must be
222  * returned in a #hb_codepoint_t output parameter.
223  *
224  * Return value: `true` if data found, `false` otherwise
225  *
226  **/
227 typedef hb_bool_t (*hb_font_get_variation_glyph_func_t) (hb_font_t *font, void *font_data,
228 							 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
229 							 hb_codepoint_t *glyph,
230 							 void *user_data);
231 
232 
233 /**
234  * hb_font_get_nominal_glyphs_func_t:
235  * @font: #hb_font_t to work upon
236  * @font_data: @font user data pointer
237  * @count: number of code points to query
238  * @first_unicode: The first Unicode code point to query
239  * @unicode_stride: The stride between successive code points
240  * @first_glyph: (out): The first glyph ID retrieved
241  * @glyph_stride: The stride between successive glyph IDs
242  * @user_data: User data pointer passed by the caller
243  *
244  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
245  *
246  * This method should retrieve the nominal glyph IDs for a sequence of
247  * Unicode code points. Glyph IDs must be returned in a #hb_codepoint_t
248  * output parameter.
249  *
250  * Return value: the number of code points processed
251  *
252  **/
253 typedef unsigned int (*hb_font_get_nominal_glyphs_func_t) (hb_font_t *font, void *font_data,
254 							   unsigned int count,
255 							   const hb_codepoint_t *first_unicode,
256 							   unsigned int unicode_stride,
257 							   hb_codepoint_t *first_glyph,
258 							   unsigned int glyph_stride,
259 							   void *user_data);
260 
261 /**
262  * hb_font_get_glyph_advance_func_t:
263  * @font: #hb_font_t to work upon
264  * @font_data: @font user data pointer
265  * @glyph: The glyph ID to query
266  * @user_data: User data pointer passed by the caller
267  *
268  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
269  *
270  * This method should retrieve the advance for a specified glyph. The
271  * method must return an #hb_position_t.
272  *
273  * Return value: The advance of @glyph within @font
274  *
275  **/
276 typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
277 							   hb_codepoint_t glyph,
278 							   void *user_data);
279 
280 /**
281  * hb_font_get_glyph_h_advance_func_t:
282  *
283  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
284  *
285  * This method should retrieve the advance for a specified glyph, in
286  * horizontal-direction text segments. Advances must be returned in
287  * an #hb_position_t output parameter.
288  *
289  **/
290 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
291 
292 /**
293  * hb_font_get_glyph_v_advance_func_t:
294  *
295  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
296  *
297  * This method should retrieve the advance for a specified glyph, in
298  * vertical-direction text segments. Advances must be returned in
299  * an #hb_position_t output parameter.
300  *
301  **/
302 typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
303 
304 /**
305  * hb_font_get_glyph_advances_func_t:
306  * @font: #hb_font_t to work upon
307  * @font_data: @font user data pointer
308  * @count: The number of glyph IDs in the sequence queried
309  * @first_glyph: The first glyph ID to query
310  * @glyph_stride: The stride between successive glyph IDs
311  * @first_advance: (out): The first advance retrieved
312  * @advance_stride: The stride between successive advances
313  * @user_data: User data pointer passed by the caller
314  *
315  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
316  *
317  * This method should retrieve the advances for a sequence of glyphs.
318  *
319  **/
320 typedef void (*hb_font_get_glyph_advances_func_t) (hb_font_t* font, void* font_data,
321 						   unsigned int count,
322 						   const hb_codepoint_t *first_glyph,
323 						   unsigned glyph_stride,
324 						   hb_position_t *first_advance,
325 						   unsigned advance_stride,
326 						   void *user_data);
327 
328 /**
329  * hb_font_get_glyph_h_advances_func_t:
330  *
331  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
332  *
333  * This method should retrieve the advances for a sequence of glyphs, in
334  * horizontal-direction text segments.
335  *
336  **/
337 typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_h_advances_func_t;
338 
339 /**
340  * hb_font_get_glyph_v_advances_func_t:
341  *
342  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
343  *
344  * This method should retrieve the advances for a sequence of glyphs, in
345  * vertical-direction text segments.
346  *
347  **/
348 typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_v_advances_func_t;
349 
350 /**
351  * hb_font_get_glyph_origin_func_t:
352  * @font: #hb_font_t to work upon
353  * @font_data: @font user data pointer
354  * @glyph: The glyph ID to query
355  * @x: (out): The X coordinate of the origin
356  * @y: (out): The Y coordinate of the origin
357  * @user_data: User data pointer passed by the caller
358  *
359  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
360  *
361  * This method should retrieve the (X,Y) coordinates (in font units) of the
362  * origin for a glyph. Each coordinate must be returned in an #hb_position_t
363  * output parameter.
364  *
365  * Return value: `true` if data found, `false` otherwise
366  *
367  **/
368 typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data,
369 						      hb_codepoint_t glyph,
370 						      hb_position_t *x, hb_position_t *y,
371 						      void *user_data);
372 
373 /**
374  * hb_font_get_glyph_h_origin_func_t:
375  *
376  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
377  *
378  * This method should retrieve the (X,Y) coordinates (in font units) of the
379  * origin for a glyph, for horizontal-direction text segments. Each
380  * coordinate must be returned in an #hb_position_t output parameter.
381  *
382  **/
383 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
384 
385 /**
386  * hb_font_get_glyph_v_origin_func_t:
387  *
388  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
389  *
390  * This method should retrieve the (X,Y) coordinates (in font units) of the
391  * origin for a glyph, for vertical-direction text segments. Each coordinate
392  * must be returned in an #hb_position_t output parameter.
393  *
394  **/
395 typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
396 
397 /**
398  * hb_font_get_glyph_kerning_func_t:
399  * @font: #hb_font_t to work upon
400  * @font_data: @font user data pointer
401  * @first_glyph: The glyph ID of the first glyph in the glyph pair
402  * @second_glyph: The glyph ID of the second glyph in the glyph pair
403  * @user_data: User data pointer passed by the caller
404  *
405  * This method should retrieve the kerning-adjustment value for a glyph-pair in
406  * the specified font, for horizontal text segments.
407  *
408  **/
409 typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
410 							   hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
411 							   void *user_data);
412 /**
413  * hb_font_get_glyph_h_kerning_func_t:
414  *
415  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
416  *
417  * This method should retrieve the kerning-adjustment value for a glyph-pair in
418  * the specified font, for horizontal text segments.
419  *
420  **/
421 typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
422 
423 
424 /**
425  * hb_font_get_glyph_extents_func_t:
426  * @font: #hb_font_t to work upon
427  * @font_data: @font user data pointer
428  * @glyph: The glyph ID to query
429  * @extents: (out): The #hb_glyph_extents_t retrieved
430  * @user_data: User data pointer passed by the caller
431  *
432  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
433  *
434  * This method should retrieve the extents for a specified glyph. Extents must be
435  * returned in an #hb_glyph_extents output parameter.
436  *
437  * Return value: `true` if data found, `false` otherwise
438  *
439  **/
440 typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
441 						       hb_codepoint_t glyph,
442 						       hb_glyph_extents_t *extents,
443 						       void *user_data);
444 
445 /**
446  * hb_font_get_glyph_contour_point_func_t:
447  * @font: #hb_font_t to work upon
448  * @font_data: @font user data pointer
449  * @glyph: The glyph ID to query
450  * @point_index: The contour-point index to query
451  * @x: (out): The X value retrieved for the contour point
452  * @y: (out): The Y value retrieved for the contour point
453  * @user_data: User data pointer passed by the caller
454  *
455  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
456  *
457  * This method should retrieve the (X,Y) coordinates (in font units) for a
458  * specified contour point in a glyph. Each coordinate must be returned as
459  * an #hb_position_t output parameter.
460  *
461  * Return value: `true` if data found, `false` otherwise
462  *
463  **/
464 typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data,
465 							     hb_codepoint_t glyph, unsigned int point_index,
466 							     hb_position_t *x, hb_position_t *y,
467 							     void *user_data);
468 
469 
470 /**
471  * hb_font_get_glyph_name_func_t:
472  * @font: #hb_font_t to work upon
473  * @font_data: @font user data pointer
474  * @glyph: The glyph ID to query
475  * @name: (out) (array length=size): Name string retrieved for the glyph ID
476  * @size: Length of the glyph-name string retrieved
477  * @user_data: User data pointer passed by the caller
478  *
479  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
480  *
481  * This method should retrieve the glyph name that corresponds to a
482  * glyph ID. The name should be returned in a string output parameter.
483  *
484  * Return value: `true` if data found, `false` otherwise
485  *
486  **/
487 typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data,
488 						    hb_codepoint_t glyph,
489 						    char *name, unsigned int size,
490 						    void *user_data);
491 
492 /**
493  * hb_font_get_glyph_from_name_func_t:
494  * @font: #hb_font_t to work upon
495  * @font_data: @font user data pointer
496  * @name: (array length=len): The name string to query
497  * @len: The length of the name queried
498  * @glyph: (out): The glyph ID retrieved
499  * @user_data: User data pointer passed by the caller
500  *
501  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
502  *
503  * This method should retrieve the glyph ID that corresponds to a glyph-name
504  * string.
505  *
506  * Return value: `true` if data found, `false` otherwise
507  *
508  **/
509 typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data,
510 							 const char *name, int len, /* -1 means nul-terminated */
511 							 hb_codepoint_t *glyph,
512 							 void *user_data);
513 
514 /**
515  * hb_font_get_glyph_shape_func_t:
516  * @font: #hb_font_t to work upon
517  * @font_data: @font user data pointer
518  * @glyph: The glyph ID to query
519  * @draw_funcs: The draw functions to send the shape data to
520  * @draw_data: The data accompanying the draw functions
521  * @user_data: User data pointer passed by the caller
522  *
523  * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
524  *
525  * Since: 4.0.0
526  *
527  **/
528 typedef void (*hb_font_get_glyph_shape_func_t) (hb_font_t *font, void *font_data,
529 						hb_codepoint_t glyph,
530 						hb_draw_funcs_t *draw_funcs, void *draw_data,
531 						void *user_data);
532 
533 
534 /* func setters */
535 
536 /**
537  * hb_font_funcs_set_font_h_extents_func:
538  * @ffuncs: A font-function structure
539  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
540  * @user_data: Data to pass to @func
541  * @destroy: (nullable): The function to call when @user_data is not needed anymore
542  *
543  * Sets the implementation function for #hb_font_get_font_h_extents_func_t.
544  *
545  * Since: 1.1.2
546  **/
547 HB_EXTERN void
548 hb_font_funcs_set_font_h_extents_func (hb_font_funcs_t *ffuncs,
549 				       hb_font_get_font_h_extents_func_t func,
550 				       void *user_data, hb_destroy_func_t destroy);
551 
552 /**
553  * hb_font_funcs_set_font_v_extents_func:
554  * @ffuncs: A font-function structure
555  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
556  * @user_data: Data to pass to @func
557  * @destroy: (nullable): The function to call when @user_data is not needed anymore
558  *
559  * Sets the implementation function for #hb_font_get_font_v_extents_func_t.
560  *
561  * Since: 1.1.2
562  **/
563 HB_EXTERN void
564 hb_font_funcs_set_font_v_extents_func (hb_font_funcs_t *ffuncs,
565 				       hb_font_get_font_v_extents_func_t func,
566 				       void *user_data, hb_destroy_func_t destroy);
567 
568 /**
569  * hb_font_funcs_set_nominal_glyph_func:
570  * @ffuncs: A font-function structure
571  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
572  * @user_data: Data to pass to @func
573  * @destroy: (nullable): The function to call when @user_data is not needed anymore
574  *
575  * Sets the implementation function for #hb_font_get_nominal_glyph_func_t.
576  *
577  * Since: 1.2.3
578  **/
579 HB_EXTERN void
580 hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t *ffuncs,
581 				      hb_font_get_nominal_glyph_func_t func,
582 				      void *user_data, hb_destroy_func_t destroy);
583 
584 /**
585  * hb_font_funcs_set_nominal_glyphs_func:
586  * @ffuncs: A font-function structure
587  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
588  * @user_data: Data to pass to @func
589  * @destroy: (nullable): The function to call when @user_data is not needed anymore
590  *
591  * Sets the implementation function for #hb_font_get_nominal_glyphs_func_t.
592  *
593  * Since: 2.0.0
594  **/
595 HB_EXTERN void
596 hb_font_funcs_set_nominal_glyphs_func (hb_font_funcs_t *ffuncs,
597 				       hb_font_get_nominal_glyphs_func_t func,
598 				       void *user_data, hb_destroy_func_t destroy);
599 
600 /**
601  * hb_font_funcs_set_variation_glyph_func:
602  * @ffuncs: A font-function structure
603  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
604  * @user_data: Data to pass to @func
605  * @destroy: (nullable): The function to call when @user_data is not needed anymore
606  *
607  * Sets the implementation function for #hb_font_get_variation_glyph_func_t.
608  *
609  * Since: 1.2.3
610  **/
611 HB_EXTERN void
612 hb_font_funcs_set_variation_glyph_func (hb_font_funcs_t *ffuncs,
613 					hb_font_get_variation_glyph_func_t func,
614 					void *user_data, hb_destroy_func_t destroy);
615 
616 /**
617  * hb_font_funcs_set_glyph_h_advance_func:
618  * @ffuncs: A font-function structure
619  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
620  * @user_data: Data to pass to @func
621  * @destroy: (nullable): The function to call when @user_data is not needed anymore
622  *
623  * Sets the implementation function for #hb_font_get_glyph_h_advance_func_t.
624  *
625  * Since: 0.9.2
626  **/
627 HB_EXTERN void
628 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
629 					hb_font_get_glyph_h_advance_func_t func,
630 					void *user_data, hb_destroy_func_t destroy);
631 
632 /**
633  * hb_font_funcs_set_glyph_v_advance_func:
634  * @ffuncs: A font-function structure
635  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
636  * @user_data: Data to pass to @func
637  * @destroy: (nullable): The function to call when @user_data is not needed anymore
638  *
639  * Sets the implementation function for #hb_font_get_glyph_v_advance_func_t.
640  *
641  * Since: 0.9.2
642  **/
643 HB_EXTERN void
644 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
645 					hb_font_get_glyph_v_advance_func_t func,
646 					void *user_data, hb_destroy_func_t destroy);
647 
648 /**
649  * hb_font_funcs_set_glyph_h_advances_func:
650  * @ffuncs: A font-function structure
651  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
652  * @user_data: Data to pass to @func
653  * @destroy: (nullable): The function to call when @user_data is not needed anymore
654  *
655  * Sets the implementation function for #hb_font_get_glyph_h_advances_func_t.
656  *
657  * Since: 1.8.6
658  **/
659 HB_EXTERN void
660 hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t *ffuncs,
661 					hb_font_get_glyph_h_advances_func_t func,
662 					void *user_data, hb_destroy_func_t destroy);
663 
664 /**
665  * hb_font_funcs_set_glyph_v_advances_func:
666  * @ffuncs: A font-function structure
667  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
668  * @user_data: Data to pass to @func
669  * @destroy: (nullable): The function to call when @user_data is not needed anymore
670  *
671  * Sets the implementation function for #hb_font_get_glyph_v_advances_func_t.
672  *
673  * Since: 1.8.6
674  **/
675 HB_EXTERN void
676 hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t *ffuncs,
677 					hb_font_get_glyph_v_advances_func_t func,
678 					void *user_data, hb_destroy_func_t destroy);
679 
680 /**
681  * hb_font_funcs_set_glyph_h_origin_func:
682  * @ffuncs: A font-function structure
683  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
684  * @user_data: Data to pass to @func
685  * @destroy: (nullable): The function to call when @user_data is not needed anymore
686  *
687  * Sets the implementation function for #hb_font_get_glyph_h_origin_func_t.
688  *
689  * Since: 0.9.2
690  **/
691 HB_EXTERN void
692 hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
693 				       hb_font_get_glyph_h_origin_func_t func,
694 				       void *user_data, hb_destroy_func_t destroy);
695 
696 /**
697  * hb_font_funcs_set_glyph_v_origin_func:
698  * @ffuncs: A font-function structure
699  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
700  * @user_data: Data to pass to @func
701  * @destroy: (nullable): The function to call when @user_data is not needed anymore
702  *
703  * Sets the implementation function for #hb_font_get_glyph_v_origin_func_t.
704  *
705  * Since: 0.9.2
706  **/
707 HB_EXTERN void
708 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
709 				       hb_font_get_glyph_v_origin_func_t func,
710 				       void *user_data, hb_destroy_func_t destroy);
711 
712 /**
713  * hb_font_funcs_set_glyph_h_kerning_func:
714  * @ffuncs: A font-function structure
715  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
716  * @user_data: Data to pass to @func
717  * @destroy: (nullable): The function to call when @user_data is not needed anymore
718  *
719  * Sets the implementation function for #hb_font_get_glyph_h_kerning_func_t.
720  *
721  * Since: 0.9.2
722  **/
723 HB_EXTERN void
724 hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
725 					hb_font_get_glyph_h_kerning_func_t func,
726 					void *user_data, hb_destroy_func_t destroy);
727 
728 /**
729  * hb_font_funcs_set_glyph_extents_func:
730  * @ffuncs: A font-function structure
731  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
732  * @user_data: Data to pass to @func
733  * @destroy: (nullable): The function to call when @user_data is not needed anymore
734  *
735  * Sets the implementation function for #hb_font_get_glyph_extents_func_t.
736  *
737  * Since: 0.9.2
738  **/
739 HB_EXTERN void
740 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
741 				      hb_font_get_glyph_extents_func_t func,
742 				      void *user_data, hb_destroy_func_t destroy);
743 
744 /**
745  * hb_font_funcs_set_glyph_contour_point_func:
746  * @ffuncs: A font-function structure
747  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
748  * @user_data: Data to pass to @func
749  * @destroy: (nullable): The function to call when @user_data is not needed anymore
750  *
751  * Sets the implementation function for #hb_font_get_glyph_contour_point_func_t.
752  *
753  * Since: 0.9.2
754  **/
755 HB_EXTERN void
756 hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
757 					    hb_font_get_glyph_contour_point_func_t func,
758 					    void *user_data, hb_destroy_func_t destroy);
759 
760 /**
761  * hb_font_funcs_set_glyph_name_func:
762  * @ffuncs: A font-function structure
763  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
764  * @user_data: Data to pass to @func
765  * @destroy: (nullable): The function to call when @user_data is not needed anymore
766  *
767  * Sets the implementation function for #hb_font_get_glyph_name_func_t.
768  *
769  * Since: 0.9.2
770  **/
771 HB_EXTERN void
772 hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs,
773 				   hb_font_get_glyph_name_func_t func,
774 				   void *user_data, hb_destroy_func_t destroy);
775 
776 /**
777  * hb_font_funcs_set_glyph_from_name_func:
778  * @ffuncs: A font-function structure
779  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
780  * @user_data: Data to pass to @func
781  * @destroy: (nullable): The function to call when @user_data is not needed anymore
782  *
783  * Sets the implementation function for #hb_font_get_glyph_from_name_func_t.
784  *
785  * Since: 0.9.2
786  **/
787 HB_EXTERN void
788 hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
789 					hb_font_get_glyph_from_name_func_t func,
790 					void *user_data, hb_destroy_func_t destroy);
791 
792 /**
793  * hb_font_funcs_set_glyph_shape_func:
794  * @ffuncs: A font-function structure
795  * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
796  * @user_data: Data to pass to @func
797  * @destroy: (nullable): The function to call when @user_data is not needed anymore
798  *
799  * Sets the implementation function for #hb_font_get_glyph_shape_func_t.
800  *
801  * Since: 4.0.0
802  **/
803 HB_EXTERN void
804 hb_font_funcs_set_glyph_shape_func (hb_font_funcs_t *ffuncs,
805 				    hb_font_get_glyph_shape_func_t func,
806 				    void *user_data, hb_destroy_func_t destroy);
807 
808 /* func dispatch */
809 
810 HB_EXTERN hb_bool_t
811 hb_font_get_h_extents (hb_font_t *font,
812 		       hb_font_extents_t *extents);
813 HB_EXTERN hb_bool_t
814 hb_font_get_v_extents (hb_font_t *font,
815 		       hb_font_extents_t *extents);
816 
817 HB_EXTERN hb_bool_t
818 hb_font_get_nominal_glyph (hb_font_t *font,
819 			   hb_codepoint_t unicode,
820 			   hb_codepoint_t *glyph);
821 HB_EXTERN hb_bool_t
822 hb_font_get_variation_glyph (hb_font_t *font,
823 			     hb_codepoint_t unicode, hb_codepoint_t variation_selector,
824 			     hb_codepoint_t *glyph);
825 
826 HB_EXTERN unsigned int
827 hb_font_get_nominal_glyphs (hb_font_t *font,
828 			    unsigned int count,
829 			    const hb_codepoint_t *first_unicode,
830 			    unsigned int unicode_stride,
831 			    hb_codepoint_t *first_glyph,
832 			    unsigned int glyph_stride);
833 
834 HB_EXTERN hb_position_t
835 hb_font_get_glyph_h_advance (hb_font_t *font,
836 			     hb_codepoint_t glyph);
837 HB_EXTERN hb_position_t
838 hb_font_get_glyph_v_advance (hb_font_t *font,
839 			     hb_codepoint_t glyph);
840 
841 HB_EXTERN void
842 hb_font_get_glyph_h_advances (hb_font_t* font,
843 			      unsigned int count,
844 			      const hb_codepoint_t *first_glyph,
845 			      unsigned glyph_stride,
846 			      hb_position_t *first_advance,
847 			      unsigned advance_stride);
848 HB_EXTERN void
849 hb_font_get_glyph_v_advances (hb_font_t* font,
850 			      unsigned int count,
851 			      const hb_codepoint_t *first_glyph,
852 			      unsigned glyph_stride,
853 			      hb_position_t *first_advance,
854 			      unsigned advance_stride);
855 
856 HB_EXTERN hb_bool_t
857 hb_font_get_glyph_h_origin (hb_font_t *font,
858 			    hb_codepoint_t glyph,
859 			    hb_position_t *x, hb_position_t *y);
860 HB_EXTERN hb_bool_t
861 hb_font_get_glyph_v_origin (hb_font_t *font,
862 			    hb_codepoint_t glyph,
863 			    hb_position_t *x, hb_position_t *y);
864 
865 HB_EXTERN hb_position_t
866 hb_font_get_glyph_h_kerning (hb_font_t *font,
867 			     hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
868 
869 HB_EXTERN hb_bool_t
870 hb_font_get_glyph_extents (hb_font_t *font,
871 			   hb_codepoint_t glyph,
872 			   hb_glyph_extents_t *extents);
873 
874 HB_EXTERN hb_bool_t
875 hb_font_get_glyph_contour_point (hb_font_t *font,
876 				 hb_codepoint_t glyph, unsigned int point_index,
877 				 hb_position_t *x, hb_position_t *y);
878 
879 HB_EXTERN hb_bool_t
880 hb_font_get_glyph_name (hb_font_t *font,
881 			hb_codepoint_t glyph,
882 			char *name, unsigned int size);
883 HB_EXTERN hb_bool_t
884 hb_font_get_glyph_from_name (hb_font_t *font,
885 			     const char *name, int len, /* -1 means nul-terminated */
886 			     hb_codepoint_t *glyph);
887 
888 HB_EXTERN void
889 hb_font_get_glyph_shape (hb_font_t *font,
890 			 hb_codepoint_t glyph,
891 			 hb_draw_funcs_t *dfuncs, void *draw_data);
892 
893 
894 /* high-level funcs, with fallback */
895 
896 /* Calls either hb_font_get_nominal_glyph() if variation_selector is 0,
897  * otherwise calls hb_font_get_variation_glyph(). */
898 HB_EXTERN hb_bool_t
899 hb_font_get_glyph (hb_font_t *font,
900 		   hb_codepoint_t unicode, hb_codepoint_t variation_selector,
901 		   hb_codepoint_t *glyph);
902 
903 HB_EXTERN void
904 hb_font_get_extents_for_direction (hb_font_t *font,
905 				   hb_direction_t direction,
906 				   hb_font_extents_t *extents);
907 HB_EXTERN void
908 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
909 					 hb_codepoint_t glyph,
910 					 hb_direction_t direction,
911 					 hb_position_t *x, hb_position_t *y);
912 HB_EXTERN void
913 hb_font_get_glyph_advances_for_direction (hb_font_t* font,
914 					  hb_direction_t direction,
915 					  unsigned int count,
916 					  const hb_codepoint_t *first_glyph,
917 					  unsigned glyph_stride,
918 					  hb_position_t *first_advance,
919 					  unsigned advance_stride);
920 HB_EXTERN void
921 hb_font_get_glyph_origin_for_direction (hb_font_t *font,
922 					hb_codepoint_t glyph,
923 					hb_direction_t direction,
924 					hb_position_t *x, hb_position_t *y);
925 HB_EXTERN void
926 hb_font_add_glyph_origin_for_direction (hb_font_t *font,
927 					hb_codepoint_t glyph,
928 					hb_direction_t direction,
929 					hb_position_t *x, hb_position_t *y);
930 HB_EXTERN void
931 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
932 					     hb_codepoint_t glyph,
933 					     hb_direction_t direction,
934 					     hb_position_t *x, hb_position_t *y);
935 
936 HB_EXTERN void
937 hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
938 					 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
939 					 hb_direction_t direction,
940 					 hb_position_t *x, hb_position_t *y);
941 
942 HB_EXTERN hb_bool_t
943 hb_font_get_glyph_extents_for_origin (hb_font_t *font,
944 				      hb_codepoint_t glyph,
945 				      hb_direction_t direction,
946 				      hb_glyph_extents_t *extents);
947 
948 HB_EXTERN hb_bool_t
949 hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
950 					    hb_codepoint_t glyph, unsigned int point_index,
951 					    hb_direction_t direction,
952 					    hb_position_t *x, hb_position_t *y);
953 
954 /* Generates gidDDD if glyph has no name. */
955 HB_EXTERN void
956 hb_font_glyph_to_string (hb_font_t *font,
957 			 hb_codepoint_t glyph,
958 			 char *s, unsigned int size);
959 /* Parses gidDDD and uniUUUU strings automatically. */
960 HB_EXTERN hb_bool_t
961 hb_font_glyph_from_string (hb_font_t *font,
962 			   const char *s, int len, /* -1 means nul-terminated */
963 			   hb_codepoint_t *glyph);
964 
965 
966 /*
967  * hb_font_t
968  */
969 
970 /* Fonts are very light-weight objects */
971 
972 HB_EXTERN hb_font_t *
973 hb_font_create (hb_face_t *face);
974 
975 HB_EXTERN hb_font_t *
976 hb_font_create_sub_font (hb_font_t *parent);
977 
978 HB_EXTERN hb_font_t *
979 hb_font_get_empty (void);
980 
981 HB_EXTERN hb_font_t *
982 hb_font_reference (hb_font_t *font);
983 
984 HB_EXTERN void
985 hb_font_destroy (hb_font_t *font);
986 
987 HB_EXTERN hb_bool_t
988 hb_font_set_user_data (hb_font_t          *font,
989 		       hb_user_data_key_t *key,
990 		       void *              data,
991 		       hb_destroy_func_t   destroy,
992 		       hb_bool_t           replace);
993 
994 
995 HB_EXTERN void *
996 hb_font_get_user_data (const hb_font_t    *font,
997 		       hb_user_data_key_t *key);
998 
999 HB_EXTERN void
1000 hb_font_make_immutable (hb_font_t *font);
1001 
1002 HB_EXTERN hb_bool_t
1003 hb_font_is_immutable (hb_font_t *font);
1004 
1005 HB_EXTERN unsigned int
1006 hb_font_get_serial (hb_font_t *font);
1007 
1008 HB_EXTERN void
1009 hb_font_changed (hb_font_t *font);
1010 
1011 HB_EXTERN void
1012 hb_font_set_parent (hb_font_t *font,
1013 		    hb_font_t *parent);
1014 
1015 HB_EXTERN hb_font_t *
1016 hb_font_get_parent (hb_font_t *font);
1017 
1018 HB_EXTERN void
1019 hb_font_set_face (hb_font_t *font,
1020 		  hb_face_t *face);
1021 
1022 HB_EXTERN hb_face_t *
1023 hb_font_get_face (hb_font_t *font);
1024 
1025 
1026 HB_EXTERN void
1027 hb_font_set_funcs (hb_font_t         *font,
1028 		   hb_font_funcs_t   *klass,
1029 		   void              *font_data,
1030 		   hb_destroy_func_t  destroy);
1031 
1032 /* Be *very* careful with this function! */
1033 HB_EXTERN void
1034 hb_font_set_funcs_data (hb_font_t         *font,
1035 			void              *font_data,
1036 			hb_destroy_func_t  destroy);
1037 
1038 
1039 HB_EXTERN void
1040 hb_font_set_scale (hb_font_t *font,
1041 		   int x_scale,
1042 		   int y_scale);
1043 
1044 HB_EXTERN void
1045 hb_font_get_scale (hb_font_t *font,
1046 		   int *x_scale,
1047 		   int *y_scale);
1048 
1049 /*
1050  * A zero value means "no hinting in that direction"
1051  */
1052 HB_EXTERN void
1053 hb_font_set_ppem (hb_font_t *font,
1054 		  unsigned int x_ppem,
1055 		  unsigned int y_ppem);
1056 
1057 HB_EXTERN void
1058 hb_font_get_ppem (hb_font_t *font,
1059 		  unsigned int *x_ppem,
1060 		  unsigned int *y_ppem);
1061 
1062 /*
1063  * Point size per EM.  Used for optical-sizing in CoreText.
1064  * A value of zero means "not set".
1065  */
1066 HB_EXTERN void
1067 hb_font_set_ptem (hb_font_t *font, float ptem);
1068 
1069 HB_EXTERN float
1070 hb_font_get_ptem (hb_font_t *font);
1071 
1072 HB_EXTERN void
1073 hb_font_set_synthetic_slant (hb_font_t *font, float slant);
1074 
1075 HB_EXTERN float
1076 hb_font_get_synthetic_slant (hb_font_t *font);
1077 
1078 HB_EXTERN void
1079 hb_font_set_variations (hb_font_t *font,
1080 			const hb_variation_t *variations,
1081 			unsigned int variations_length);
1082 
1083 HB_EXTERN void
1084 hb_font_set_var_coords_design (hb_font_t *font,
1085 			       const float *coords,
1086 			       unsigned int coords_length);
1087 
1088 HB_EXTERN const float *
1089 hb_font_get_var_coords_design (hb_font_t *font,
1090 			       unsigned int *length);
1091 
1092 HB_EXTERN void
1093 hb_font_set_var_coords_normalized (hb_font_t *font,
1094 				   const int *coords, /* 2.14 normalized */
1095 				   unsigned int coords_length);
1096 
1097 HB_EXTERN const int *
1098 hb_font_get_var_coords_normalized (hb_font_t *font,
1099 				   unsigned int *length);
1100 
1101 HB_EXTERN void
1102 hb_font_set_var_named_instance (hb_font_t *font,
1103 				unsigned instance_index);
1104 
1105 
1106 HB_END_DECLS
1107 
1108 #endif /* HB_FONT_H */
1109