| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2009,2010 Red Hat, Inc. | 2 * Copyright © 2009,2010 Red Hat, Inc. |
| 3 * Copyright © 2011,2012 Google, Inc. | 3 * Copyright © 2011,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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 if (!first_lang) | 274 if (!first_lang) |
| 275 atexit (free_langs); /* First person registers atexit() callback. */ | 275 atexit (free_langs); /* First person registers atexit() callback. */ |
| 276 #endif | 276 #endif |
| 277 | 277 |
| 278 return lang; | 278 return lang; |
| 279 } | 279 } |
| 280 | 280 |
| 281 | 281 |
| 282 /** | 282 /** |
| 283 * hb_language_from_string: | 283 * hb_language_from_string: |
| 284 * @str: (array length=len) (element-type uint8_t): | 284 * @str: (array length=len) (element-type uint8_t): a string representing |
| 285 * @len: | 285 * ISO 639 language code |
| 286 * @len: length of the @str, or -1 if it is %NULL-terminated. |
| 286 * | 287 * |
| 287 * | 288 * Converts @str representing an ISO 639 language code to the corresponding |
| 289 * #hb_language_t. |
| 288 * | 290 * |
| 289 * Return value: (transfer none): | 291 * Return value: (transfer none): |
| 292 * The #hb_language_t corresponding to the ISO 639 language code. |
| 290 * | 293 * |
| 291 * Since: 0.9.2 | 294 * Since: 0.9.2 |
| 292 **/ | 295 **/ |
| 293 hb_language_t | 296 hb_language_t |
| 294 hb_language_from_string (const char *str, int len) | 297 hb_language_from_string (const char *str, int len) |
| 295 { | 298 { |
| 296 if (!str || !len || !*str) | 299 if (!str || !len || !*str) |
| 297 return HB_LANGUAGE_INVALID; | 300 return HB_LANGUAGE_INVALID; |
| 298 | 301 |
| 299 hb_language_item_t *item = NULL; | 302 hb_language_item_t *item = NULL; |
| 300 if (len >= 0) | 303 if (len >= 0) |
| 301 { | 304 { |
| 302 /* NUL-terminate it. */ | 305 /* NUL-terminate it. */ |
| 303 char strbuf[64]; | 306 char strbuf[64]; |
| 304 len = MIN (len, (int) sizeof (strbuf) - 1); | 307 len = MIN (len, (int) sizeof (strbuf) - 1); |
| 305 memcpy (strbuf, str, len); | 308 memcpy (strbuf, str, len); |
| 306 strbuf[len] = '\0'; | 309 strbuf[len] = '\0'; |
| 307 item = lang_find_or_insert (strbuf); | 310 item = lang_find_or_insert (strbuf); |
| 308 } | 311 } |
| 309 else | 312 else |
| 310 item = lang_find_or_insert (str); | 313 item = lang_find_or_insert (str); |
| 311 | 314 |
| 312 return likely (item) ? item->lang : HB_LANGUAGE_INVALID; | 315 return likely (item) ? item->lang : HB_LANGUAGE_INVALID; |
| 313 } | 316 } |
| 314 | 317 |
| 315 /** | 318 /** |
| 316 * hb_language_to_string: | 319 * hb_language_to_string: |
| 317 * @language: | 320 * @language: an #hb_language_t to convert. |
| 318 * | 321 * |
| 319 * | 322 * See hb_language_from_string(). |
| 320 * | 323 * |
| 321 * Return value: (transfer none): | 324 * Return value: (transfer none): |
| 325 * A %NULL-terminated string representing the @language. Must not be freed by |
| 326 * the caller. |
| 322 * | 327 * |
| 323 * Since: 0.9.2 | 328 * Since: 0.9.2 |
| 324 **/ | 329 **/ |
| 325 const char * | 330 const char * |
| 326 hb_language_to_string (hb_language_t language) | 331 hb_language_to_string (hb_language_t language) |
| 327 { | 332 { |
| 328 /* This is actually NULL-safe! */ | 333 /* This is actually NULL-safe! */ |
| 329 return language->s; | 334 return language->s; |
| 330 } | 335 } |
| 331 | 336 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 350 } | 355 } |
| 351 | 356 |
| 352 return default_language; | 357 return default_language; |
| 353 } | 358 } |
| 354 | 359 |
| 355 | 360 |
| 356 /* hb_script_t */ | 361 /* hb_script_t */ |
| 357 | 362 |
| 358 /** | 363 /** |
| 359 * hb_script_from_iso15924_tag: | 364 * hb_script_from_iso15924_tag: |
| 360 * @tag: | 365 * @tag: an #hb_tag_t representing an ISO 15924 tag. |
| 361 * | 366 * |
| 362 * | 367 * Converts an ISO 15924 script tag to a corresponding #hb_script_t. |
| 363 * | 368 * |
| 364 * Return value: | 369 * Return value: |
| 370 * An #hb_script_t corresponding to the ISO 15924 tag. |
| 365 * | 371 * |
| 366 * Since: 0.9.2 | 372 * Since: 0.9.2 |
| 367 **/ | 373 **/ |
| 368 hb_script_t | 374 hb_script_t |
| 369 hb_script_from_iso15924_tag (hb_tag_t tag) | 375 hb_script_from_iso15924_tag (hb_tag_t tag) |
| 370 { | 376 { |
| 371 if (unlikely (tag == HB_TAG_NONE)) | 377 if (unlikely (tag == HB_TAG_NONE)) |
| 372 return HB_SCRIPT_INVALID; | 378 return HB_SCRIPT_INVALID; |
| 373 | 379 |
| 374 /* Be lenient, adjust case (one capital letter followed by three small letters
) */ | 380 /* Be lenient, adjust case (one capital letter followed by three small letters
) */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 394 /* If it looks right, just use the tag as a script */ | 400 /* If it looks right, just use the tag as a script */ |
| 395 if (((uint32_t) tag & 0xE0E0E0E0u) == 0x40606060u) | 401 if (((uint32_t) tag & 0xE0E0E0E0u) == 0x40606060u) |
| 396 return (hb_script_t) tag; | 402 return (hb_script_t) tag; |
| 397 | 403 |
| 398 /* Otherwise, return unknown */ | 404 /* Otherwise, return unknown */ |
| 399 return HB_SCRIPT_UNKNOWN; | 405 return HB_SCRIPT_UNKNOWN; |
| 400 } | 406 } |
| 401 | 407 |
| 402 /** | 408 /** |
| 403 * hb_script_from_string: | 409 * hb_script_from_string: |
| 404 * @s: (array length=len) (element-type uint8_t): | 410 * @str: (array length=len) (element-type uint8_t): a string representing an |
| 405 * @len: | 411 * ISO 15924 tag. |
| 412 * @len: length of the @str, or -1 if it is %NULL-terminated. |
| 406 * | 413 * |
| 407 * | 414 * Converts a string @str representing an ISO 15924 script tag to a |
| 415 * corresponding #hb_script_t. Shorthand for hb_tag_from_string() then |
| 416 * hb_script_from_iso15924_tag(). |
| 408 * | 417 * |
| 409 * Return value: | 418 * Return value: |
| 419 * An #hb_script_t corresponding to the ISO 15924 tag. |
| 410 * | 420 * |
| 411 * Since: 0.9.2 | 421 * Since: 0.9.2 |
| 412 **/ | 422 **/ |
| 413 hb_script_t | 423 hb_script_t |
| 414 hb_script_from_string (const char *s, int len) | 424 hb_script_from_string (const char *str, int len) |
| 415 { | 425 { |
| 416 return hb_script_from_iso15924_tag (hb_tag_from_string (s, len)); | 426 return hb_script_from_iso15924_tag (hb_tag_from_string (str, len)); |
| 417 } | 427 } |
| 418 | 428 |
| 419 /** | 429 /** |
| 420 * hb_script_to_iso15924_tag: | 430 * hb_script_to_iso15924_tag: |
| 421 * @script: | 431 * @script: an #hb_script_ to convert. |
| 422 * | 432 * |
| 423 * | 433 * See hb_script_from_iso15924_tag(). |
| 424 * | 434 * |
| 425 * Return value: | 435 * Return value: |
| 436 * An #hb_tag_t representing an ISO 15924 script tag. |
| 426 * | 437 * |
| 427 * Since: 0.9.2 | 438 * Since: 0.9.2 |
| 428 **/ | 439 **/ |
| 429 hb_tag_t | 440 hb_tag_t |
| 430 hb_script_to_iso15924_tag (hb_script_t script) | 441 hb_script_to_iso15924_tag (hb_script_t script) |
| 431 { | 442 { |
| 432 return (hb_tag_t) script; | 443 return (hb_tag_t) script; |
| 433 } | 444 } |
| 434 | 445 |
| 435 /** | 446 /** |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 if (!key) | 525 if (!key) |
| 515 return false; | 526 return false; |
| 516 | 527 |
| 517 if (replace) { | 528 if (replace) { |
| 518 if (!data && !destroy) { | 529 if (!data && !destroy) { |
| 519 items.remove (key, lock); | 530 items.remove (key, lock); |
| 520 return true; | 531 return true; |
| 521 } | 532 } |
| 522 } | 533 } |
| 523 hb_user_data_item_t item = {key, data, destroy}; | 534 hb_user_data_item_t item = {key, data, destroy}; |
| 524 bool ret = !!items.replace_or_insert (item, lock, replace); | 535 bool ret = !!items.replace_or_insert (item, lock, (bool) replace); |
| 525 | 536 |
| 526 return ret; | 537 return ret; |
| 527 } | 538 } |
| 528 | 539 |
| 529 void * | 540 void * |
| 530 hb_user_data_array_t::get (hb_user_data_key_t *key) | 541 hb_user_data_array_t::get (hb_user_data_key_t *key) |
| 531 { | 542 { |
| 532 hb_user_data_item_t item = {NULL }; | 543 hb_user_data_item_t item = {NULL }; |
| 533 | 544 |
| 534 return items.find (key, &item, lock) ? item.data : NULL; | 545 return items.find (key, &item, lock) ? item.data : NULL; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 * | 595 * |
| 585 * Since: 0.9.30 | 596 * Since: 0.9.30 |
| 586 **/ | 597 **/ |
| 587 hb_bool_t | 598 hb_bool_t |
| 588 hb_version_atleast (unsigned int major, | 599 hb_version_atleast (unsigned int major, |
| 589 unsigned int minor, | 600 unsigned int minor, |
| 590 unsigned int micro) | 601 unsigned int micro) |
| 591 { | 602 { |
| 592 return HB_VERSION_ATLEAST (major, minor, micro); | 603 return HB_VERSION_ATLEAST (major, minor, micro); |
| 593 } | 604 } |
| OLD | NEW |