2 * Copyright (C) 2006 Behdad Esfahbod
4 * This is part of HarfBuzz, an OpenType Layout engine library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
26 #include "hb_unicode_tables.h"
28 #include "harfbuzz-buffer.c"
29 #include "harfbuzz-gdef.c"
30 #include "harfbuzz-gsub.c"
31 #include "harfbuzz-gpos.c"
32 #include "harfbuzz-impl.c"
33 #include "harfbuzz-open.c"
34 #include "harfbuzz-stream.c"
37 HB_Error hb_getScriptID(HB_UShort value, HB_Script *scriptID)
39 HB_Error error = HB_Err_Ok;
40 hb_uint8 script = value>>8;
42 *scriptID = HB_Script_Common;
44 if(0 == scriptTableStruct[script].pSubTable)
46 *scriptID = (HB_Script)scriptTableStruct[script].scriptID;
48 else if(scriptTableStruct[script].pSubTable != 0)
50 if((value&0xFF) < scriptTableStruct[script].scriptID)//check the size of the sub table array
52 *scriptID = scriptTableStruct[script].pSubTable[(value&0xFF)];
56 error = HB_Err_Not_Covered;
61 error = HB_Err_Invalid_SubTable;
67 HB_Error hb_getTextWithScriptID(HB_UShort *text, int textLen, HB_Script *scriptID, int *scriptLen)
69 HB_Script cur_script_id;
70 HB_Error error = HB_Err_Ok;
71 HB_UShort *curText = text ;
73 *scriptID = HB_Script_Common;
76 if((NULL == curText) || (0 == textLen))
78 return HB_Err_Invalid_Argument;
81 hb_getScriptID(*curText, scriptID);
88 if(HB_DOTTED_CIRCLE == *curText || HB_ZWJ == *curText || HB_ZWNJ == *curText)
95 hb_getScriptID(*curText, &cur_script_id);
97 if(*scriptID != cur_script_id)
106 *scriptLen = curText -text ;
112 int hb_getSyllableLength(HB_UShort *text, int textLen, HB_Script *scriptID)
118 case HB_Script_Devanagari:
119 case HB_Script_Bengali:
120 case HB_Script_Gurmukhi:
121 case HB_Script_Gujarati:
122 case HB_Script_Oriya:
123 case HB_Script_Tamil:
124 case HB_Script_Telugu:
125 case HB_Script_Kannada:
126 case HB_Script_Malayalam:
127 case HB_Script_Sinhala:
128 len = indic_nextSyllableBoundary(*scriptID, (const HB_UChar16*)text, 0, textLen, &invalid);
130 case HB_Script_Khmer:
131 len = khmer_nextSyllableBoundary(text, 0, textLen, &invalid);
133 case HB_Script_Myanmar:
134 len = myanmar_nextSyllableBoundary(text, 0, textLen, &invalid);
136 case HB_Script_Tibetan:
137 len = tibetan_nextSyllableBoundary(text, 0, textLen, &invalid);