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

Switch to Source codePreprocessed file
LineSource CodeCoverage
1enum { -
2 Hangul_SBase = 0xac00, -
3 Hangul_LBase = 0x1100, -
4 Hangul_VBase = 0x1161, -
5 Hangul_TBase = 0x11a7, -
6 Hangul_SCount = 11172, -
7 Hangul_LCount = 19, -
8 Hangul_VCount = 21, -
9 Hangul_TCount = 28, -
10 Hangul_NCount = 21*28 -
11}; -
12 -
13 -
14 -
15 -
16 -
17 -
18 -
19typedef enum { -
20 L, -
21 V, -
22 T, -
23 LV, -
24 LVT, -
25 X -
26} HangulType; -
27 -
28static HangulType hangul_type(unsigned short uc) { -
29 if (uc > Hangul_SBase && uc < Hangul_SBase + Hangul_SCount)
evaluated: uc > Hangul_SBase
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:8
partially evaluated: uc < Hangul_SBase + Hangul_SCount
TRUEFALSE
yes
Evaluation Count:28
no
Evaluation Count:0
0-28
30 return ((uc - Hangul_SBase) % Hangul_TCount == 0) ? LV : LVT;
executed: return ((uc - Hangul_SBase) % Hangul_TCount == 0) ? LV : LVT;
Execution Count:28
28
31 if (uc < Hangul_LBase || uc > 0x11ff)
partially evaluated: uc < Hangul_LBase
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
never evaluated: uc > 0x11ff
0-8
32 return X;
executed: return X;
Execution Count:8
8
33 if (uc < Hangul_VBase)
never evaluated: uc < Hangul_VBase
0
34 return L;
never executed: return L;
0
35 if (uc < Hangul_TBase)
never evaluated: uc < Hangul_TBase
0
36 return V;
never executed: return V;
0
37 return T;
never executed: return T;
0
38} -
39 -
40static int hangul_nextSyllableBoundary(const HB_UChar16 *s, int start, int end) -
41{ -
42 const HB_UChar16 *uc = s + start; -
43 -
44 HangulType state = hangul_type(*uc); -
45 int pos = 1; -
46 -
47 while (pos < end - start) {
evaluated: pos < end - start
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:4
4-16
48 HangulType newState = hangul_type(uc[pos]); -
49 switch(newState) { -
50 case X: -
51 goto finish;
executed: goto finish;
Execution Count:4
4
52 case L: -
53 case V: -
54 case T: -
55 if (state > newState)
never evaluated: state > newState
0
56 goto finish;
never executed: goto finish;
0
57 state = newState; -
58 break;
never executed: break;
0
59 case LV: -
60 if (state > L)
partially evaluated: state > L
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
61 goto finish;
executed: goto finish;
Execution Count:8
8
62 state = V; -
63 break;
never executed: break;
0
64 case LVT: -
65 if (state > L)
partially evaluated: state > L
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
66 goto finish;
executed: goto finish;
Execution Count:4
4
67 state = T; -
68 }
never executed: }
0
69 ++pos; -
70 }
never executed: }
0
71 -
72 finish: -
73 return start+pos;
executed: return start+pos;
Execution Count:20
20
74} -
75 -
76 -
77static const HB_OpenTypeFeature hangul_features [] = { -
78 { ( ( (HB_UInt)'c' << 24 ) | ( (HB_UInt)'c' << 16 ) | ( (HB_UInt)'m' << 8 ) | (HB_UInt)'p' ), CcmpProperty }, -
79 { ( ( (HB_UInt)'l' << 24 ) | ( (HB_UInt)'j' << 16 ) | ( (HB_UInt)'m' << 8 ) | (HB_UInt)'o' ), CcmpProperty }, -
80 { ( ( (HB_UInt)'v' << 24 ) | ( (HB_UInt)'j' << 16 ) | ( (HB_UInt)'m' << 8 ) | (HB_UInt)'o' ), CcmpProperty }, -
81 { ( ( (HB_UInt)'t' << 24 ) | ( (HB_UInt)'j' << 16 ) | ( (HB_UInt)'m' << 8 ) | (HB_UInt)'o' ), CcmpProperty }, -
82 { 0, 0 } -
83}; -
84 -
85 -
86static HB_Bool hangul_shape_syllable(HB_ShaperItem *item, HB_Bool openType) -
87{ -
88 const HB_UChar16 *ch = item->string + item->item.pos; -
89 int len = item->item.length; -
90 -
91 const int availableGlyphs = item->num_glyphs; -
92 -
93 -
94 int i; -
95 HB_UChar16 composed = 0; -
96 -
97 if (item->item.length == 2) {
partially evaluated: item->item.length == 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
98 int LIndex = ch[0] - Hangul_LBase; -
99 int VIndex = ch[1] - Hangul_VBase; -
100 if (LIndex >= 0 && LIndex < Hangul_LCount &&
never evaluated: LIndex >= 0
never evaluated: LIndex < Hangul_LCount
0
101 VIndex >= 0 && VIndex < Hangul_VCount)
never evaluated: VIndex >= 0
never evaluated: VIndex < Hangul_VCount
0
102 composed = (LIndex * Hangul_VCount + VIndex) * Hangul_TCount + Hangul_SBase;
never executed: composed = (LIndex * Hangul_VCount + VIndex) * Hangul_TCount + Hangul_SBase;
0
103 } else if (item->item.length == 3) {
never executed: }
partially evaluated: item->item.length == 3
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
104 int LIndex = ch[0] - Hangul_LBase; -
105 int VIndex = ch[1] - Hangul_VBase; -
106 int TIndex = ch[2] - Hangul_TBase; -
107 if (LIndex >= 0 && LIndex < Hangul_LCount &&
never evaluated: LIndex >= 0
never evaluated: LIndex < Hangul_LCount
0
108 VIndex >= 0 && VIndex < Hangul_VCount &&
never evaluated: VIndex >= 0
never evaluated: VIndex < Hangul_VCount
0
109 TIndex >= 0 && TIndex < Hangul_TCount)
never evaluated: TIndex >= 0
never evaluated: TIndex < Hangul_TCount
0
110 composed = (LIndex * Hangul_VCount + VIndex) * Hangul_TCount + TIndex + Hangul_SBase;
never executed: composed = (LIndex * Hangul_VCount + VIndex) * Hangul_TCount + TIndex + Hangul_SBase;
0
111 }
never executed: }
0
112 -
113 -
114 -
115 -
116 if (composed) {
partially evaluated: composed
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
117 ch = &composed; -
118 len = 1; -
119 }
never executed: }
0
120 -
121 if (!item->font->klass->convertStringToGlyphIndices(item->font, 0-20
122 ch, len, 0-20
123 item->glyphs, &item->num_glyphs, 0-20
124 item->item.bidiLevel % 2))
partially evaluated: !item->font->klass->convertStringToGlyphIndices(item->font, ch, len, item->glyphs, &item->num_glyphs, item->item.bidiLevel % 2)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
125 return 0;
never executed: return 0;
0
126 for (i = 0; i < len; i++) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:20
20
127 item->attributes[i].mark = 0; -
128 item->attributes[i].clusterStart = 0; -
129 item->attributes[i].justification = 0; -
130 item->attributes[i].zeroWidth = 0; -
131 -
132 }
executed: }
Execution Count:20
20
133 -
134 -
135 if (!composed && openType) {
partially evaluated: !composed
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
partially evaluated: openType
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
136 HB_Bool positioned; -
137 -
138 unsigned short stacklogClusters[512]; unsigned short *logClusters = stacklogClusters; if ((len) >= 512) logClusters = (unsigned short *)malloc((len) * sizeof(unsigned short));;
never executed: logClusters = (unsigned short *)malloc((len) * sizeof(unsigned short));
never evaluated: (len) >= 512
0
139 for (i = 0; i < len; ++i)
never evaluated: i < len
0
140 logClusters[i] = i;
never executed: logClusters[i] = i;
0
141 item->log_clusters = logClusters; -
142 -
143 HB_OpenTypeShape(item, 0); -
144 -
145 positioned = HB_OpenTypePosition(item, availableGlyphs, 0); -
146 -
147 if (stacklogClusters != logClusters) free(logClusters);;
never executed: free(logClusters);
never evaluated: stacklogClusters != logClusters
0
148 -
149 if (!positioned)
never evaluated: !positioned
0
150 return 0;
never executed: return 0;
0
151 } else {
never executed: }
0
152 HB_HeuristicPosition(item); -
153 }
executed: }
Execution Count:20
20
154 -
155 -
156 item->attributes[0].clusterStart = (!0); -
157 return (!0);
executed: return (!0);
Execution Count:20
20
158} -
159 -
160HB_Bool HB_HangulShape(HB_ShaperItem *item) -
161{ -
162 const HB_UChar16 *uc = item->string + item->item.pos; -
163 HB_Bool allPrecomposed = (!0); -
164 int i; -
165 -
166 ((item->item.script == HB_Script_Hangul) ? static_cast<void> (0) : __assert_fail ("item->item.script == HB_Script_Hangul", "../3rdparty/harfbuzz/src/harfbuzz-hangul.c", 219, __PRETTY_FUNCTION__)); -
167 -
168 for (i = 0; i < (int)item->item.length; ++i) {
evaluated: i < (int)item->item.length
TRUEFALSE
yes
Evaluation Count:96
yes
Evaluation Count:28
28-96
169 if (!(uc[i] >= Hangul_SBase && uc[i] < Hangul_SBase + Hangul_SCount)) {
evaluated: uc[i] >= Hangul_SBase
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:4
partially evaluated: uc[i] < Hangul_SBase + Hangul_SCount
TRUEFALSE
yes
Evaluation Count:92
no
Evaluation Count:0
0-92
170 allPrecomposed = 0; -
171 break;
executed: break;
Execution Count:4
4
172 } -
173 }
executed: }
Execution Count:92
92
174 -
175 if (!allPrecomposed) {
evaluated: !allPrecomposed
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:28
4-28
176 HB_Bool openType = 0; -
177 unsigned short *logClusters = item->log_clusters; -
178 HB_ShaperItem syllable; -
179 int first_glyph = 0; -
180 int sstart = item->item.pos; -
181 int end = sstart + item->item.length; -
182 -
183 -
184 openType = HB_SelectScript(item, hangul_features); -
185 -
186 syllable = *item; -
187 -
188 while (sstart < end) {
evaluated: sstart < end
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:4
4-20
189 int send = hangul_nextSyllableBoundary(item->string, sstart, end); -
190 -
191 syllable.item.pos = sstart; -
192 syllable.item.length = send-sstart; -
193 syllable.glyphs = item->glyphs + first_glyph; -
194 syllable.attributes = item->attributes + first_glyph; -
195 syllable.offsets = item->offsets + first_glyph; -
196 syllable.advances = item->advances + first_glyph; -
197 syllable.num_glyphs = item->num_glyphs - first_glyph; -
198 if (!hangul_shape_syllable(&syllable, openType)) {
partially evaluated: !hangul_shape_syllable(&syllable, openType)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
199 item->num_glyphs += syllable.num_glyphs; -
200 return 0;
never executed: return 0;
0
201 } -
202 -
203 for (i = sstart; i < send; ++i)
evaluated: i < send
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:20
20
204 logClusters[i-item->item.pos] = first_glyph;
executed: logClusters[i-item->item.pos] = first_glyph;
Execution Count:20
20
205 sstart = send; -
206 first_glyph += syllable.num_glyphs; -
207 }
executed: }
Execution Count:20
20
208 item->num_glyphs = first_glyph; -
209 return (!0);
executed: return (!0);
Execution Count:4
4
210 } -
211 -
212 return HB_BasicShape(item);
executed: return HB_BasicShape(item);
Execution Count:28
28
213} -
214 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial