| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 1998-2004 David Turner and Werner Lemberg | 2 * Copyright © 1998-2004 David Turner and Werner Lemberg |
| 3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc. | 3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc. |
| 4 * Copyright © 2011,2012 Google, Inc. | 4 * Copyright © 2011,2012 Google, Inc. |
| 5 * | 5 * |
| 6 * This is part of HarfBuzz, a text shaping library. | 6 * This is part of HarfBuzz, a text shaping library. |
| 7 * | 7 * |
| 8 * Permission is hereby granted, without written agreement and without | 8 * Permission is hereby granted, without written agreement and without |
| 9 * license or royalty fees, to use, copy, modify, and distribute this | 9 * license or royalty fees, to use, copy, modify, and distribute this |
| 10 * software and its documentation for any purpose, provided that the | 10 * software and its documentation for any purpose, provided that the |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "hb-buffer-private.hh" | 30 #include "hb-buffer-private.hh" |
| 31 #include "hb-utf-private.hh" | 31 #include "hb-utf-private.hh" |
| 32 | 32 |
| 33 | 33 |
| 34 #ifndef HB_DEBUG_BUFFER | 34 #ifndef HB_DEBUG_BUFFER |
| 35 #define HB_DEBUG_BUFFER (HB_DEBUG+0) | 35 #define HB_DEBUG_BUFFER (HB_DEBUG+0) |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 /** |
| 39 * SECTION: hb-buffer |
| 40 * @title: Buffers |
| 41 * @short_description: Input and output buffers |
| 42 * @include: hb.h |
| 43 * |
| 44 * Buffers serve dual role in HarfBuzz; they hold the input characters that are |
| 45 * passed hb_shape(), and after shaping they hold the output glyphs. |
| 46 **/ |
| 38 | 47 |
| 39 /** | 48 /** |
| 49 * hb_segment_properties_equal: |
| 50 * @a: first #hb_segment_properties_t to compare. |
| 51 * @b: second #hb_segment_properties_t to compare. |
| 52 * |
| 53 * Checks the equality of two #hb_segment_properties_t's. |
| 54 * |
| 55 * Return value: (transfer full): |
| 56 * %true if all properties of @a equal those of @b, false otherwise. |
| 57 * |
| 40 * Since: 0.9.7 | 58 * Since: 0.9.7 |
| 41 **/ | 59 **/ |
| 42 hb_bool_t | 60 hb_bool_t |
| 43 hb_segment_properties_equal (const hb_segment_properties_t *a, | 61 hb_segment_properties_equal (const hb_segment_properties_t *a, |
| 44 const hb_segment_properties_t *b) | 62 const hb_segment_properties_t *b) |
| 45 { | 63 { |
| 46 return a->direction == b->direction && | 64 return a->direction == b->direction && |
| 47 a->script == b->script && | 65 a->script == b->script && |
| 48 a->language == b->language && | 66 a->language == b->language && |
| 49 a->reserved1 == b->reserved1 && | 67 a->reserved1 == b->reserved1 && |
| 50 a->reserved2 == b->reserved2; | 68 a->reserved2 == b->reserved2; |
| 51 | 69 |
| 52 } | 70 } |
| 53 | 71 |
| 54 /** | 72 /** |
| 73 * hb_segment_properties_hash: |
| 74 * @p: #hb_segment_properties_t to hash. |
| 75 * |
| 76 * Creates a hash representing @p. |
| 77 * |
| 78 * Return value: |
| 79 * A hash of @p. |
| 80 * |
| 55 * Since: 0.9.7 | 81 * Since: 0.9.7 |
| 56 **/ | 82 **/ |
| 57 unsigned int | 83 unsigned int |
| 58 hb_segment_properties_hash (const hb_segment_properties_t *p) | 84 hb_segment_properties_hash (const hb_segment_properties_t *p) |
| 59 { | 85 { |
| 60 return (unsigned int) p->direction ^ | 86 return (unsigned int) p->direction ^ |
| 61 (unsigned int) p->script ^ | 87 (unsigned int) p->script ^ |
| 62 (intptr_t) (p->language); | 88 (intptr_t) (p->language); |
| 63 } | 89 } |
| 64 | 90 |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 { | 725 { |
| 700 memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes)); | 726 memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes)); |
| 701 memset (allocated_var_owner, 0, sizeof (allocated_var_owner)); | 727 memset (allocated_var_owner, 0, sizeof (allocated_var_owner)); |
| 702 } | 728 } |
| 703 | 729 |
| 704 /* Public API */ | 730 /* Public API */ |
| 705 | 731 |
| 706 /** | 732 /** |
| 707 * hb_buffer_create: (Xconstructor) | 733 * hb_buffer_create: (Xconstructor) |
| 708 * | 734 * |
| 709 * | 735 * Creates a new #hb_buffer_t with all properties to defaults. |
| 710 * | 736 * |
| 711 * Return value: (transfer full) | 737 * Return value: (transfer full): |
| 738 * A newly allocated #hb_buffer_t with a reference count of 1. The initial |
| 739 * reference count should be released with hb_buffer_destroy() when you are done |
| 740 * using the #hb_buffer_t. This function never returns %NULL. If memory cannot |
| 741 * be allocated, a special #hb_buffer_t object will be returned on which |
| 742 * hb_buffer_allocation_successful() returns %false. |
| 712 * | 743 * |
| 713 * Since: 0.9.2 | 744 * Since: 0.9.2 |
| 714 **/ | 745 **/ |
| 715 hb_buffer_t * | 746 hb_buffer_t * |
| 716 hb_buffer_create (void) | 747 hb_buffer_create (void) |
| 717 { | 748 { |
| 718 hb_buffer_t *buffer; | 749 hb_buffer_t *buffer; |
| 719 | 750 |
| 720 if (!(buffer = hb_object_create<hb_buffer_t> ())) | 751 if (!(buffer = hb_object_create<hb_buffer_t> ())) |
| 721 return hb_buffer_get_empty (); | 752 return hb_buffer_get_empty (); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 true /* have_positions */ | 787 true /* have_positions */ |
| 757 | 788 |
| 758 /* Zero is good enough for everything else. */ | 789 /* Zero is good enough for everything else. */ |
| 759 }; | 790 }; |
| 760 | 791 |
| 761 return const_cast<hb_buffer_t *> (&_hb_buffer_nil); | 792 return const_cast<hb_buffer_t *> (&_hb_buffer_nil); |
| 762 } | 793 } |
| 763 | 794 |
| 764 /** | 795 /** |
| 765 * hb_buffer_reference: (skip) | 796 * hb_buffer_reference: (skip) |
| 766 * @buffer: a buffer. | 797 * @buffer: an #hb_buffer_t. |
| 767 * | 798 * |
| 768 * | 799 * Increases the reference count on @buffer by one. This prevents @buffer from |
| 800 * being destroyed until a matching call to hb_buffer_destroy() is made. |
| 769 * | 801 * |
| 770 * Return value: (transfer full): | 802 * Return value: (transfer full): |
| 803 * The referenced #hb_buffer_t. |
| 771 * | 804 * |
| 772 * Since: 0.9.2 | 805 * Since: 0.9.2 |
| 773 **/ | 806 **/ |
| 774 hb_buffer_t * | 807 hb_buffer_t * |
| 775 hb_buffer_reference (hb_buffer_t *buffer) | 808 hb_buffer_reference (hb_buffer_t *buffer) |
| 776 { | 809 { |
| 777 return hb_object_reference (buffer); | 810 return hb_object_reference (buffer); |
| 778 } | 811 } |
| 779 | 812 |
| 780 /** | 813 /** |
| 781 * hb_buffer_destroy: (skip) | 814 * hb_buffer_destroy: (skip) |
| 782 * @buffer: a buffer. | 815 * @buffer: an #hb_buffer_t. |
| 783 * | 816 * |
| 784 * | 817 * Deallocate the @buffer. |
| 818 * Decreases the reference count on @buffer by one. If the result is zero, then |
| 819 * @buffer and all associated resources are freed. See hb_buffer_reference(). |
| 785 * | 820 * |
| 786 * Since: 0.9.2 | 821 * Since: 0.9.2 |
| 787 **/ | 822 **/ |
| 788 void | 823 void |
| 789 hb_buffer_destroy (hb_buffer_t *buffer) | 824 hb_buffer_destroy (hb_buffer_t *buffer) |
| 790 { | 825 { |
| 791 if (!hb_object_destroy (buffer)) return; | 826 if (!hb_object_destroy (buffer)) return; |
| 792 | 827 |
| 793 hb_unicode_funcs_destroy (buffer->unicode); | 828 hb_unicode_funcs_destroy (buffer->unicode); |
| 794 | 829 |
| 795 free (buffer->info); | 830 free (buffer->info); |
| 796 free (buffer->pos); | 831 free (buffer->pos); |
| 832 if (buffer->message_destroy) |
| 833 buffer->message_destroy (buffer->message_data); |
| 797 | 834 |
| 798 free (buffer); | 835 free (buffer); |
| 799 } | 836 } |
| 800 | 837 |
| 801 /** | 838 /** |
| 802 * hb_buffer_set_user_data: (skip) | 839 * hb_buffer_set_user_data: (skip) |
| 803 * @buffer: a buffer. | 840 * @buffer: an #hb_buffer_t. |
| 804 * @key: | 841 * @key: |
| 805 * @data: | 842 * @data: |
| 806 * @destroy: | 843 * @destroy: |
| 807 * @replace: | 844 * @replace: |
| 808 * | 845 * |
| 809 * | 846 * |
| 810 * | 847 * |
| 811 * Return value: | 848 * Return value: |
| 812 * | 849 * |
| 813 * Since: 0.9.2 | 850 * Since: 0.9.2 |
| 814 **/ | 851 **/ |
| 815 hb_bool_t | 852 hb_bool_t |
| 816 hb_buffer_set_user_data (hb_buffer_t *buffer, | 853 hb_buffer_set_user_data (hb_buffer_t *buffer, |
| 817 hb_user_data_key_t *key, | 854 hb_user_data_key_t *key, |
| 818 void * data, | 855 void * data, |
| 819 hb_destroy_func_t destroy, | 856 hb_destroy_func_t destroy, |
| 820 hb_bool_t replace) | 857 hb_bool_t replace) |
| 821 { | 858 { |
| 822 return hb_object_set_user_data (buffer, key, data, destroy, replace); | 859 return hb_object_set_user_data (buffer, key, data, destroy, replace); |
| 823 } | 860 } |
| 824 | 861 |
| 825 /** | 862 /** |
| 826 * hb_buffer_get_user_data: (skip) | 863 * hb_buffer_get_user_data: (skip) |
| 827 * @buffer: a buffer. | 864 * @buffer: an #hb_buffer_t. |
| 828 * @key: | 865 * @key: |
| 829 * | 866 * |
| 830 * | 867 * |
| 831 * | 868 * |
| 832 * Return value: | 869 * Return value: |
| 833 * | 870 * |
| 834 * Since: 0.9.2 | 871 * Since: 0.9.2 |
| 835 **/ | 872 **/ |
| 836 void * | 873 void * |
| 837 hb_buffer_get_user_data (hb_buffer_t *buffer, | 874 hb_buffer_get_user_data (hb_buffer_t *buffer, |
| 838 hb_user_data_key_t *key) | 875 hb_user_data_key_t *key) |
| 839 { | 876 { |
| 840 return hb_object_get_user_data (buffer, key); | 877 return hb_object_get_user_data (buffer, key); |
| 841 } | 878 } |
| 842 | 879 |
| 843 | 880 |
| 844 /** | 881 /** |
| 845 * hb_buffer_set_content_type: | 882 * hb_buffer_set_content_type: |
| 846 * @buffer: a buffer. | 883 * @buffer: an #hb_buffer_t. |
| 847 * @content_type: | 884 * @content_type: the type of buffer contents to set |
| 848 * | 885 * |
| 849 * | 886 * Sets the type of @buffer contents, buffers are either empty, contain |
| 887 * characters (before shaping) or glyphs (the result of shaping). |
| 850 * | 888 * |
| 851 * Since: 0.9.5 | 889 * Since: 0.9.5 |
| 852 **/ | 890 **/ |
| 853 void | 891 void |
| 854 hb_buffer_set_content_type (hb_buffer_t *buffer, | 892 hb_buffer_set_content_type (hb_buffer_t *buffer, |
| 855 hb_buffer_content_type_t content_type) | 893 hb_buffer_content_type_t content_type) |
| 856 { | 894 { |
| 857 buffer->content_type = content_type; | 895 buffer->content_type = content_type; |
| 858 } | 896 } |
| 859 | 897 |
| 860 /** | 898 /** |
| 861 * hb_buffer_get_content_type: | 899 * hb_buffer_get_content_type: |
| 862 * @buffer: a buffer. | 900 * @buffer: an #hb_buffer_t. |
| 863 * | 901 * |
| 864 * | 902 * see hb_buffer_set_content_type(). |
| 865 * | 903 * |
| 866 * Return value: | 904 * Return value: |
| 905 * The type of @buffer contents. |
| 867 * | 906 * |
| 868 * Since: 0.9.5 | 907 * Since: 0.9.5 |
| 869 **/ | 908 **/ |
| 870 hb_buffer_content_type_t | 909 hb_buffer_content_type_t |
| 871 hb_buffer_get_content_type (hb_buffer_t *buffer) | 910 hb_buffer_get_content_type (hb_buffer_t *buffer) |
| 872 { | 911 { |
| 873 return buffer->content_type; | 912 return buffer->content_type; |
| 874 } | 913 } |
| 875 | 914 |
| 876 | 915 |
| 877 /** | 916 /** |
| 878 * hb_buffer_set_unicode_funcs: | 917 * hb_buffer_set_unicode_funcs: |
| 879 * @buffer: a buffer. | 918 * @buffer: an #hb_buffer_t. |
| 880 * @unicode_funcs: | 919 * @unicode_funcs: |
| 881 * | 920 * |
| 882 * | 921 * |
| 883 * | 922 * |
| 884 * Since: 0.9.2 | 923 * Since: 0.9.2 |
| 885 **/ | 924 **/ |
| 886 void | 925 void |
| 887 hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, | 926 hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, |
| 888 hb_unicode_funcs_t *unicode_funcs) | 927 hb_unicode_funcs_t *unicode_funcs) |
| 889 { | 928 { |
| 890 if (unlikely (hb_object_is_inert (buffer))) | 929 if (unlikely (hb_object_is_inert (buffer))) |
| 891 return; | 930 return; |
| 892 | 931 |
| 893 if (!unicode_funcs) | 932 if (!unicode_funcs) |
| 894 unicode_funcs = hb_unicode_funcs_get_default (); | 933 unicode_funcs = hb_unicode_funcs_get_default (); |
| 895 | 934 |
| 896 | 935 |
| 897 hb_unicode_funcs_reference (unicode_funcs); | 936 hb_unicode_funcs_reference (unicode_funcs); |
| 898 hb_unicode_funcs_destroy (buffer->unicode); | 937 hb_unicode_funcs_destroy (buffer->unicode); |
| 899 buffer->unicode = unicode_funcs; | 938 buffer->unicode = unicode_funcs; |
| 900 } | 939 } |
| 901 | 940 |
| 902 /** | 941 /** |
| 903 * hb_buffer_get_unicode_funcs: | 942 * hb_buffer_get_unicode_funcs: |
| 904 * @buffer: a buffer. | 943 * @buffer: an #hb_buffer_t. |
| 905 * | 944 * |
| 906 * | 945 * |
| 907 * | 946 * |
| 908 * Return value: | 947 * Return value: |
| 909 * | 948 * |
| 910 * Since: 0.9.2 | 949 * Since: 0.9.2 |
| 911 **/ | 950 **/ |
| 912 hb_unicode_funcs_t * | 951 hb_unicode_funcs_t * |
| 913 hb_buffer_get_unicode_funcs (hb_buffer_t *buffer) | 952 hb_buffer_get_unicode_funcs (hb_buffer_t *buffer) |
| 914 { | 953 { |
| 915 return buffer->unicode; | 954 return buffer->unicode; |
| 916 } | 955 } |
| 917 | 956 |
| 918 /** | 957 /** |
| 919 * hb_buffer_set_direction: | 958 * hb_buffer_set_direction: |
| 920 * @buffer: a buffer. | 959 * @buffer: an #hb_buffer_t. |
| 921 * @direction: | 960 * @direction: the #hb_direction_t of the @buffer |
| 922 * | 961 * |
| 923 * | 962 * Set the text flow direction of the buffer. No shaping can happen without |
| 963 * setting @buffer direction, and it controls the visual direction for the |
| 964 * output glyphs; for RTL direction the glyphs will be reversed. Many layout |
| 965 * features depend on the proper setting of the direction, for example, |
| 966 * reversing RTL text before shaping, then shaping with LTR direction is not |
| 967 * the same as keeping the text in logical order and shaping with RTL |
| 968 * direction. |
| 924 * | 969 * |
| 925 * Since: 0.9.2 | 970 * Since: 0.9.2 |
| 926 **/ | 971 **/ |
| 927 void | 972 void |
| 928 hb_buffer_set_direction (hb_buffer_t *buffer, | 973 hb_buffer_set_direction (hb_buffer_t *buffer, |
| 929 hb_direction_t direction) | 974 hb_direction_t direction) |
| 930 | 975 |
| 931 { | 976 { |
| 932 if (unlikely (hb_object_is_inert (buffer))) | 977 if (unlikely (hb_object_is_inert (buffer))) |
| 933 return; | 978 return; |
| 934 | 979 |
| 935 buffer->props.direction = direction; | 980 buffer->props.direction = direction; |
| 936 } | 981 } |
| 937 | 982 |
| 938 /** | 983 /** |
| 939 * hb_buffer_get_direction: | 984 * hb_buffer_get_direction: |
| 940 * @buffer: a buffer. | 985 * @buffer: an #hb_buffer_t. |
| 941 * | 986 * |
| 942 * | 987 * See hb_buffer_set_direction() |
| 943 * | 988 * |
| 944 * Return value: | 989 * Return value: |
| 990 * The direction of the @buffer. |
| 945 * | 991 * |
| 946 * Since: 0.9.2 | 992 * Since: 0.9.2 |
| 947 **/ | 993 **/ |
| 948 hb_direction_t | 994 hb_direction_t |
| 949 hb_buffer_get_direction (hb_buffer_t *buffer) | 995 hb_buffer_get_direction (hb_buffer_t *buffer) |
| 950 { | 996 { |
| 951 return buffer->props.direction; | 997 return buffer->props.direction; |
| 952 } | 998 } |
| 953 | 999 |
| 954 /** | 1000 /** |
| 955 * hb_buffer_set_script: | 1001 * hb_buffer_set_script: |
| 956 * @buffer: a buffer. | 1002 * @buffer: an #hb_buffer_t. |
| 957 * @script: | 1003 * @script: an #hb_script_t to set. |
| 958 * | 1004 * |
| 959 * | 1005 * Sets the script of @buffer to @script. |
| 1006 * |
| 1007 * Script is crucial for choosing the proper shaping behaviour for scripts that |
| 1008 * require it (e.g. Arabic) and the which OpenType features defined in the font |
| 1009 * to be applied. |
| 1010 * |
| 1011 * You can pass one of the predefined #hb_script_t values, or use |
| 1012 * hb_script_from_string() or hb_script_from_iso15924_tag() to get the |
| 1013 * corresponding script from an ISO 15924 script tag. |
| 960 * | 1014 * |
| 961 * Since: 0.9.2 | 1015 * Since: 0.9.2 |
| 962 **/ | 1016 **/ |
| 963 void | 1017 void |
| 964 hb_buffer_set_script (hb_buffer_t *buffer, | 1018 hb_buffer_set_script (hb_buffer_t *buffer, |
| 965 hb_script_t script) | 1019 hb_script_t script) |
| 966 { | 1020 { |
| 967 if (unlikely (hb_object_is_inert (buffer))) | 1021 if (unlikely (hb_object_is_inert (buffer))) |
| 968 return; | 1022 return; |
| 969 | 1023 |
| 970 buffer->props.script = script; | 1024 buffer->props.script = script; |
| 971 } | 1025 } |
| 972 | 1026 |
| 973 /** | 1027 /** |
| 974 * hb_buffer_get_script: | 1028 * hb_buffer_get_script: |
| 975 * @buffer: a buffer. | 1029 * @buffer: an #hb_buffer_t. |
| 976 * | 1030 * |
| 977 * | 1031 * See hb_buffer_set_script(). |
| 978 * | 1032 * |
| 979 * Return value: | 1033 * Return value: |
| 1034 * The #hb_script_t of the @buffer. |
| 980 * | 1035 * |
| 981 * Since: 0.9.2 | 1036 * Since: 0.9.2 |
| 982 **/ | 1037 **/ |
| 983 hb_script_t | 1038 hb_script_t |
| 984 hb_buffer_get_script (hb_buffer_t *buffer) | 1039 hb_buffer_get_script (hb_buffer_t *buffer) |
| 985 { | 1040 { |
| 986 return buffer->props.script; | 1041 return buffer->props.script; |
| 987 } | 1042 } |
| 988 | 1043 |
| 989 /** | 1044 /** |
| 990 * hb_buffer_set_language: | 1045 * hb_buffer_set_language: |
| 991 * @buffer: a buffer. | 1046 * @buffer: an #hb_buffer_t. |
| 992 * @language: | 1047 * @language: an hb_language_t to set. |
| 993 * | 1048 * |
| 994 * | 1049 * Sets the language of @buffer to @language. |
| 1050 * |
| 1051 * Languages are crucial for selecting which OpenType feature to apply to the |
| 1052 * buffer which can result in applying language-specific behaviour. Languages |
| 1053 * are orthogonal to the scripts, and though they are related, they are |
| 1054 * different concepts and should not be confused with each other. |
| 1055 * |
| 1056 * Use hb_language_from_string() to convert from ISO 639 language codes to |
| 1057 * #hb_language_t. |
| 995 * | 1058 * |
| 996 * Since: 0.9.2 | 1059 * Since: 0.9.2 |
| 997 **/ | 1060 **/ |
| 998 void | 1061 void |
| 999 hb_buffer_set_language (hb_buffer_t *buffer, | 1062 hb_buffer_set_language (hb_buffer_t *buffer, |
| 1000 hb_language_t language) | 1063 hb_language_t language) |
| 1001 { | 1064 { |
| 1002 if (unlikely (hb_object_is_inert (buffer))) | 1065 if (unlikely (hb_object_is_inert (buffer))) |
| 1003 return; | 1066 return; |
| 1004 | 1067 |
| 1005 buffer->props.language = language; | 1068 buffer->props.language = language; |
| 1006 } | 1069 } |
| 1007 | 1070 |
| 1008 /** | 1071 /** |
| 1009 * hb_buffer_get_language: | 1072 * hb_buffer_get_language: |
| 1010 * @buffer: a buffer. | 1073 * @buffer: an #hb_buffer_t. |
| 1011 * | 1074 * |
| 1012 * | 1075 * See hb_buffer_set_language(). |
| 1013 * | 1076 * |
| 1014 * Return value: (transfer none): | 1077 * Return value: (transfer none): |
| 1078 * The #hb_language_t of the buffer. Must not be freed by the caller. |
| 1015 * | 1079 * |
| 1016 * Since: 0.9.2 | 1080 * Since: 0.9.2 |
| 1017 **/ | 1081 **/ |
| 1018 hb_language_t | 1082 hb_language_t |
| 1019 hb_buffer_get_language (hb_buffer_t *buffer) | 1083 hb_buffer_get_language (hb_buffer_t *buffer) |
| 1020 { | 1084 { |
| 1021 return buffer->props.language; | 1085 return buffer->props.language; |
| 1022 } | 1086 } |
| 1023 | 1087 |
| 1024 /** | 1088 /** |
| 1025 * hb_buffer_set_segment_properties: | 1089 * hb_buffer_set_segment_properties: |
| 1026 * @buffer: a buffer. | 1090 * @buffer: an #hb_buffer_t. |
| 1027 * @props: | 1091 * @props: an #hb_segment_properties_t to use. |
| 1028 * | 1092 * |
| 1029 * | 1093 * Sets the segment properties of the buffer, a shortcut for calling |
| 1094 * hb_buffer_set_direction(), hb_buffer_set_script() and |
| 1095 * hb_buffer_set_language() individually. |
| 1030 * | 1096 * |
| 1031 * Since: 0.9.7 | 1097 * Since: 0.9.7 |
| 1032 **/ | 1098 **/ |
| 1033 void | 1099 void |
| 1034 hb_buffer_set_segment_properties (hb_buffer_t *buffer, | 1100 hb_buffer_set_segment_properties (hb_buffer_t *buffer, |
| 1035 const hb_segment_properties_t *props) | 1101 const hb_segment_properties_t *props) |
| 1036 { | 1102 { |
| 1037 if (unlikely (hb_object_is_inert (buffer))) | 1103 if (unlikely (hb_object_is_inert (buffer))) |
| 1038 return; | 1104 return; |
| 1039 | 1105 |
| 1040 buffer->props = *props; | 1106 buffer->props = *props; |
| 1041 } | 1107 } |
| 1042 | 1108 |
| 1043 /** | 1109 /** |
| 1044 * hb_buffer_get_segment_properties: | 1110 * hb_buffer_get_segment_properties: |
| 1045 * @buffer: a buffer. | 1111 * @buffer: an #hb_buffer_t. |
| 1046 * @props: (out): | 1112 * @props: (out): the output #hb_segment_properties_t. |
| 1047 * | 1113 * |
| 1048 * | 1114 * Sets @props to the #hb_segment_properties_t of @buffer. |
| 1049 * | 1115 * |
| 1050 * Since: 0.9.7 | 1116 * Since: 0.9.7 |
| 1051 **/ | 1117 **/ |
| 1052 void | 1118 void |
| 1053 hb_buffer_get_segment_properties (hb_buffer_t *buffer, | 1119 hb_buffer_get_segment_properties (hb_buffer_t *buffer, |
| 1054 hb_segment_properties_t *props) | 1120 hb_segment_properties_t *props) |
| 1055 { | 1121 { |
| 1056 *props = buffer->props; | 1122 *props = buffer->props; |
| 1057 } | 1123 } |
| 1058 | 1124 |
| 1059 | 1125 |
| 1060 /** | 1126 /** |
| 1061 * hb_buffer_set_flags: | 1127 * hb_buffer_set_flags: |
| 1062 * @buffer: a buffer. | 1128 * @buffer: an #hb_buffer_t. |
| 1063 * @flags: | 1129 * @flags: the buffer flags to set. |
| 1064 * | 1130 * |
| 1065 * | 1131 * Sets @buffer flags to @flags. See #hb_buffer_flags_t. |
| 1066 * | 1132 * |
| 1067 * Since: 0.9.7 | 1133 * Since: 0.9.7 |
| 1068 **/ | 1134 **/ |
| 1069 void | 1135 void |
| 1070 hb_buffer_set_flags (hb_buffer_t *buffer, | 1136 hb_buffer_set_flags (hb_buffer_t *buffer, |
| 1071 hb_buffer_flags_t flags) | 1137 hb_buffer_flags_t flags) |
| 1072 { | 1138 { |
| 1073 if (unlikely (hb_object_is_inert (buffer))) | 1139 if (unlikely (hb_object_is_inert (buffer))) |
| 1074 return; | 1140 return; |
| 1075 | 1141 |
| 1076 buffer->flags = flags; | 1142 buffer->flags = flags; |
| 1077 } | 1143 } |
| 1078 | 1144 |
| 1079 /** | 1145 /** |
| 1080 * hb_buffer_get_flags: | 1146 * hb_buffer_get_flags: |
| 1081 * @buffer: a buffer. | 1147 * @buffer: an #hb_buffer_t. |
| 1082 * | 1148 * |
| 1083 * | 1149 * See hb_buffer_set_flags(). |
| 1084 * | 1150 * |
| 1085 * Return value: | 1151 * Return value: |
| 1152 * The @buffer flags. |
| 1086 * | 1153 * |
| 1087 * Since: 0.9.7 | 1154 * Since: 0.9.7 |
| 1088 **/ | 1155 **/ |
| 1089 hb_buffer_flags_t | 1156 hb_buffer_flags_t |
| 1090 hb_buffer_get_flags (hb_buffer_t *buffer) | 1157 hb_buffer_get_flags (hb_buffer_t *buffer) |
| 1091 { | 1158 { |
| 1092 return buffer->flags; | 1159 return buffer->flags; |
| 1093 } | 1160 } |
| 1094 | 1161 |
| 1095 /** | 1162 /** |
| 1096 * hb_buffer_set_cluster_level: | 1163 * hb_buffer_set_cluster_level: |
| 1097 * @buffer: a buffer. | 1164 * @buffer: an #hb_buffer_t. |
| 1098 * @cluster_level: | 1165 * @cluster_level: |
| 1099 * | 1166 * |
| 1100 * | 1167 * |
| 1101 * | 1168 * |
| 1102 * Since: 0.9.42 | 1169 * Since: 0.9.42 |
| 1103 **/ | 1170 **/ |
| 1104 void | 1171 void |
| 1105 hb_buffer_set_cluster_level (hb_buffer_t *buffer, | 1172 hb_buffer_set_cluster_level (hb_buffer_t *buffer, |
| 1106 hb_buffer_cluster_level_t cluster_level) | 1173 hb_buffer_cluster_level_t cluster_level) |
| 1107 { | 1174 { |
| 1108 if (unlikely (hb_object_is_inert (buffer))) | 1175 if (unlikely (hb_object_is_inert (buffer))) |
| 1109 return; | 1176 return; |
| 1110 | 1177 |
| 1111 buffer->cluster_level = cluster_level; | 1178 buffer->cluster_level = cluster_level; |
| 1112 } | 1179 } |
| 1113 | 1180 |
| 1114 /** | 1181 /** |
| 1115 * hb_buffer_get_cluster_level: | 1182 * hb_buffer_get_cluster_level: |
| 1116 * @buffer: a buffer. | 1183 * @buffer: an #hb_buffer_t. |
| 1117 * | 1184 * |
| 1118 * | 1185 * |
| 1119 * | 1186 * |
| 1120 * Return value: | 1187 * Return value: |
| 1121 * | 1188 * |
| 1122 * Since: 0.9.42 | 1189 * Since: 0.9.42 |
| 1123 **/ | 1190 **/ |
| 1124 hb_buffer_cluster_level_t | 1191 hb_buffer_cluster_level_t |
| 1125 hb_buffer_get_cluster_level (hb_buffer_t *buffer) | 1192 hb_buffer_get_cluster_level (hb_buffer_t *buffer) |
| 1126 { | 1193 { |
| 1127 return buffer->cluster_level; | 1194 return buffer->cluster_level; |
| 1128 } | 1195 } |
| 1129 | 1196 |
| 1130 | 1197 |
| 1131 /** | 1198 /** |
| 1132 * hb_buffer_set_replacement_codepoint: | 1199 * hb_buffer_set_replacement_codepoint: |
| 1133 * @buffer: a buffer. | 1200 * @buffer: an #hb_buffer_t. |
| 1134 * @replacement: | 1201 * @replacement: the replacement #hb_codepoint_t |
| 1135 * | 1202 * |
| 1136 * | 1203 * Sets the #hb_codepoint_t that replaces invalid entries for a given encoding |
| 1204 * when adding text to @buffer. |
| 1205 * |
| 1206 * Default is %HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT. |
| 1137 * | 1207 * |
| 1138 * Since: 0.9.31 | 1208 * Since: 0.9.31 |
| 1139 **/ | 1209 **/ |
| 1140 void | 1210 void |
| 1141 hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, | 1211 hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, |
| 1142 hb_codepoint_t replacement) | 1212 hb_codepoint_t replacement) |
| 1143 { | 1213 { |
| 1144 if (unlikely (hb_object_is_inert (buffer))) | 1214 if (unlikely (hb_object_is_inert (buffer))) |
| 1145 return; | 1215 return; |
| 1146 | 1216 |
| 1147 buffer->replacement = replacement; | 1217 buffer->replacement = replacement; |
| 1148 } | 1218 } |
| 1149 | 1219 |
| 1150 /** | 1220 /** |
| 1151 * hb_buffer_get_replacement_codepoint: | 1221 * hb_buffer_get_replacement_codepoint: |
| 1152 * @buffer: a buffer. | 1222 * @buffer: an #hb_buffer_t. |
| 1153 * | 1223 * |
| 1154 * | 1224 * See hb_buffer_set_replacement_codepoint(). |
| 1155 * | 1225 * |
| 1156 * Return value: | 1226 * Return value: |
| 1227 * The @buffer replacement #hb_codepoint_t. |
| 1157 * | 1228 * |
| 1158 * Since: 0.9.31 | 1229 * Since: 0.9.31 |
| 1159 **/ | 1230 **/ |
| 1160 hb_codepoint_t | 1231 hb_codepoint_t |
| 1161 hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer) | 1232 hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer) |
| 1162 { | 1233 { |
| 1163 return buffer->replacement; | 1234 return buffer->replacement; |
| 1164 } | 1235 } |
| 1165 | 1236 |
| 1166 | 1237 |
| 1167 /** | 1238 /** |
| 1168 * hb_buffer_reset: | 1239 * hb_buffer_reset: |
| 1169 * @buffer: a buffer. | 1240 * @buffer: an #hb_buffer_t. |
| 1170 * | 1241 * |
| 1171 * | 1242 * Resets the buffer to its initial status, as if it was just newly created |
| 1243 * with hb_buffer_create(). |
| 1172 * | 1244 * |
| 1173 * Since: 0.9.2 | 1245 * Since: 0.9.2 |
| 1174 **/ | 1246 **/ |
| 1175 void | 1247 void |
| 1176 hb_buffer_reset (hb_buffer_t *buffer) | 1248 hb_buffer_reset (hb_buffer_t *buffer) |
| 1177 { | 1249 { |
| 1178 buffer->reset (); | 1250 buffer->reset (); |
| 1179 } | 1251 } |
| 1180 | 1252 |
| 1181 /** | 1253 /** |
| 1182 * hb_buffer_clear_contents: | 1254 * hb_buffer_clear_contents: |
| 1183 * @buffer: a buffer. | 1255 * @buffer: an #hb_buffer_t. |
| 1184 * | 1256 * |
| 1185 * | 1257 * Similar to hb_buffer_reset(), but does not clear the Unicode functions and |
| 1258 * the replacement code point. |
| 1186 * | 1259 * |
| 1187 * Since: 0.9.11 | 1260 * Since: 0.9.11 |
| 1188 **/ | 1261 **/ |
| 1189 void | 1262 void |
| 1190 hb_buffer_clear_contents (hb_buffer_t *buffer) | 1263 hb_buffer_clear_contents (hb_buffer_t *buffer) |
| 1191 { | 1264 { |
| 1192 buffer->clear (); | 1265 buffer->clear (); |
| 1193 } | 1266 } |
| 1194 | 1267 |
| 1195 /** | 1268 /** |
| 1196 * hb_buffer_pre_allocate: | 1269 * hb_buffer_pre_allocate: |
| 1197 * @buffer: a buffer. | 1270 * @buffer: an #hb_buffer_t. |
| 1198 * @size: | 1271 * @size: number of items to pre allocate. |
| 1199 * | 1272 * |
| 1200 * | 1273 * Pre allocates memory for @buffer to fit at least @size number of items. |
| 1201 * | 1274 * |
| 1202 * Return value: | 1275 * Return value: |
| 1276 * %true if @buffer memory allocation succeeded, %false otherwise. |
| 1203 * | 1277 * |
| 1204 * Since: 0.9.2 | 1278 * Since: 0.9.2 |
| 1205 **/ | 1279 **/ |
| 1206 hb_bool_t | 1280 hb_bool_t |
| 1207 hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size) | 1281 hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size) |
| 1208 { | 1282 { |
| 1209 return buffer->ensure (size); | 1283 return buffer->ensure (size); |
| 1210 } | 1284 } |
| 1211 | 1285 |
| 1212 /** | 1286 /** |
| 1213 * hb_buffer_allocation_successful: | 1287 * hb_buffer_allocation_successful: |
| 1214 * @buffer: a buffer. | 1288 * @buffer: an #hb_buffer_t. |
| 1215 * | 1289 * |
| 1216 * | 1290 * Check if allocating memory for the buffer succeeded. |
| 1217 * | 1291 * |
| 1218 * Return value: | 1292 * Return value: |
| 1293 * %true if @buffer memory allocation succeeded, %false otherwise. |
| 1219 * | 1294 * |
| 1220 * Since: 0.9.2 | 1295 * Since: 0.9.2 |
| 1221 **/ | 1296 **/ |
| 1222 hb_bool_t | 1297 hb_bool_t |
| 1223 hb_buffer_allocation_successful (hb_buffer_t *buffer) | 1298 hb_buffer_allocation_successful (hb_buffer_t *buffer) |
| 1224 { | 1299 { |
| 1225 return !buffer->in_error; | 1300 return !buffer->in_error; |
| 1226 } | 1301 } |
| 1227 | 1302 |
| 1228 /** | 1303 /** |
| 1229 * hb_buffer_add: | 1304 * hb_buffer_add: |
| 1230 * @buffer: a buffer. | 1305 * @buffer: an #hb_buffer_t. |
| 1231 * @codepoint: | 1306 * @codepoint: a Unicode code point. |
| 1232 * @cluster: | 1307 * @cluster: the cluster value of @codepoint. |
| 1233 * | 1308 * |
| 1234 * | 1309 * Appends a character with the Unicode value of @codepoint to @buffer, and |
| 1310 * gives it the initial cluster value of @cluster. Clusters can be any thing |
| 1311 * the client wants, they are usually used to refer to the index of the |
| 1312 * character in the input text stream and are output in |
| 1313 * #hb_glyph_info_t.cluster field. |
| 1314 * |
| 1315 * This function does not check the validity of @codepoint, it is up to the |
| 1316 * caller to ensure it is a valid Unicode code point. |
| 1235 * | 1317 * |
| 1236 * Since: 0.9.7 | 1318 * Since: 0.9.7 |
| 1237 **/ | 1319 **/ |
| 1238 void | 1320 void |
| 1239 hb_buffer_add (hb_buffer_t *buffer, | 1321 hb_buffer_add (hb_buffer_t *buffer, |
| 1240 hb_codepoint_t codepoint, | 1322 hb_codepoint_t codepoint, |
| 1241 unsigned int cluster) | 1323 unsigned int cluster) |
| 1242 { | 1324 { |
| 1243 buffer->add (codepoint, cluster); | 1325 buffer->add (codepoint, cluster); |
| 1244 buffer->clear_context (1); | 1326 buffer->clear_context (1); |
| 1245 } | 1327 } |
| 1246 | 1328 |
| 1247 /** | 1329 /** |
| 1248 * hb_buffer_set_length: | 1330 * hb_buffer_set_length: |
| 1249 * @buffer: a buffer. | 1331 * @buffer: an #hb_buffer_t. |
| 1250 * @length: | 1332 * @length: the new length of @buffer. |
| 1251 * | 1333 * |
| 1252 * | 1334 * Similar to hb_buffer_pre_allocate(), but clears any new items added at the |
| 1335 * end. |
| 1253 * | 1336 * |
| 1254 * Return value: | 1337 * Return value: |
| 1338 * %true if @buffer memory allocation succeeded, %false otherwise. |
| 1255 * | 1339 * |
| 1256 * Since: 0.9.2 | 1340 * Since: 0.9.2 |
| 1257 **/ | 1341 **/ |
| 1258 hb_bool_t | 1342 hb_bool_t |
| 1259 hb_buffer_set_length (hb_buffer_t *buffer, | 1343 hb_buffer_set_length (hb_buffer_t *buffer, |
| 1260 unsigned int length) | 1344 unsigned int length) |
| 1261 { | 1345 { |
| 1262 if (unlikely (hb_object_is_inert (buffer))) | 1346 if (unlikely (hb_object_is_inert (buffer))) |
| 1263 return length == 0; | 1347 return length == 0; |
| 1264 | 1348 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1279 buffer->content_type = HB_BUFFER_CONTENT_TYPE_INVALID; | 1363 buffer->content_type = HB_BUFFER_CONTENT_TYPE_INVALID; |
| 1280 buffer->clear_context (0); | 1364 buffer->clear_context (0); |
| 1281 } | 1365 } |
| 1282 buffer->clear_context (1); | 1366 buffer->clear_context (1); |
| 1283 | 1367 |
| 1284 return true; | 1368 return true; |
| 1285 } | 1369 } |
| 1286 | 1370 |
| 1287 /** | 1371 /** |
| 1288 * hb_buffer_get_length: | 1372 * hb_buffer_get_length: |
| 1289 * @buffer: a buffer. | 1373 * @buffer: an #hb_buffer_t. |
| 1290 * | 1374 * |
| 1291 * Returns the number of items in the buffer. | 1375 * Returns the number of items in the buffer. |
| 1292 * | 1376 * |
| 1293 * Return value: buffer length. | 1377 * Return value: |
| 1378 * The @buffer length. |
| 1379 * The value valid as long as buffer has not been modified. |
| 1294 * | 1380 * |
| 1295 * Since: 0.9.2 | 1381 * Since: 0.9.2 |
| 1296 **/ | 1382 **/ |
| 1297 unsigned int | 1383 unsigned int |
| 1298 hb_buffer_get_length (hb_buffer_t *buffer) | 1384 hb_buffer_get_length (hb_buffer_t *buffer) |
| 1299 { | 1385 { |
| 1300 return buffer->len; | 1386 return buffer->len; |
| 1301 } | 1387 } |
| 1302 | 1388 |
| 1303 /** | 1389 /** |
| 1304 * hb_buffer_get_glyph_infos: | 1390 * hb_buffer_get_glyph_infos: |
| 1305 * @buffer: a buffer. | 1391 * @buffer: an #hb_buffer_t. |
| 1306 * @length: (out): output array length. | 1392 * @length: (out): output array length. |
| 1307 * | 1393 * |
| 1308 * Returns buffer glyph information array. Returned pointer | 1394 * Returns @buffer glyph information array. Returned pointer |
| 1309 * is valid as long as buffer contents are not modified. | 1395 * is valid as long as @buffer contents are not modified. |
| 1310 * | 1396 * |
| 1311 * Return value: (transfer none) (array length=length): buffer glyph information
array. | 1397 * Return value: (transfer none) (array length=length): |
| 1398 * The @buffer glyph information array. |
| 1399 * The value valid as long as buffer has not been modified. |
| 1312 * | 1400 * |
| 1313 * Since: 0.9.2 | 1401 * Since: 0.9.2 |
| 1314 **/ | 1402 **/ |
| 1315 hb_glyph_info_t * | 1403 hb_glyph_info_t * |
| 1316 hb_buffer_get_glyph_infos (hb_buffer_t *buffer, | 1404 hb_buffer_get_glyph_infos (hb_buffer_t *buffer, |
| 1317 unsigned int *length) | 1405 unsigned int *length) |
| 1318 { | 1406 { |
| 1319 if (length) | 1407 if (length) |
| 1320 *length = buffer->len; | 1408 *length = buffer->len; |
| 1321 | 1409 |
| 1322 return (hb_glyph_info_t *) buffer->info; | 1410 return (hb_glyph_info_t *) buffer->info; |
| 1323 } | 1411 } |
| 1324 | 1412 |
| 1325 /** | 1413 /** |
| 1326 * hb_buffer_get_glyph_positions: | 1414 * hb_buffer_get_glyph_positions: |
| 1327 * @buffer: a buffer. | 1415 * @buffer: an #hb_buffer_t. |
| 1328 * @length: (out): output length. | 1416 * @length: (out): output length. |
| 1329 * | 1417 * |
| 1330 * Returns buffer glyph position array. Returned pointer | 1418 * Returns @buffer glyph position array. Returned pointer |
| 1331 * is valid as long as buffer contents are not modified. | 1419 * is valid as long as @buffer contents are not modified. |
| 1332 * | 1420 * |
| 1333 * Return value: (transfer none) (array length=length): buffer glyph position ar
ray. | 1421 * Return value: (transfer none) (array length=length): |
| 1422 * The @buffer glyph position array. |
| 1423 * The value valid as long as buffer has not been modified. |
| 1334 * | 1424 * |
| 1335 * Since: 0.9.2 | 1425 * Since: 0.9.2 |
| 1336 **/ | 1426 **/ |
| 1337 hb_glyph_position_t * | 1427 hb_glyph_position_t * |
| 1338 hb_buffer_get_glyph_positions (hb_buffer_t *buffer, | 1428 hb_buffer_get_glyph_positions (hb_buffer_t *buffer, |
| 1339 unsigned int *length) | 1429 unsigned int *length) |
| 1340 { | 1430 { |
| 1341 if (!buffer->have_positions) | 1431 if (!buffer->have_positions) |
| 1342 buffer->clear_positions (); | 1432 buffer->clear_positions (); |
| 1343 | 1433 |
| 1344 if (length) | 1434 if (length) |
| 1345 *length = buffer->len; | 1435 *length = buffer->len; |
| 1346 | 1436 |
| 1347 return (hb_glyph_position_t *) buffer->pos; | 1437 return (hb_glyph_position_t *) buffer->pos; |
| 1348 } | 1438 } |
| 1349 | 1439 |
| 1350 /** | 1440 /** |
| 1351 * hb_buffer_reverse: | 1441 * hb_buffer_reverse: |
| 1352 * @buffer: a buffer. | 1442 * @buffer: an #hb_buffer_t. |
| 1353 * | 1443 * |
| 1354 * Reverses buffer contents. | 1444 * Reverses buffer contents. |
| 1355 * | 1445 * |
| 1356 * Since: 0.9.2 | 1446 * Since: 0.9.2 |
| 1357 **/ | 1447 **/ |
| 1358 void | 1448 void |
| 1359 hb_buffer_reverse (hb_buffer_t *buffer) | 1449 hb_buffer_reverse (hb_buffer_t *buffer) |
| 1360 { | 1450 { |
| 1361 buffer->reverse (); | 1451 buffer->reverse (); |
| 1362 } | 1452 } |
| 1363 | 1453 |
| 1364 /** | 1454 /** |
| 1365 * hb_buffer_reverse_range: | 1455 * hb_buffer_reverse_range: |
| 1366 * @buffer: a buffer. | 1456 * @buffer: an #hb_buffer_t. |
| 1367 * @start: start index. | 1457 * @start: start index. |
| 1368 * @end: end index. | 1458 * @end: end index. |
| 1369 * | 1459 * |
| 1370 * Reverses buffer contents between start to end. | 1460 * Reverses buffer contents between start to end. |
| 1371 * | 1461 * |
| 1372 * Since: 0.9.41 | 1462 * Since: 0.9.41 |
| 1373 **/ | 1463 **/ |
| 1374 void | 1464 void |
| 1375 hb_buffer_reverse_range (hb_buffer_t *buffer, | 1465 hb_buffer_reverse_range (hb_buffer_t *buffer, |
| 1376 unsigned int start, unsigned int end) | 1466 unsigned int start, unsigned int end) |
| 1377 { | 1467 { |
| 1378 buffer->reverse_range (start, end); | 1468 buffer->reverse_range (start, end); |
| 1379 } | 1469 } |
| 1380 | 1470 |
| 1381 /** | 1471 /** |
| 1382 * hb_buffer_reverse_clusters: | 1472 * hb_buffer_reverse_clusters: |
| 1383 * @buffer: a buffer. | 1473 * @buffer: an #hb_buffer_t. |
| 1384 * | 1474 * |
| 1385 * Reverses buffer clusters. That is, the buffer contents are | 1475 * Reverses buffer clusters. That is, the buffer contents are |
| 1386 * reversed, then each cluster (consecutive items having the | 1476 * reversed, then each cluster (consecutive items having the |
| 1387 * same cluster number) are reversed again. | 1477 * same cluster number) are reversed again. |
| 1388 * | 1478 * |
| 1389 * Since: 0.9.2 | 1479 * Since: 0.9.2 |
| 1390 **/ | 1480 **/ |
| 1391 void | 1481 void |
| 1392 hb_buffer_reverse_clusters (hb_buffer_t *buffer) | 1482 hb_buffer_reverse_clusters (hb_buffer_t *buffer) |
| 1393 { | 1483 { |
| 1394 buffer->reverse_clusters (); | 1484 buffer->reverse_clusters (); |
| 1395 } | 1485 } |
| 1396 | 1486 |
| 1397 /** | 1487 /** |
| 1398 * hb_buffer_guess_segment_properties: | 1488 * hb_buffer_guess_segment_properties: |
| 1399 * @buffer: a buffer. | 1489 * @buffer: an #hb_buffer_t. |
| 1400 * | 1490 * |
| 1401 * Sets unset buffer segment properties based on buffer Unicode | 1491 * Sets unset buffer segment properties based on buffer Unicode |
| 1402 * contents. If buffer is not empty, it must have content type | 1492 * contents. If buffer is not empty, it must have content type |
| 1403 * %HB_BUFFER_CONTENT_TYPE_UNICODE. | 1493 * %HB_BUFFER_CONTENT_TYPE_UNICODE. |
| 1404 * | 1494 * |
| 1405 * If buffer script is not set (ie. is %HB_SCRIPT_INVALID), it | 1495 * If buffer script is not set (ie. is %HB_SCRIPT_INVALID), it |
| 1406 * will be set to the Unicode script of the first character in | 1496 * will be set to the Unicode script of the first character in |
| 1407 * the buffer that has a script other than %HB_SCRIPT_COMMON, | 1497 * the buffer that has a script other than %HB_SCRIPT_COMMON, |
| 1408 * %HB_SCRIPT_INHERITED, and %HB_SCRIPT_UNKNOWN. | 1498 * %HB_SCRIPT_INHERITED, and %HB_SCRIPT_UNKNOWN. |
| 1409 * | 1499 * |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 hb_codepoint_t u; | 1578 hb_codepoint_t u; |
| 1489 next = utf_t::next (next, end, &u, replacement); | 1579 next = utf_t::next (next, end, &u, replacement); |
| 1490 buffer->context[1][buffer->context_len[1]++] = u; | 1580 buffer->context[1][buffer->context_len[1]++] = u; |
| 1491 } | 1581 } |
| 1492 | 1582 |
| 1493 buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; | 1583 buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; |
| 1494 } | 1584 } |
| 1495 | 1585 |
| 1496 /** | 1586 /** |
| 1497 * hb_buffer_add_utf8: | 1587 * hb_buffer_add_utf8: |
| 1498 * @buffer: a buffer. | 1588 * @buffer: an #hb_buffer_t. |
| 1499 * @text: (array length=text_length) (element-type uint8_t): | 1589 * @text: (array length=text_length) (element-type uint8_t): an array of UTF-8 |
| 1500 * @text_length: | 1590 * characters to append. |
| 1501 * @item_offset: | 1591 * @text_length: the length of the @text, or -1 if it is %NULL terminated. |
| 1502 * @item_length: | 1592 * @item_offset: the offset of the first character to add to the @buffer. |
| 1593 * @item_length: the number of characters to add to the @buffer, or -1 for the |
| 1594 * end of @text (assuming it is %NULL terminated). |
| 1503 * | 1595 * |
| 1504 * | 1596 * See hb_buffer_add_codepoints(). |
| 1597 * |
| 1598 * Replaces invalid UTF-8 characters with the @buffer replacement code point, |
| 1599 * see hb_buffer_set_replacement_codepoint(). |
| 1505 * | 1600 * |
| 1506 * Since: 0.9.2 | 1601 * Since: 0.9.2 |
| 1507 **/ | 1602 **/ |
| 1508 void | 1603 void |
| 1509 hb_buffer_add_utf8 (hb_buffer_t *buffer, | 1604 hb_buffer_add_utf8 (hb_buffer_t *buffer, |
| 1510 const char *text, | 1605 const char *text, |
| 1511 int text_length, | 1606 int text_length, |
| 1512 unsigned int item_offset, | 1607 unsigned int item_offset, |
| 1513 int item_length) | 1608 int item_length) |
| 1514 { | 1609 { |
| 1515 hb_buffer_add_utf<hb_utf8_t> (buffer, (const uint8_t *) text, text_length, ite
m_offset, item_length); | 1610 hb_buffer_add_utf<hb_utf8_t> (buffer, (const uint8_t *) text, text_length, ite
m_offset, item_length); |
| 1516 } | 1611 } |
| 1517 | 1612 |
| 1518 /** | 1613 /** |
| 1519 * hb_buffer_add_utf16: | 1614 * hb_buffer_add_utf16: |
| 1520 * @buffer: a buffer. | 1615 * @buffer: an #hb_buffer_t. |
| 1521 * @text: (array length=text_length): | 1616 * @text: (array length=text_length): an array of UTF-16 characters to append. |
| 1522 * @text_length: | 1617 * @text_length: the length of the @text, or -1 if it is %NULL terminated. |
| 1523 * @item_offset: | 1618 * @item_offset: the offset of the first character to add to the @buffer. |
| 1524 * @item_length: | 1619 * @item_length: the number of characters to add to the @buffer, or -1 for the |
| 1620 * end of @text (assuming it is %NULL terminated). |
| 1525 * | 1621 * |
| 1526 * | 1622 * See hb_buffer_add_codepoints(). |
| 1623 * |
| 1624 * Replaces invalid UTF-16 characters with the @buffer replacement code point, |
| 1625 * see hb_buffer_set_replacement_codepoint(). |
| 1527 * | 1626 * |
| 1528 * Since: 0.9.2 | 1627 * Since: 0.9.2 |
| 1529 **/ | 1628 **/ |
| 1530 void | 1629 void |
| 1531 hb_buffer_add_utf16 (hb_buffer_t *buffer, | 1630 hb_buffer_add_utf16 (hb_buffer_t *buffer, |
| 1532 const uint16_t *text, | 1631 const uint16_t *text, |
| 1533 int text_length, | 1632 int text_length, |
| 1534 unsigned int item_offset, | 1633 unsigned int item_offset, |
| 1535 int item_length) | 1634 int item_length) |
| 1536 { | 1635 { |
| 1537 hb_buffer_add_utf<hb_utf16_t> (buffer, text, text_length, item_offset, item_le
ngth); | 1636 hb_buffer_add_utf<hb_utf16_t> (buffer, text, text_length, item_offset, item_le
ngth); |
| 1538 } | 1637 } |
| 1539 | 1638 |
| 1540 /** | 1639 /** |
| 1541 * hb_buffer_add_utf32: | 1640 * hb_buffer_add_utf32: |
| 1542 * @buffer: a buffer. | 1641 * @buffer: an #hb_buffer_t. |
| 1543 * @text: (array length=text_length): | 1642 * @text: (array length=text_length): an array of UTF-32 characters to append. |
| 1544 * @text_length: | 1643 * @text_length: the length of the @text, or -1 if it is %NULL terminated. |
| 1545 * @item_offset: | 1644 * @item_offset: the offset of the first character to add to the @buffer. |
| 1546 * @item_length: | 1645 * @item_length: the number of characters to add to the @buffer, or -1 for the |
| 1646 * end of @text (assuming it is %NULL terminated). |
| 1547 * | 1647 * |
| 1548 * | 1648 * See hb_buffer_add_codepoints(). |
| 1649 * |
| 1650 * Replaces invalid UTF-32 characters with the @buffer replacement code point, |
| 1651 * see hb_buffer_set_replacement_codepoint(). |
| 1549 * | 1652 * |
| 1550 * Since: 0.9.2 | 1653 * Since: 0.9.2 |
| 1551 **/ | 1654 **/ |
| 1552 void | 1655 void |
| 1553 hb_buffer_add_utf32 (hb_buffer_t *buffer, | 1656 hb_buffer_add_utf32 (hb_buffer_t *buffer, |
| 1554 const uint32_t *text, | 1657 const uint32_t *text, |
| 1555 int text_length, | 1658 int text_length, |
| 1556 unsigned int item_offset, | 1659 unsigned int item_offset, |
| 1557 int item_length) | 1660 int item_length) |
| 1558 { | 1661 { |
| 1559 hb_buffer_add_utf<hb_utf32_t<> > (buffer, text, text_length, item_offset, item
_length); | 1662 hb_buffer_add_utf<hb_utf32_t<> > (buffer, text, text_length, item_offset, item
_length); |
| 1560 } | 1663 } |
| 1561 | 1664 |
| 1562 /** | 1665 /** |
| 1563 * hb_buffer_add_latin1: | 1666 * hb_buffer_add_latin1: |
| 1564 * @buffer: a buffer. | 1667 * @buffer: an #hb_buffer_t. |
| 1565 * @text: (array length=text_length) (element-type uint8_t): | 1668 * @text: (array length=text_length) (element-type uint8_t): an array of UTF-8 |
| 1566 * @text_length: | 1669 * characters to append. |
| 1567 * @item_offset: | 1670 * @text_length: the length of the @text, or -1 if it is %NULL terminated. |
| 1568 * @item_length: | 1671 * @item_offset: the offset of the first character to add to the @buffer. |
| 1672 * @item_length: the number of characters to add to the @buffer, or -1 for the |
| 1673 * end of @text (assuming it is %NULL terminated). |
| 1569 * | 1674 * |
| 1570 * | 1675 * Similar to hb_buffer_add_codepoints(), but allows only access to first 256 |
| 1676 * Unicode code points that can fit in 8-bit strings. |
| 1677 * |
| 1678 * <note>Has nothing to do with non-Unicode Latin-1 encoding.</note> |
| 1571 * | 1679 * |
| 1572 * Since: 0.9.39 | 1680 * Since: 0.9.39 |
| 1573 **/ | 1681 **/ |
| 1574 void | 1682 void |
| 1575 hb_buffer_add_latin1 (hb_buffer_t *buffer, | 1683 hb_buffer_add_latin1 (hb_buffer_t *buffer, |
| 1576 const uint8_t *text, | 1684 const uint8_t *text, |
| 1577 int text_length, | 1685 int text_length, |
| 1578 unsigned int item_offset, | 1686 unsigned int item_offset, |
| 1579 int item_length) | 1687 int item_length) |
| 1580 { | 1688 { |
| 1581 hb_buffer_add_utf<hb_latin1_t> (buffer, text, text_length, item_offset, item_l
ength); | 1689 hb_buffer_add_utf<hb_latin1_t> (buffer, text, text_length, item_offset, item_l
ength); |
| 1582 } | 1690 } |
| 1583 | 1691 |
| 1584 /** | 1692 /** |
| 1585 * hb_buffer_add_codepoints: | 1693 * hb_buffer_add_codepoints: |
| 1586 * @buffer: a buffer. | 1694 * @buffer: a #hb_buffer_t to append characters to. |
| 1587 * @text: (array length=text_length): | 1695 * @text: (array length=text_length): an array of Unicode code points to append. |
| 1588 * @text_length: | 1696 * @text_length: the length of the @text, or -1 if it is %NULL terminated. |
| 1589 * @item_offset: | 1697 * @item_offset: the offset of the first code point to add to the @buffer. |
| 1590 * @item_length: | 1698 * @item_length: the number of code points to add to the @buffer, or -1 for the |
| 1699 * end of @text (assuming it is %NULL terminated). |
| 1591 * | 1700 * |
| 1592 * | 1701 * Appends characters from @text array to @buffer. The @item_offset is the |
| 1702 * position of the first character from @text that will be appended, and |
| 1703 * @item_length is the number of character. When shaping part of a larger text |
| 1704 * (e.g. a run of text from a paragraph), instead of passing just the substring |
| 1705 * corresponding to the run, it is preferable to pass the whole |
| 1706 * paragraph and specify the run start and length as @item_offset and |
| 1707 * @item_length, respectively, to give HarfBuzz the full context to be able, |
| 1708 * for example, to do cross-run Arabic shaping or properly handle combining |
| 1709 * marks at stat of run. |
| 1710 * |
| 1711 * This function does not check the validity of @text, it is up to the caller |
| 1712 * to ensure it contains a valid Unicode code points. |
| 1593 * | 1713 * |
| 1594 * Since: 0.9.31 | 1714 * Since: 0.9.31 |
| 1595 **/ | 1715 **/ |
| 1596 void | 1716 void |
| 1597 hb_buffer_add_codepoints (hb_buffer_t *buffer, | 1717 hb_buffer_add_codepoints (hb_buffer_t *buffer, |
| 1598 const hb_codepoint_t *text, | 1718 const hb_codepoint_t *text, |
| 1599 int text_length, | 1719 int text_length, |
| 1600 unsigned int item_offset, | 1720 unsigned int item_offset, |
| 1601 int item_length) | 1721 int item_length) |
| 1602 { | 1722 { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 for (unsigned int i = start + 1; i < end; i++) { | 1774 for (unsigned int i = start + 1; i < end; i++) { |
| 1655 pos[i].x_offset -= total_x_advance; | 1775 pos[i].x_offset -= total_x_advance; |
| 1656 pos[i].y_offset -= total_y_advance; | 1776 pos[i].y_offset -= total_y_advance; |
| 1657 } | 1777 } |
| 1658 hb_stable_sort (buffer->info + start + 1, end - start - 1, compare_info_code
point, buffer->pos + start + 1); | 1778 hb_stable_sort (buffer->info + start + 1, end - start - 1, compare_info_code
point, buffer->pos + start + 1); |
| 1659 } | 1779 } |
| 1660 } | 1780 } |
| 1661 | 1781 |
| 1662 /** | 1782 /** |
| 1663 * hb_buffer_normalize_glyphs: | 1783 * hb_buffer_normalize_glyphs: |
| 1664 * @buffer: a buffer. | 1784 * @buffer: an #hb_buffer_t. |
| 1665 * | 1785 * |
| 1666 * | 1786 * Reorders a glyph buffer to have canonical in-cluster glyph order / position. |
| 1787 * The resulting clusters should behave identical to pre-reordering clusters. |
| 1788 * |
| 1789 * <note>This has nothing to do with Unicode normalization.</note> |
| 1667 * | 1790 * |
| 1668 * Since: 0.9.2 | 1791 * Since: 0.9.2 |
| 1669 **/ | 1792 **/ |
| 1670 void | 1793 void |
| 1671 hb_buffer_normalize_glyphs (hb_buffer_t *buffer) | 1794 hb_buffer_normalize_glyphs (hb_buffer_t *buffer) |
| 1672 { | 1795 { |
| 1673 assert (buffer->have_positions); | 1796 assert (buffer->have_positions); |
| 1674 assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); | 1797 assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); |
| 1675 | 1798 |
| 1676 bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); | 1799 bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1702 continue; | 1825 continue; |
| 1703 /* Move item i to occupy place for item j, shift what's in between. */ | 1826 /* Move item i to occupy place for item j, shift what's in between. */ |
| 1704 merge_clusters (j, i + 1); | 1827 merge_clusters (j, i + 1); |
| 1705 { | 1828 { |
| 1706 hb_glyph_info_t t = info[i]; | 1829 hb_glyph_info_t t = info[i]; |
| 1707 memmove (&info[j + 1], &info[j], (i - j) * sizeof (hb_glyph_info_t)); | 1830 memmove (&info[j + 1], &info[j], (i - j) * sizeof (hb_glyph_info_t)); |
| 1708 info[j] = t; | 1831 info[j] = t; |
| 1709 } | 1832 } |
| 1710 } | 1833 } |
| 1711 } | 1834 } |
| 1835 |
| 1836 /* |
| 1837 * Debugging. |
| 1838 */ |
| 1839 |
| 1840 /** |
| 1841 * hb_buffer_set_message_func: |
| 1842 * @buffer: an #hb_buffer_t. |
| 1843 * @func: (closure user_data) (destroy destroy) (scope notified): |
| 1844 * @user_data: |
| 1845 * @destroy: |
| 1846 * |
| 1847 * |
| 1848 * |
| 1849 * Since: 1.1.3 |
| 1850 **/ |
| 1851 void |
| 1852 hb_buffer_set_message_func (hb_buffer_t *buffer, |
| 1853 hb_buffer_message_func_t func, |
| 1854 void *user_data, hb_destroy_func_t destroy) |
| 1855 { |
| 1856 if (buffer->message_destroy) |
| 1857 buffer->message_destroy (buffer->message_data); |
| 1858 |
| 1859 if (func) { |
| 1860 buffer->message_func = func; |
| 1861 buffer->message_data = user_data; |
| 1862 buffer->message_destroy = destroy; |
| 1863 } else { |
| 1864 buffer->message_func = NULL; |
| 1865 buffer->message_data = NULL; |
| 1866 buffer->message_destroy = NULL; |
| 1867 } |
| 1868 } |
| 1869 |
| 1870 bool |
| 1871 hb_buffer_t::message_impl (hb_font_t *font, const char *fmt, va_list ap) |
| 1872 { |
| 1873 char buf[100]; |
| 1874 vsnprintf (buf, sizeof (buf), fmt, ap); |
| 1875 return (bool) this->message_func (this, font, buf, this->message_data); |
| 1876 } |
| OLD | NEW |