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 (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 /* func setters */ 516 517 /** 518 * hb_font_funcs_set_font_h_extents_func: 519 * @ffuncs: A font-function structure 520 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 521 * @user_data: Data to pass to @func 522 * @destroy: (nullable): The function to call when @user_data is not needed anymore 523 * 524 * Sets the implementation function for #hb_font_get_font_h_extents_func_t. 525 * 526 * Since: 1.1.2 527 **/ 528 HB_EXTERN void 529 hb_font_funcs_set_font_h_extents_func (hb_font_funcs_t *ffuncs, 530 hb_font_get_font_h_extents_func_t func, 531 void *user_data, hb_destroy_func_t destroy); 532 533 /** 534 * hb_font_funcs_set_font_v_extents_func: 535 * @ffuncs: A font-function structure 536 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 537 * @user_data: Data to pass to @func 538 * @destroy: (nullable): The function to call when @user_data is not needed anymore 539 * 540 * Sets the implementation function for #hb_font_get_font_v_extents_func_t. 541 * 542 * Since: 1.1.2 543 **/ 544 HB_EXTERN void 545 hb_font_funcs_set_font_v_extents_func (hb_font_funcs_t *ffuncs, 546 hb_font_get_font_v_extents_func_t func, 547 void *user_data, hb_destroy_func_t destroy); 548 549 /** 550 * hb_font_funcs_set_nominal_glyph_func: 551 * @ffuncs: A font-function structure 552 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 553 * @user_data: Data to pass to @func 554 * @destroy: (nullable): The function to call when @user_data is not needed anymore 555 * 556 * Sets the implementation function for #hb_font_get_nominal_glyph_func_t. 557 * 558 * Since: 1.2.3 559 **/ 560 HB_EXTERN void 561 hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t *ffuncs, 562 hb_font_get_nominal_glyph_func_t func, 563 void *user_data, hb_destroy_func_t destroy); 564 565 /** 566 * hb_font_funcs_set_nominal_glyphs_func: 567 * @ffuncs: A font-function structure 568 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 569 * @user_data: Data to pass to @func 570 * @destroy: (nullable): The function to call when @user_data is not needed anymore 571 * 572 * Sets the implementation function for #hb_font_get_nominal_glyphs_func_t. 573 * 574 * Since: 2.0.0 575 **/ 576 HB_EXTERN void 577 hb_font_funcs_set_nominal_glyphs_func (hb_font_funcs_t *ffuncs, 578 hb_font_get_nominal_glyphs_func_t func, 579 void *user_data, hb_destroy_func_t destroy); 580 581 /** 582 * hb_font_funcs_set_variation_glyph_func: 583 * @ffuncs: A font-function structure 584 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 585 * @user_data: Data to pass to @func 586 * @destroy: (nullable): The function to call when @user_data is not needed anymore 587 * 588 * Sets the implementation function for #hb_font_get_variation_glyph_func_t. 589 * 590 * Since: 1.2.3 591 **/ 592 HB_EXTERN void 593 hb_font_funcs_set_variation_glyph_func (hb_font_funcs_t *ffuncs, 594 hb_font_get_variation_glyph_func_t func, 595 void *user_data, hb_destroy_func_t destroy); 596 597 /** 598 * hb_font_funcs_set_glyph_h_advance_func: 599 * @ffuncs: A font-function structure 600 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 601 * @user_data: Data to pass to @func 602 * @destroy: (nullable): The function to call when @user_data is not needed anymore 603 * 604 * Sets the implementation function for #hb_font_get_glyph_h_advance_func_t. 605 * 606 * Since: 0.9.2 607 **/ 608 HB_EXTERN void 609 hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs, 610 hb_font_get_glyph_h_advance_func_t func, 611 void *user_data, hb_destroy_func_t destroy); 612 613 /** 614 * hb_font_funcs_set_glyph_v_advance_func: 615 * @ffuncs: A font-function structure 616 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 617 * @user_data: Data to pass to @func 618 * @destroy: (nullable): The function to call when @user_data is not needed anymore 619 * 620 * Sets the implementation function for #hb_font_get_glyph_v_advance_func_t. 621 * 622 * Since: 0.9.2 623 **/ 624 HB_EXTERN void 625 hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs, 626 hb_font_get_glyph_v_advance_func_t func, 627 void *user_data, hb_destroy_func_t destroy); 628 629 /** 630 * hb_font_funcs_set_glyph_h_advances_func: 631 * @ffuncs: A font-function structure 632 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 633 * @user_data: Data to pass to @func 634 * @destroy: (nullable): The function to call when @user_data is not needed anymore 635 * 636 * Sets the implementation function for #hb_font_get_glyph_h_advances_func_t. 637 * 638 * Since: 1.8.6 639 **/ 640 HB_EXTERN void 641 hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t *ffuncs, 642 hb_font_get_glyph_h_advances_func_t func, 643 void *user_data, hb_destroy_func_t destroy); 644 645 /** 646 * hb_font_funcs_set_glyph_v_advances_func: 647 * @ffuncs: A font-function structure 648 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 649 * @user_data: Data to pass to @func 650 * @destroy: (nullable): The function to call when @user_data is not needed anymore 651 * 652 * Sets the implementation function for #hb_font_get_glyph_v_advances_func_t. 653 * 654 * Since: 1.8.6 655 **/ 656 HB_EXTERN void 657 hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t *ffuncs, 658 hb_font_get_glyph_v_advances_func_t func, 659 void *user_data, hb_destroy_func_t destroy); 660 661 /** 662 * hb_font_funcs_set_glyph_h_origin_func: 663 * @ffuncs: A font-function structure 664 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 665 * @user_data: Data to pass to @func 666 * @destroy: (nullable): The function to call when @user_data is not needed anymore 667 * 668 * Sets the implementation function for #hb_font_get_glyph_h_origin_func_t. 669 * 670 * Since: 0.9.2 671 **/ 672 HB_EXTERN void 673 hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs, 674 hb_font_get_glyph_h_origin_func_t func, 675 void *user_data, hb_destroy_func_t destroy); 676 677 /** 678 * hb_font_funcs_set_glyph_v_origin_func: 679 * @ffuncs: A font-function structure 680 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 681 * @user_data: Data to pass to @func 682 * @destroy: (nullable): The function to call when @user_data is not needed anymore 683 * 684 * Sets the implementation function for #hb_font_get_glyph_v_origin_func_t. 685 * 686 * Since: 0.9.2 687 **/ 688 HB_EXTERN void 689 hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs, 690 hb_font_get_glyph_v_origin_func_t func, 691 void *user_data, hb_destroy_func_t destroy); 692 693 /** 694 * hb_font_funcs_set_glyph_h_kerning_func: 695 * @ffuncs: A font-function structure 696 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 697 * @user_data: Data to pass to @func 698 * @destroy: (nullable): The function to call when @user_data is not needed anymore 699 * 700 * Sets the implementation function for #hb_font_get_glyph_h_kerning_func_t. 701 * 702 * Since: 0.9.2 703 **/ 704 HB_EXTERN void 705 hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs, 706 hb_font_get_glyph_h_kerning_func_t func, 707 void *user_data, hb_destroy_func_t destroy); 708 709 /** 710 * hb_font_funcs_set_glyph_extents_func: 711 * @ffuncs: A font-function structure 712 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 713 * @user_data: Data to pass to @func 714 * @destroy: (nullable): The function to call when @user_data is not needed anymore 715 * 716 * Sets the implementation function for #hb_font_get_glyph_extents_func_t. 717 * 718 * Since: 0.9.2 719 **/ 720 HB_EXTERN void 721 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs, 722 hb_font_get_glyph_extents_func_t func, 723 void *user_data, hb_destroy_func_t destroy); 724 725 /** 726 * hb_font_funcs_set_glyph_contour_point_func: 727 * @ffuncs: A font-function structure 728 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 729 * @user_data: Data to pass to @func 730 * @destroy: (nullable): The function to call when @user_data is not needed anymore 731 * 732 * Sets the implementation function for #hb_font_get_glyph_contour_point_func_t. 733 * 734 * Since: 0.9.2 735 **/ 736 HB_EXTERN void 737 hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs, 738 hb_font_get_glyph_contour_point_func_t func, 739 void *user_data, hb_destroy_func_t destroy); 740 741 /** 742 * hb_font_funcs_set_glyph_name_func: 743 * @ffuncs: A font-function structure 744 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 745 * @user_data: Data to pass to @func 746 * @destroy: (nullable): The function to call when @user_data is not needed anymore 747 * 748 * Sets the implementation function for #hb_font_get_glyph_name_func_t. 749 * 750 * Since: 0.9.2 751 **/ 752 HB_EXTERN void 753 hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs, 754 hb_font_get_glyph_name_func_t func, 755 void *user_data, hb_destroy_func_t destroy); 756 757 /** 758 * hb_font_funcs_set_glyph_from_name_func: 759 * @ffuncs: A font-function structure 760 * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign 761 * @user_data: Data to pass to @func 762 * @destroy: (nullable): The function to call when @user_data is not needed anymore 763 * 764 * Sets the implementation function for #hb_font_get_glyph_from_name_func_t. 765 * 766 * Since: 0.9.2 767 **/ 768 HB_EXTERN void 769 hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs, 770 hb_font_get_glyph_from_name_func_t func, 771 void *user_data, hb_destroy_func_t destroy); 772 773 /* func dispatch */ 774 775 HB_EXTERN hb_bool_t 776 hb_font_get_h_extents (hb_font_t *font, 777 hb_font_extents_t *extents); 778 HB_EXTERN hb_bool_t 779 hb_font_get_v_extents (hb_font_t *font, 780 hb_font_extents_t *extents); 781 782 HB_EXTERN hb_bool_t 783 hb_font_get_nominal_glyph (hb_font_t *font, 784 hb_codepoint_t unicode, 785 hb_codepoint_t *glyph); 786 HB_EXTERN hb_bool_t 787 hb_font_get_variation_glyph (hb_font_t *font, 788 hb_codepoint_t unicode, hb_codepoint_t variation_selector, 789 hb_codepoint_t *glyph); 790 791 HB_EXTERN unsigned int 792 hb_font_get_nominal_glyphs (hb_font_t *font, 793 unsigned int count, 794 const hb_codepoint_t *first_unicode, 795 unsigned int unicode_stride, 796 hb_codepoint_t *first_glyph, 797 unsigned int glyph_stride); 798 799 HB_EXTERN hb_position_t 800 hb_font_get_glyph_h_advance (hb_font_t *font, 801 hb_codepoint_t glyph); 802 HB_EXTERN hb_position_t 803 hb_font_get_glyph_v_advance (hb_font_t *font, 804 hb_codepoint_t glyph); 805 806 HB_EXTERN void 807 hb_font_get_glyph_h_advances (hb_font_t* font, 808 unsigned int count, 809 const hb_codepoint_t *first_glyph, 810 unsigned glyph_stride, 811 hb_position_t *first_advance, 812 unsigned advance_stride); 813 HB_EXTERN void 814 hb_font_get_glyph_v_advances (hb_font_t* font, 815 unsigned int count, 816 const hb_codepoint_t *first_glyph, 817 unsigned glyph_stride, 818 hb_position_t *first_advance, 819 unsigned advance_stride); 820 821 HB_EXTERN hb_bool_t 822 hb_font_get_glyph_h_origin (hb_font_t *font, 823 hb_codepoint_t glyph, 824 hb_position_t *x, hb_position_t *y); 825 HB_EXTERN hb_bool_t 826 hb_font_get_glyph_v_origin (hb_font_t *font, 827 hb_codepoint_t glyph, 828 hb_position_t *x, hb_position_t *y); 829 830 HB_EXTERN hb_position_t 831 hb_font_get_glyph_h_kerning (hb_font_t *font, 832 hb_codepoint_t left_glyph, hb_codepoint_t right_glyph); 833 834 HB_EXTERN hb_bool_t 835 hb_font_get_glyph_extents (hb_font_t *font, 836 hb_codepoint_t glyph, 837 hb_glyph_extents_t *extents); 838 839 HB_EXTERN hb_bool_t 840 hb_font_get_glyph_contour_point (hb_font_t *font, 841 hb_codepoint_t glyph, unsigned int point_index, 842 hb_position_t *x, hb_position_t *y); 843 844 HB_EXTERN hb_bool_t 845 hb_font_get_glyph_name (hb_font_t *font, 846 hb_codepoint_t glyph, 847 char *name, unsigned int size); 848 HB_EXTERN hb_bool_t 849 hb_font_get_glyph_from_name (hb_font_t *font, 850 const char *name, int len, /* -1 means nul-terminated */ 851 hb_codepoint_t *glyph); 852 853 854 /* high-level funcs, with fallback */ 855 856 /* Calls either hb_font_get_nominal_glyph() if variation_selector is 0, 857 * otherwise calls hb_font_get_variation_glyph(). */ 858 HB_EXTERN hb_bool_t 859 hb_font_get_glyph (hb_font_t *font, 860 hb_codepoint_t unicode, hb_codepoint_t variation_selector, 861 hb_codepoint_t *glyph); 862 863 HB_EXTERN void 864 hb_font_get_extents_for_direction (hb_font_t *font, 865 hb_direction_t direction, 866 hb_font_extents_t *extents); 867 HB_EXTERN void 868 hb_font_get_glyph_advance_for_direction (hb_font_t *font, 869 hb_codepoint_t glyph, 870 hb_direction_t direction, 871 hb_position_t *x, hb_position_t *y); 872 HB_EXTERN void 873 hb_font_get_glyph_advances_for_direction (hb_font_t* font, 874 hb_direction_t direction, 875 unsigned int count, 876 const hb_codepoint_t *first_glyph, 877 unsigned glyph_stride, 878 hb_position_t *first_advance, 879 unsigned advance_stride); 880 HB_EXTERN void 881 hb_font_get_glyph_origin_for_direction (hb_font_t *font, 882 hb_codepoint_t glyph, 883 hb_direction_t direction, 884 hb_position_t *x, hb_position_t *y); 885 HB_EXTERN void 886 hb_font_add_glyph_origin_for_direction (hb_font_t *font, 887 hb_codepoint_t glyph, 888 hb_direction_t direction, 889 hb_position_t *x, hb_position_t *y); 890 HB_EXTERN void 891 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, 892 hb_codepoint_t glyph, 893 hb_direction_t direction, 894 hb_position_t *x, hb_position_t *y); 895 896 HB_EXTERN void 897 hb_font_get_glyph_kerning_for_direction (hb_font_t *font, 898 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, 899 hb_direction_t direction, 900 hb_position_t *x, hb_position_t *y); 901 902 HB_EXTERN hb_bool_t 903 hb_font_get_glyph_extents_for_origin (hb_font_t *font, 904 hb_codepoint_t glyph, 905 hb_direction_t direction, 906 hb_glyph_extents_t *extents); 907 908 HB_EXTERN hb_bool_t 909 hb_font_get_glyph_contour_point_for_origin (hb_font_t *font, 910 hb_codepoint_t glyph, unsigned int point_index, 911 hb_direction_t direction, 912 hb_position_t *x, hb_position_t *y); 913 914 /* Generates gidDDD if glyph has no name. */ 915 HB_EXTERN void 916 hb_font_glyph_to_string (hb_font_t *font, 917 hb_codepoint_t glyph, 918 char *s, unsigned int size); 919 /* Parses gidDDD and uniUUUU strings automatically. */ 920 HB_EXTERN hb_bool_t 921 hb_font_glyph_from_string (hb_font_t *font, 922 const char *s, int len, /* -1 means nul-terminated */ 923 hb_codepoint_t *glyph); 924 925 926 /* 927 * hb_font_t 928 */ 929 930 /* Fonts are very light-weight objects */ 931 932 HB_EXTERN hb_font_t * 933 hb_font_create (hb_face_t *face); 934 935 HB_EXTERN hb_font_t * 936 hb_font_create_sub_font (hb_font_t *parent); 937 938 HB_EXTERN hb_font_t * 939 hb_font_get_empty (void); 940 941 HB_EXTERN hb_font_t * 942 hb_font_reference (hb_font_t *font); 943 944 HB_EXTERN void 945 hb_font_destroy (hb_font_t *font); 946 947 HB_EXTERN hb_bool_t 948 hb_font_set_user_data (hb_font_t *font, 949 hb_user_data_key_t *key, 950 void * data, 951 hb_destroy_func_t destroy, 952 hb_bool_t replace); 953 954 955 HB_EXTERN void * 956 hb_font_get_user_data (hb_font_t *font, 957 hb_user_data_key_t *key); 958 959 HB_EXTERN void 960 hb_font_make_immutable (hb_font_t *font); 961 962 HB_EXTERN hb_bool_t 963 hb_font_is_immutable (hb_font_t *font); 964 965 HB_EXTERN void 966 hb_font_set_parent (hb_font_t *font, 967 hb_font_t *parent); 968 969 HB_EXTERN hb_font_t * 970 hb_font_get_parent (hb_font_t *font); 971 972 HB_EXTERN void 973 hb_font_set_face (hb_font_t *font, 974 hb_face_t *face); 975 976 HB_EXTERN hb_face_t * 977 hb_font_get_face (hb_font_t *font); 978 979 980 HB_EXTERN void 981 hb_font_set_funcs (hb_font_t *font, 982 hb_font_funcs_t *klass, 983 void *font_data, 984 hb_destroy_func_t destroy); 985 986 /* Be *very* careful with this function! */ 987 HB_EXTERN void 988 hb_font_set_funcs_data (hb_font_t *font, 989 void *font_data, 990 hb_destroy_func_t destroy); 991 992 993 HB_EXTERN void 994 hb_font_set_scale (hb_font_t *font, 995 int x_scale, 996 int y_scale); 997 998 HB_EXTERN void 999 hb_font_get_scale (hb_font_t *font, 1000 int *x_scale, 1001 int *y_scale); 1002 1003 /* 1004 * A zero value means "no hinting in that direction" 1005 */ 1006 HB_EXTERN void 1007 hb_font_set_ppem (hb_font_t *font, 1008 unsigned int x_ppem, 1009 unsigned int y_ppem); 1010 1011 HB_EXTERN void 1012 hb_font_get_ppem (hb_font_t *font, 1013 unsigned int *x_ppem, 1014 unsigned int *y_ppem); 1015 1016 /* 1017 * Point size per EM. Used for optical-sizing in CoreText. 1018 * A value of zero means "not set". 1019 */ 1020 HB_EXTERN void 1021 hb_font_set_ptem (hb_font_t *font, float ptem); 1022 1023 HB_EXTERN float 1024 hb_font_get_ptem (hb_font_t *font); 1025 1026 HB_EXTERN void 1027 hb_font_set_variations (hb_font_t *font, 1028 const hb_variation_t *variations, 1029 unsigned int variations_length); 1030 1031 HB_EXTERN void 1032 hb_font_set_var_coords_design (hb_font_t *font, 1033 const float *coords, 1034 unsigned int coords_length); 1035 1036 #ifdef HB_EXPERIMENTAL_API 1037 HB_EXTERN const float * 1038 hb_font_get_var_coords_design (hb_font_t *font, 1039 unsigned int *length); 1040 #endif 1041 1042 HB_EXTERN void 1043 hb_font_set_var_coords_normalized (hb_font_t *font, 1044 const int *coords, /* 2.14 normalized */ 1045 unsigned int coords_length); 1046 1047 HB_EXTERN const int * 1048 hb_font_get_var_coords_normalized (hb_font_t *font, 1049 unsigned int *length); 1050 1051 HB_EXTERN void 1052 hb_font_set_var_named_instance (hb_font_t *font, 1053 unsigned instance_index); 1054 1055 #ifdef HB_EXPERIMENTAL_API 1056 HB_EXTERN hb_bool_t 1057 hb_font_draw_glyph (hb_font_t *font, hb_codepoint_t glyph, 1058 const hb_draw_funcs_t *funcs, void *user_data); 1059 #endif 1060 1061 HB_END_DECLS 1062 1063 #endif /* HB_FONT_H */ 1064