| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2009 Red Hat, Inc. | 2 * Copyright © 2009 Red Hat, Inc. |
| 3 * Copyright © 2012 Google, Inc. | 3 * Copyright © 2012 Google, Inc. |
| 4 * | 4 * |
| 5 * This is part of HarfBuzz, a text shaping library. | 5 * This is part of HarfBuzz, a text shaping library. |
| 6 * | 6 * |
| 7 * Permission is hereby granted, without written agreement and without | 7 * Permission is hereby granted, without written agreement and without |
| 8 * license or royalty fees, to use, copy, modify, and distribute this | 8 * license or royalty fees, to use, copy, modify, and distribute this |
| 9 * software and its documentation for any purpose, provided that the | 9 * software and its documentation for any purpose, provided that the |
| 10 * above copyright notice and the following two paragraphs appear in | 10 * above copyright notice and the following two paragraphs appear in |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "hb-blob.h" | 34 #include "hb-blob.h" |
| 35 #include "hb-open-file-private.hh" | 35 #include "hb-open-file-private.hh" |
| 36 #include "hb-ot-head-table.hh" | 36 #include "hb-ot-head-table.hh" |
| 37 #include "hb-ot-maxp-table.hh" | 37 #include "hb-ot-maxp-table.hh" |
| 38 | 38 |
| 39 #include "hb-cache-private.hh" | 39 #include "hb-cache-private.hh" |
| 40 | 40 |
| 41 #include <string.h> | 41 #include <string.h> |
| 42 | 42 |
| 43 | 43 |
| 44 | |
| 45 /* | 44 /* |
| 46 * hb_font_funcs_t | 45 * hb_font_funcs_t |
| 47 */ | 46 */ |
| 48 | 47 |
| 49 static hb_bool_t | 48 static hb_bool_t |
| 50 hb_font_get_glyph_nil (hb_font_t *font, | 49 hb_font_get_glyph_nil (hb_font_t *font, |
| 51 void *font_data HB_UNUSED, | 50 void *font_data HB_UNUSED, |
| 52 hb_codepoint_t unicode, | 51 hb_codepoint_t unicode, |
| 53 hb_codepoint_t variation_selector, | 52 hb_codepoint_t variation_selector, |
| 54 hb_codepoint_t *glyph, | 53 hb_codepoint_t *glyph, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 true, /* immutable */ | 223 true, /* immutable */ |
| 225 | 224 |
| 226 { | 225 { |
| 227 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil, | 226 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil, |
| 228 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS | 227 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 229 #undef HB_FONT_FUNC_IMPLEMENT | 228 #undef HB_FONT_FUNC_IMPLEMENT |
| 230 } | 229 } |
| 231 }; | 230 }; |
| 232 | 231 |
| 233 | 232 |
| 233 /** |
| 234 * hb_font_funcs_create: (Xconstructor) |
| 235 * |
| 236 * |
| 237 * |
| 238 * Return value: (transfer full): |
| 239 * |
| 240 * Since: 1.0 |
| 241 **/ |
| 234 hb_font_funcs_t * | 242 hb_font_funcs_t * |
| 235 hb_font_funcs_create (void) | 243 hb_font_funcs_create (void) |
| 236 { | 244 { |
| 237 hb_font_funcs_t *ffuncs; | 245 hb_font_funcs_t *ffuncs; |
| 238 | 246 |
| 239 if (!(ffuncs = hb_object_create<hb_font_funcs_t> ())) | 247 if (!(ffuncs = hb_object_create<hb_font_funcs_t> ())) |
| 240 return hb_font_funcs_get_empty (); | 248 return hb_font_funcs_get_empty (); |
| 241 | 249 |
| 242 ffuncs->get = _hb_font_funcs_nil.get; | 250 ffuncs->get = _hb_font_funcs_nil.get; |
| 243 | 251 |
| 244 return ffuncs; | 252 return ffuncs; |
| 245 } | 253 } |
| 246 | 254 |
| 255 /** |
| 256 * hb_font_funcs_get_empty: |
| 257 * |
| 258 * |
| 259 * |
| 260 * Return value: (transfer full): |
| 261 * |
| 262 * Since: 1.0 |
| 263 **/ |
| 247 hb_font_funcs_t * | 264 hb_font_funcs_t * |
| 248 hb_font_funcs_get_empty (void) | 265 hb_font_funcs_get_empty (void) |
| 249 { | 266 { |
| 250 return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil); | 267 return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil); |
| 251 } | 268 } |
| 252 | 269 |
| 270 /** |
| 271 * hb_font_funcs_reference: (skip) |
| 272 * @ffuncs: font functions. |
| 273 * |
| 274 * |
| 275 * |
| 276 * Return value: |
| 277 * |
| 278 * Since: 1.0 |
| 279 **/ |
| 253 hb_font_funcs_t * | 280 hb_font_funcs_t * |
| 254 hb_font_funcs_reference (hb_font_funcs_t *ffuncs) | 281 hb_font_funcs_reference (hb_font_funcs_t *ffuncs) |
| 255 { | 282 { |
| 256 return hb_object_reference (ffuncs); | 283 return hb_object_reference (ffuncs); |
| 257 } | 284 } |
| 258 | 285 |
| 286 /** |
| 287 * hb_font_funcs_destroy: (skip) |
| 288 * @ffuncs: font functions. |
| 289 * |
| 290 * |
| 291 * |
| 292 * Since: 1.0 |
| 293 **/ |
| 259 void | 294 void |
| 260 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs) | 295 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs) |
| 261 { | 296 { |
| 262 if (!hb_object_destroy (ffuncs)) return; | 297 if (!hb_object_destroy (ffuncs)) return; |
| 263 | 298 |
| 264 #define HB_FONT_FUNC_IMPLEMENT(name) if (ffuncs->destroy.name) \ | 299 #define HB_FONT_FUNC_IMPLEMENT(name) if (ffuncs->destroy.name) \ |
| 265 ffuncs->destroy.name (ffuncs->user_data.name); | 300 ffuncs->destroy.name (ffuncs->user_data.name); |
| 266 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS | 301 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 267 #undef HB_FONT_FUNC_IMPLEMENT | 302 #undef HB_FONT_FUNC_IMPLEMENT |
| 268 | 303 |
| 269 free (ffuncs); | 304 free (ffuncs); |
| 270 } | 305 } |
| 271 | 306 |
| 307 /** |
| 308 * hb_font_funcs_set_user_data: (skip) |
| 309 * @ffuncs: font functions. |
| 310 * @key: |
| 311 * @data: |
| 312 * @destroy: |
| 313 * @replace: |
| 314 * |
| 315 * |
| 316 * |
| 317 * Return value: |
| 318 * |
| 319 * Since: 1.0 |
| 320 **/ |
| 272 hb_bool_t | 321 hb_bool_t |
| 273 hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs, | 322 hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs, |
| 274 hb_user_data_key_t *key, | 323 hb_user_data_key_t *key, |
| 275 void * data, | 324 void * data, |
| 276 hb_destroy_func_t destroy, | 325 hb_destroy_func_t destroy, |
| 277 hb_bool_t replace) | 326 hb_bool_t replace) |
| 278 { | 327 { |
| 279 return hb_object_set_user_data (ffuncs, key, data, destroy, replace); | 328 return hb_object_set_user_data (ffuncs, key, data, destroy, replace); |
| 280 } | 329 } |
| 281 | 330 |
| 331 /** |
| 332 * hb_font_funcs_get_user_data: (skip) |
| 333 * @ffuncs: font functions. |
| 334 * @key: |
| 335 * |
| 336 * |
| 337 * |
| 338 * Return value: (transfer none): |
| 339 * |
| 340 * Since: 1.0 |
| 341 **/ |
| 282 void * | 342 void * |
| 283 hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs, | 343 hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs, |
| 284 hb_user_data_key_t *key) | 344 hb_user_data_key_t *key) |
| 285 { | 345 { |
| 286 return hb_object_get_user_data (ffuncs, key); | 346 return hb_object_get_user_data (ffuncs, key); |
| 287 } | 347 } |
| 288 | 348 |
| 289 | 349 |
| 350 /** |
| 351 * hb_font_funcs_make_immutable: |
| 352 * @ffuncs: font functions. |
| 353 * |
| 354 * |
| 355 * |
| 356 * Since: 1.0 |
| 357 **/ |
| 290 void | 358 void |
| 291 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs) | 359 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs) |
| 292 { | 360 { |
| 293 if (hb_object_is_inert (ffuncs)) | 361 if (hb_object_is_inert (ffuncs)) |
| 294 return; | 362 return; |
| 295 | 363 |
| 296 ffuncs->immutable = true; | 364 ffuncs->immutable = true; |
| 297 } | 365 } |
| 298 | 366 |
| 367 /** |
| 368 * hb_font_funcs_is_immutable: |
| 369 * @ffuncs: font functions. |
| 370 * |
| 371 * |
| 372 * |
| 373 * Return value: |
| 374 * |
| 375 * Since: 1.0 |
| 376 **/ |
| 299 hb_bool_t | 377 hb_bool_t |
| 300 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs) | 378 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs) |
| 301 { | 379 { |
| 302 return ffuncs->immutable; | 380 return ffuncs->immutable; |
| 303 } | 381 } |
| 304 | 382 |
| 305 | 383 |
| 306 #define HB_FONT_FUNC_IMPLEMENT(name) \ | 384 #define HB_FONT_FUNC_IMPLEMENT(name) \ |
| 307 \ | 385 \ |
| 308 void \ | 386 void \ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 330 ffuncs->destroy.name = NULL; \ | 408 ffuncs->destroy.name = NULL; \ |
| 331 } \ | 409 } \ |
| 332 } | 410 } |
| 333 | 411 |
| 334 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS | 412 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS |
| 335 #undef HB_FONT_FUNC_IMPLEMENT | 413 #undef HB_FONT_FUNC_IMPLEMENT |
| 336 | 414 |
| 337 | 415 |
| 338 /* Public getters */ | 416 /* Public getters */ |
| 339 | 417 |
| 418 /** |
| 419 * hb_font_get_glyph: |
| 420 * @font: a font. |
| 421 * @unicode: |
| 422 * @variation_selector: |
| 423 * @glyph: (out): |
| 424 * |
| 425 * |
| 426 * |
| 427 * Return value: |
| 428 * |
| 429 * Since: 1.0 |
| 430 **/ |
| 340 hb_bool_t | 431 hb_bool_t |
| 341 hb_font_get_glyph (hb_font_t *font, | 432 hb_font_get_glyph (hb_font_t *font, |
| 342 hb_codepoint_t unicode, hb_codepoint_t variation_selector, | 433 hb_codepoint_t unicode, hb_codepoint_t variation_selector, |
| 343 hb_codepoint_t *glyph) | 434 hb_codepoint_t *glyph) |
| 344 { | 435 { |
| 345 return font->get_glyph (unicode, variation_selector, glyph); | 436 return font->get_glyph (unicode, variation_selector, glyph); |
| 346 } | 437 } |
| 347 | 438 |
| 439 /** |
| 440 * hb_font_get_glyph_h_advance: |
| 441 * @font: a font. |
| 442 * @glyph: |
| 443 * |
| 444 * |
| 445 * |
| 446 * Return value: |
| 447 * |
| 448 * Since: 1.0 |
| 449 **/ |
| 348 hb_position_t | 450 hb_position_t |
| 349 hb_font_get_glyph_h_advance (hb_font_t *font, | 451 hb_font_get_glyph_h_advance (hb_font_t *font, |
| 350 hb_codepoint_t glyph) | 452 hb_codepoint_t glyph) |
| 351 { | 453 { |
| 352 return font->get_glyph_h_advance (glyph); | 454 return font->get_glyph_h_advance (glyph); |
| 353 } | 455 } |
| 354 | 456 |
| 457 /** |
| 458 * hb_font_get_glyph_v_advance: |
| 459 * @font: a font. |
| 460 * @glyph: |
| 461 * |
| 462 * |
| 463 * |
| 464 * Return value: |
| 465 * |
| 466 * Since: 1.0 |
| 467 **/ |
| 355 hb_position_t | 468 hb_position_t |
| 356 hb_font_get_glyph_v_advance (hb_font_t *font, | 469 hb_font_get_glyph_v_advance (hb_font_t *font, |
| 357 hb_codepoint_t glyph) | 470 hb_codepoint_t glyph) |
| 358 { | 471 { |
| 359 return font->get_glyph_v_advance (glyph); | 472 return font->get_glyph_v_advance (glyph); |
| 360 } | 473 } |
| 361 | 474 |
| 475 /** |
| 476 * hb_font_get_glyph_h_origin: |
| 477 * @font: a font. |
| 478 * @glyph: |
| 479 * @x: (out): |
| 480 * @y: (out): |
| 481 * |
| 482 * |
| 483 * |
| 484 * Return value: |
| 485 * |
| 486 * Since: 1.0 |
| 487 **/ |
| 362 hb_bool_t | 488 hb_bool_t |
| 363 hb_font_get_glyph_h_origin (hb_font_t *font, | 489 hb_font_get_glyph_h_origin (hb_font_t *font, |
| 364 hb_codepoint_t glyph, | 490 hb_codepoint_t glyph, |
| 365 hb_position_t *x, hb_position_t *y) | 491 hb_position_t *x, hb_position_t *y) |
| 366 { | 492 { |
| 367 return font->get_glyph_h_origin (glyph, x, y); | 493 return font->get_glyph_h_origin (glyph, x, y); |
| 368 } | 494 } |
| 369 | 495 |
| 496 /** |
| 497 * hb_font_get_glyph_v_origin: |
| 498 * @font: a font. |
| 499 * @glyph: |
| 500 * @x: (out): |
| 501 * @y: (out): |
| 502 * |
| 503 * |
| 504 * |
| 505 * Return value: |
| 506 * |
| 507 * Since: 1.0 |
| 508 **/ |
| 370 hb_bool_t | 509 hb_bool_t |
| 371 hb_font_get_glyph_v_origin (hb_font_t *font, | 510 hb_font_get_glyph_v_origin (hb_font_t *font, |
| 372 hb_codepoint_t glyph, | 511 hb_codepoint_t glyph, |
| 373 hb_position_t *x, hb_position_t *y) | 512 hb_position_t *x, hb_position_t *y) |
| 374 { | 513 { |
| 375 return font->get_glyph_v_origin (glyph, x, y); | 514 return font->get_glyph_v_origin (glyph, x, y); |
| 376 } | 515 } |
| 377 | 516 |
| 517 /** |
| 518 * hb_font_get_glyph_h_kerning: |
| 519 * @font: a font. |
| 520 * @left_glyph: |
| 521 * @right_glyph: |
| 522 * |
| 523 * |
| 524 * |
| 525 * Return value: |
| 526 * |
| 527 * Since: 1.0 |
| 528 **/ |
| 378 hb_position_t | 529 hb_position_t |
| 379 hb_font_get_glyph_h_kerning (hb_font_t *font, | 530 hb_font_get_glyph_h_kerning (hb_font_t *font, |
| 380 hb_codepoint_t left_glyph, hb_codepoint_t right_gly
ph) | 531 hb_codepoint_t left_glyph, hb_codepoint_t right_gly
ph) |
| 381 { | 532 { |
| 382 return font->get_glyph_h_kerning (left_glyph, right_glyph); | 533 return font->get_glyph_h_kerning (left_glyph, right_glyph); |
| 383 } | 534 } |
| 384 | 535 |
| 536 /** |
| 537 * hb_font_get_glyph_v_kerning: |
| 538 * @font: a font. |
| 539 * @top_glyph: |
| 540 * @bottom_glyph: |
| 541 * |
| 542 * |
| 543 * |
| 544 * Return value: |
| 545 * |
| 546 * Since: 1.0 |
| 547 **/ |
| 385 hb_position_t | 548 hb_position_t |
| 386 hb_font_get_glyph_v_kerning (hb_font_t *font, | 549 hb_font_get_glyph_v_kerning (hb_font_t *font, |
| 387 » » » hb_codepoint_t left_glyph, hb_codepoint_t right_gly
ph) | 550 » » » hb_codepoint_t top_glyph, hb_codepoint_t bottom_gly
ph) |
| 388 { | 551 { |
| 389 return font->get_glyph_v_kerning (left_glyph, right_glyph); | 552 return font->get_glyph_v_kerning (top_glyph, bottom_glyph); |
| 390 } | 553 } |
| 391 | 554 |
| 555 /** |
| 556 * hb_font_get_glyph_extents: |
| 557 * @font: a font. |
| 558 * @glyph: |
| 559 * @extents: (out): |
| 560 * |
| 561 * |
| 562 * |
| 563 * Return value: |
| 564 * |
| 565 * Since: 1.0 |
| 566 **/ |
| 392 hb_bool_t | 567 hb_bool_t |
| 393 hb_font_get_glyph_extents (hb_font_t *font, | 568 hb_font_get_glyph_extents (hb_font_t *font, |
| 394 hb_codepoint_t glyph, | 569 hb_codepoint_t glyph, |
| 395 hb_glyph_extents_t *extents) | 570 hb_glyph_extents_t *extents) |
| 396 { | 571 { |
| 397 return font->get_glyph_extents (glyph, extents); | 572 return font->get_glyph_extents (glyph, extents); |
| 398 } | 573 } |
| 399 | 574 |
| 575 /** |
| 576 * hb_font_get_glyph_contour_point: |
| 577 * @font: a font. |
| 578 * @glyph: |
| 579 * @point_index: |
| 580 * @x: (out): |
| 581 * @y: (out): |
| 582 * |
| 583 * |
| 584 * |
| 585 * Return value: |
| 586 * |
| 587 * Since: 1.0 |
| 588 **/ |
| 400 hb_bool_t | 589 hb_bool_t |
| 401 hb_font_get_glyph_contour_point (hb_font_t *font, | 590 hb_font_get_glyph_contour_point (hb_font_t *font, |
| 402 hb_codepoint_t glyph, unsigned int point_index, | 591 hb_codepoint_t glyph, unsigned int point_index, |
| 403 hb_position_t *x, hb_position_t *y) | 592 hb_position_t *x, hb_position_t *y) |
| 404 { | 593 { |
| 405 return font->get_glyph_contour_point (glyph, point_index, x, y); | 594 return font->get_glyph_contour_point (glyph, point_index, x, y); |
| 406 } | 595 } |
| 407 | 596 |
| 597 /** |
| 598 * hb_font_get_glyph_name: |
| 599 * @font: a font. |
| 600 * @glyph: |
| 601 * @name: (array length=size): |
| 602 * @size: |
| 603 * |
| 604 * |
| 605 * |
| 606 * Return value: |
| 607 * |
| 608 * Since: 1.0 |
| 609 **/ |
| 408 hb_bool_t | 610 hb_bool_t |
| 409 hb_font_get_glyph_name (hb_font_t *font, | 611 hb_font_get_glyph_name (hb_font_t *font, |
| 410 hb_codepoint_t glyph, | 612 hb_codepoint_t glyph, |
| 411 char *name, unsigned int size) | 613 char *name, unsigned int size) |
| 412 { | 614 { |
| 413 return font->get_glyph_name (glyph, name, size); | 615 return font->get_glyph_name (glyph, name, size); |
| 414 } | 616 } |
| 415 | 617 |
| 618 /** |
| 619 * hb_font_get_glyph_from_name: |
| 620 * @font: a font. |
| 621 * @name: (array length=len): |
| 622 * @len: |
| 623 * @glyph: (out): |
| 624 * |
| 625 * |
| 626 * |
| 627 * Return value: |
| 628 * |
| 629 * Since: 1.0 |
| 630 **/ |
| 416 hb_bool_t | 631 hb_bool_t |
| 417 hb_font_get_glyph_from_name (hb_font_t *font, | 632 hb_font_get_glyph_from_name (hb_font_t *font, |
| 418 const char *name, int len, /* -1 means nul-terminat
ed */ | 633 const char *name, int len, /* -1 means nul-terminat
ed */ |
| 419 hb_codepoint_t *glyph) | 634 hb_codepoint_t *glyph) |
| 420 { | 635 { |
| 421 return font->get_glyph_from_name (name, len, glyph); | 636 return font->get_glyph_from_name (name, len, glyph); |
| 422 } | 637 } |
| 423 | 638 |
| 424 | 639 |
| 425 /* A bit higher-level, and with fallback */ | 640 /* A bit higher-level, and with fallback */ |
| 426 | 641 |
| 642 /** |
| 643 * hb_font_get_glyph_advance_for_direction: |
| 644 * @font: a font. |
| 645 * @glyph: |
| 646 * @direction: |
| 647 * @x: (out): |
| 648 * @y: (out): |
| 649 * |
| 650 * |
| 651 * |
| 652 * Since: 1.0 |
| 653 **/ |
| 427 void | 654 void |
| 428 hb_font_get_glyph_advance_for_direction (hb_font_t *font, | 655 hb_font_get_glyph_advance_for_direction (hb_font_t *font, |
| 429 hb_codepoint_t glyph, | 656 hb_codepoint_t glyph, |
| 430 hb_direction_t direction, | 657 hb_direction_t direction, |
| 431 hb_position_t *x, hb_position_t *y) | 658 hb_position_t *x, hb_position_t *y) |
| 432 { | 659 { |
| 433 return font->get_glyph_advance_for_direction (glyph, direction, x, y); | 660 return font->get_glyph_advance_for_direction (glyph, direction, x, y); |
| 434 } | 661 } |
| 435 | 662 |
| 663 /** |
| 664 * hb_font_get_glyph_origin_for_direction: |
| 665 * @font: a font. |
| 666 * @glyph: |
| 667 * @direction: |
| 668 * @x: (out): |
| 669 * @y: (out): |
| 670 * |
| 671 * |
| 672 * |
| 673 * Since: 1.0 |
| 674 **/ |
| 436 void | 675 void |
| 437 hb_font_get_glyph_origin_for_direction (hb_font_t *font, | 676 hb_font_get_glyph_origin_for_direction (hb_font_t *font, |
| 438 hb_codepoint_t glyph, | 677 hb_codepoint_t glyph, |
| 439 hb_direction_t direction, | 678 hb_direction_t direction, |
| 440 hb_position_t *x, hb_position_t *y) | 679 hb_position_t *x, hb_position_t *y) |
| 441 { | 680 { |
| 442 return font->get_glyph_origin_for_direction (glyph, direction, x, y); | 681 return font->get_glyph_origin_for_direction (glyph, direction, x, y); |
| 443 } | 682 } |
| 444 | 683 |
| 684 /** |
| 685 * hb_font_add_glyph_origin_for_direction: |
| 686 * @font: a font. |
| 687 * @glyph: |
| 688 * @direction: |
| 689 * @x: (out): |
| 690 * @y: (out): |
| 691 * |
| 692 * |
| 693 * |
| 694 * Since: 1.0 |
| 695 **/ |
| 445 void | 696 void |
| 446 hb_font_add_glyph_origin_for_direction (hb_font_t *font, | 697 hb_font_add_glyph_origin_for_direction (hb_font_t *font, |
| 447 hb_codepoint_t glyph, | 698 hb_codepoint_t glyph, |
| 448 hb_direction_t direction, | 699 hb_direction_t direction, |
| 449 hb_position_t *x, hb_position_t *y) | 700 hb_position_t *x, hb_position_t *y) |
| 450 { | 701 { |
| 451 return font->add_glyph_origin_for_direction (glyph, direction, x, y); | 702 return font->add_glyph_origin_for_direction (glyph, direction, x, y); |
| 452 } | 703 } |
| 453 | 704 |
| 705 /** |
| 706 * hb_font_subtract_glyph_origin_for_direction: |
| 707 * @font: a font. |
| 708 * @glyph: |
| 709 * @direction: |
| 710 * @x: (out): |
| 711 * @y: (out): |
| 712 * |
| 713 * |
| 714 * |
| 715 * Since: 1.0 |
| 716 **/ |
| 454 void | 717 void |
| 455 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, | 718 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, |
| 456 hb_codepoint_t glyph, | 719 hb_codepoint_t glyph, |
| 457 hb_direction_t direction, | 720 hb_direction_t direction, |
| 458 hb_position_t *x, hb_position_t *y) | 721 hb_position_t *x, hb_position_t *y) |
| 459 { | 722 { |
| 460 return font->subtract_glyph_origin_for_direction (glyph, direction, x, y); | 723 return font->subtract_glyph_origin_for_direction (glyph, direction, x, y); |
| 461 } | 724 } |
| 462 | 725 |
| 726 /** |
| 727 * hb_font_get_glyph_kerning_for_direction: |
| 728 * @font: a font. |
| 729 * @first_glyph: |
| 730 * @second_glyph: |
| 731 * @direction: |
| 732 * @x: (out): |
| 733 * @y: (out): |
| 734 * |
| 735 * |
| 736 * |
| 737 * Since: 1.0 |
| 738 **/ |
| 463 void | 739 void |
| 464 hb_font_get_glyph_kerning_for_direction (hb_font_t *font, | 740 hb_font_get_glyph_kerning_for_direction (hb_font_t *font, |
| 465 hb_codepoint_t first_glyph, hb_codepoin
t_t second_glyph, | 741 hb_codepoint_t first_glyph, hb_codepoin
t_t second_glyph, |
| 466 hb_direction_t direction, | 742 hb_direction_t direction, |
| 467 hb_position_t *x, hb_position_t *y) | 743 hb_position_t *x, hb_position_t *y) |
| 468 { | 744 { |
| 469 return font->get_glyph_kerning_for_direction (first_glyph, second_glyph, direc
tion, x, y); | 745 return font->get_glyph_kerning_for_direction (first_glyph, second_glyph, direc
tion, x, y); |
| 470 } | 746 } |
| 471 | 747 |
| 748 /** |
| 749 * hb_font_get_glyph_extents_for_origin: |
| 750 * @font: a font. |
| 751 * @glyph: |
| 752 * @direction: |
| 753 * @extents: (out): |
| 754 * |
| 755 * |
| 756 * |
| 757 * Return value: |
| 758 * |
| 759 * Since: 1.0 |
| 760 **/ |
| 472 hb_bool_t | 761 hb_bool_t |
| 473 hb_font_get_glyph_extents_for_origin (hb_font_t *font, | 762 hb_font_get_glyph_extents_for_origin (hb_font_t *font, |
| 474 hb_codepoint_t glyph, | 763 hb_codepoint_t glyph, |
| 475 hb_direction_t direction, | 764 hb_direction_t direction, |
| 476 hb_glyph_extents_t *extents) | 765 hb_glyph_extents_t *extents) |
| 477 { | 766 { |
| 478 return font->get_glyph_extents_for_origin (glyph, direction, extents); | 767 return font->get_glyph_extents_for_origin (glyph, direction, extents); |
| 479 } | 768 } |
| 480 | 769 |
| 770 /** |
| 771 * hb_font_get_glyph_contour_point_for_origin: |
| 772 * @font: a font. |
| 773 * @glyph: |
| 774 * @point_index: |
| 775 * @direction: |
| 776 * @x: (out): |
| 777 * @y: (out): |
| 778 * |
| 779 * |
| 780 * |
| 781 * Return value: |
| 782 * |
| 783 * Since: 1.0 |
| 784 **/ |
| 481 hb_bool_t | 785 hb_bool_t |
| 482 hb_font_get_glyph_contour_point_for_origin (hb_font_t *font, | 786 hb_font_get_glyph_contour_point_for_origin (hb_font_t *font, |
| 483 hb_codepoint_t glyph, unsigned int p
oint_index, | 787 hb_codepoint_t glyph, unsigned int p
oint_index, |
| 484 hb_direction_t direction, | 788 hb_direction_t direction, |
| 485 hb_position_t *x, hb_position_t *y) | 789 hb_position_t *x, hb_position_t *y) |
| 486 { | 790 { |
| 487 return font->get_glyph_contour_point_for_origin (glyph, point_index, direction
, x, y); | 791 return font->get_glyph_contour_point_for_origin (glyph, point_index, direction
, x, y); |
| 488 } | 792 } |
| 489 | 793 |
| 490 /* Generates gidDDD if glyph has no name. */ | 794 /* Generates gidDDD if glyph has no name. */ |
| 795 /** |
| 796 * hb_font_glyph_to_string: |
| 797 * @font: a font. |
| 798 * @glyph: |
| 799 * @s: (array length=size): |
| 800 * @size: |
| 801 * |
| 802 * |
| 803 * |
| 804 * Since: 1.0 |
| 805 **/ |
| 491 void | 806 void |
| 492 hb_font_glyph_to_string (hb_font_t *font, | 807 hb_font_glyph_to_string (hb_font_t *font, |
| 493 hb_codepoint_t glyph, | 808 hb_codepoint_t glyph, |
| 494 char *s, unsigned int size) | 809 char *s, unsigned int size) |
| 495 { | 810 { |
| 496 font->glyph_to_string (glyph, s, size); | 811 font->glyph_to_string (glyph, s, size); |
| 497 } | 812 } |
| 498 | 813 |
| 499 /* Parses gidDDD and uniUUUU strings automatically. */ | 814 /* Parses gidDDD and uniUUUU strings automatically. */ |
| 815 /** |
| 816 * hb_font_glyph_from_string: |
| 817 * @font: a font. |
| 818 * @s: (array length=len): |
| 819 * @len: |
| 820 * @glyph: (out): |
| 821 * |
| 822 * |
| 823 * |
| 824 * Return value: |
| 825 * |
| 826 * Since: 1.0 |
| 827 **/ |
| 500 hb_bool_t | 828 hb_bool_t |
| 501 hb_font_glyph_from_string (hb_font_t *font, | 829 hb_font_glyph_from_string (hb_font_t *font, |
| 502 const char *s, int len, /* -1 means nul-terminated */ | 830 const char *s, int len, /* -1 means nul-terminated */ |
| 503 hb_codepoint_t *glyph) | 831 hb_codepoint_t *glyph) |
| 504 { | 832 { |
| 505 return font->glyph_from_string (s, len, glyph); | 833 return font->glyph_from_string (s, len, glyph); |
| 506 } | 834 } |
| 507 | 835 |
| 508 | 836 |
| 509 /* | 837 /* |
| 510 * hb_face_t | |
| 511 */ | |
| 512 | |
| 513 static const hb_face_t _hb_face_nil = { | |
| 514 HB_OBJECT_HEADER_STATIC, | |
| 515 | |
| 516 true, /* immutable */ | |
| 517 | |
| 518 NULL, /* reference_table_func */ | |
| 519 NULL, /* user_data */ | |
| 520 NULL, /* destroy */ | |
| 521 | |
| 522 0, /* index */ | |
| 523 1000, /* upem */ | |
| 524 0, /* num_glyphs */ | |
| 525 | |
| 526 { | |
| 527 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, | |
| 528 #include "hb-shaper-list.hh" | |
| 529 #undef HB_SHAPER_IMPLEMENT | |
| 530 }, | |
| 531 | |
| 532 NULL, /* shape_plans */ | |
| 533 }; | |
| 534 | |
| 535 | |
| 536 hb_face_t * | |
| 537 hb_face_create_for_tables (hb_reference_table_func_t reference_table_func, | |
| 538 void *user_data, | |
| 539 hb_destroy_func_t destroy) | |
| 540 { | |
| 541 hb_face_t *face; | |
| 542 | |
| 543 if (!reference_table_func || !(face = hb_object_create<hb_face_t> ())) { | |
| 544 if (destroy) | |
| 545 destroy (user_data); | |
| 546 return hb_face_get_empty (); | |
| 547 } | |
| 548 | |
| 549 face->reference_table_func = reference_table_func; | |
| 550 face->user_data = user_data; | |
| 551 face->destroy = destroy; | |
| 552 | |
| 553 face->upem = 0; | |
| 554 face->num_glyphs = (unsigned int) -1; | |
| 555 | |
| 556 return face; | |
| 557 } | |
| 558 | |
| 559 | |
| 560 typedef struct hb_face_for_data_closure_t { | |
| 561 hb_blob_t *blob; | |
| 562 unsigned int index; | |
| 563 } hb_face_for_data_closure_t; | |
| 564 | |
| 565 static hb_face_for_data_closure_t * | |
| 566 _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index) | |
| 567 { | |
| 568 hb_face_for_data_closure_t *closure; | |
| 569 | |
| 570 closure = (hb_face_for_data_closure_t *) malloc (sizeof (hb_face_for_data_clos
ure_t)); | |
| 571 if (unlikely (!closure)) | |
| 572 return NULL; | |
| 573 | |
| 574 closure->blob = blob; | |
| 575 closure->index = index; | |
| 576 | |
| 577 return closure; | |
| 578 } | |
| 579 | |
| 580 static void | |
| 581 _hb_face_for_data_closure_destroy (hb_face_for_data_closure_t *closure) | |
| 582 { | |
| 583 hb_blob_destroy (closure->blob); | |
| 584 free (closure); | |
| 585 } | |
| 586 | |
| 587 static hb_blob_t * | |
| 588 _hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void
*user_data) | |
| 589 { | |
| 590 hb_face_for_data_closure_t *data = (hb_face_for_data_closure_t *) user_data; | |
| 591 | |
| 592 if (tag == HB_TAG_NONE) | |
| 593 return hb_blob_reference (data->blob); | |
| 594 | |
| 595 const OT::OpenTypeFontFile &ot_file = *OT::Sanitizer<OT::OpenTypeFontFile>::lo
ck_instance (data->blob); | |
| 596 const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index); | |
| 597 | |
| 598 const OT::OpenTypeTable &table = ot_face.get_table_by_tag (tag); | |
| 599 | |
| 600 hb_blob_t *blob = hb_blob_create_sub_blob (data->blob, table.offset, table.len
gth); | |
| 601 | |
| 602 return blob; | |
| 603 } | |
| 604 | |
| 605 hb_face_t * | |
| 606 hb_face_create (hb_blob_t *blob, | |
| 607 unsigned int index) | |
| 608 { | |
| 609 hb_face_t *face; | |
| 610 | |
| 611 if (unlikely (!blob || !hb_blob_get_length (blob))) | |
| 612 return hb_face_get_empty (); | |
| 613 | |
| 614 hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (OT::Sa
nitizer<OT::OpenTypeFontFile>::sanitize (hb_blob_reference (blob)), index); | |
| 615 | |
| 616 if (unlikely (!closure)) | |
| 617 return hb_face_get_empty (); | |
| 618 | |
| 619 face = hb_face_create_for_tables (_hb_face_for_data_reference_table, | |
| 620 closure, | |
| 621 (hb_destroy_func_t) _hb_face_for_data_closur
e_destroy); | |
| 622 | |
| 623 hb_face_set_index (face, index); | |
| 624 | |
| 625 return face; | |
| 626 } | |
| 627 | |
| 628 hb_face_t * | |
| 629 hb_face_get_empty (void) | |
| 630 { | |
| 631 return const_cast<hb_face_t *> (&_hb_face_nil); | |
| 632 } | |
| 633 | |
| 634 | |
| 635 hb_face_t * | |
| 636 hb_face_reference (hb_face_t *face) | |
| 637 { | |
| 638 return hb_object_reference (face); | |
| 639 } | |
| 640 | |
| 641 void | |
| 642 hb_face_destroy (hb_face_t *face) | |
| 643 { | |
| 644 if (!hb_object_destroy (face)) return; | |
| 645 | |
| 646 for (hb_face_t::plan_node_t *node = face->shape_plans; node; ) | |
| 647 { | |
| 648 hb_face_t::plan_node_t *next = node->next; | |
| 649 hb_shape_plan_destroy (node->shape_plan); | |
| 650 free (node); | |
| 651 node = next; | |
| 652 } | |
| 653 | |
| 654 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, face); | |
| 655 #include "hb-shaper-list.hh" | |
| 656 #undef HB_SHAPER_IMPLEMENT | |
| 657 | |
| 658 if (face->destroy) | |
| 659 face->destroy (face->user_data); | |
| 660 | |
| 661 free (face); | |
| 662 } | |
| 663 | |
| 664 hb_bool_t | |
| 665 hb_face_set_user_data (hb_face_t *face, | |
| 666 hb_user_data_key_t *key, | |
| 667 void * data, | |
| 668 hb_destroy_func_t destroy, | |
| 669 hb_bool_t replace) | |
| 670 { | |
| 671 return hb_object_set_user_data (face, key, data, destroy, replace); | |
| 672 } | |
| 673 | |
| 674 void * | |
| 675 hb_face_get_user_data (hb_face_t *face, | |
| 676 hb_user_data_key_t *key) | |
| 677 { | |
| 678 return hb_object_get_user_data (face, key); | |
| 679 } | |
| 680 | |
| 681 void | |
| 682 hb_face_make_immutable (hb_face_t *face) | |
| 683 { | |
| 684 if (hb_object_is_inert (face)) | |
| 685 return; | |
| 686 | |
| 687 face->immutable = true; | |
| 688 } | |
| 689 | |
| 690 hb_bool_t | |
| 691 hb_face_is_immutable (hb_face_t *face) | |
| 692 { | |
| 693 return face->immutable; | |
| 694 } | |
| 695 | |
| 696 | |
| 697 hb_blob_t * | |
| 698 hb_face_reference_table (hb_face_t *face, | |
| 699 hb_tag_t tag) | |
| 700 { | |
| 701 return face->reference_table (tag); | |
| 702 } | |
| 703 | |
| 704 hb_blob_t * | |
| 705 hb_face_reference_blob (hb_face_t *face) | |
| 706 { | |
| 707 return face->reference_table (HB_TAG_NONE); | |
| 708 } | |
| 709 | |
| 710 void | |
| 711 hb_face_set_index (hb_face_t *face, | |
| 712 unsigned int index) | |
| 713 { | |
| 714 if (hb_object_is_inert (face)) | |
| 715 return; | |
| 716 | |
| 717 face->index = index; | |
| 718 } | |
| 719 | |
| 720 unsigned int | |
| 721 hb_face_get_index (hb_face_t *face) | |
| 722 { | |
| 723 return face->index; | |
| 724 } | |
| 725 | |
| 726 void | |
| 727 hb_face_set_upem (hb_face_t *face, | |
| 728 unsigned int upem) | |
| 729 { | |
| 730 if (hb_object_is_inert (face)) | |
| 731 return; | |
| 732 | |
| 733 face->upem = upem; | |
| 734 } | |
| 735 | |
| 736 unsigned int | |
| 737 hb_face_get_upem (hb_face_t *face) | |
| 738 { | |
| 739 return face->get_upem (); | |
| 740 } | |
| 741 | |
| 742 void | |
| 743 hb_face_t::load_upem (void) const | |
| 744 { | |
| 745 hb_blob_t *head_blob = OT::Sanitizer<OT::head>::sanitize (reference_table (HB_
OT_TAG_head)); | |
| 746 const OT::head *head_table = OT::Sanitizer<OT::head>::lock_instance (head_blob
); | |
| 747 upem = head_table->get_upem (); | |
| 748 hb_blob_destroy (head_blob); | |
| 749 } | |
| 750 | |
| 751 void | |
| 752 hb_face_set_glyph_count (hb_face_t *face, | |
| 753 unsigned int glyph_count) | |
| 754 { | |
| 755 if (hb_object_is_inert (face)) | |
| 756 return; | |
| 757 | |
| 758 face->num_glyphs = glyph_count; | |
| 759 } | |
| 760 | |
| 761 unsigned int | |
| 762 hb_face_get_glyph_count (hb_face_t *face) | |
| 763 { | |
| 764 return face->get_num_glyphs (); | |
| 765 } | |
| 766 | |
| 767 void | |
| 768 hb_face_t::load_num_glyphs (void) const | |
| 769 { | |
| 770 hb_blob_t *maxp_blob = OT::Sanitizer<OT::maxp>::sanitize (reference_table (HB_
OT_TAG_maxp)); | |
| 771 const OT::maxp *maxp_table = OT::Sanitizer<OT::maxp>::lock_instance (maxp_blob
); | |
| 772 num_glyphs = maxp_table->get_num_glyphs (); | |
| 773 hb_blob_destroy (maxp_blob); | |
| 774 } | |
| 775 | |
| 776 | |
| 777 /* | |
| 778 * hb_font_t | 838 * hb_font_t |
| 779 */ | 839 */ |
| 780 | 840 |
| 841 /** |
| 842 * hb_font_create: (Xconstructor) |
| 843 * @face: a face. |
| 844 * |
| 845 * |
| 846 * |
| 847 * Return value: (transfer full): |
| 848 * |
| 849 * Since: 1.0 |
| 850 **/ |
| 781 hb_font_t * | 851 hb_font_t * |
| 782 hb_font_create (hb_face_t *face) | 852 hb_font_create (hb_face_t *face) |
| 783 { | 853 { |
| 784 hb_font_t *font; | 854 hb_font_t *font; |
| 785 | 855 |
| 786 if (unlikely (!face)) | 856 if (unlikely (!face)) |
| 787 face = hb_face_get_empty (); | 857 face = hb_face_get_empty (); |
| 788 if (unlikely (hb_object_is_inert (face))) | 858 if (unlikely (hb_object_is_inert (face))) |
| 789 return hb_font_get_empty (); | 859 return hb_font_get_empty (); |
| 790 if (!(font = hb_object_create<hb_font_t> ())) | 860 if (!(font = hb_object_create<hb_font_t> ())) |
| 791 return hb_font_get_empty (); | 861 return hb_font_get_empty (); |
| 792 | 862 |
| 793 hb_face_make_immutable (face); | 863 hb_face_make_immutable (face); |
| 794 font->face = hb_face_reference (face); | 864 font->face = hb_face_reference (face); |
| 795 font->klass = hb_font_funcs_get_empty (); | 865 font->klass = hb_font_funcs_get_empty (); |
| 796 | 866 |
| 797 return font; | 867 return font; |
| 798 } | 868 } |
| 799 | 869 |
| 870 /** |
| 871 * hb_font_create_sub_font: |
| 872 * @parent: parent font. |
| 873 * |
| 874 * |
| 875 * |
| 876 * Return value: (transfer full): |
| 877 * |
| 878 * Since: 1.0 |
| 879 **/ |
| 800 hb_font_t * | 880 hb_font_t * |
| 801 hb_font_create_sub_font (hb_font_t *parent) | 881 hb_font_create_sub_font (hb_font_t *parent) |
| 802 { | 882 { |
| 803 if (unlikely (!parent)) | 883 if (unlikely (!parent)) |
| 804 return hb_font_get_empty (); | 884 return hb_font_get_empty (); |
| 805 | 885 |
| 806 hb_font_t *font = hb_font_create (parent->face); | 886 hb_font_t *font = hb_font_create (parent->face); |
| 807 | 887 |
| 808 if (unlikely (hb_object_is_inert (font))) | 888 if (unlikely (hb_object_is_inert (font))) |
| 809 return font; | 889 return font; |
| 810 | 890 |
| 811 hb_font_make_immutable (parent); | 891 hb_font_make_immutable (parent); |
| 812 font->parent = hb_font_reference (parent); | 892 font->parent = hb_font_reference (parent); |
| 813 | 893 |
| 814 font->x_scale = parent->x_scale; | 894 font->x_scale = parent->x_scale; |
| 815 font->y_scale = parent->y_scale; | 895 font->y_scale = parent->y_scale; |
| 816 font->x_ppem = parent->x_ppem; | 896 font->x_ppem = parent->x_ppem; |
| 817 font->y_ppem = parent->y_ppem; | 897 font->y_ppem = parent->y_ppem; |
| 818 | 898 |
| 819 return font; | 899 return font; |
| 820 } | 900 } |
| 821 | 901 |
| 902 /** |
| 903 * hb_font_get_empty: |
| 904 * |
| 905 * |
| 906 * |
| 907 * Return value: (transfer full) |
| 908 * |
| 909 * Since: 1.0 |
| 910 **/ |
| 822 hb_font_t * | 911 hb_font_t * |
| 823 hb_font_get_empty (void) | 912 hb_font_get_empty (void) |
| 824 { | 913 { |
| 825 static const hb_font_t _hb_font_nil = { | 914 static const hb_font_t _hb_font_nil = { |
| 826 HB_OBJECT_HEADER_STATIC, | 915 HB_OBJECT_HEADER_STATIC, |
| 827 | 916 |
| 828 true, /* immutable */ | 917 true, /* immutable */ |
| 829 | 918 |
| 830 NULL, /* parent */ | 919 NULL, /* parent */ |
| 831 const_cast<hb_face_t *> (&_hb_face_nil), | 920 const_cast<hb_face_t *> (&_hb_face_nil), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 843 { | 932 { |
| 844 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, | 933 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, |
| 845 #include "hb-shaper-list.hh" | 934 #include "hb-shaper-list.hh" |
| 846 #undef HB_SHAPER_IMPLEMENT | 935 #undef HB_SHAPER_IMPLEMENT |
| 847 } | 936 } |
| 848 }; | 937 }; |
| 849 | 938 |
| 850 return const_cast<hb_font_t *> (&_hb_font_nil); | 939 return const_cast<hb_font_t *> (&_hb_font_nil); |
| 851 } | 940 } |
| 852 | 941 |
| 942 /** |
| 943 * hb_font_reference: (skip) |
| 944 * @font: a font. |
| 945 * |
| 946 * |
| 947 * |
| 948 * Return value: (transfer full): |
| 949 * |
| 950 * Since: 1.0 |
| 951 **/ |
| 853 hb_font_t * | 952 hb_font_t * |
| 854 hb_font_reference (hb_font_t *font) | 953 hb_font_reference (hb_font_t *font) |
| 855 { | 954 { |
| 856 return hb_object_reference (font); | 955 return hb_object_reference (font); |
| 857 } | 956 } |
| 858 | 957 |
| 958 /** |
| 959 * hb_font_destroy: (skip) |
| 960 * @font: a font. |
| 961 * |
| 962 * |
| 963 * |
| 964 * Since: 1.0 |
| 965 **/ |
| 859 void | 966 void |
| 860 hb_font_destroy (hb_font_t *font) | 967 hb_font_destroy (hb_font_t *font) |
| 861 { | 968 { |
| 862 if (!hb_object_destroy (font)) return; | 969 if (!hb_object_destroy (font)) return; |
| 863 | 970 |
| 864 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, font); | 971 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, font); |
| 865 #include "hb-shaper-list.hh" | 972 #include "hb-shaper-list.hh" |
| 866 #undef HB_SHAPER_IMPLEMENT | 973 #undef HB_SHAPER_IMPLEMENT |
| 867 | 974 |
| 868 if (font->destroy) | 975 if (font->destroy) |
| 869 font->destroy (font->user_data); | 976 font->destroy (font->user_data); |
| 870 | 977 |
| 871 hb_font_destroy (font->parent); | 978 hb_font_destroy (font->parent); |
| 872 hb_face_destroy (font->face); | 979 hb_face_destroy (font->face); |
| 873 hb_font_funcs_destroy (font->klass); | 980 hb_font_funcs_destroy (font->klass); |
| 874 | 981 |
| 875 free (font); | 982 free (font); |
| 876 } | 983 } |
| 877 | 984 |
| 985 /** |
| 986 * hb_font_set_user_data: (skip) |
| 987 * @font: a font. |
| 988 * @key: |
| 989 * @data: |
| 990 * @destroy: |
| 991 * @replace: |
| 992 * |
| 993 * |
| 994 * |
| 995 * Return value: |
| 996 * |
| 997 * Since: 1.0 |
| 998 **/ |
| 878 hb_bool_t | 999 hb_bool_t |
| 879 hb_font_set_user_data (hb_font_t *font, | 1000 hb_font_set_user_data (hb_font_t *font, |
| 880 hb_user_data_key_t *key, | 1001 hb_user_data_key_t *key, |
| 881 void * data, | 1002 void * data, |
| 882 hb_destroy_func_t destroy, | 1003 hb_destroy_func_t destroy, |
| 883 hb_bool_t replace) | 1004 hb_bool_t replace) |
| 884 { | 1005 { |
| 885 return hb_object_set_user_data (font, key, data, destroy, replace); | 1006 return hb_object_set_user_data (font, key, data, destroy, replace); |
| 886 } | 1007 } |
| 887 | 1008 |
| 1009 /** |
| 1010 * hb_font_get_user_data: (skip) |
| 1011 * @font: a font. |
| 1012 * @key: |
| 1013 * |
| 1014 * |
| 1015 * |
| 1016 * Return value: (transfer none): |
| 1017 * |
| 1018 * Since: 1.0 |
| 1019 **/ |
| 888 void * | 1020 void * |
| 889 hb_font_get_user_data (hb_font_t *font, | 1021 hb_font_get_user_data (hb_font_t *font, |
| 890 hb_user_data_key_t *key) | 1022 hb_user_data_key_t *key) |
| 891 { | 1023 { |
| 892 return hb_object_get_user_data (font, key); | 1024 return hb_object_get_user_data (font, key); |
| 893 } | 1025 } |
| 894 | 1026 |
| 1027 /** |
| 1028 * hb_font_make_immutable: |
| 1029 * @font: a font. |
| 1030 * |
| 1031 * |
| 1032 * |
| 1033 * Since: 1.0 |
| 1034 **/ |
| 895 void | 1035 void |
| 896 hb_font_make_immutable (hb_font_t *font) | 1036 hb_font_make_immutable (hb_font_t *font) |
| 897 { | 1037 { |
| 898 if (hb_object_is_inert (font)) | 1038 if (hb_object_is_inert (font)) |
| 899 return; | 1039 return; |
| 900 | 1040 |
| 901 font->immutable = true; | 1041 font->immutable = true; |
| 902 } | 1042 } |
| 903 | 1043 |
| 1044 /** |
| 1045 * hb_font_is_immutable: |
| 1046 * @font: a font. |
| 1047 * |
| 1048 * |
| 1049 * |
| 1050 * Return value: |
| 1051 * |
| 1052 * Since: 1.0 |
| 1053 **/ |
| 904 hb_bool_t | 1054 hb_bool_t |
| 905 hb_font_is_immutable (hb_font_t *font) | 1055 hb_font_is_immutable (hb_font_t *font) |
| 906 { | 1056 { |
| 907 return font->immutable; | 1057 return font->immutable; |
| 908 } | 1058 } |
| 909 | 1059 |
| 1060 /** |
| 1061 * hb_font_get_parent: |
| 1062 * @font: a font. |
| 1063 * |
| 1064 * |
| 1065 * |
| 1066 * Return value: (transfer none): |
| 1067 * |
| 1068 * Since: 1.0 |
| 1069 **/ |
| 910 hb_font_t * | 1070 hb_font_t * |
| 911 hb_font_get_parent (hb_font_t *font) | 1071 hb_font_get_parent (hb_font_t *font) |
| 912 { | 1072 { |
| 913 return font->parent; | 1073 return font->parent; |
| 914 } | 1074 } |
| 915 | 1075 |
| 1076 /** |
| 1077 * hb_font_get_face: |
| 1078 * @font: a font. |
| 1079 * |
| 1080 * |
| 1081 * |
| 1082 * Return value: (transfer none): |
| 1083 * |
| 1084 * Since: 1.0 |
| 1085 **/ |
| 916 hb_face_t * | 1086 hb_face_t * |
| 917 hb_font_get_face (hb_font_t *font) | 1087 hb_font_get_face (hb_font_t *font) |
| 918 { | 1088 { |
| 919 return font->face; | 1089 return font->face; |
| 920 } | 1090 } |
| 921 | 1091 |
| 922 | 1092 |
| 1093 /** |
| 1094 * hb_font_set_funcs: |
| 1095 * @font: a font. |
| 1096 * @klass: (closure font_data) (destroy destroy) (scope notified): |
| 1097 * @font_data: |
| 1098 * @destroy: |
| 1099 * |
| 1100 * |
| 1101 * |
| 1102 * Since: 1.0 |
| 1103 **/ |
| 923 void | 1104 void |
| 924 hb_font_set_funcs (hb_font_t *font, | 1105 hb_font_set_funcs (hb_font_t *font, |
| 925 hb_font_funcs_t *klass, | 1106 hb_font_funcs_t *klass, |
| 926 » » void *user_data, | 1107 » » void *font_data, |
| 927 hb_destroy_func_t destroy) | 1108 hb_destroy_func_t destroy) |
| 928 { | 1109 { |
| 929 if (font->immutable) { | 1110 if (font->immutable) { |
| 930 if (destroy) | 1111 if (destroy) |
| 931 destroy (user_data); | 1112 destroy (font_data); |
| 932 return; | 1113 return; |
| 933 } | 1114 } |
| 934 | 1115 |
| 935 if (font->destroy) | 1116 if (font->destroy) |
| 936 font->destroy (font->user_data); | 1117 font->destroy (font->user_data); |
| 937 | 1118 |
| 938 if (!klass) | 1119 if (!klass) |
| 939 klass = hb_font_funcs_get_empty (); | 1120 klass = hb_font_funcs_get_empty (); |
| 940 | 1121 |
| 941 hb_font_funcs_reference (klass); | 1122 hb_font_funcs_reference (klass); |
| 942 hb_font_funcs_destroy (font->klass); | 1123 hb_font_funcs_destroy (font->klass); |
| 943 font->klass = klass; | 1124 font->klass = klass; |
| 944 font->user_data = user_data; | 1125 font->user_data = font_data; |
| 945 font->destroy = destroy; | 1126 font->destroy = destroy; |
| 946 } | 1127 } |
| 947 | 1128 |
| 1129 /** |
| 1130 * hb_font_set_funcs_data: |
| 1131 * @font: a font. |
| 1132 * @font_data: (destroy destroy) (scope notified): |
| 1133 * @destroy: |
| 1134 * |
| 1135 * |
| 1136 * |
| 1137 * Since: 1.0 |
| 1138 **/ |
| 948 void | 1139 void |
| 949 hb_font_set_funcs_data (hb_font_t *font, | 1140 hb_font_set_funcs_data (hb_font_t *font, |
| 950 » » void *user_data, | 1141 » » void *font_data, |
| 951 hb_destroy_func_t destroy) | 1142 hb_destroy_func_t destroy) |
| 952 { | 1143 { |
| 953 /* Destroy user_data? */ | 1144 /* Destroy user_data? */ |
| 954 if (font->immutable) { | 1145 if (font->immutable) { |
| 955 if (destroy) | 1146 if (destroy) |
| 956 destroy (user_data); | 1147 destroy (font_data); |
| 957 return; | 1148 return; |
| 958 } | 1149 } |
| 959 | 1150 |
| 960 if (font->destroy) | 1151 if (font->destroy) |
| 961 font->destroy (font->user_data); | 1152 font->destroy (font->user_data); |
| 962 | 1153 |
| 963 font->user_data = user_data; | 1154 font->user_data = font_data; |
| 964 font->destroy = destroy; | 1155 font->destroy = destroy; |
| 965 } | 1156 } |
| 966 | 1157 |
| 967 | 1158 |
| 1159 /** |
| 1160 * hb_font_set_scale: |
| 1161 * @font: a font. |
| 1162 * @x_scale: |
| 1163 * @y_scale: |
| 1164 * |
| 1165 * |
| 1166 * |
| 1167 * Since: 1.0 |
| 1168 **/ |
| 968 void | 1169 void |
| 969 hb_font_set_scale (hb_font_t *font, | 1170 hb_font_set_scale (hb_font_t *font, |
| 970 int x_scale, | 1171 int x_scale, |
| 971 int y_scale) | 1172 int y_scale) |
| 972 { | 1173 { |
| 973 if (font->immutable) | 1174 if (font->immutable) |
| 974 return; | 1175 return; |
| 975 | 1176 |
| 976 font->x_scale = x_scale; | 1177 font->x_scale = x_scale; |
| 977 font->y_scale = y_scale; | 1178 font->y_scale = y_scale; |
| 978 } | 1179 } |
| 979 | 1180 |
| 1181 /** |
| 1182 * hb_font_get_scale: |
| 1183 * @font: a font. |
| 1184 * @x_scale: (out): |
| 1185 * @y_scale: (out): |
| 1186 * |
| 1187 * |
| 1188 * |
| 1189 * Since: 1.0 |
| 1190 **/ |
| 980 void | 1191 void |
| 981 hb_font_get_scale (hb_font_t *font, | 1192 hb_font_get_scale (hb_font_t *font, |
| 982 int *x_scale, | 1193 int *x_scale, |
| 983 int *y_scale) | 1194 int *y_scale) |
| 984 { | 1195 { |
| 985 if (x_scale) *x_scale = font->x_scale; | 1196 if (x_scale) *x_scale = font->x_scale; |
| 986 if (y_scale) *y_scale = font->y_scale; | 1197 if (y_scale) *y_scale = font->y_scale; |
| 987 } | 1198 } |
| 988 | 1199 |
| 1200 /** |
| 1201 * hb_font_set_ppem: |
| 1202 * @font: a font. |
| 1203 * @x_ppem: |
| 1204 * @y_ppem: |
| 1205 * |
| 1206 * |
| 1207 * |
| 1208 * Since: 1.0 |
| 1209 **/ |
| 989 void | 1210 void |
| 990 hb_font_set_ppem (hb_font_t *font, | 1211 hb_font_set_ppem (hb_font_t *font, |
| 991 unsigned int x_ppem, | 1212 unsigned int x_ppem, |
| 992 unsigned int y_ppem) | 1213 unsigned int y_ppem) |
| 993 { | 1214 { |
| 994 if (font->immutable) | 1215 if (font->immutable) |
| 995 return; | 1216 return; |
| 996 | 1217 |
| 997 font->x_ppem = x_ppem; | 1218 font->x_ppem = x_ppem; |
| 998 font->y_ppem = y_ppem; | 1219 font->y_ppem = y_ppem; |
| 999 } | 1220 } |
| 1000 | 1221 |
| 1222 /** |
| 1223 * hb_font_get_ppem: |
| 1224 * @font: a font. |
| 1225 * @x_ppem: (out): |
| 1226 * @y_ppem: (out): |
| 1227 * |
| 1228 * |
| 1229 * |
| 1230 * Since: 1.0 |
| 1231 **/ |
| 1001 void | 1232 void |
| 1002 hb_font_get_ppem (hb_font_t *font, | 1233 hb_font_get_ppem (hb_font_t *font, |
| 1003 unsigned int *x_ppem, | 1234 unsigned int *x_ppem, |
| 1004 unsigned int *y_ppem) | 1235 unsigned int *y_ppem) |
| 1005 { | 1236 { |
| 1006 if (x_ppem) *x_ppem = font->x_ppem; | 1237 if (x_ppem) *x_ppem = font->x_ppem; |
| 1007 if (y_ppem) *y_ppem = font->y_ppem; | 1238 if (y_ppem) *y_ppem = font->y_ppem; |
| 1008 } | 1239 } |
| OLD | NEW |