../3rdparty/harfbuzz/src/harfbuzz-tibetan.c

Switch to Source codePreprocessed file
LineSource CodeCoverage
1typedef enum { -
2 TibetanOther, -
3 TibetanHeadConsonant, -
4 TibetanSubjoinedConsonant, -
5 TibetanSubjoinedVowel, -
6 TibetanVowel -
7} TibetanForm; -
8 -
9 -
10static const unsigned char tibetanForm[0x80] = { -
11 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
12 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
13 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
14 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
15 -
16 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
17 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
18 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
19 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
20 -
21 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
22 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
23 TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, -
24 TibetanOther, TibetanOther, TibetanOther, TibetanOther, -
25 -
26 TibetanOther, TibetanVowel, TibetanVowel, TibetanVowel, -
27 TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel, -
28 TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel, -
29 TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel, -
30 -
31 TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel, -
32 TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel, -
33 TibetanOther, TibetanOther, TibetanOther, TibetanOther, -
34 TibetanOther, TibetanOther, TibetanOther, TibetanOther, -
35 -
36 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
37 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
38 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
39 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
40 -
41 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
42 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
43 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
44 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
45 -
46 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
47 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
48 TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, -
49 TibetanSubjoinedConsonant, TibetanOther, TibetanOther, TibetanOther -
50}; -
51 -
52 -
53 -
54 -
55 -
56 -
57static const HB_OpenTypeFeature tibetan_features[] = { -
58 { ( ( (HB_UInt)'c' << 24 ) | ( (HB_UInt)'c' << 16 ) | ( (HB_UInt)'m' << 8 ) | (HB_UInt)'p' ), CcmpProperty }, -
59 { ( ( (HB_UInt)'a' << 24 ) | ( (HB_UInt)'b' << 16 ) | ( (HB_UInt)'v' << 8 ) | (HB_UInt)'s' ), AboveSubstProperty }, -
60 { ( ( (HB_UInt)'b' << 24 ) | ( (HB_UInt)'l' << 16 ) | ( (HB_UInt)'w' << 8 ) | (HB_UInt)'s' ), BelowSubstProperty }, -
61 { ( ( (HB_UInt)'c' << 24 ) | ( (HB_UInt)'a' << 16 ) | ( (HB_UInt)'l' << 8 ) | (HB_UInt)'t' ), CaltProperty }, -
62 {0, 0} -
63}; -
64 -
65 -
66static HB_Bool tibetan_shape_syllable(HB_Bool openType, HB_ShaperItem *item, HB_Bool invalid) -
67{ -
68 hb_uint32 i; -
69 const HB_UChar16 *str = item->string + item->item.pos; -
70 int len = item->item.length; -
71 -
72 const int availableGlyphs = item->num_glyphs; -
73 -
74 HB_Bool haveGlyphs; -
75 HB_UChar16 stackreordered[512]; HB_UChar16 *reordered = stackreordered; if ((len + 4) >= 512) reordered = (HB_UChar16 *)malloc((len + 4) * sizeof(HB_UChar16));;
never executed: reordered = (HB_UChar16 *)malloc((len + 4) * sizeof(HB_UChar16));
never evaluated: (len + 4) >= 512
0
76 -
77 if (item->num_glyphs < item->item.length + 4) {
never evaluated: item->num_glyphs < item->item.length + 4
0
78 item->num_glyphs = item->item.length + 4; -
79 return 0;
never executed: return 0;
0
80 } -
81 -
82 if (invalid) {
never evaluated: invalid
0
83 *reordered = 0x25cc; -
84 memcpy(reordered+1, str, len*sizeof(HB_UChar16)); -
85 len++; -
86 str = reordered; -
87 }
never executed: }
0
88 -
89 haveGlyphs = item->font->klass->convertStringToGlyphIndices(item->font, -
90 str, len, -
91 item->glyphs, &item->num_glyphs, -
92 item->item.bidiLevel % 2); -
93 -
94 if (stackreordered != reordered) free(reordered);;
never executed: free(reordered);
never evaluated: stackreordered != reordered
0
95 -
96 if (!haveGlyphs)
never evaluated: !haveGlyphs
0
97 return 0;
never executed: return 0;
0
98 -
99 for (i = 0; i < item->item.length; i++) {
never evaluated: i < item->item.length
0
100 item->attributes[i].mark = 0; -
101 item->attributes[i].clusterStart = 0; -
102 item->attributes[i].justification = 0; -
103 item->attributes[i].zeroWidth = 0; -
104 -
105 }
never executed: }
0
106 -
107 -
108 -
109 -
110 if (openType) {
never evaluated: openType
0
111 HB_OpenTypeShape(item, 0); -
112 if (!HB_OpenTypePosition(item, availableGlyphs, 0))
never evaluated: !HB_OpenTypePosition(item, availableGlyphs, 0)
0
113 return 0;
never executed: return 0;
0
114 } else {
never executed: }
0
115 HB_HeuristicPosition(item); -
116 }
never executed: }
0
117 -
118 -
119 item->attributes[0].clusterStart = (!0); -
120 return (!0);
never executed: return (!0);
0
121} -
122 -
123 -
124static int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) -
125{ -
126 const HB_UChar16 *uc = s + start; -
127 -
128 int pos = 0; -
129 TibetanForm state = (TibetanForm)tibetanForm[*uc - 0x0f40]; -
130 -
131 -
132 pos++; -
133 -
134 if (state != TibetanHeadConsonant) {
never evaluated: state != TibetanHeadConsonant
0
135 if (state != TibetanOther)
never evaluated: state != TibetanOther
0
136 *invalid = (!0);
never executed: *invalid = (!0);
0
137 goto finish;
never executed: goto finish;
0
138 } -
139 -
140 while (pos < end - start) {
never evaluated: pos < end - start
0
141 TibetanForm newState = (TibetanForm)tibetanForm[uc[pos] - 0x0f40]; -
142 switch(newState) { -
143 case TibetanSubjoinedConsonant: -
144 case TibetanSubjoinedVowel: -
145 if (state != TibetanHeadConsonant &&
never evaluated: state != TibetanHeadConsonant
0
146 state != TibetanSubjoinedConsonant)
never evaluated: state != TibetanSubjoinedConsonant
0
147 goto finish;
never executed: goto finish;
0
148 state = newState; -
149 break;
never executed: break;
0
150 case TibetanVowel: -
151 if (state != TibetanHeadConsonant &&
never evaluated: state != TibetanHeadConsonant
0
152 state != TibetanSubjoinedConsonant &&
never evaluated: state != TibetanSubjoinedConsonant
0
153 state != TibetanSubjoinedVowel)
never evaluated: state != TibetanSubjoinedVowel
0
154 goto finish;
never executed: goto finish;
0
155 break;
never executed: break;
0
156 case TibetanOther: -
157 case TibetanHeadConsonant: -
158 goto finish;
never executed: goto finish;
0
159 } -
160 pos++; -
161 }
never executed: }
0
162 -
163finish:
code before this statement never executed: finish:
0
164 *invalid = 0; -
165 return start+pos;
never executed: return start+pos;
0
166} -
167 -
168HB_Bool HB_TibetanShape(HB_ShaperItem *item) -
169{ -
170 -
171 HB_Bool openType = 0; -
172 unsigned short *logClusters = item->log_clusters; -
173 -
174 HB_ShaperItem syllable = *item; -
175 int first_glyph = 0; -
176 -
177 int sstart = item->item.pos; -
178 int end = sstart + item->item.length; -
179 -
180 ((item->item.script == HB_Script_Tibetan) ? static_cast<void> (0) : __assert_fail ("item->item.script == HB_Script_Tibetan", "../3rdparty/harfbuzz/src/harfbuzz-tibetan.c", 219, __PRETTY_FUNCTION__)); -
181 -
182 -
183 openType = HB_SelectScript(item, tibetan_features); -
184 -
185 -
186 while (sstart < end) {
never evaluated: sstart < end
0
187 HB_Bool invalid; -
188 int i; -
189 int send = tibetan_nextSyllableBoundary(item->string, sstart, end, &invalid); -
190 -
191 -
192 syllable.item.pos = sstart; -
193 syllable.item.length = send-sstart; -
194 syllable.glyphs = item->glyphs + first_glyph; -
195 syllable.attributes = item->attributes + first_glyph; -
196 syllable.offsets = item->offsets + first_glyph; -
197 syllable.advances = item->advances + first_glyph; -
198 syllable.num_glyphs = item->num_glyphs - first_glyph; -
199 if (!tibetan_shape_syllable(openType, &syllable, invalid)) {
never evaluated: !tibetan_shape_syllable(openType, &syllable, invalid)
0
200 item->num_glyphs += syllable.num_glyphs; -
201 return 0;
never executed: return 0;
0
202 } -
203 -
204 for (i = sstart; i < send; ++i)
never evaluated: i < send
0
205 logClusters[i-item->item.pos] = first_glyph;
never executed: logClusters[i-item->item.pos] = first_glyph;
0
206 sstart = send; -
207 first_glyph += syllable.num_glyphs; -
208 }
never executed: }
0
209 item->num_glyphs = first_glyph; -
210 return (!0);
never executed: return (!0);
0
211} -
212 -
213void HB_TibetanAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes) -
214{ -
215 int end = from + len; -
216 const HB_UChar16 *uc = text + from; -
217 hb_uint32 i = 0; -
218 ((script) = (script)); -
219 attributes += from; -
220 while (i < len) {
never evaluated: i < len
0
221 HB_Bool invalid; -
222 hb_uint32 boundary = tibetan_nextSyllableBoundary(text, from+i, end, &invalid) - from; -
223 -
224 attributes[i].graphemeBoundary = (!0); -
225 -
226 if (boundary > len-1) boundary = len;
never executed: boundary = len;
never evaluated: boundary > len-1
0
227 i++; -
228 while (i < boundary) {
never evaluated: i < boundary
0
229 attributes[i].graphemeBoundary = 0; -
230 ++uc; -
231 ++i; -
232 }
never executed: }
0
233 ((i == boundary) ? static_cast<void> (0) : __assert_fail ("i == boundary", "../3rdparty/harfbuzz/src/harfbuzz-tibetan.c", 272, __PRETTY_FUNCTION__)); -
234 }
never executed: }
0
235}
never executed: }
0
236 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial