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

source code of include/harfbuzz/hb-font.h