1 #include "harfbuzz-external.h" 2 3 #include <glib.h> 4 5 static int hb_category_for_char(HB_UChar32 ch)6hb_category_for_char(HB_UChar32 ch) { 7 switch (g_unichar_type(ch)) { 8 case G_UNICODE_CONTROL: 9 return HB_Other_Control; 10 case G_UNICODE_FORMAT: 11 return HB_Other_Format; 12 case G_UNICODE_UNASSIGNED: 13 return HB_Other_NotAssigned; 14 case G_UNICODE_PRIVATE_USE: 15 return HB_Other_PrivateUse; 16 case G_UNICODE_SURROGATE: 17 return HB_Other_Surrogate; 18 case G_UNICODE_LOWERCASE_LETTER: 19 return HB_Letter_Lowercase; 20 case G_UNICODE_MODIFIER_LETTER: 21 return HB_Letter_Modifier; 22 case G_UNICODE_OTHER_LETTER: 23 return HB_Letter_Other; 24 case G_UNICODE_TITLECASE_LETTER: 25 return HB_Letter_Titlecase; 26 case G_UNICODE_UPPERCASE_LETTER: 27 return HB_Letter_Uppercase; 28 case G_UNICODE_COMBINING_MARK: 29 return HB_Mark_SpacingCombining; 30 case G_UNICODE_ENCLOSING_MARK: 31 return HB_Mark_Enclosing; 32 case G_UNICODE_NON_SPACING_MARK: 33 return HB_Mark_NonSpacing; 34 case G_UNICODE_DECIMAL_NUMBER: 35 return HB_Number_DecimalDigit; 36 case G_UNICODE_LETTER_NUMBER: 37 return HB_Number_Letter; 38 case G_UNICODE_OTHER_NUMBER: 39 return HB_Number_Other; 40 case G_UNICODE_CONNECT_PUNCTUATION: 41 return HB_Punctuation_Connector; 42 case G_UNICODE_DASH_PUNCTUATION: 43 return HB_Punctuation_Dash; 44 case G_UNICODE_CLOSE_PUNCTUATION: 45 return HB_Punctuation_Close; 46 case G_UNICODE_FINAL_PUNCTUATION: 47 return HB_Punctuation_FinalQuote; 48 case G_UNICODE_INITIAL_PUNCTUATION: 49 return HB_Punctuation_InitialQuote; 50 case G_UNICODE_OTHER_PUNCTUATION: 51 return HB_Punctuation_Other; 52 case G_UNICODE_OPEN_PUNCTUATION: 53 return HB_Punctuation_Open; 54 case G_UNICODE_CURRENCY_SYMBOL: 55 return HB_Symbol_Currency; 56 case G_UNICODE_MODIFIER_SYMBOL: 57 return HB_Symbol_Modifier; 58 case G_UNICODE_MATH_SYMBOL: 59 return HB_Symbol_Math; 60 case G_UNICODE_OTHER_SYMBOL: 61 return HB_Symbol_Other; 62 case G_UNICODE_LINE_SEPARATOR: 63 return HB_Separator_Line; 64 case G_UNICODE_PARAGRAPH_SEPARATOR: 65 return HB_Separator_Paragraph; 66 case G_UNICODE_SPACE_SEPARATOR: 67 return HB_Separator_Space; 68 default: 69 return HB_Symbol_Other; 70 } 71 } 72 73 HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch)74HB_GetLineBreakClass(HB_UChar32 ch) { 75 switch (g_unichar_break_type(ch)) { 76 case G_UNICODE_BREAK_MANDATORY: 77 return HB_LineBreak_BK; 78 case G_UNICODE_BREAK_CARRIAGE_RETURN: 79 return HB_LineBreak_CR; 80 case G_UNICODE_BREAK_LINE_FEED: 81 return HB_LineBreak_LF; 82 case G_UNICODE_BREAK_COMBINING_MARK: 83 return HB_LineBreak_CM; 84 case G_UNICODE_BREAK_SURROGATE: 85 return HB_LineBreak_SG; 86 case G_UNICODE_BREAK_ZERO_WIDTH_SPACE: 87 return HB_LineBreak_ZW; 88 case G_UNICODE_BREAK_INSEPARABLE: 89 return HB_LineBreak_IN; 90 case G_UNICODE_BREAK_NON_BREAKING_GLUE: 91 return HB_LineBreak_GL; 92 case G_UNICODE_BREAK_CONTINGENT: 93 return HB_LineBreak_AL; 94 case G_UNICODE_BREAK_SPACE: 95 return HB_LineBreak_SP; 96 case G_UNICODE_BREAK_AFTER: 97 return HB_LineBreak_BA; 98 case G_UNICODE_BREAK_BEFORE: 99 return HB_LineBreak_BB; 100 case G_UNICODE_BREAK_BEFORE_AND_AFTER: 101 return HB_LineBreak_B2; 102 case G_UNICODE_BREAK_HYPHEN: 103 return HB_LineBreak_HY; 104 case G_UNICODE_BREAK_NON_STARTER: 105 return HB_LineBreak_NS; 106 case G_UNICODE_BREAK_OPEN_PUNCTUATION: 107 return HB_LineBreak_OP; 108 case G_UNICODE_BREAK_CLOSE_PUNCTUATION: 109 return HB_LineBreak_CL; 110 case G_UNICODE_BREAK_QUOTATION: 111 return HB_LineBreak_QU; 112 case G_UNICODE_BREAK_EXCLAMATION: 113 return HB_LineBreak_EX; 114 case G_UNICODE_BREAK_IDEOGRAPHIC: 115 return HB_LineBreak_ID; 116 case G_UNICODE_BREAK_NUMERIC: 117 return HB_LineBreak_NU; 118 case G_UNICODE_BREAK_INFIX_SEPARATOR: 119 return HB_LineBreak_IS; 120 case G_UNICODE_BREAK_SYMBOL: 121 return HB_LineBreak_SY; 122 case G_UNICODE_BREAK_ALPHABETIC: 123 return HB_LineBreak_AL; 124 case G_UNICODE_BREAK_PREFIX: 125 return HB_LineBreak_PR; 126 case G_UNICODE_BREAK_POSTFIX: 127 return HB_LineBreak_PO; 128 case G_UNICODE_BREAK_COMPLEX_CONTEXT: 129 return HB_LineBreak_SA; 130 case G_UNICODE_BREAK_AMBIGUOUS: 131 return HB_LineBreak_AL; 132 case G_UNICODE_BREAK_UNKNOWN: 133 return HB_LineBreak_AL; 134 case G_UNICODE_BREAK_NEXT_LINE: 135 return HB_LineBreak_AL; 136 case G_UNICODE_BREAK_WORD_JOINER: 137 return HB_LineBreak_WJ; 138 case G_UNICODE_BREAK_HANGUL_L_JAMO: 139 return HB_LineBreak_JL; 140 case G_UNICODE_BREAK_HANGUL_V_JAMO: 141 return HB_LineBreak_JV; 142 case G_UNICODE_BREAK_HANGUL_T_JAMO: 143 return HB_LineBreak_JT; 144 case G_UNICODE_BREAK_HANGUL_LV_SYLLABLE: 145 return HB_LineBreak_H2; 146 case G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE: 147 return HB_LineBreak_H3; 148 default: 149 return HB_LineBreak_AL; 150 } 151 } 152 153 int HB_GetUnicodeCharCombiningClass(HB_UChar32 ch)154HB_GetUnicodeCharCombiningClass(HB_UChar32 ch) { 155 return g_unichar_combining_class(ch); 156 } 157 158 void HB_GetUnicodeCharProperties(HB_UChar32 ch,HB_CharCategory * category,int * combiningClass)159HB_GetUnicodeCharProperties(HB_UChar32 ch, 160 HB_CharCategory *category, 161 int *combiningClass) { 162 *category = hb_category_for_char(ch); 163 *combiningClass = g_unichar_combining_class(ch); 164 } 165 166 HB_CharCategory HB_GetUnicodeCharCategory(HB_UChar32 ch)167HB_GetUnicodeCharCategory(HB_UChar32 ch) { 168 return hb_category_for_char(ch); 169 } 170