qtextengine.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextengine.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6static const float smallCapsFraction = 0.7f;-
7-
8namespace {-
9-
10-
11class Itemizer {-
12public:-
13 Itemizer(const QString &string, const QScriptAnalysis *analysis, QScriptItemArray &items)-
14 : m_string(string),-
15 m_analysis(analysis),-
16 m_items(items),-
17 m_splitter(0)-
18 {-
19 }
never executed: end of block
0
20 ~Itemizer()-
21 {-
22 delete m_splitter;-
23 }
never executed: end of block
0
24-
25-
26-
27 void generate(int start, int length, QFont::Capitalization caps)-
28 {-
29 if (caps == QFont::SmallCaps
caps == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
30 generateScriptItemsSmallCaps(reinterpret_cast<const ushort *>(m_string.unicode()), start, length);
never executed: generateScriptItemsSmallCaps(reinterpret_cast<const ushort *>(m_string.unicode()), start, length);
0
31 else if(caps == QFont::Capitalize
caps == QFont::CapitalizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
32 generateScriptItemsCapitalize(start, length);
never executed: generateScriptItemsCapitalize(start, length);
0
33 else if(caps != QFont::MixedCase
caps != QFont::MixedCaseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
34 generateScriptItemsAndChangeCase(start, length,-
35 caps == QFont::AllLowercase ? QScriptAnalysis::Lowercase : QScriptAnalysis::Uppercase);-
36 }
never executed: end of block
0
37 else-
38 generateScriptItems(start, length);
never executed: generateScriptItems(start, length);
0
39 }-
40-
41private:-
42 enum { MaxItemLength = 4096 };-
43-
44 void generateScriptItemsAndChangeCase(int start, int length, QScriptAnalysis::Flags flags)-
45 {-
46 generateScriptItems(start, length);-
47 if (m_items.isEmpty()
m_items.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
48 return;
never executed: return;
0
49 QScriptItemArray::Iterator iter = m_items.end();-
50 do {-
51 iter--;-
52 if (iter->analysis.flags < QScriptAnalysis::LineOrParagraphSeparator
iter->analysis...graphSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
53 iter->analysis.flags = flags;
never executed: iter->analysis.flags = flags;
0
54 }
never executed: end of block
while (iter->position > start
iter->position > startDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
55 }
never executed: end of block
0
56-
57 void generateScriptItems(int start, int length)-
58 {-
59 if (!length
!lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
60 return;
never executed: return;
0
61 const int end = start + length;-
62 for (int i = start + 1; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
63 if (m_analysis[i].bidiLevel == m_analysis[start].bidiLevel
m_analysis[i]....art].bidiLevelDescription
TRUEnever evaluated
FALSEnever evaluated
0
64 && m_analysis[i].flags == m_analysis[start].flags
m_analysis[i]....s[start].flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
65 && (m_analysis[i].script == m_analysis[start].script
m_analysis[i]....[start].scriptDescription
TRUEnever evaluated
FALSEnever evaluated
|| m_string[i] == QLatin1Char('.')
m_string[i] ==...atin1Char('.')Description
TRUEnever evaluated
FALSEnever evaluated
)
0
66 && m_analysis[i].flags < QScriptAnalysis::SpaceTabOrObject
m_analysis[i]....aceTabOrObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
67 && i - start < MaxItemLength
i - start < MaxItemLengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
68 continue;
never executed: continue;
0
69 m_items.append(QScriptItem(start, m_analysis[start]));-
70 start = i;-
71 }
never executed: end of block
0
72 m_items.append(QScriptItem(start, m_analysis[start]));-
73 }
never executed: end of block
0
74-
75 void generateScriptItemsCapitalize(int start, int length)-
76 {-
77 if (!length
!lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
78 return;
never executed: return;
0
79-
80 if (!m_splitter
!m_splitterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
81 m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word,
never executed: m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, m_string.constData(), m_string.length(), 0, 0);
0
82 m_string.constData(), m_string.length(),
never executed: m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, m_string.constData(), m_string.length(), 0, 0);
0
83 0, 0);
never executed: m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, m_string.constData(), m_string.length(), 0, 0);
0
84-
85 m_splitter->setPosition(start);-
86 QScriptAnalysis itemAnalysis = m_analysis[start];-
87-
88 if (m_splitter->boundaryReasons() & QTextBoundaryFinder::StartOfItem
m_splitter->bo...r::StartOfItemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
89 itemAnalysis.flags = QScriptAnalysis::Uppercase;
never executed: itemAnalysis.flags = QScriptAnalysis::Uppercase;
0
90-
91 m_splitter->toNextBoundary();-
92-
93 const int end = start + length;-
94 for (int i = start + 1; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
95 bool atWordStart = false;-
96-
97 if (i == m_splitter->position()
i == m_splitter->position()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
98 if (m_splitter->boundaryReasons() & QTextBoundaryFinder::StartOfItem
m_splitter->bo...r::StartOfItemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
99 ((!(m_analysis[i].flags < QScriptAnalysis::TabOrObject)) ? qt_assert("m_analysis[i].flags < QScriptAnalysis::TabOrObject",__FILE__,155) : qt_noop());-
100 atWordStart = true;-
101 }
never executed: end of block
0
102-
103 m_splitter->toNextBoundary();-
104 }
never executed: end of block
0
105-
106 if (m_analysis[i] == itemAnalysis
m_analysis[i] == itemAnalysisDescription
TRUEnever evaluated
FALSEnever evaluated
0
107 && m_analysis[i].flags < QScriptAnalysis::TabOrObject
m_analysis[i]....s::TabOrObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
108 && !atWordStart
!atWordStartDescription
TRUEnever evaluated
FALSEnever evaluated
0
109 && i - start < MaxItemLength
i - start < MaxItemLengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
110 continue;
never executed: continue;
0
111-
112 m_items.append(QScriptItem(start, itemAnalysis));-
113 start = i;-
114 itemAnalysis = m_analysis[start];-
115-
116 if (atWordStart
atWordStartDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
117 itemAnalysis.flags = QScriptAnalysis::Uppercase;
never executed: itemAnalysis.flags = QScriptAnalysis::Uppercase;
0
118 }
never executed: end of block
0
119 m_items.append(QScriptItem(start, itemAnalysis));-
120 }
never executed: end of block
0
121-
122 void generateScriptItemsSmallCaps(const ushort *uc, int start, int length)-
123 {-
124 if (!length
!lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
125 return;
never executed: return;
0
126 bool lower = (QChar::category(uc[start]) == QChar::Letter_Lowercase);-
127 const int end = start + length;-
128-
129 for (int i = start + 1; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
130 bool l = (QChar::category(uc[i]) == QChar::Letter_Lowercase);-
131 if ((
(m_analysis[i]...alysis[start])Description
TRUEnever evaluated
FALSEnever evaluated
m_analysis[i] == m_analysis[start])
(m_analysis[i]...alysis[start])Description
TRUEnever evaluated
FALSEnever evaluated
0
132 && m_analysis[i].flags < QScriptAnalysis::TabOrObject
m_analysis[i]....s::TabOrObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
133 && l == lower
l == lowerDescription
TRUEnever evaluated
FALSEnever evaluated
0
134 && i - start < MaxItemLength
i - start < MaxItemLengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
135 continue;
never executed: continue;
0
136 m_items.append(QScriptItem(start, m_analysis[start]));-
137 if (lower
lowerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
138 m_items.last().analysis.flags = QScriptAnalysis::SmallCaps;
never executed: m_items.last().analysis.flags = QScriptAnalysis::SmallCaps;
0
139-
140 start = i;-
141 lower = l;-
142 }
never executed: end of block
0
143 m_items.append(QScriptItem(start, m_analysis[start]));-
144 if (lower
lowerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
145 m_items.last().analysis.flags = QScriptAnalysis::SmallCaps;
never executed: m_items.last().analysis.flags = QScriptAnalysis::SmallCaps;
0
146 }
never executed: end of block
0
147-
148 const QString &m_string;-
149 const QScriptAnalysis * const m_analysis;-
150 QScriptItemArray &m_items;-
151 QTextBoundaryFinder *m_splitter;-
152};-
153}-
154struct QBidiStatus {-
155 QBidiStatus() {-
156 eor = QChar::DirON;-
157 lastStrong = QChar::DirON;-
158 last = QChar:: DirON;-
159 dir = QChar::DirON;-
160 }
never executed: end of block
0
161 QChar::Direction eor;-
162 QChar::Direction lastStrong;-
163 QChar::Direction last;-
164 QChar::Direction dir;-
165};-
166-
167enum { MaxBidiLevel = 61 };-
168-
169struct QBidiControl {-
170 inline QBidiControl(bool rtl)-
171 : cCtx(0), base(rtl ? 1 : 0), level(rtl ? 1 : 0), override(false) {}
never executed: end of block
0
172-
173 inline void embed(bool rtl, bool o = false) {-
174 unsigned int toAdd = 1;-
175 if((
(level%2 != 0) == rtlDescription
TRUEnever evaluated
FALSEnever evaluated
level%2 != 0) == rtl
(level%2 != 0) == rtlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
176 ++toAdd;-
177 }
never executed: end of block
0
178 if (level + toAdd <= MaxBidiLevel
level + toAdd <= MaxBidiLevelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
179 ctx[cCtx].level = level;-
180 ctx[cCtx].override = override;-
181 cCtx++;-
182 override = o;-
183 level += toAdd;-
184 }
never executed: end of block
0
185 }
never executed: end of block
0
186 inline bool canPop() const { return
never executed: return cCtx != 0;
cCtx != 0;
never executed: return cCtx != 0;
}
0
187 inline void pdf() {-
188 ((!(cCtx)) ? qt_assert("cCtx",__FILE__,267) : qt_noop());-
189 --cCtx;-
190 level = ctx[cCtx].level;-
191 override = ctx[cCtx].override;-
192 }
never executed: end of block
0
193-
194 inline QChar::Direction basicDirection() const {-
195 return
never executed: return (base ? QChar::DirR : QChar:: DirL);
(base ? QChar::DirR : QChar:: DirL);
never executed: return (base ? QChar::DirR : QChar:: DirL);
0
196 }-
197 inline unsigned int baseLevel() const {-
198 return
never executed: return base;
base;
never executed: return base;
0
199 }-
200 inline QChar::Direction direction() const {-
201 return
never executed: return ((level%2) ? QChar::DirR : QChar:: DirL);
((level%2) ? QChar::DirR : QChar:: DirL);
never executed: return ((level%2) ? QChar::DirR : QChar:: DirL);
0
202 }-
203-
204 struct {-
205 unsigned int level;-
206 bool override;-
207 } ctx[MaxBidiLevel];-
208 unsigned int cCtx;-
209 const unsigned int base;-
210 unsigned int level;-
211 bool override;-
212};-
213-
214-
215static void appendItems(QScriptAnalysis *analysis, int &start, int &stop, const QBidiControl &control, QChar::Direction dir)-
216{-
217 if (start > stop
start > stopDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
218 return;
never executed: return;
0
219-
220 int level = control.level;-
221-
222 if(dir != QChar::DirON
dir != QChar::DirONDescription
TRUEnever evaluated
FALSEnever evaluated
&& !control.override
!control.overrideDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
223-
224 if(level % 2
level % 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
225 if(dir == QChar::DirL
dir == QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
|| dir == QChar::DirAN
dir == QChar::DirANDescription
TRUEnever evaluated
FALSEnever evaluated
|| dir == QChar::DirEN
dir == QChar::DirENDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
226 level++;
never executed: level++;
0
227 }
never executed: end of block
else {
0
228 if(dir == QChar::DirR
dir == QChar::DirRDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
229 level++;
never executed: level++;
0
230 else if(dir == QChar::DirAN
dir == QChar::DirANDescription
TRUEnever evaluated
FALSEnever evaluated
|| dir == QChar::DirEN
dir == QChar::DirENDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
231 level += 2;
never executed: level += 2;
0
232 }
never executed: end of block
0
233 }-
234-
235-
236-
237-
238 QScriptAnalysis *s = analysis + start;-
239 const QScriptAnalysis *e = analysis + stop;-
240 while (s <= e
s <= eDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
241 s->bidiLevel = level;-
242 ++s;-
243 }
never executed: end of block
0
244 ++stop;-
245 start = stop;-
246}
never executed: end of block
0
247-
248static QChar::Direction skipBoundryNeutrals(QScriptAnalysis *analysis,-
249 const ushort *unicode, int length,-
250 int &sor, int &eor, QBidiControl &control)-
251{-
252 QChar::Direction dir = control.basicDirection();-
253 int level = sor > 0
sor > 0Description
TRUEnever evaluated
FALSEnever evaluated
? analysis[sor - 1].bidiLevel : control.level;
0
254 while (sor < length
sor < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
255 dir = QChar::direction(unicode[sor]);-
256-
257 if (dir != QChar::DirBN
dir != QChar::DirBNDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
258 break;
never executed: break;
0
259 analysis[sor++].bidiLevel = level;-
260 }
never executed: end of block
0
261-
262 eor = sor;-
263 if (eor == length
eor == lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
264 dir = control.basicDirection();
never executed: dir = control.basicDirection();
0
265-
266 return
never executed: return dir;
dir;
never executed: return dir;
0
267}-
268-
269-
270static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiControl &control)-
271{-
272 bool rightToLeft = (control.basicDirection() == 1);-
273 bool hasBidi = rightToLeft;-
274-
275-
276-
277-
278 int sor = 0;-
279 int eor = -1;-
280-
281-
282 int length = engine->layoutData->string.length();-
283-
284 const ushort *unicode = (const ushort *)engine->layoutData->string.unicode();-
285 int current = 0;-
286-
287 QChar::Direction dir = rightToLeft
rightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
? QChar::DirR : QChar::DirL;
0
288 QBidiStatus status;-
289-
290 QChar::Direction sdir = QChar::direction(*unicode);-
291 if (sdir != QChar::DirL
sdir != QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
&& sdir != QChar::DirR
sdir != QChar::DirRDescription
TRUEnever evaluated
FALSEnever evaluated
&& sdir != QChar::DirEN
sdir != QChar::DirENDescription
TRUEnever evaluated
FALSEnever evaluated
&& sdir != QChar::DirAN
sdir != QChar::DirANDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
292 sdir = QChar::DirON;
never executed: sdir = QChar::DirON;
0
293 else-
294 dir = QChar::DirON;
never executed: dir = QChar::DirON;
0
295 status.eor = sdir;-
296 status.lastStrong = rightToLeft
rightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
? QChar::DirR : QChar::DirL;
0
297 status.last = status.lastStrong;-
298 status.dir = sdir;-
299-
300-
301 while (current <= length
current <= lengthDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
302-
303 QChar::Direction dirCurrent;-
304 if (current == (int)length
current == (int)lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
305 dirCurrent = control.basicDirection();
never executed: dirCurrent = control.basicDirection();
0
306 else-
307 dirCurrent = QChar::direction(unicode[current]);
never executed: dirCurrent = QChar::direction(unicode[current]);
0
308 switch(dirCurrent) {-
309-
310-
311 case
never executed: case QChar::DirRLE:
QChar::DirRLE:
never executed: case QChar::DirRLE:
0
312 case
never executed: case QChar::DirRLO:
QChar::DirRLO:
never executed: case QChar::DirRLO:
0
313 case
never executed: case QChar::DirLRE:
QChar::DirLRE:
never executed: case QChar::DirLRE:
0
314 case
never executed: case QChar::DirLRO:
QChar::DirLRO:
never executed: case QChar::DirLRO:
0
315 {-
316 bool rtl = (dirCurrent == QChar::DirRLE
dirCurrent == QChar::DirRLEDescription
TRUEnever evaluated
FALSEnever evaluated
|| dirCurrent == QChar::DirRLO
dirCurrent == QChar::DirRLODescription
TRUEnever evaluated
FALSEnever evaluated
);
0
317 hasBidi |= rtl;-
318 bool override = (dirCurrent == QChar::DirLRO
dirCurrent == QChar::DirLRODescription
TRUEnever evaluated
FALSEnever evaluated
|| dirCurrent == QChar::DirRLO
dirCurrent == QChar::DirRLODescription
TRUEnever evaluated
FALSEnever evaluated
);
0
319-
320 unsigned int level = control.level+1;-
321 if ((
(level%2 != 0) == rtlDescription
TRUEnever evaluated
FALSEnever evaluated
level%2 != 0) == rtl
(level%2 != 0) == rtlDescription
TRUEnever evaluated
FALSEnever evaluated
) ++
never executed: ++level;
level;
never executed: ++level;
0
322 if(level < MaxBidiLevel
level < MaxBidiLevelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
323 eor = current-1;-
324 appendItems(analysis, sor, eor, control, dir);-
325 eor = current;-
326 control.embed(rtl, override);-
327 QChar::Direction edir = (rtl
rtlDescription
TRUEnever evaluated
FALSEnever evaluated
? QChar::DirR : QChar::DirL);
0
328 dir = status.eor = edir;-
329 status.lastStrong = edir;-
330 }
never executed: end of block
0
331 break;
never executed: break;
0
332 }-
333 case
never executed: case QChar::DirPDF:
QChar::DirPDF:
never executed: case QChar::DirPDF:
0
334 {-
335 if (control.canPop()
control.canPop()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
336 if (dir != control.direction()
dir != control.direction()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
337 eor = current-1;-
338 appendItems(analysis, sor, eor, control, dir);-
339 dir = control.direction();-
340 }
never executed: end of block
0
341 eor = current;-
342 appendItems(analysis, sor, eor, control, dir);-
343 control.pdf();-
344 dir = QChar::DirON; status.eor = QChar::DirON;-
345 status.last = control.direction();-
346 if (control.override
control.overrideDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
347 dir = control.direction();
never executed: dir = control.direction();
0
348 else-
349 dir = QChar::DirON;
never executed: dir = QChar::DirON;
0
350 status.lastStrong = control.direction();-
351 }
never executed: end of block
0
352 break;
never executed: break;
0
353 }-
354-
355-
356 case
never executed: case QChar::DirL:
QChar::DirL:
never executed: case QChar::DirL:
0
357 if(dir == QChar::DirON
dir == QChar::DirONDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
358 dir = QChar::DirL;
never executed: dir = QChar::DirL;
0
359 switch(status.last)-
360 {-
361 case
never executed: case QChar::DirL:
QChar::DirL:
never executed: case QChar::DirL:
0
362 eor = current; status.eor = QChar::DirL; break;
never executed: break;
0
363 case
never executed: case QChar::DirR:
QChar::DirR:
never executed: case QChar::DirR:
0
364 case
never executed: case QChar::DirAL:
QChar::DirAL:
never executed: case QChar::DirAL:
0
365 case
never executed: case QChar::DirEN:
QChar::DirEN:
never executed: case QChar::DirEN:
0
366 case
never executed: case QChar::DirAN:
QChar::DirAN:
never executed: case QChar::DirAN:
0
367 if (eor >= 0
eor >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
368 appendItems(analysis, sor, eor, control, dir);-
369 status.eor = dir = skipBoundryNeutrals(analysis, unicode, length, sor, eor, control);-
370 }
never executed: end of block
else {
0
371 eor = current; status.eor = dir;-
372 }
never executed: end of block
0
373 break;
never executed: break;
0
374 case
never executed: case QChar::DirES:
QChar::DirES:
never executed: case QChar::DirES:
0
375 case
never executed: case QChar::DirET:
QChar::DirET:
never executed: case QChar::DirET:
0
376 case
never executed: case QChar::DirCS:
QChar::DirCS:
never executed: case QChar::DirCS:
0
377 case
never executed: case QChar::DirBN:
QChar::DirBN:
never executed: case QChar::DirBN:
0
378 case
never executed: case QChar::DirB:
QChar::DirB:
never executed: case QChar::DirB:
0
379 case
never executed: case QChar::DirS:
QChar::DirS:
never executed: case QChar::DirS:
0
380 case
never executed: case QChar::DirWS:
QChar::DirWS:
never executed: case QChar::DirWS:
0
381 case
never executed: case QChar::DirON:
QChar::DirON:
never executed: case QChar::DirON:
0
382 if(dir != QChar::DirL
dir != QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
383-
384 if(control.direction() == QChar::DirR
control.direct...== QChar::DirRDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
385 if(status.eor != QChar::DirR
status.eor != QChar::DirRDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
386-
387 appendItems(analysis, sor, eor, control, dir);-
388 status.eor = QChar::DirON;-
389 dir = QChar::DirR;-
390 }
never executed: end of block
0
391 eor = current - 1;-
392 appendItems(analysis, sor, eor, control, dir);-
393 status.eor = dir = skipBoundryNeutrals(analysis, unicode, length, sor, eor, control);-
394 }
never executed: end of block
else {
0
395 if(status.eor != QChar::DirL
status.eor != QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
396 appendItems(analysis, sor, eor, control, dir);-
397 status.eor = QChar::DirON;-
398 dir = QChar::DirL;-
399 }
never executed: end of block
else {
0
400 eor = current; status.eor = QChar::DirL; break;
never executed: break;
0
401 }-
402 }-
403 } else {-
404 eor = current; status.eor = QChar::DirL;-
405 }
never executed: end of block
0
406 default
never executed: default:
:
never executed: default:
code before this statement never executed: default:
0
407 break;
never executed: break;
0
408 }-
409 status.lastStrong = QChar::DirL;-
410 break;
never executed: break;
0
411 case
never executed: case QChar::DirAL:
QChar::DirAL:
never executed: case QChar::DirAL:
0
412 case
never executed: case QChar::DirR:
QChar::DirR:
never executed: case QChar::DirR:
0
413 hasBidi = true;-
414 if(dir == QChar::DirON
dir == QChar::DirONDescription
TRUEnever evaluated
FALSEnever evaluated
) dir = QChar::DirR;
never executed: dir = QChar::DirR;
0
415 switch(status.last)-
416 {-
417 case
never executed: case QChar::DirL:
QChar::DirL:
never executed: case QChar::DirL:
0
418 case
never executed: case QChar::DirEN:
QChar::DirEN:
never executed: case QChar::DirEN:
0
419 case
never executed: case QChar::DirAN:
QChar::DirAN:
never executed: case QChar::DirAN:
0
420 if (eor >= 0
eor >= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
421 appendItems(analysis, sor, eor, control, dir);
never executed: appendItems(analysis, sor, eor, control, dir);
0
422-
423 case
never executed: case QChar::DirR:
QChar::DirR:
never executed: case QChar::DirR:
code before this statement never executed: case QChar::DirR:
0
424 case
never executed: case QChar::DirAL:
QChar::DirAL:
never executed: case QChar::DirAL:
0
425 dir = QChar::DirR; eor = current; status.eor = QChar::DirR; break;
never executed: break;
0
426 case
never executed: case QChar::DirES:
QChar::DirES:
never executed: case QChar::DirES:
0
427 case
never executed: case QChar::DirET:
QChar::DirET:
never executed: case QChar::DirET:
0
428 case
never executed: case QChar::DirCS:
QChar::DirCS:
never executed: case QChar::DirCS:
0
429 case
never executed: case QChar::DirBN:
QChar::DirBN:
never executed: case QChar::DirBN:
0
430 case
never executed: case QChar::DirB:
QChar::DirB:
never executed: case QChar::DirB:
0
431 case
never executed: case QChar::DirS:
QChar::DirS:
never executed: case QChar::DirS:
0
432 case
never executed: case QChar::DirWS:
QChar::DirWS:
never executed: case QChar::DirWS:
0
433 case
never executed: case QChar::DirON:
QChar::DirON:
never executed: case QChar::DirON:
0
434 if(status.eor != QChar::DirR
status.eor != QChar::DirRDescription
TRUEnever evaluated
FALSEnever evaluated
&& status.eor != QChar::DirAL
status.eor != QChar::DirALDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
435-
436 if(control.direction() == QChar::DirR
control.direct...== QChar::DirRDescription
TRUEnever evaluated
FALSEnever evaluated
0
437 || status.lastStrong == QChar::DirR
status.lastStr...== QChar::DirRDescription
TRUEnever evaluated
FALSEnever evaluated
|| status.lastStrong == QChar::DirAL
status.lastStr...= QChar::DirALDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
438 appendItems(analysis, sor, eor, control, dir);-
439 dir = QChar::DirR; status.eor = QChar::DirON;-
440 eor = current;-
441 }
never executed: end of block
else {
0
442 eor = current - 1;-
443 appendItems(analysis, sor, eor, control, dir);-
444 dir = QChar::DirR; status.eor = QChar::DirON;-
445 }
never executed: end of block
0
446 } else {-
447 eor = current; status.eor = QChar::DirR;-
448 }
never executed: end of block
0
449 default
never executed: default:
:
never executed: default:
code before this statement never executed: default:
0
450 break;
never executed: break;
0
451 }-
452 status.lastStrong = dirCurrent;-
453 break;
never executed: break;
0
454-
455-
456-
457 case
never executed: case QChar::DirNSM:
QChar::DirNSM:
never executed: case QChar::DirNSM:
0
458 if (eor == current-1
eor == current-1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
459 eor = current;
never executed: eor = current;
0
460 break;
never executed: break;
0
461 case
never executed: case QChar::DirEN:
QChar::DirEN:
never executed: case QChar::DirEN:
0
462-
463 if(status.lastStrong != QChar::DirAL
status.lastStr...= QChar::DirALDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
464 if(dir == QChar::DirON
dir == QChar::DirONDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
465 if(status.lastStrong == QChar::DirL
status.lastStr...== QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
466 dir = QChar::DirL;
never executed: dir = QChar::DirL;
0
467 else-
468 dir = QChar::DirEN;
never executed: dir = QChar::DirEN;
0
469 }-
470 switch(status.last)-
471 {-
472 case
never executed: case QChar::DirET:
QChar::DirET:
never executed: case QChar::DirET:
0
473 if (status.lastStrong == QChar::DirR
status.lastStr...== QChar::DirRDescription
TRUEnever evaluated
FALSEnever evaluated
|| status.lastStrong == QChar::DirAL
status.lastStr...= QChar::DirALDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
474 appendItems(analysis, sor, eor, control, dir);-
475 status.eor = QChar::DirON;-
476 dir = QChar::DirAN;-
477 }
never executed: end of block
0
478-
479 case
never executed: case QChar::DirEN:
QChar::DirEN:
never executed: case QChar::DirEN:
code before this statement never executed: case QChar::DirEN:
0
480 case
never executed: case QChar::DirL:
QChar::DirL:
never executed: case QChar::DirL:
0
481 eor = current;-
482 status.eor = dirCurrent;-
483 break;
never executed: break;
0
484 case
never executed: case QChar::DirR:
QChar::DirR:
never executed: case QChar::DirR:
0
485 case
never executed: case QChar::DirAL:
QChar::DirAL:
never executed: case QChar::DirAL:
0
486 case
never executed: case QChar::DirAN:
QChar::DirAN:
never executed: case QChar::DirAN:
0
487 if (eor >= 0
eor >= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
488 appendItems(analysis, sor, eor, control, dir);
never executed: appendItems(analysis, sor, eor, control, dir);
0
489 else-
490 eor = current;
never executed: eor = current;
0
491 status.eor = QChar::DirEN;-
492 dir = QChar::DirAN; break;
never executed: break;
0
493 case
never executed: case QChar::DirES:
QChar::DirES:
never executed: case QChar::DirES:
0
494 case
never executed: case QChar::DirCS:
QChar::DirCS:
never executed: case QChar::DirCS:
0
495 if(status.eor == QChar::DirEN
status.eor == QChar::DirENDescription
TRUEnever evaluated
FALSEnever evaluated
|| dir == QChar::DirAN
dir == QChar::DirANDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
496 eor = current; break;
never executed: break;
0
497 }-
498 case
never executed: case QChar::DirBN:
QChar::DirBN:
never executed: case QChar::DirBN:
code before this statement never executed: case QChar::DirBN:
0
499 case
never executed: case QChar::DirB:
QChar::DirB:
never executed: case QChar::DirB:
0
500 case
never executed: case QChar::DirS:
QChar::DirS:
never executed: case QChar::DirS:
0
501 case
never executed: case QChar::DirWS:
QChar::DirWS:
never executed: case QChar::DirWS:
0
502 case
never executed: case QChar::DirON:
QChar::DirON:
never executed: case QChar::DirON:
0
503 if(status.eor == QChar::DirR
status.eor == QChar::DirRDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
504-
505 eor = current - 1;-
506 appendItems(analysis, sor, eor, control, dir);-
507 dir = QChar::DirON; status.eor = QChar::DirEN;-
508 dir = QChar::DirAN;-
509 }
never executed: end of block
0
510 else if(status.eor == QChar::DirL
status.eor == QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
||
0
511 (status.eor == QChar::DirEN
status.eor == QChar::DirENDescription
TRUEnever evaluated
FALSEnever evaluated
&& status.lastStrong == QChar::DirL
status.lastStr...== QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
512 eor = current; status.eor = dirCurrent;-
513 }
never executed: end of block
else {
0
514-
515 if(dir != QChar::DirL
dir != QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
516 appendItems(analysis, sor, eor, control, dir);-
517 dir = QChar::DirON; status.eor = QChar::DirON;-
518 eor = current - 1;-
519 dir = QChar::DirR;-
520 appendItems(analysis, sor, eor, control, dir);-
521 dir = QChar::DirON; status.eor = QChar::DirON;-
522 dir = QChar::DirAN;-
523 }
never executed: end of block
else {
0
524 eor = current; status.eor = dirCurrent;-
525 }
never executed: end of block
0
526 }-
527 default
never executed: default:
:
never executed: default:
code before this statement never executed: default:
0
528 break;
never executed: break;
0
529 }-
530 break;
never executed: break;
0
531 }-
532 case
never executed: case QChar::DirAN:
QChar::DirAN:
never executed: case QChar::DirAN:
code before this statement never executed: case QChar::DirAN:
0
533 hasBidi = true;-
534 dirCurrent = QChar::DirAN;-
535 if(dir == QChar::DirON
dir == QChar::DirONDescription
TRUEnever evaluated
FALSEnever evaluated
) dir = QChar::DirAN;
never executed: dir = QChar::DirAN;
0
536 switch(status.last)-
537 {-
538 case
never executed: case QChar::DirL:
QChar::DirL:
never executed: case QChar::DirL:
0
539 case
never executed: case QChar::DirAN:
QChar::DirAN:
never executed: case QChar::DirAN:
0
540 eor = current; status.eor = QChar::DirAN; break;
never executed: break;
0
541 case
never executed: case QChar::DirR:
QChar::DirR:
never executed: case QChar::DirR:
0
542 case
never executed: case QChar::DirAL:
QChar::DirAL:
never executed: case QChar::DirAL:
0
543 case
never executed: case QChar::DirEN:
QChar::DirEN:
never executed: case QChar::DirEN:
0
544 if (eor >= 0
eor >= 0Description
TRUEnever evaluated
FALSEnever evaluated
){
0
545 appendItems(analysis, sor, eor, control, dir);-
546 }
never executed: end of block
else {
0
547 eor = current;-
548 }
never executed: end of block
0
549 dir = QChar::DirAN; status.eor = QChar::DirAN;-
550 break;
never executed: break;
0
551 case
never executed: case QChar::DirCS:
QChar::DirCS:
never executed: case QChar::DirCS:
0
552 if(status.eor == QChar::DirAN
status.eor == QChar::DirANDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
553 eor = current; break;
never executed: break;
0
554 }-
555 case
never executed: case QChar::DirES:
QChar::DirES:
never executed: case QChar::DirES:
code before this statement never executed: case QChar::DirES:
0
556 case
never executed: case QChar::DirET:
QChar::DirET:
never executed: case QChar::DirET:
0
557 case
never executed: case QChar::DirBN:
QChar::DirBN:
never executed: case QChar::DirBN:
0
558 case
never executed: case QChar::DirB:
QChar::DirB:
never executed: case QChar::DirB:
0
559 case
never executed: case QChar::DirS:
QChar::DirS:
never executed: case QChar::DirS:
0
560 case
never executed: case QChar::DirWS:
QChar::DirWS:
never executed: case QChar::DirWS:
0
561 case
never executed: case QChar::DirON:
QChar::DirON:
never executed: case QChar::DirON:
0
562 if(status.eor == QChar::DirR
status.eor == QChar::DirRDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
563-
564 eor = current - 1;-
565 appendItems(analysis, sor, eor, control, dir);-
566 status.eor = QChar::DirAN;-
567 dir = QChar::DirAN;-
568 }
never executed: end of block
else if(status.eor == QChar::DirL
status.eor == QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
||
0
569 (status.eor == QChar::DirEN
status.eor == QChar::DirENDescription
TRUEnever evaluated
FALSEnever evaluated
&& status.lastStrong == QChar::DirL
status.lastStr...== QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
570 eor = current; status.eor = dirCurrent;-
571 }
never executed: end of block
else {
0
572-
573 if(dir != QChar::DirL
dir != QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
574 appendItems(analysis, sor, eor, control, dir);-
575 status.eor = QChar::DirON;-
576 eor = current - 1;-
577 dir = QChar::DirR;-
578 appendItems(analysis, sor, eor, control, dir);-
579 status.eor = QChar::DirAN;-
580 dir = QChar::DirAN;-
581 }
never executed: end of block
else {
0
582 eor = current; status.eor = dirCurrent;-
583 }
never executed: end of block
0
584 }-
585 default
never executed: default:
:
never executed: default:
code before this statement never executed: default:
0
586 break;
never executed: break;
0
587 }-
588 break;
never executed: break;
0
589 case
never executed: case QChar::DirES:
QChar::DirES:
never executed: case QChar::DirES:
0
590 case
never executed: case QChar::DirCS:
QChar::DirCS:
never executed: case QChar::DirCS:
0
591 break;
never executed: break;
0
592 case
never executed: case QChar::DirET:
QChar::DirET:
never executed: case QChar::DirET:
0
593 if(status.last == QChar::DirEN
status.last == QChar::DirENDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
594 dirCurrent = QChar::DirEN;-
595 eor = current; status.eor = dirCurrent;-
596 }
never executed: end of block
0
597 break;
never executed: break;
0
598-
599-
600 case
never executed: case QChar::DirBN:
QChar::DirBN:
never executed: case QChar::DirBN:
0
601 break;
never executed: break;
0
602-
603 case
never executed: case QChar::DirB:
QChar::DirB:
never executed: case QChar::DirB:
0
604-
605 break;
never executed: break;
0
606 case
never executed: case QChar::DirS:
QChar::DirS:
never executed: case QChar::DirS:
0
607-
608 break;
never executed: break;
0
609 case
never executed: case QChar::DirWS:
QChar::DirWS:
never executed: case QChar::DirWS:
0
610 case
never executed: case QChar::DirON:
QChar::DirON:
never executed: case QChar::DirON:
0
611 break;
never executed: break;
0
612 default
never executed: default:
:
never executed: default:
0
613 break;
never executed: break;
0
614 }-
615-
616-
617-
618 if(current >= (int)length
current >= (int)lengthDescription
TRUEnever evaluated
FALSEnever evaluated
) break;
never executed: break;
0
619-
620-
621 switch(dirCurrent) {-
622 case
never executed: case QChar::DirET:
QChar::DirET:
never executed: case QChar::DirET:
0
623 case
never executed: case QChar::DirES:
QChar::DirES:
never executed: case QChar::DirES:
0
624 case
never executed: case QChar::DirCS:
QChar::DirCS:
never executed: case QChar::DirCS:
0
625 case
never executed: case QChar::DirS:
QChar::DirS:
never executed: case QChar::DirS:
0
626 case
never executed: case QChar::DirWS:
QChar::DirWS:
never executed: case QChar::DirWS:
0
627 case
never executed: case QChar::DirON:
QChar::DirON:
never executed: case QChar::DirON:
0
628 switch(status.last)-
629 {-
630 case
never executed: case QChar::DirL:
QChar::DirL:
never executed: case QChar::DirL:
0
631 case
never executed: case QChar::DirR:
QChar::DirR:
never executed: case QChar::DirR:
0
632 case
never executed: case QChar::DirAL:
QChar::DirAL:
never executed: case QChar::DirAL:
0
633 case
never executed: case QChar::DirEN:
QChar::DirEN:
never executed: case QChar::DirEN:
0
634 case
never executed: case QChar::DirAN:
QChar::DirAN:
never executed: case QChar::DirAN:
0
635 status.last = dirCurrent;-
636 break;
never executed: break;
0
637 default
never executed: default:
:
never executed: default:
0
638 status.last = QChar::DirON;-
639 }
never executed: end of block
0
640 break;
never executed: break;
0
641 case
never executed: case QChar::DirNSM:
QChar::DirNSM:
never executed: case QChar::DirNSM:
0
642 case
never executed: case QChar::DirBN:
QChar::DirBN:
never executed: case QChar::DirBN:
0
643-
644 break;
never executed: break;
0
645 case
never executed: case QChar::DirLRO:
QChar::DirLRO:
never executed: case QChar::DirLRO:
0
646 case
never executed: case QChar::DirLRE:
QChar::DirLRE:
never executed: case QChar::DirLRE:
0
647 status.last = QChar::DirL;-
648 break;
never executed: break;
0
649 case
never executed: case QChar::DirRLO:
QChar::DirRLO:
never executed: case QChar::DirRLO:
0
650 case
never executed: case QChar::DirRLE:
QChar::DirRLE:
never executed: case QChar::DirRLE:
0
651 status.last = QChar::DirR;-
652 break;
never executed: break;
0
653 case
never executed: case QChar::DirEN:
QChar::DirEN:
never executed: case QChar::DirEN:
0
654 if (status.last == QChar::DirL
status.last == QChar::DirLDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
655 status.last = QChar::DirL;-
656 break;
never executed: break;
0
657 }-
658-
659 default
never executed: default:
:
never executed: default:
code before this statement never executed: default:
0
660 status.last = dirCurrent;-
661 }
never executed: end of block
0
662-
663 ++current;-
664 }
never executed: end of block
0
665-
666-
667-
668-
669 eor = current - 1;-
670-
671 if (sor <= eor
sor <= eorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
672 appendItems(analysis, sor, eor, control, dir);
never executed: appendItems(analysis, sor, eor, control, dir);
0
673-
674 return
never executed: return hasBidi;
hasBidi;
never executed: return hasBidi;
0
675}-
676-
677void QTextEngine::bidiReorder(int numItems, const quint8 *levels, int *visualOrder)-
678{-
679-
680-
681 quint8 levelLow = 128;-
682 quint8 levelHigh = 0;-
683 int i = 0;-
684 while (i < numItems
i < numItemsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
685-
686 if (levels[i] > levelHigh
levels[i] > levelHighDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
687 levelHigh = levels[i];
never executed: levelHigh = levels[i];
0
688 if (levels[i] < levelLow
levels[i] < levelLowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
689 levelLow = levels[i];
never executed: levelLow = levels[i];
0
690 i++;-
691 }
never executed: end of block
0
692-
693-
694-
695-
696-
697-
698 if(!(levelLow%2)
!(levelLow%2)Description
TRUEnever evaluated
FALSEnever evaluated
) levelLow++;
never executed: levelLow++;
0
699-
700-
701-
702-
703-
704 int count = numItems - 1;-
705 for (i = 0; i < numItems
i < numItemsDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
706 visualOrder[i] = i;
never executed: visualOrder[i] = i;
0
707-
708 while(levelHigh >= levelLow
levelHigh >= levelLowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
709 int i = 0;-
710 while (i < count
i < countDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
711 while(i < count
i < countDescription
TRUEnever evaluated
FALSEnever evaluated
&& levels[i] < levelHigh
levels[i] < levelHighDescription
TRUEnever evaluated
FALSEnever evaluated
) i++;
never executed: i++;
0
712 int start = i;-
713 while(i <= count
i <= countDescription
TRUEnever evaluated
FALSEnever evaluated
&& levels[i] >= levelHigh
levels[i] >= levelHighDescription
TRUEnever evaluated
FALSEnever evaluated
) i++;
never executed: i++;
0
714 int end = i-1;-
715-
716 if(start != end
start != endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
717-
718 for(int j = 0; j < (end-start+1)/2
j < (end-start+1)/2Description
TRUEnever evaluated
FALSEnever evaluated
; j++) {
0
719 int tmp = visualOrder[start+j];-
720 visualOrder[start+j] = visualOrder[end-j];-
721 visualOrder[end-j] = tmp;-
722 }
never executed: end of block
0
723 }
never executed: end of block
0
724 i++;-
725 }
never executed: end of block
0
726 levelHigh--;-
727 }
never executed: end of block
0
728-
729-
730-
731-
732-
733-
734}
never executed: end of block
0
735-
736-
737enum JustificationClass {-
738 Justification_Prohibited = 0,-
739 Justification_Arabic_Space = 1,-
740 Justification_Character = 2,-
741 Justification_Space = 4,-
742 Justification_Arabic_Normal = 7,-
743 Justification_Arabic_Waw = 8,-
744 Justification_Arabic_BaRa = 9,-
745 Justification_Arabic_Alef = 10,-
746 Justification_Arabic_HahDal = 11,-
747 Justification_Arabic_Seen = 12,-
748 Justification_Arabic_Kashida = 13-
749};-
750-
751-
752-
753-
754-
755-
756-
757static inline void qt_getDefaultJustificationOpportunities(const ushort *string, int length, QGlyphLayout g, ushort *log_clusters, int spaceAs)-
758{-
759 int str_pos = 0;-
760 while (str_pos < length
str_pos < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
761 int glyph_pos = log_clusters[str_pos];-
762-
763 ((!(glyph_pos < g.numGlyphs && g.attributes[glyph_pos].clusterStart)) ? qt_assert("glyph_pos < g.numGlyphs && g.attributes[glyph_pos].clusterStart",__FILE__,852) : qt_noop());-
764-
765 uint ucs4 = string[str_pos];-
766 if (QChar::isHighSurrogate(ucs4)
QChar::isHighSurrogate(ucs4)Description
TRUEnever evaluated
FALSEnever evaluated
&& str_pos + 1 < length
str_pos + 1 < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
767 ushort low = string[str_pos + 1];-
768 if (QChar::isLowSurrogate(low)
QChar::isLowSurrogate(low)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
769 ++str_pos;-
770 ucs4 = QChar::surrogateToUcs4(ucs4, low);-
771 }
never executed: end of block
0
772 }
never executed: end of block
0
773-
774-
775 do {-
776 ++str_pos;-
777 }
never executed: end of block
while (str_pos < length
str_pos < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
&& log_clusters[str_pos] == glyph_pos
log_clusters[s...] == glyph_posDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
778 do {-
779 ++glyph_pos;-
780 }
never executed: end of block
while (glyph_pos < g.numGlyphs
glyph_pos < g.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
&& !g.attributes[glyph_pos].clusterStart
!g.attributes[...].clusterStartDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
781 --glyph_pos;-
782-
783-
784 if (__builtin_expect(!!(QChar::isLetterOrNumber(ucs4)), true)
__builtin_expe...(ucs4)), true)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
785 g.attributes[glyph_pos].justification = Justification_Character;
never executed: g.attributes[glyph_pos].justification = Justification_Character;
0
786 else if (__builtin_expect(!!(QChar::isSpace(ucs4)), true)
__builtin_expe...(ucs4)), true)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
787 g.attributes[glyph_pos].justification = spaceAs;
never executed: g.attributes[glyph_pos].justification = spaceAs;
0
788 }
never executed: end of block
0
789}
never executed: end of block
0
790-
791static inline void qt_getJustificationOpportunities(const ushort *string, int length, const QScriptItem &si, QGlyphLayout g, ushort *log_clusters)-
792{-
793 ((!(length > 0 && g.numGlyphs > 0)) ? qt_assert("length > 0 && g.numGlyphs > 0",__FILE__,882) : qt_noop());-
794-
795 for (int glyph_pos = 0; glyph_pos < g.numGlyphs
glyph_pos < g.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++glyph_pos)
0
796 g.attributes[glyph_pos].justification = Justification_Prohibited;
never executed: g.attributes[glyph_pos].justification = Justification_Prohibited;
0
797-
798 int spaceAs;-
799-
800 switch (si.analysis.script) {-
801 case
never executed: case QChar::Script_Arabic:
QChar::Script_Arabic:
never executed: case QChar::Script_Arabic:
0
802 case
never executed: case QChar::Script_Syriac:
QChar::Script_Syriac:
never executed: case QChar::Script_Syriac:
0
803 case
never executed: case QChar::Script_Nko:
QChar::Script_Nko:
never executed: case QChar::Script_Nko:
0
804 case
never executed: case QChar::Script_Mandaic:
QChar::Script_Mandaic:
never executed: case QChar::Script_Mandaic:
0
805 case
never executed: case QChar::Script_Mongolian:
QChar::Script_Mongolian:
never executed: case QChar::Script_Mongolian:
0
806 case
never executed: case QChar::Script_PhagsPa:
QChar::Script_PhagsPa:
never executed: case QChar::Script_PhagsPa:
0
807 case
never executed: case QChar::Script_Manichaean:
QChar::Script_Manichaean:
never executed: case QChar::Script_Manichaean:
0
808 case
never executed: case QChar::Script_PsalterPahlavi:
QChar::Script_PsalterPahlavi:
never executed: case QChar::Script_PsalterPahlavi:
0
809-
810 spaceAs = Justification_Arabic_Space;-
811 break;
never executed: break;
0
812-
813 case
never executed: case QChar::Script_Tibetan:
QChar::Script_Tibetan:
never executed: case QChar::Script_Tibetan:
0
814 case
never executed: case QChar::Script_Hiragana:
QChar::Script_Hiragana:
never executed: case QChar::Script_Hiragana:
0
815 case
never executed: case QChar::Script_Katakana:
QChar::Script_Katakana:
never executed: case QChar::Script_Katakana:
0
816 case
never executed: case QChar::Script_Bopomofo:
QChar::Script_Bopomofo:
never executed: case QChar::Script_Bopomofo:
0
817 case
never executed: case QChar::Script_Han:
QChar::Script_Han:
never executed: case QChar::Script_Han:
0
818-
819 spaceAs = Justification_Character;-
820 break;
never executed: break;
0
821-
822 default
never executed: default:
:
never executed: default:
0
823 spaceAs = Justification_Space;-
824 break;
never executed: break;
0
825 }-
826-
827 qt_getDefaultJustificationOpportunities(string, length, g, log_clusters, spaceAs);-
828}
never executed: end of block
0
829-
830-
831-
832-
833-
834void QTextEngine::shapeLine(const QScriptLine &line)-
835{-
836 QFixed x;-
837 bool first = true;-
838 int item = findItem(line.from);-
839 if (item == -1
item == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
840 return;
never executed: return;
0
841-
842 const int end = findItem(line.from + line.length + line.trailingSpaces - 1, item);-
843 for ( ; item <= end
item <= endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++item) {
0
844 QScriptItem &si = layoutData->items[item];-
845 if (si.analysis.flags == QScriptAnalysis::Tab
si.analysis.fl...tAnalysis::TabDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
846 ensureSpace(1);-
847 si.width = calculateTabWidth(item, x);-
848 }
never executed: end of block
else {
0
849 shape(item);-
850 }
never executed: end of block
0
851 if (first
firstDescription
TRUEnever evaluated
FALSEnever evaluated
&& si.position != line.from
si.position != line.fromDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
852 QGlyphLayout glyphs = shapedGlyphs(&si);-
853 ((!(line.from > si.position)) ? qt_assert("line.from > si.position",__FILE__,942) : qt_noop());-
854 for (int i = line.from - si.position - 1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; i--) {
0
855 x -= glyphs.effectiveAdvance(i);-
856 }
never executed: end of block
0
857 }
never executed: end of block
0
858 first = false;-
859-
860 x += si.width;-
861 }
never executed: end of block
0
862}
never executed: end of block
0
863-
864-
865extern bool qt_useHarfbuzzNG();-
866-
867-
868void QTextEngine::shapeText(int item) const-
869{-
870 ((!(item < layoutData->items.size())) ? qt_assert("item < layoutData->items.size()",__FILE__,959) : qt_noop());-
871 QScriptItem &si = layoutData->items[item];-
872-
873 if (si.num_glyphs
si.num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
874 return;
never executed: return;
0
875-
876 si.width = 0;-
877 si.glyph_data_offset = layoutData->used;-
878-
879 const ushort *string = reinterpret_cast<const ushort *>(layoutData->string.constData()) + si.position;-
880 const int itemLength = length(item);-
881-
882 QString casedString;-
883 if (si.analysis.flags
si.analysis.flagsDescription
TRUEnever evaluated
FALSEnever evaluated
&& si.analysis.flags <= QScriptAnalysis::SmallCaps
si.analysis.fl...sis::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
884 casedString.resize(itemLength);-
885 ushort *uc = reinterpret_cast<ushort *>(casedString.data());-
886 for (int i = 0; i < itemLength
i < itemLengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
887 uint ucs4 = string[i];-
888 if (QChar::isHighSurrogate(ucs4)
QChar::isHighSurrogate(ucs4)Description
TRUEnever evaluated
FALSEnever evaluated
&& i + 1 < itemLength
i + 1 < itemLengthDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
889 uint low = string[i + 1];-
890 if (QChar::isLowSurrogate(low)
QChar::isLowSurrogate(low)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
891 ++i;-
892 ucs4 = QChar::surrogateToUcs4(ucs4, low);-
893 ucs4 = si.analysis.flags == QScriptAnalysis::Lowercase
si.analysis.fl...sis::LowercaseDescription
TRUEnever evaluated
FALSEnever evaluated
? QChar::toLower(ucs4)
0
894 : QChar::toUpper(ucs4);-
895-
896 uc[i] = QChar::lowSurrogate(ucs4);-
897 }
never executed: end of block
0
898 }
never executed: end of block
else {
0
899 uc[i] = si.analysis.flags == QScriptAnalysis::Lowercase
si.analysis.fl...sis::LowercaseDescription
TRUEnever evaluated
FALSEnever evaluated
? QChar::toLower(ucs4)
0
900 : QChar::toUpper(ucs4);-
901 }
never executed: end of block
0
902 }-
903 string = reinterpret_cast<const ushort *>(casedString.constData());-
904 }
never executed: end of block
0
905-
906 if (__builtin_expect(!!(!ensureSpace(itemLength)), false)
__builtin_expe...ngth)), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
907 do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,996) : qt_noop()); __builtin_unreachable(); } while (0);-
908 return;
never executed: return;
0
909 }-
910-
911 QFontEngine *fontEngine = this->fontEngine(si, &si.ascent, &si.descent, &si.leading);-
912-
913-
914-
915 QVector<uint> itemBoundaries;-
916 itemBoundaries.reserve(24);-
917 if (fontEngine->type() == QFontEngine::Multi
fontEngine->ty...tEngine::MultiDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
918-
919-
920 QGlyphLayout initialGlyphs = availableGlyphs(&si);-
921-
922 int nGlyphs = initialGlyphs.numGlyphs;-
923 QFontEngine::ShaperFlags shaperFlags(QFontEngine::GlyphIndicesOnly);-
924 if (!fontEngine->stringToCMap(reinterpret_cast<const QChar *>(string), itemLength, &initialGlyphs, &nGlyphs, shaperFlags)
!fontEngine->s..., shaperFlags)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
925 do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,1014) : qt_noop()); __builtin_unreachable(); }
never executed: end of block
while (0);
0
926-
927 uint lastEngine = ~0u;-
928 for (int i = 0, glyph_pos = 0; i < itemLength
i < itemLengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i, ++glyph_pos) {
0
929 const uint engineIdx = initialGlyphs.glyphs[glyph_pos] >> 24;-
930 if (lastEngine != engineIdx
lastEngine != engineIdxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
931 itemBoundaries.append(i);-
932 itemBoundaries.append(glyph_pos);-
933 itemBoundaries.append(engineIdx);-
934-
935 if (engineIdx != 0
engineIdx != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
936 QFontEngine *actualFontEngine = static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx);-
937 si.ascent = qMax(actualFontEngine->ascent(), si.ascent);-
938 si.descent = qMax(actualFontEngine->descent(), si.descent);-
939 si.leading = qMax(actualFontEngine->leading(), si.leading);-
940 }
never executed: end of block
0
941-
942 lastEngine = engineIdx;-
943 }
never executed: end of block
0
944-
945 if (QChar::isHighSurrogate(string[i])
QChar::isHighS...ate(string[i])Description
TRUEnever evaluated
FALSEnever evaluated
&& i + 1 < itemLength
i + 1 < itemLengthDescription
TRUEnever evaluated
FALSEnever evaluated
&& QChar::isLowSurrogate(string[i + 1])
QChar::isLowSu...string[i + 1])Description
TRUEnever evaluated
FALSEnever evaluated
)
0
946 ++
never executed: ++i;
i;
never executed: ++i;
0
947 }
never executed: end of block
0
948 }
never executed: end of block
else {
0
949 itemBoundaries.append(0);-
950 itemBoundaries.append(0);-
951 itemBoundaries.append(0);-
952 }
never executed: end of block
0
953-
954 bool kerningEnabled;-
955 bool letterSpacingIsAbsolute;-
956 QFixed letterSpacing, wordSpacing;-
957-
958 if (useRawFont
useRawFontDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
959 QTextCharFormat f = format(&si);-
960 kerningEnabled = f.fontKerning();-
961 wordSpacing = QFixed::fromReal(f.fontWordSpacing());-
962 letterSpacing = QFixed::fromReal(f.fontLetterSpacing());-
963 letterSpacingIsAbsolute = true;-
964 }
never executed: end of block
else
0
965-
966 {-
967 QFont font = this->font(si);-
968 kerningEnabled = font.d->kerning;-
969 letterSpacingIsAbsolute = font.d->letterSpacingIsAbsolute;-
970 letterSpacing = font.d->letterSpacing;-
971 wordSpacing = font.d->wordSpacing;-
972-
973 if (letterSpacingIsAbsolute
letterSpacingIsAbsoluteDescription
TRUEnever evaluated
FALSEnever evaluated
&& letterSpacing.value()
letterSpacing.value()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
974 letterSpacing *= font.d->dpi / qt_defaultDpiY();
never executed: letterSpacing *= font.d->dpi / qt_defaultDpiY();
0
975 }
never executed: end of block
0
976-
977-
978 if (__builtin_expect(!!(qt_useHarfbuzzNG()), true)
__builtin_expe...zzNG()), true)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
979 si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled, letterSpacing != 0);
never executed: si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled, letterSpacing != 0);
0
980 else-
981-
982 si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled);
never executed: si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled);
0
983 if (__builtin_expect(!!(si.num_glyphs == 0), false)
__builtin_expe... == 0), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
984 do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,1073) : qt_noop()); __builtin_unreachable(); } while (0);-
985 return;
never executed: return;
0
986 }-
987-
988-
989 layoutData->used += si.num_glyphs;-
990-
991 QGlyphLayout glyphs = shapedGlyphs(&si);-
992-
993-
994 if (__builtin_expect(!!(qt_useHarfbuzzNG()), true)
__builtin_expe...zzNG()), true)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
995 qt_getJustificationOpportunities(string, itemLength, si, glyphs, logClusters(&si));
never executed: qt_getJustificationOpportunities(string, itemLength, si, glyphs, logClusters(&si));
0
996-
997-
998 if (letterSpacing != 0
letterSpacing != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
999 for (int i = 1; i < si.num_glyphs
i < si.num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1000 if (glyphs.attributes[i].clusterStart
glyphs.attribu...].clusterStartDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1001 if (letterSpacingIsAbsolute
letterSpacingIsAbsoluteDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1002 glyphs.advances[i - 1] += letterSpacing;
never executed: glyphs.advances[i - 1] += letterSpacing;
0
1003 else {-
1004 QFixed &advance = glyphs.advances[i - 1];-
1005 advance += (letterSpacing - 100) * advance / 100;-
1006 }
never executed: end of block
0
1007 }-
1008 }
never executed: end of block
0
1009 if (letterSpacingIsAbsolute
letterSpacingIsAbsoluteDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1010 glyphs.advances[si.num_glyphs - 1] += letterSpacing;
never executed: glyphs.advances[si.num_glyphs - 1] += letterSpacing;
0
1011 else {-
1012 QFixed &advance = glyphs.advances[si.num_glyphs - 1];-
1013 advance += (letterSpacing - 100) * advance / 100;-
1014 }
never executed: end of block
0
1015 }-
1016 if (wordSpacing != 0
wordSpacing != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1017 for (int i = 0; i < si.num_glyphs
i < si.num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1018 if (glyphs.attributes[i].justification == Justification_Space
glyphs.attribu...fication_SpaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1019 || glyphs.attributes[i].justification == Justification_Arabic_Space
glyphs.attribu...n_Arabic_SpaceDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1020-
1021 if (i + 1 == si.num_glyphs
i + 1 == si.num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1022 ||(glyphs.attributes[i+1].justification != Justification_Space
glyphs.attribu...fication_SpaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1023 && glyphs.attributes[i+1].justification != Justification_Arabic_Space
glyphs.attribu...n_Arabic_SpaceDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
1024 glyphs.advances[i] += wordSpacing;
never executed: glyphs.advances[i] += wordSpacing;
0
1025 }
never executed: end of block
0
1026 }
never executed: end of block
0
1027 }
never executed: end of block
0
1028-
1029 for (int i = 0; i < si.num_glyphs
i < si.num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1030 si.width += glyphs.advances[i] * !glyphs.attributes[i].dontPrint;
never executed: si.width += glyphs.advances[i] * !glyphs.attributes[i].dontPrint;
0
1031}
never executed: end of block
0
1032-
1033-
1034-
1035-
1036-
1037-
1038-
1039-
1040int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si,-
1041 const ushort *string,-
1042 int itemLength,-
1043 QFontEngine *fontEngine,-
1044 const QVector<uint> &itemBoundaries,-
1045 bool kerningEnabled,-
1046 bool hasLetterSpacing) const-
1047{-
1048 uint glyphs_shaped = 0;-
1049-
1050 hb_buffer_t *buffer = hb_buffer_create();-
1051 hb_buffer_set_unicode_funcs(buffer, hb_qt_get_unicode_funcs());-
1052 hb_buffer_pre_allocate(buffer, itemLength);-
1053 if (__builtin_expect(!!(!hb_buffer_allocation_successful(buffer)), false)
__builtin_expe...ffer)), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1054 hb_buffer_destroy(buffer);-
1055 return
never executed: return 0;
0;
never executed: return 0;
0
1056 }-
1057-
1058 hb_segment_properties_t props = {HB_DIRECTION_INVALID, HB_SCRIPT_INVALID, ((hb_language_t) __null), __null, __null};-
1059 props.direction = si.analysis.bidiLevel % 2
si.analysis.bidiLevel % 2Description
TRUEnever evaluated
FALSEnever evaluated
? HB_DIRECTION_RTL : HB_DIRECTION_LTR;
0
1060 QChar::Script script = QChar::Script(si.analysis.script);-
1061 props.script = hb_qt_script_to_script(script);-
1062-
1063-
1064 for (int k = 0; k < itemBoundaries.size()
k < itemBoundaries.size()Description
TRUEnever evaluated
FALSEnever evaluated
; k += 3) {
0
1065 const uint item_pos = itemBoundaries[k];-
1066 const uint item_length = (k + 4 < itemBoundaries.size()
k + 4 < itemBoundaries.size()Description
TRUEnever evaluated
FALSEnever evaluated
? itemBoundaries[k + 3] : itemLength) - item_pos;
0
1067 const uint engineIdx = itemBoundaries[k + 2];-
1068-
1069 QFontEngine *actualFontEngine = fontEngine->type() != QFontEngine::Multi
fontEngine->ty...tEngine::MultiDescription
TRUEnever evaluated
FALSEnever evaluated
? fontEngine
0
1070 : static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx);-
1071-
1072-
1073-
1074 hb_buffer_clear_contents(buffer);-
1075 hb_buffer_add_utf16(buffer, reinterpret_cast<const uint16_t *>(string) + item_pos, item_length, 0, item_length);-
1076-
1077 hb_buffer_set_segment_properties(buffer, &props);-
1078 hb_buffer_guess_segment_properties(buffer);-
1079-
1080 uint buffer_flags = HB_BUFFER_FLAG_DEFAULT;-
1081-
1082-
1083 if (__builtin_expect(!!(actualFontEngine->symbol), false)
__builtin_expe...ymbol), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1084 buffer_flags |= HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES;
never executed: buffer_flags |= HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES;
0
1085 hb_buffer_set_flags(buffer, hb_buffer_flags_t(buffer_flags));-
1086-
1087-
1088-
1089 {-
1090 hb_font_t *hb_font = hb_qt_font_get_for_engine(actualFontEngine);-
1091 ((!(hb_font)) ? qt_assert("hb_font",__FILE__,1181) : qt_noop());-
1092 hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0);-
1093-
1094-
1095-
1096 bool scriptRequiresOpenType = ((script >= QChar::Script_Syriac
script >= QChar::Script_SyriacDescription
TRUEnever evaluated
FALSEnever evaluated
&& script <= QChar::Script_Sinhala
script <= QCha...Script_SinhalaDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1097 || script == QChar::Script_Khmer
script == QChar::Script_KhmerDescription
TRUEnever evaluated
FALSEnever evaluated
|| script == QChar::Script_Nko
script == QChar::Script_NkoDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
1098-
1099 bool dontLigate = hasLetterSpacing
hasLetterSpacingDescription
TRUEnever evaluated
FALSEnever evaluated
&& !scriptRequiresOpenType
!scriptRequiresOpenTypeDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
1100 const hb_feature_t features[5] = {-
1101 { ((hb_tag_t)((((uint8_t)('k'))<<24)|(((uint8_t)('e'))<<16)|(((uint8_t)('r'))<<8)|((uint8_t)('n')))), !!kerningEnabled, 0, uint(-1) },-
1102 { ((hb_tag_t)((((uint8_t)('l'))<<24)|(((uint8_t)('i'))<<16)|(((uint8_t)('g'))<<8)|((uint8_t)('a')))), !dontLigate, 0, uint(-1) },-
1103 { ((hb_tag_t)((((uint8_t)('c'))<<24)|(((uint8_t)('l'))<<16)|(((uint8_t)('i'))<<8)|((uint8_t)('g')))), !dontLigate, 0, uint(-1) },-
1104 { ((hb_tag_t)((((uint8_t)('d'))<<24)|(((uint8_t)('l'))<<16)|(((uint8_t)('i'))<<8)|((uint8_t)('g')))), !dontLigate, 0, uint(-1) },-
1105 { ((hb_tag_t)((((uint8_t)('h'))<<24)|(((uint8_t)('l'))<<16)|(((uint8_t)('i'))<<8)|((uint8_t)('g')))), !dontLigate, 0, uint(-1) } };-
1106 const int num_features = dontLigate
dontLigateDescription
TRUEnever evaluated
FALSEnever evaluated
? 5 : 1;
0
1107-
1108 const char *const *shaper_list = nullptr;-
1109 bool shapedOk = hb_shape_full(hb_font, buffer, features, num_features, shaper_list);-
1110 if (__builtin_expect(!!(!shapedOk), false)
__builtin_expe...pedOk), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1111 hb_buffer_destroy(buffer);-
1112 return
never executed: return 0;
0;
never executed: return 0;
0
1113 }-
1114-
1115 if (__builtin_expect(!!(((((unsigned int) (props.direction)) & ~2U) == 5)), false)
__builtin_expe...== 5)), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1116 hb_buffer_reverse(buffer);
never executed: hb_buffer_reverse(buffer);
0
1117 }-
1118-
1119 const uint num_glyphs = hb_buffer_get_length(buffer);-
1120-
1121 if (__builtin_expect(!!(num_glyphs == 0 || !ensureSpace(glyphs_shaped + num_glyphs)), false)
__builtin_expe...yphs)), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1122 hb_buffer_destroy(buffer);-
1123 return
never executed: return 0;
0;
never executed: return 0;
0
1124 }-
1125-
1126-
1127 QGlyphLayout g = availableGlyphs(&si).mid(glyphs_shaped, num_glyphs);-
1128 ushort *log_clusters = logClusters(&si) + item_pos;-
1129-
1130 hb_glyph_info_t *infos = hb_buffer_get_glyph_infos(buffer, 0);-
1131 hb_glyph_position_t *positions = hb_buffer_get_glyph_positions(buffer, 0);-
1132 uint str_pos = 0;-
1133 uint last_cluster = ~0u;-
1134 uint last_glyph_pos = glyphs_shaped;-
1135 for (uint i = 0; i < num_glyphs
i < num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i, ++infos, ++positions) {
0
1136 g.glyphs[i] = infos->codepoint;-
1137-
1138 g.advances[i] = QFixed::fromFixed(positions->x_advance);-
1139 g.offsets[i].x = QFixed::fromFixed(positions->x_offset);-
1140 g.offsets[i].y = QFixed::fromFixed(positions->y_offset);-
1141-
1142 uint cluster = infos->cluster;-
1143 if (__builtin_expect(!!(last_cluster != cluster), true)
__builtin_expe...luster), true)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1144 g.attributes[i].clusterStart = true;-
1145-
1146-
1147-
1148 while (last_cluster++ < cluster
last_cluster++ < clusterDescription
TRUEnever evaluated
FALSEnever evaluated
&& str_pos < item_length
str_pos < item_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1149 log_clusters[str_pos++] = last_glyph_pos;
never executed: log_clusters[str_pos++] = last_glyph_pos;
0
1150 last_glyph_pos = i + glyphs_shaped;-
1151 last_cluster = cluster;-
1152-
1153-
1154 switch (string[item_pos + str_pos]) {-
1155 case
never executed: case QChar::LineFeed:
QChar::LineFeed:
never executed: case QChar::LineFeed:
0
1156 case
never executed: case 0x000c:
0x000c:
never executed: case 0x000c:
0
1157 case
never executed: case QChar::CarriageReturn:
QChar::CarriageReturn:
never executed: case QChar::CarriageReturn:
0
1158 case
never executed: case QChar::LineSeparator:
QChar::LineSeparator:
never executed: case QChar::LineSeparator:
0
1159 case
never executed: case QChar::ParagraphSeparator:
QChar::ParagraphSeparator:
never executed: case QChar::ParagraphSeparator:
0
1160 g.attributes[i].dontPrint = true;-
1161 break;
never executed: break;
0
1162 case
never executed: case QChar::SoftHyphen:
QChar::SoftHyphen:
never executed: case QChar::SoftHyphen:
0
1163 if (!actualFontEngine->symbol
!actualFontEngine->symbolDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1164-
1165-
1166-
1167 g.glyphs[i] = actualFontEngine->glyphIndex('-');-
1168 if (__builtin_expect(!!(g.glyphs[i] != 0), true)
__builtin_expe...] != 0), true)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1169 QGlyphLayout tmp = g.mid(i, 1);-
1170 actualFontEngine->recalcAdvances(&tmp, 0);-
1171 }
never executed: end of block
0
1172 g.attributes[i].dontPrint = true;-
1173 }
never executed: end of block
0
1174 break;
never executed: break;
0
1175 default
never executed: default:
:
never executed: default:
0
1176 break;
never executed: break;
0
1177 }-
1178 }-
1179 }
never executed: end of block
0
1180 while (str_pos < item_length
str_pos < item_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1181 log_clusters[str_pos++] = last_glyph_pos;
never executed: log_clusters[str_pos++] = last_glyph_pos;
0
1182-
1183 if (__builtin_expect(!!(engineIdx != 0), false)
__builtin_expe... != 0), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1184 for (quint32 i = 0; i < num_glyphs
i < num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1185 g.glyphs[i] |= (engineIdx << 24);
never executed: g.glyphs[i] |= (engineIdx << 24);
0
1186 }
never executed: end of block
0
1187 if (!actualFontEngine->supportsSubPixelPositions()
!actualFontEng...xelPositions()Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(actualFontEng...ntegerMetrics)Description
TRUEnever evaluated
FALSEnever evaluated
actualFontEngine->fontDef.styleStrategy & QFont::ForceIntegerMetrics)
(actualFontEng...ntegerMetrics)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1188 for (uint i = 0; i < num_glyphs
i < num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1189 g.advances[i] = g.advances[i].round();
never executed: g.advances[i] = g.advances[i].round();
0
1190 }
never executed: end of block
0
1191-
1192 glyphs_shaped += num_glyphs;-
1193 }
never executed: end of block
0
1194-
1195 hb_buffer_destroy(buffer);-
1196-
1197 return
never executed: return glyphs_shaped;
glyphs_shaped;
never executed: return glyphs_shaped;
0
1198}-
1199-
1200-
1201-
1202-
1203-
1204-
1205-
1206-
1207-
1208static_assert(bool(sizeof(HB_Glyph) == sizeof(glyph_t)), "sizeof(HB_Glyph) == sizeof(glyph_t)");-
1209static_assert(bool(sizeof(HB_Fixed) == sizeof(QFixed)), "sizeof(HB_Fixed) == sizeof(QFixed)");-
1210static_assert(bool(sizeof(HB_FixedPoint) == sizeof(QFixedPoint)), "sizeof(HB_FixedPoint) == sizeof(QFixedPoint)");-
1211-
1212static inline void moveGlyphData(const QGlyphLayout &destination, const QGlyphLayout &source, int num)-
1213{-
1214 if (num > 0
num > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& destination.glyphs != source.glyphs
destination.gl... source.glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1215 memmove(destination.glyphs, source.glyphs, num * sizeof(glyph_t));
never executed: memmove(destination.glyphs, source.glyphs, num * sizeof(glyph_t));
0
1216}
never executed: end of block
0
1217-
1218int QTextEngine::shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const-
1219{-
1220 HB_ShaperItem entire_shaper_item;-
1221 memset(&entire_shaper_item, 0, sizeof(entire_shaper_item));-
1222 entire_shaper_item.string = reinterpret_cast<const HB_UChar16 *>(string);-
1223 entire_shaper_item.stringLength = itemLength;-
1224 entire_shaper_item.item.script = script_to_hbscript(si.analysis.script);-
1225 entire_shaper_item.item.pos = 0;-
1226 entire_shaper_item.item.length = itemLength;-
1227 entire_shaper_item.item.bidiLevel = si.analysis.bidiLevel;-
1228-
1229 entire_shaper_item.shaperFlags = 0;-
1230 if (!kerningEnabled
!kerningEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1231 entire_shaper_item.shaperFlags |= HB_ShaperFlag_NoKerning;
never executed: entire_shaper_item.shaperFlags |= HB_ShaperFlag_NoKerning;
0
1232 if (option.useDesignMetrics()
option.useDesignMetrics()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1233 entire_shaper_item.shaperFlags |= HB_ShaperFlag_UseDesignMetrics;
never executed: entire_shaper_item.shaperFlags |= HB_ShaperFlag_UseDesignMetrics;
0
1234-
1235-
1236 entire_shaper_item.num_glyphs = 0;-
1237 for (int i = 0; i < itemLength
i < itemLengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i, ++entire_shaper_item.num_glyphs) {
0
1238 if (QChar::isHighSurrogate(string[i])
QChar::isHighS...ate(string[i])Description
TRUEnever evaluated
FALSEnever evaluated
&& i + 1 < itemLength
i + 1 < itemLengthDescription
TRUEnever evaluated
FALSEnever evaluated
&& QChar::isLowSurrogate(string[i + 1])
QChar::isLowSu...string[i + 1])Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1239 ++
never executed: ++i;
i;
never executed: ++i;
0
1240 }
never executed: end of block
0
1241-
1242-
1243 int remaining_glyphs = entire_shaper_item.num_glyphs;-
1244 int glyph_pos = 0;-
1245-
1246 for (int k = 0; k < itemBoundaries.size()
k < itemBoundaries.size()Description
TRUEnever evaluated
FALSEnever evaluated
; k += 3) {
0
1247 HB_ShaperItem shaper_item = entire_shaper_item;-
1248 shaper_item.item.pos = itemBoundaries[k];-
1249 if (k + 4 < itemBoundaries.size()
k + 4 < itemBoundaries.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1250 shaper_item.item.length = itemBoundaries[k + 3] - shaper_item.item.pos;-
1251 shaper_item.num_glyphs = itemBoundaries[k + 4] - itemBoundaries[k + 1];-
1252 }
never executed: end of block
else {
0
1253 shaper_item.item.length -= shaper_item.item.pos - entire_shaper_item.item.pos;-
1254 shaper_item.num_glyphs -= itemBoundaries[k + 1];-
1255 }
never executed: end of block
0
1256 shaper_item.initialGlyphCount = shaper_item.num_glyphs;-
1257 if (shaper_item.num_glyphs < shaper_item.item.length
shaper_item.nu...em.item.lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1258 shaper_item.num_glyphs = shaper_item.item.length;
never executed: shaper_item.num_glyphs = shaper_item.item.length;
0
1259-
1260 uint engineIdx = itemBoundaries[k + 2];-
1261 QFontEngine *actualFontEngine = fontEngine;-
1262 if (fontEngine->type() == QFontEngine::Multi
fontEngine->ty...tEngine::MultiDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1263 actualFontEngine = static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx);-
1264-
1265 if ((
(si.analysis.b...evel % 2) == 0Description
TRUEnever evaluated
FALSEnever evaluated
si.analysis.bidiLevel % 2) == 0
(si.analysis.b...evel % 2) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1266 shaper_item.glyphIndicesPresent = true;
never executed: shaper_item.glyphIndicesPresent = true;
0
1267 }
never executed: end of block
0
1268-
1269 shaper_item.font = (HB_Font)actualFontEngine->harfbuzzFont();-
1270 shaper_item.face = (HB_Face)actualFontEngine->harfbuzzFace();-
1271-
1272 remaining_glyphs -= shaper_item.initialGlyphCount;-
1273-
1274 QVarLengthArray<HB_GlyphAttributes, 128> hbGlyphAttributes;-
1275 do {-
1276 if (!ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs)
!ensureSpace(g...aining_glyphs)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1277 return
never executed: return 0;
0;
never executed: return 0;
0
1278 if (hbGlyphAttributes.size() < int(shaper_item.num_glyphs)
hbGlyphAttribu...em.num_glyphs)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1279 hbGlyphAttributes.resize(shaper_item.num_glyphs);-
1280 memset(hbGlyphAttributes.data(), 0, hbGlyphAttributes.size() * sizeof(HB_GlyphAttributes));-
1281 }
never executed: end of block
0
1282-
1283 const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos);-
1284 if (fontEngine->type() == QFontEngine::Multi
fontEngine->ty...tEngine::MultiDescription
TRUEnever evaluated
FALSEnever evaluated
&& shaper_item.num_glyphs > shaper_item.item.length
shaper_item.nu...em.item.lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1285 moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
never executed: moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
0
1286-
1287 shaper_item.glyphs = reinterpret_cast<HB_Glyph *>(g.glyphs);-
1288 shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances);-
1289 shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets);-
1290 shaper_item.attributes = hbGlyphAttributes.data();-
1291-
1292 if (engineIdx != 0
engineIdx != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& shaper_item.glyphIndicesPresent
shaper_item.gl...IndicesPresentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1293 for (quint32 i = 0; i < shaper_item.initialGlyphCount
i < shaper_ite...tialGlyphCountDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1294 shaper_item.glyphs[i] &= 0x00ffffff;
never executed: shaper_item.glyphs[i] &= 0x00ffffff;
0
1295 }
never executed: end of block
0
1296-
1297 shaper_item.log_clusters = logClusters(&si) + shaper_item.item.pos - entire_shaper_item.item.pos;-
1298 }
never executed: end of block
while (!qShapeItem(&shaper_item)
!qShapeItem(&shaper_item)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1299-
1300 QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos, shaper_item.num_glyphs);-
1301 if (fontEngine->type() == QFontEngine::Multi
fontEngine->ty...tEngine::MultiDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1302 moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
never executed: moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
0
1303-
1304 for (quint32 i = 0; i < shaper_item.num_glyphs
i < shaper_item.num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1305 HB_GlyphAttributes hbAttrs = hbGlyphAttributes.at(i);-
1306 QGlyphAttributes &attrs = g.attributes[i];-
1307 attrs.clusterStart = hbAttrs.clusterStart;-
1308 attrs.dontPrint = hbAttrs.dontPrint;-
1309 attrs.justification = hbAttrs.justification;-
1310 }
never executed: end of block
0
1311-
1312 for (quint32 i = 0; i < shaper_item.item.length
i < shaper_item.item.lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1313-
1314 if (shaper_item.log_clusters[i] >= shaper_item.num_glyphs
shaper_item.lo...tem.num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1315 shaper_item.log_clusters[i] = shaper_item.num_glyphs - 1;
never executed: shaper_item.log_clusters[i] = shaper_item.num_glyphs - 1;
0
1316 shaper_item.log_clusters[i] += glyph_pos;-
1317 }
never executed: end of block
0
1318-
1319 if (kerningEnabled
kerningEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
&& !shaper_item.kerning_applied
!shaper_item.kerning_appliedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1320 actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0));
never executed: actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0));
0
1321-
1322 if (engineIdx != 0
engineIdx != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1323 for (quint32 i = 0; i < shaper_item.num_glyphs
i < shaper_item.num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1324 g.glyphs[i] |= (engineIdx << 24);
never executed: g.glyphs[i] |= (engineIdx << 24);
0
1325 }
never executed: end of block
0
1326-
1327 glyph_pos += shaper_item.num_glyphs;-
1328 }
never executed: end of block
0
1329-
1330 return
never executed: return glyph_pos;
glyph_pos;
never executed: return glyph_pos;
0
1331}-
1332-
1333void QTextEngine::init(QTextEngine *e)-
1334{-
1335 e->ignoreBidi = false;-
1336 e->cacheGlyphs = false;-
1337 e->forceJustification = false;-
1338 e->visualMovement = false;-
1339 e->delayDecorations = false;-
1340-
1341 e->layoutData = 0;-
1342-
1343 e->minWidth = 0;-
1344 e->maxWidth = 0;-
1345-
1346 e->specialData = 0;-
1347 e->stackEngine = false;-
1348-
1349 e->useRawFont = false;-
1350-
1351}
never executed: end of block
0
1352-
1353QTextEngine::QTextEngine()-
1354{-
1355 init(this);-
1356}
never executed: end of block
0
1357-
1358QTextEngine::QTextEngine(const QString &str, const QFont &f)-
1359 : text(str),-
1360 fnt(f)-
1361{-
1362 init(this);-
1363}
never executed: end of block
0
1364-
1365QTextEngine::~QTextEngine()-
1366{-
1367 if (!stackEngine
!stackEngineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1368 delete layoutData;
never executed: delete layoutData;
0
1369 delete specialData;-
1370 resetFontEngineCache();-
1371}
never executed: end of block
0
1372-
1373const QCharAttributes *QTextEngine::attributes() const-
1374{-
1375 if (layoutData
layoutDataDescription
TRUEnever evaluated
FALSEnever evaluated
&& layoutData->haveCharAttributes
layoutData->haveCharAttributesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1376 return
never executed: return (QCharAttributes *) layoutData->memory;
(QCharAttributes *) layoutData->memory;
never executed: return (QCharAttributes *) layoutData->memory;
0
1377-
1378 itemize();-
1379 if (! ensureSpace(layoutData->string.length())
! ensureSpace(...ring.length())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1380 return
never executed: return __null;
__null;
never executed: return __null;
0
1381-
1382 QVarLengthArray<QUnicodeTools::ScriptItem> scriptItems(layoutData->items.size());-
1383 for (int i = 0; i < layoutData->items.size()
i < layoutData->items.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1384 const QScriptItem &si = layoutData->items[i];-
1385 scriptItems[i].position = si.position;-
1386 scriptItems[i].script = si.analysis.script;-
1387 }
never executed: end of block
0
1388-
1389 QUnicodeTools::initCharAttributes(reinterpret_cast<const ushort *>(layoutData->string.constData()),-
1390 layoutData->string.length(),-
1391 scriptItems.data(), scriptItems.size(),-
1392 (QCharAttributes *)layoutData->memory);-
1393-
1394-
1395 layoutData->haveCharAttributes = true;-
1396 return
never executed: return (QCharAttributes *) layoutData->memory;
(QCharAttributes *) layoutData->memory;
never executed: return (QCharAttributes *) layoutData->memory;
0
1397}-
1398-
1399void QTextEngine::shape(int item) const-
1400{-
1401 if (layoutData->items[item].analysis.flags == QScriptAnalysis::Object
layoutData->it...alysis::ObjectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1402 ensureSpace(1);-
1403 if (block.docHandle()
block.docHandle()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1404 docLayout()->resizeInlineObject(QTextInlineObject(item, const_cast<QTextEngine *>(this)),-
1405 layoutData->items[item].position + block.position(),-
1406 format(&layoutData->items[item]));-
1407 }
never executed: end of block
0
1408 }
never executed: end of block
else if (layoutData->items[item].analysis.flags == QScriptAnalysis::Tab
layoutData->it...tAnalysis::TabDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1409-
1410 fontEngine(layoutData->items[item],-
1411 &layoutData->items[item].ascent,-
1412 &layoutData->items[item].descent,-
1413 &layoutData->items[item].leading);-
1414 }
never executed: end of block
else {
0
1415 shapeText(item);-
1416 }
never executed: end of block
0
1417}-
1418-
1419static inline void releaseCachedFontEngine(QFontEngine *fontEngine)-
1420{-
1421 if (fontEngine
fontEngineDescription
TRUEnever evaluated
FALSEnever evaluated
&& !fontEngine->ref.deref()
!fontEngine->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1422 delete fontEngine;
never executed: delete fontEngine;
0
1423}
never executed: end of block
0
1424-
1425void QTextEngine::resetFontEngineCache()-
1426{-
1427 releaseCachedFontEngine(feCache.prevFontEngine);-
1428 releaseCachedFontEngine(feCache.prevScaledFontEngine);-
1429 feCache.reset();-
1430}
never executed: end of block
0
1431-
1432void QTextEngine::invalidate()-
1433{-
1434 freeMemory();-
1435 minWidth = 0;-
1436 maxWidth = 0;-
1437-
1438 resetFontEngineCache();-
1439}
never executed: end of block
0
1440-
1441void QTextEngine::clearLineData()-
1442{-
1443 lines.clear();-
1444}
never executed: end of block
0
1445-
1446void QTextEngine::validate() const-
1447{-
1448 if (layoutData
layoutDataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1449 return;
never executed: return;
0
1450 layoutData = new LayoutData();-
1451 if (block.docHandle()
block.docHandle()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1452 layoutData->string = block.text();-
1453 const bool nextBlockValid = block.next().isValid();-
1454 if (!nextBlockValid
!nextBlockValidDescription
TRUEnever evaluated
FALSEnever evaluated
&& option.flags() & QTextOption::ShowDocumentTerminator
option.flags()...mentTerminatorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1455 layoutData->string += QChar(0xA7);-
1456 }
never executed: end of block
else if (option.flags() & QTextOption::ShowLineAndParagraphSeparators
option.flags()...raphSeparatorsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1457 layoutData->string += QLatin1Char(nextBlockValid ? 0xb6 : 0x20);-
1458 }
never executed: end of block
0
1459-
1460 }
never executed: end of block
else {
0
1461 layoutData->string = text;-
1462 }
never executed: end of block
0
1463 if (specialData
specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
&& specialData->preeditPosition != -1
specialData->p...Position != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1464 layoutData->string.insert(specialData->preeditPosition, specialData->preeditText);
never executed: layoutData->string.insert(specialData->preeditPosition, specialData->preeditText);
0
1465}
never executed: end of block
0
1466-
1467void QTextEngine::itemize() const-
1468{-
1469 validate();-
1470 if (layoutData->items.size()
layoutData->items.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1471 return;
never executed: return;
0
1472-
1473 int length = layoutData->string.length();-
1474 if (!length
!lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1475 return;
never executed: return;
0
1476-
1477 const ushort *string = reinterpret_cast<const ushort *>(layoutData->string.unicode());-
1478-
1479 bool ignore = ignoreBidi;-
1480-
1481 bool rtl = isRightToLeft();-
1482-
1483 if (!ignore
!ignoreDescription
TRUEnever evaluated
FALSEnever evaluated
&& !rtl
!rtlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1484 ignore = true;-
1485 const QChar *start = layoutData->string.unicode();-
1486 const QChar * const end = start + length;-
1487 while (start < end
start < endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1488 if (start->unicode() >= 0x590
start->unicode() >= 0x590Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1489 ignore = false;-
1490 break;
never executed: break;
0
1491 }-
1492 ++start;-
1493 }
never executed: end of block
0
1494 }
never executed: end of block
0
1495-
1496 QVarLengthArray<QScriptAnalysis, 4096> scriptAnalysis(length);-
1497 QScriptAnalysis *analysis = scriptAnalysis.data();-
1498-
1499 QBidiControl control(rtl);-
1500-
1501 if (ignore
ignoreDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1502 memset(analysis, 0, length*sizeof(QScriptAnalysis));-
1503 if (option.textDirection() == Qt::RightToLeft
option.textDir...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1504 for (int i = 0; i < length
i < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1505 analysis[i].bidiLevel = 1;
never executed: analysis[i].bidiLevel = 1;
0
1506 layoutData->hasBidi = true;-
1507 }
never executed: end of block
0
1508 }
never executed: end of block
else {
0
1509 layoutData->hasBidi = bidiItemize(const_cast<QTextEngine *>(this), analysis, control);-
1510 }
never executed: end of block
0
1511-
1512 {-
1513 QVarLengthArray<uchar> scripts(length);-
1514 QUnicodeTools::initScripts(string, length, scripts.data());-
1515 for (int i = 0; i < length
i < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1516 analysis[i].script = scripts.at(i);
never executed: analysis[i].script = scripts.at(i);
0
1517 }-
1518-
1519 const ushort *uc = string;-
1520 const ushort *e = uc + length;-
1521 while (uc < e
uc < eDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1522 switch (*uc) {-
1523 case
never executed: case QChar::ObjectReplacementCharacter:
QChar::ObjectReplacementCharacter:
never executed: case QChar::ObjectReplacementCharacter:
0
1524 analysis->flags = QScriptAnalysis::Object;-
1525 break;
never executed: break;
0
1526 case
never executed: case QChar::LineSeparator:
QChar::LineSeparator:
never executed: case QChar::LineSeparator:
0
1527 if (analysis->bidiLevel % 2
analysis->bidiLevel % 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1528 --
never executed: --analysis->bidiLevel;
analysis->bidiLevel;
never executed: --analysis->bidiLevel;
0
1529 analysis->flags = QScriptAnalysis::LineOrParagraphSeparator;-
1530 if (option.flags() & QTextOption::ShowLineAndParagraphSeparators
option.flags()...raphSeparatorsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1531 const int offset = uc - string;-
1532 layoutData->string.detach();-
1533 string = reinterpret_cast<const ushort *>(layoutData->string.unicode());-
1534 uc = string + offset;-
1535 e = uc + length;-
1536 *const_cast<ushort*>(uc) = 0x21B5;-
1537 }
never executed: end of block
0
1538 break;
never executed: break;
0
1539 case
never executed: case QChar::Tabulation:
QChar::Tabulation:
never executed: case QChar::Tabulation:
0
1540 analysis->flags = QScriptAnalysis::Tab;-
1541 analysis->bidiLevel = control.baseLevel();-
1542 break;
never executed: break;
0
1543 case
never executed: case QChar::Space:
QChar::Space:
never executed: case QChar::Space:
0
1544 case
never executed: case QChar::Nbsp:
QChar::Nbsp:
never executed: case QChar::Nbsp:
0
1545 if (option.flags() & QTextOption::ShowTabsAndSpaces
option.flags()...wTabsAndSpacesDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1546 analysis->flags = QScriptAnalysis::Space;-
1547 analysis->bidiLevel = control.baseLevel();-
1548 break;
never executed: break;
0
1549 }-
1550-
1551 default
never executed: default:
:
never executed: default:
code before this statement never executed: default:
0
1552 analysis->flags = QScriptAnalysis::None;-
1553 break;
never executed: break;
0
1554 }-
1555-
1556-
1557-
1558 ++uc;-
1559 ++analysis;-
1560 }
never executed: end of block
0
1561 if (option.flags() & QTextOption::ShowLineAndParagraphSeparators
option.flags()...raphSeparatorsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1562 (analysis-1)->flags = QScriptAnalysis::LineOrParagraphSeparator;-
1563 }
never executed: end of block
0
1564-
1565 analysis = scriptAnalysis.data();-
1566 if (qt_useHarfbuzzNG()
qt_useHarfbuzzNG()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1567-
1568 for (int i = 0; i < length
i < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1569 switch (analysis[i].script) {-
1570 case
never executed: case QChar::Script_Latin:
QChar::Script_Latin:
never executed: case QChar::Script_Latin:
0
1571 case
never executed: case QChar::Script_Hiragana:
QChar::Script_Hiragana:
never executed: case QChar::Script_Hiragana:
0
1572 case
never executed: case QChar::Script_Katakana:
QChar::Script_Katakana:
never executed: case QChar::Script_Katakana:
0
1573 case
never executed: case QChar::Script_Bopomofo:
QChar::Script_Bopomofo:
never executed: case QChar::Script_Bopomofo:
0
1574 case
never executed: case QChar::Script_Han:
QChar::Script_Han:
never executed: case QChar::Script_Han:
0
1575 analysis[i].script = QChar::Script_Common;-
1576 break;
never executed: break;
0
1577 default
never executed: default:
:
never executed: default:
0
1578 break;
never executed: break;
0
1579 }-
1580 }-
1581 }
never executed: end of block
else {
0
1582 for (int i = 0; i < length
i < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1583 analysis[i].script = hbscript_to_script(script_to_hbscript(analysis[i].script));
never executed: analysis[i].script = hbscript_to_script(script_to_hbscript(analysis[i].script));
0
1584 }
never executed: end of block
0
1585-
1586-
1587 Itemizer itemizer(layoutData->string, scriptAnalysis.data(), layoutData->items);-
1588-
1589 const QTextDocumentPrivate *p = block.docHandle();-
1590 if (p
pDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1591 SpecialData *s = specialData;-
1592-
1593 QTextDocumentPrivate::FragmentIterator it = p->find(block.position());-
1594 QTextDocumentPrivate::FragmentIterator end = p->find(block.position() + block.length() - 1);-
1595 int format = it.value()->format;-
1596-
1597 int prevPosition = 0;-
1598 int position = prevPosition;-
1599 while (1) {-
1600 const QTextFragmentData * const frag = it.value();-
1601 if (it == end
it == endDescription
TRUEnever evaluated
FALSEnever evaluated
|| format != frag->format
format != frag->formatDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1602 if (s
sDescription
TRUEnever evaluated
FALSEnever evaluated
&& position >= s->preeditPosition
position >= s->preeditPositionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1603 position += s->preeditText.length();-
1604 s = 0;-
1605 }
never executed: end of block
0
1606 ((!(position <= length)) ? qt_assert("position <= length",__FILE__,1725) : qt_noop());-
1607 QFont::Capitalization capitalization =-
1608 formatCollection()->charFormat(format).hasProperty(QTextFormat::FontCapitalization)
formatCollecti...apitalization)Description
TRUEnever evaluated
FALSEnever evaluated
0
1609 ? formatCollection()->charFormat(format).fontCapitalization()-
1610 : formatCollection()->defaultFont().capitalization();-
1611 itemizer.generate(prevPosition, position - prevPosition, capitalization);-
1612 if (it == end
it == endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1613 if (position < length
position < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1614 itemizer.generate(position, length - position, capitalization);
never executed: itemizer.generate(position, length - position, capitalization);
0
1615 break;
never executed: break;
0
1616 }-
1617 format = frag->format;-
1618 prevPosition = position;-
1619 }
never executed: end of block
0
1620 position += frag->size_array[0];-
1621 ++it;-
1622 }
never executed: end of block
0
1623 }
never executed: end of block
else {
0
1624-
1625 if (useRawFont
useRawFontDescription
TRUEnever evaluated
FALSEnever evaluated
&& specialData
specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1626 int lastIndex = 0;-
1627 for (int i = 0; i < specialData->formats.size()
i < specialDat...formats.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1628 const QTextLayout::FormatRange &range = specialData->formats.at(i);-
1629 const QTextCharFormat &format = range.format;-
1630 if (format.hasProperty(QTextFormat::FontCapitalization)
format.hasProp...apitalization)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1631 itemizer.generate(lastIndex, range.start - lastIndex, QFont::MixedCase);-
1632 itemizer.generate(range.start, range.length, format.fontCapitalization());-
1633 lastIndex = range.start + range.length;-
1634 }
never executed: end of block
0
1635 }
never executed: end of block
0
1636 itemizer.generate(lastIndex, length - lastIndex, QFont::MixedCase);-
1637 }
never executed: end of block
else
0
1638-
1639 itemizer.generate(0, length, static_cast<QFont::Capitalization> (fnt.d->capital));
never executed: itemizer.generate(0, length, static_cast<QFont::Capitalization> (fnt.d->capital));
0
1640 }-
1641-
1642 addRequiredBoundaries();-
1643 resolveFormats();-
1644}
never executed: end of block
0
1645-
1646bool QTextEngine::isRightToLeft() const-
1647{-
1648 switch (option.textDirection()) {-
1649 case
never executed: case Qt::LeftToRight:
Qt::LeftToRight:
never executed: case Qt::LeftToRight:
0
1650 return
never executed: return false;
false;
never executed: return false;
0
1651 case
never executed: case Qt::RightToLeft:
Qt::RightToLeft:
never executed: case Qt::RightToLeft:
0
1652 return
never executed: return true;
true;
never executed: return true;
0
1653 default
never executed: default:
:
never executed: default:
0
1654 break;
never executed: break;
0
1655 }-
1656 if (!layoutData
!layoutDataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1657 itemize();
never executed: itemize();
0
1658-
1659 if (layoutData->string.isEmpty()
layoutData->string.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1660 return
never executed: return QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft;
QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft;
never executed: return QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft;
0
1661 return
never executed: return layoutData->string.isRightToLeft();
layoutData->string.isRightToLeft();
never executed: return layoutData->string.isRightToLeft();
0
1662}-
1663-
1664-
1665int QTextEngine::findItem(int strPos, int firstItem) const-
1666{-
1667 itemize();-
1668 if (strPos < 0
strPos < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| strPos >= layoutData->string.size()
strPos >= layo...>string.size()Description
TRUEnever evaluated
FALSEnever evaluated
|| firstItem < 0
firstItem < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1669 return
never executed: return -1;
-1;
never executed: return -1;
0
1670-
1671 int left = firstItem + 1;-
1672 int right = layoutData->items.size()-1;-
1673 while(left <= right
left <= rightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1674 int middle = ((right-left)/2)+left;-
1675 if (strPos > layoutData->items[middle].position
strPos > layou...ddle].positionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1676 left = middle+1;
never executed: left = middle+1;
0
1677 else if(strPos < layoutData->items[middle].position
strPos < layou...ddle].positionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1678 right = middle-1;
never executed: right = middle-1;
0
1679 else {-
1680 return
never executed: return middle;
middle;
never executed: return middle;
0
1681 }-
1682 }-
1683 return
never executed: return right;
right;
never executed: return right;
0
1684}-
1685-
1686QFixed QTextEngine::width(int from, int len) const-
1687{-
1688 itemize();-
1689-
1690 QFixed w = 0;-
1691-
1692-
1693 for (int i = 0; i < layoutData->items.size()
i < layoutData->items.size()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1694 const QScriptItem *si = layoutData->items.constData() + i;-
1695 int pos = si->position;-
1696 int ilen = length(i);-
1697-
1698 if (pos >= from + len
pos >= from + lenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1699 break;
never executed: break;
0
1700 if (pos + ilen > from
pos + ilen > fromDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1701 if (!si->num_glyphs
!si->num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1702 shape(i);
never executed: shape(i);
0
1703-
1704 if (si->analysis.flags == QScriptAnalysis::Object
si->analysis.f...alysis::ObjectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1705 w += si->width;-
1706 continue;
never executed: continue;
0
1707 } else if (si->analysis.flags == QScriptAnalysis::Tab
si->analysis.f...tAnalysis::TabDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1708 w += calculateTabWidth(i, w);-
1709 continue;
never executed: continue;
0
1710 }-
1711-
1712-
1713 QGlyphLayout glyphs = shapedGlyphs(si);-
1714 unsigned short *logClusters = this->logClusters(si);-
1715-
1716-
1717-
1718-
1719-
1720-
1721 int charFrom = from - pos;-
1722 if (charFrom < 0
charFrom < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1723 charFrom = 0;
never executed: charFrom = 0;
0
1724 int glyphStart = logClusters[charFrom];-
1725 if (charFrom > 0
charFrom > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& logClusters[charFrom-1] == glyphStart
logClusters[ch... == glyphStartDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1726 while (charFrom < ilen
charFrom < ilenDescription
TRUEnever evaluated
FALSEnever evaluated
&& logClusters[charFrom] == glyphStart
logClusters[ch... == glyphStartDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1727 charFrom++;
never executed: charFrom++;
0
1728 if (charFrom < ilen
charFrom < ilenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1729 glyphStart = logClusters[charFrom];-
1730 int charEnd = from + len - 1 - pos;-
1731 if (charEnd >= ilen
charEnd >= ilenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1732 charEnd = ilen-1;
never executed: charEnd = ilen-1;
0
1733 int glyphEnd = logClusters[charEnd];-
1734 while (charEnd < ilen
charEnd < ilenDescription
TRUEnever evaluated
FALSEnever evaluated
&& logClusters[charEnd] == glyphEnd
logClusters[ch...d] == glyphEndDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1735 charEnd++;
never executed: charEnd++;
0
1736 glyphEnd = (
(charEnd == ilen)Description
TRUEnever evaluated
FALSEnever evaluated
charEnd == ilen)
(charEnd == ilen)Description
TRUEnever evaluated
FALSEnever evaluated
? si->num_glyphs : logClusters[charEnd];
0
1737-
1738-
1739 for (int i = glyphStart; i < glyphEnd
i < glyphEndDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
1740 w += glyphs.advances[i] * !glyphs.attributes[i].dontPrint;
never executed: w += glyphs.advances[i] * !glyphs.attributes[i].dontPrint;
0
1741 }
never executed: end of block
0
1742 }
never executed: end of block
0
1743 }
never executed: end of block
0
1744-
1745 return
never executed: return w;
w;
never executed: return w;
0
1746}-
1747-
1748glyph_metrics_t QTextEngine::boundingBox(int from, int len) const-
1749{-
1750 itemize();-
1751-
1752 glyph_metrics_t gm;-
1753-
1754 for (int i = 0; i < layoutData->items.size()
i < layoutData->items.size()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1755 const QScriptItem *si = layoutData->items.constData() + i;-
1756-
1757 int pos = si->position;-
1758 int ilen = length(i);-
1759 if (pos > from + len
pos > from + lenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1760 break;
never executed: break;
0
1761 if (pos + ilen > from
pos + ilen > fromDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1762 if (!si->num_glyphs
!si->num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1763 shape(i);
never executed: shape(i);
0
1764-
1765 if (si->analysis.flags == QScriptAnalysis::Object
si->analysis.f...alysis::ObjectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1766 gm.width += si->width;-
1767 continue;
never executed: continue;
0
1768 } else if (si->analysis.flags == QScriptAnalysis::Tab
si->analysis.f...tAnalysis::TabDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1769 gm.width += calculateTabWidth(i, gm.width);-
1770 continue;
never executed: continue;
0
1771 }-
1772-
1773 unsigned short *logClusters = this->logClusters(si);-
1774 QGlyphLayout glyphs = shapedGlyphs(si);-
1775-
1776-
1777 int charFrom = from - pos;-
1778 if (charFrom < 0
charFrom < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1779 charFrom = 0;
never executed: charFrom = 0;
0
1780 int glyphStart = logClusters[charFrom];-
1781 if (charFrom > 0
charFrom > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& logClusters[charFrom-1] == glyphStart
logClusters[ch... == glyphStartDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1782 while (charFrom < ilen
charFrom < ilenDescription
TRUEnever evaluated
FALSEnever evaluated
&& logClusters[charFrom] == glyphStart
logClusters[ch... == glyphStartDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1783 charFrom++;
never executed: charFrom++;
0
1784 if (charFrom < ilen
charFrom < ilenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1785 QFontEngine *fe = fontEngine(*si);-
1786 glyphStart = logClusters[charFrom];-
1787 int charEnd = from + len - 1 - pos;-
1788 if (charEnd >= ilen
charEnd >= ilenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1789 charEnd = ilen-1;
never executed: charEnd = ilen-1;
0
1790 int glyphEnd = logClusters[charEnd];-
1791 while (charEnd < ilen
charEnd < ilenDescription
TRUEnever evaluated
FALSEnever evaluated
&& logClusters[charEnd] == glyphEnd
logClusters[ch...d] == glyphEndDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1792 charEnd++;
never executed: charEnd++;
0
1793 glyphEnd = (
(charEnd == ilen)Description
TRUEnever evaluated
FALSEnever evaluated
charEnd == ilen)
(charEnd == ilen)Description
TRUEnever evaluated
FALSEnever evaluated
? si->num_glyphs : logClusters[charEnd];
0
1794 if (glyphStart <= glyphEnd
glyphStart <= glyphEndDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1795 glyph_metrics_t m = fe->boundingBox(glyphs.mid(glyphStart, glyphEnd - glyphStart));-
1796 gm.x = qMin(gm.x, m.x + gm.xoff);-
1797 gm.y = qMin(gm.y, m.y + gm.yoff);-
1798 gm.width = qMax(gm.width, m.width+gm.xoff);-
1799 gm.height = qMax(gm.height, m.height+gm.yoff);-
1800 gm.xoff += m.xoff;-
1801 gm.yoff += m.yoff;-
1802 }
never executed: end of block
0
1803 }
never executed: end of block
0
1804 }
never executed: end of block
0
1805 }
never executed: end of block
0
1806 return
never executed: return gm;
gm;
never executed: return gm;
0
1807}-
1808-
1809glyph_metrics_t QTextEngine::tightBoundingBox(int from, int len) const-
1810{-
1811 itemize();-
1812-
1813 glyph_metrics_t gm;-
1814-
1815 for (int i = 0; i < layoutData->items.size()
i < layoutData->items.size()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1816 const QScriptItem *si = layoutData->items.constData() + i;-
1817 int pos = si->position;-
1818 int ilen = length(i);-
1819 if (pos > from + len
pos > from + lenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1820 break;
never executed: break;
0
1821 if (pos + len > from
pos + len > fromDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1822 if (!si->num_glyphs
!si->num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1823 shape(i);
never executed: shape(i);
0
1824 unsigned short *logClusters = this->logClusters(si);-
1825 QGlyphLayout glyphs = shapedGlyphs(si);-
1826-
1827-
1828 int charFrom = from - pos;-
1829 if (charFrom < 0
charFrom < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1830 charFrom = 0;
never executed: charFrom = 0;
0
1831 int glyphStart = logClusters[charFrom];-
1832 if (charFrom > 0
charFrom > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& logClusters[charFrom-1] == glyphStart
logClusters[ch... == glyphStartDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1833 while (charFrom < ilen
charFrom < ilenDescription
TRUEnever evaluated
FALSEnever evaluated
&& logClusters[charFrom] == glyphStart
logClusters[ch... == glyphStartDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1834 charFrom++;
never executed: charFrom++;
0
1835 if (charFrom < ilen
charFrom < ilenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1836 glyphStart = logClusters[charFrom];-
1837 int charEnd = from + len - 1 - pos;-
1838 if (charEnd >= ilen
charEnd >= ilenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1839 charEnd = ilen-1;
never executed: charEnd = ilen-1;
0
1840 int glyphEnd = logClusters[charEnd];-
1841 while (charEnd < ilen
charEnd < ilenDescription
TRUEnever evaluated
FALSEnever evaluated
&& logClusters[charEnd] == glyphEnd
logClusters[ch...d] == glyphEndDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1842 charEnd++;
never executed: charEnd++;
0
1843 glyphEnd = (
(charEnd == ilen)Description
TRUEnever evaluated
FALSEnever evaluated
charEnd == ilen)
(charEnd == ilen)Description
TRUEnever evaluated
FALSEnever evaluated
? si->num_glyphs : logClusters[charEnd];
0
1844 if (glyphStart <= glyphEnd
glyphStart <= glyphEndDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1845 QFontEngine *fe = fontEngine(*si);-
1846 glyph_metrics_t m = fe->tightBoundingBox(glyphs.mid(glyphStart, glyphEnd - glyphStart));-
1847 gm.x = qMin(gm.x, m.x + gm.xoff);-
1848 gm.y = qMin(gm.y, m.y + gm.yoff);-
1849 gm.width = qMax(gm.width, m.width+gm.xoff);-
1850 gm.height = qMax(gm.height, m.height+gm.yoff);-
1851 gm.xoff += m.xoff;-
1852 gm.yoff += m.yoff;-
1853 }
never executed: end of block
0
1854 }
never executed: end of block
0
1855 }
never executed: end of block
0
1856 }
never executed: end of block
0
1857 return
never executed: return gm;
gm;
never executed: return gm;
0
1858}-
1859-
1860QFont QTextEngine::font(const QScriptItem &si) const-
1861{-
1862 QFont font = fnt;-
1863 if (hasFormats()
hasFormats()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1864 QTextCharFormat f = format(&si);-
1865 font = f.font();-
1866-
1867 if (block.docHandle()
block.docHandle()Description
TRUEnever evaluated
FALSEnever evaluated
&& block.docHandle()->layout()
block.docHandle()->layout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1868-
1869 QPaintDevice *pdev = block.docHandle()->layout()->paintDevice();-
1870 if (pdev
pdevDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1871 font = QFont(font, pdev);
never executed: font = QFont(font, pdev);
0
1872 }
never executed: end of block
else {
0
1873 font = font.resolve(fnt);-
1874 }
never executed: end of block
0
1875 QTextCharFormat::VerticalAlignment valign = f.verticalAlignment();-
1876 if (valign == QTextCharFormat::AlignSuperScript
valign == QTex...ignSuperScriptDescription
TRUEnever evaluated
FALSEnever evaluated
|| valign == QTextCharFormat::AlignSubScript
valign == QTex...AlignSubScriptDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1877 if (font.pointSize() != -1
font.pointSize() != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1878 font.setPointSize((font.pointSize() * 2) / 3);
never executed: font.setPointSize((font.pointSize() * 2) / 3);
0
1879 else-
1880 font.setPixelSize((font.pixelSize() * 2) / 3);
never executed: font.setPixelSize((font.pixelSize() * 2) / 3);
0
1881 }-
1882 }
never executed: end of block
0
1883-
1884 if (si.analysis.flags == QScriptAnalysis::SmallCaps
si.analysis.fl...sis::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1885 font = font.d->smallCapsFont();
never executed: font = font.d->smallCapsFont();
0
1886-
1887 return
never executed: return font;
font;
never executed: return font;
0
1888}-
1889-
1890QTextEngine::FontEngineCache::FontEngineCache()-
1891{-
1892 reset();-
1893}
never executed: end of block
0
1894-
1895-
1896-
1897QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFixed *descent, QFixed *leading) const-
1898{-
1899 QFontEngine *engine = 0;-
1900 QFontEngine *scaledEngine = 0;-
1901 int script = si.analysis.script;-
1902-
1903 QFont font = fnt;-
1904-
1905 if (useRawFont
useRawFontDescription
TRUEnever evaluated
FALSEnever evaluated
&& rawFont.isValid()
rawFont.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1906 if (feCache.prevFontEngine
feCache.prevFontEngineDescription
TRUEnever evaluated
FALSEnever evaluated
&& feCache.prevFontEngine->type() == QFontEngine::Multi
feCache.prevFo...tEngine::MultiDescription
TRUEnever evaluated
FALSEnever evaluated
&& feCache.prevScript == script
feCache.prevScript == scriptDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1907 engine = feCache.prevFontEngine;-
1908 }
never executed: end of block
else {
0
1909 engine = QFontEngineMulti::createMultiFontEngine(rawFont.d->fontEngine, script);-
1910 feCache.prevFontEngine = engine;-
1911 feCache.prevScript = script;-
1912 engine->ref.ref();-
1913 if (feCache.prevScaledFontEngine
feCache.prevScaledFontEngineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1914 releaseCachedFontEngine(feCache.prevScaledFontEngine);-
1915 feCache.prevScaledFontEngine = 0;-
1916 }
never executed: end of block
0
1917 }
never executed: end of block
0
1918 if (si.analysis.flags == QScriptAnalysis::SmallCaps
si.analysis.fl...sis::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1919 if (feCache.prevScaledFontEngine
feCache.prevScaledFontEngineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1920 scaledEngine = feCache.prevScaledFontEngine;-
1921 }
never executed: end of block
else {
0
1922 QFontEngine *scEngine = rawFont.d->fontEngine->cloneWithSize(smallCapsFraction * rawFont.pixelSize());-
1923 scEngine->ref.ref();-
1924 scaledEngine = QFontEngineMulti::createMultiFontEngine(scEngine, script);-
1925 scaledEngine->ref.ref();-
1926 feCache.prevScaledFontEngine = scaledEngine;-
1927-
1928 if (!scEngine->ref.deref()
!scEngine->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1929 delete scEngine;
never executed: delete scEngine;
0
1930-
1931 }
never executed: end of block
0
1932 }-
1933 }
never executed: end of block
else
0
1934-
1935 {-
1936 if (hasFormats()
hasFormats()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1937 if (feCache.prevFontEngine
feCache.prevFontEngineDescription
TRUEnever evaluated
FALSEnever evaluated
&& feCache.prevPosition == si.position
feCache.prevPo...== si.positionDescription
TRUEnever evaluated
FALSEnever evaluated
&& feCache.prevLength == length(&si)
feCache.prevLe...== length(&si)Description
TRUEnever evaluated
FALSEnever evaluated
&& feCache.prevScript == script
feCache.prevScript == scriptDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1938 engine = feCache.prevFontEngine;-
1939 scaledEngine = feCache.prevScaledFontEngine;-
1940 }
never executed: end of block
else {
0
1941 QTextCharFormat f = format(&si);-
1942 font = f.font();-
1943-
1944 if (block.docHandle()
block.docHandle()Description
TRUEnever evaluated
FALSEnever evaluated
&& block.docHandle()->layout()
block.docHandle()->layout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1945-
1946 QPaintDevice *pdev = block.docHandle()->layout()->paintDevice();-
1947 if (pdev
pdevDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1948 font = QFont(font, pdev);
never executed: font = QFont(font, pdev);
0
1949 }
never executed: end of block
else {
0
1950 font = font.resolve(fnt);-
1951 }
never executed: end of block
0
1952 engine = font.d->engineForScript(script);-
1953 if (engine
engineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1954 engine->ref.ref();
never executed: engine->ref.ref();
0
1955-
1956 QTextCharFormat::VerticalAlignment valign = f.verticalAlignment();-
1957 if (valign == QTextCharFormat::AlignSuperScript
valign == QTex...ignSuperScriptDescription
TRUEnever evaluated
FALSEnever evaluated
|| valign == QTextCharFormat::AlignSubScript
valign == QTex...AlignSubScriptDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1958 if (font.pointSize() != -1
font.pointSize() != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1959 font.setPointSize((font.pointSize() * 2) / 3);
never executed: font.setPointSize((font.pointSize() * 2) / 3);
0
1960 else-
1961 font.setPixelSize((font.pixelSize() * 2) / 3);
never executed: font.setPixelSize((font.pixelSize() * 2) / 3);
0
1962 scaledEngine = font.d->engineForScript(script);-
1963 if (scaledEngine
scaledEngineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1964 scaledEngine->ref.ref();
never executed: scaledEngine->ref.ref();
0
1965 }
never executed: end of block
0
1966-
1967 if (feCache.prevFontEngine
feCache.prevFontEngineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1968 releaseCachedFontEngine(feCache.prevFontEngine);
never executed: releaseCachedFontEngine(feCache.prevFontEngine);
0
1969 feCache.prevFontEngine = engine;-
1970-
1971 if (feCache.prevScaledFontEngine
feCache.prevScaledFontEngineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1972 releaseCachedFontEngine(feCache.prevScaledFontEngine);
never executed: releaseCachedFontEngine(feCache.prevScaledFontEngine);
0
1973 feCache.prevScaledFontEngine = scaledEngine;-
1974-
1975 feCache.prevScript = script;-
1976 feCache.prevPosition = si.position;-
1977 feCache.prevLength = length(&si);-
1978 }
never executed: end of block
0
1979 } else {-
1980 if (feCache.prevFontEngine
feCache.prevFontEngineDescription
TRUEnever evaluated
FALSEnever evaluated
&& feCache.prevScript == script
feCache.prevScript == scriptDescription
TRUEnever evaluated
FALSEnever evaluated
&& feCache.prevPosition == -1
feCache.prevPosition == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1981 engine = feCache.prevFontEngine;
never executed: engine = feCache.prevFontEngine;
0
1982 else {-
1983 engine = font.d->engineForScript(script);-
1984-
1985 if (engine
engineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1986 engine->ref.ref();
never executed: engine->ref.ref();
0
1987 if (feCache.prevFontEngine
feCache.prevFontEngineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1988 releaseCachedFontEngine(feCache.prevFontEngine);
never executed: releaseCachedFontEngine(feCache.prevFontEngine);
0
1989 feCache.prevFontEngine = engine;-
1990-
1991 feCache.prevScript = script;-
1992 feCache.prevPosition = -1;-
1993 feCache.prevLength = -1;-
1994 feCache.prevScaledFontEngine = 0;-
1995 }
never executed: end of block
0
1996 }-
1997-
1998 if (si.analysis.flags == QScriptAnalysis::SmallCaps
si.analysis.fl...sis::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1999 QFontPrivate *p = font.d->smallCapsFontPrivate();-
2000 scaledEngine = p->engineForScript(script);-
2001 }
never executed: end of block
0
2002 }
never executed: end of block
0
2003-
2004 if (ascent
ascentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2005 *ascent = engine->ascent();-
2006 *descent = engine->descent();-
2007 *leading = engine->leading();-
2008 }
never executed: end of block
0
2009-
2010 if (scaledEngine
scaledEngineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2011 return
never executed: return scaledEngine;
scaledEngine;
never executed: return scaledEngine;
0
2012 return
never executed: return engine;
engine;
never executed: return engine;
0
2013}-
2014-
2015struct QJustificationPoint {-
2016 int type;-
2017 QFixed kashidaWidth;-
2018 QGlyphLayout glyph;-
2019};-
2020-
2021template<> class QTypeInfo<QJustificationPoint > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_PRIMITIVE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QJustificationPoint)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QJustificationPoint >::value, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QJustificationPoint) }; static inline const char *name() { return "QJustificationPoint"; } };-
2022-
2023static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph, QFontEngine *fe)-
2024{-
2025 point->type = type;-
2026 point->glyph = glyph;-
2027-
2028 if (type >= Justification_Arabic_Normal
type >= Justif..._Arabic_NormalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2029 QChar ch(0x640);-
2030-
2031 glyph_t kashidaGlyph = fe->glyphIndex(ch.unicode());-
2032 if (kashidaGlyph != 0
kashidaGlyph != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2033 QGlyphLayout g;-
2034 g.numGlyphs = 1;-
2035 g.glyphs = &kashidaGlyph;-
2036 g.advances = &point->kashidaWidth;-
2037 fe->recalcAdvances(&g, 0);-
2038-
2039 if (point->kashidaWidth == 0
point->kashidaWidth == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2040 point->type = Justification_Prohibited;
never executed: point->type = Justification_Prohibited;
0
2041 }
never executed: end of block
else {
0
2042 point->type = Justification_Prohibited;-
2043 point->kashidaWidth = 0;-
2044 }
never executed: end of block
0
2045 }-
2046}
never executed: end of block
0
2047-
2048-
2049void QTextEngine::justify(const QScriptLine &line)-
2050{-
2051-
2052 if (line.gridfitted
line.gridfittedDescription
TRUEnever evaluated
FALSEnever evaluated
&& line.justified
line.justifiedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2053 return;
never executed: return;
0
2054-
2055 if (!line.gridfitted
!line.gridfittedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2056-
2057 const_cast<QScriptLine &>(line).gridfitted = true;-
2058 }
never executed: end of block
0
2059-
2060 if ((
(option.alignm...::AlignJustifyDescription
TRUEnever evaluated
FALSEnever evaluated
option.alignment() & Qt::AlignHorizontal_Mask) != Qt::AlignJustify
(option.alignm...::AlignJustifyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2061 return;
never executed: return;
0
2062-
2063 itemize();-
2064-
2065 if (!forceJustification
!forceJustificationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2066 int end = line.from + (int)line.length + line.trailingSpaces;-
2067 if (end == layoutData->string.length()
end == layoutD...tring.length()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2068 return;
never executed: return;
0
2069 if (end
endDescription
TRUEnever evaluated
FALSEnever evaluated
&& layoutData->items[findItem(end-1)].analysis.flags == QScriptAnalysis::LineOrParagraphSeparator
layoutData->it...graphSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2070 return;
never executed: return;
0
2071 }
never executed: end of block
0
2072-
2073-
2074 int maxJustify = 0;-
2075-
2076-
2077 int line_length = line.length;-
2078 const QCharAttributes *a = attributes();-
2079 if (! a
! aDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2080 return;
never executed: return;
0
2081 a += line.from;-
2082 while (line_length
line_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
&& a[line_length-1].whiteSpace
a[line_length-1].whiteSpaceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2083 --
never executed: --line_length;
line_length;
never executed: --line_length;
0
2084-
2085 --line_length;-
2086-
2087 if (line_length <= 0
line_length <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2088 return;
never executed: return;
0
2089-
2090 int firstItem = findItem(line.from);-
2091 int lastItem = findItem(line.from + line_length - 1, firstItem);-
2092 int nItems = (firstItem >= 0
firstItem >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& lastItem >= firstItem
lastItem >= firstItemDescription
TRUEnever evaluated
FALSEnever evaluated
)? (lastItem-firstItem+1) : 0;
0
2093-
2094 QVarLengthArray<QJustificationPoint> justificationPoints;-
2095 int nPoints = 0;-
2096-
2097 QFixed minKashida = 0x100000;-
2098-
2099-
2100-
2101-
2102 for (int i = 0; i < nItems
i < nItemsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2103 QScriptItem &si = layoutData->items[firstItem + i];-
2104 if (!si.num_glyphs
!si.num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2105 shape(firstItem + i);
never executed: shape(firstItem + i);
0
2106 }
never executed: end of block
0
2107-
2108 for (int i = 0; i < nItems
i < nItemsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2109 QScriptItem &si = layoutData->items[firstItem + i];-
2110-
2111 int kashida_type = Justification_Arabic_Normal;-
2112 int kashida_pos = -1;-
2113-
2114 int start = qMax(line.from - si.position, 0);-
2115 int end = qMin(line.from + line_length - (int)si.position, length(firstItem+i));-
2116-
2117 unsigned short *log_clusters = logClusters(&si);-
2118-
2119 int gs = log_clusters[start];-
2120 int ge = (end == length(firstItem+i)
end == length(firstItem+i)Description
TRUEnever evaluated
FALSEnever evaluated
? si.num_glyphs : log_clusters[end]);
0
2121-
2122 ((!(ge <= si.num_glyphs)) ? qt_assert("ge <= si.num_glyphs",__FILE__,2241) : qt_noop());-
2123-
2124 const QGlyphLayout g = shapedGlyphs(&si);-
2125-
2126 for (int i = gs; i < ge
i < geDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2127 g.justifications[i].type = QGlyphJustification::JustifyNone;-
2128 g.justifications[i].nKashidas = 0;-
2129 g.justifications[i].space_18d6 = 0;-
2130-
2131 justificationPoints.resize(nPoints+3);-
2132 int justification = g.attributes[i].justification;-
2133-
2134 switch(justification) {-
2135 case
never executed: case Justification_Prohibited:
Justification_Prohibited:
never executed: case Justification_Prohibited:
0
2136 break;
never executed: break;
0
2137 case
never executed: case Justification_Space:
Justification_Space:
never executed: case Justification_Space:
0
2138-
2139 case
never executed: case Justification_Arabic_Space:
Justification_Arabic_Space:
never executed: case Justification_Arabic_Space:
0
2140 if (kashida_pos >= 0
kashida_pos >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2141-
2142 set(&justificationPoints[nPoints], kashida_type, g.mid(kashida_pos), fontEngine(si));-
2143 if (justificationPoints[nPoints].kashidaWidth > 0
justificationP...shidaWidth > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2144 minKashida = qMin(minKashida, justificationPoints[nPoints].kashidaWidth);-
2145 maxJustify = qMax(maxJustify, justificationPoints[nPoints].type);-
2146 ++nPoints;-
2147 }
never executed: end of block
0
2148 }
never executed: end of block
0
2149 kashida_pos = -1;-
2150 kashida_type = Justification_Arabic_Normal;-
2151-
2152 case
never executed: case Justification_Character:
Justification_Character:
never executed: case Justification_Character:
code before this statement never executed: case Justification_Character:
0
2153 set(&justificationPoints[nPoints++], justification, g.mid(i), fontEngine(si));-
2154 maxJustify = qMax(maxJustify, justification);-
2155 break;
never executed: break;
0
2156 case
never executed: case Justification_Arabic_Normal:
Justification_Arabic_Normal:
never executed: case Justification_Arabic_Normal:
0
2157 case
never executed: case Justification_Arabic_Waw:
Justification_Arabic_Waw:
never executed: case Justification_Arabic_Waw:
0
2158 case
never executed: case Justification_Arabic_BaRa:
Justification_Arabic_BaRa:
never executed: case Justification_Arabic_BaRa:
0
2159 case
never executed: case Justification_Arabic_Alef:
Justification_Arabic_Alef:
never executed: case Justification_Arabic_Alef:
0
2160 case
never executed: case Justification_Arabic_HahDal:
Justification_Arabic_HahDal:
never executed: case Justification_Arabic_HahDal:
0
2161 case
never executed: case Justification_Arabic_Seen:
Justification_Arabic_Seen:
never executed: case Justification_Arabic_Seen:
0
2162 case
never executed: case Justification_Arabic_Kashida:
Justification_Arabic_Kashida:
never executed: case Justification_Arabic_Kashida:
0
2163 if (justification >= kashida_type
justification >= kashida_typeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2164 kashida_pos = i;-
2165 kashida_type = justification;-
2166 }
never executed: end of block
0
2167 }
never executed: end of block
0
2168 }
never executed: end of block
0
2169 if (kashida_pos >= 0
kashida_pos >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2170 set(&justificationPoints[nPoints], kashida_type, g.mid(kashida_pos), fontEngine(si));-
2171 if (justificationPoints[nPoints].kashidaWidth > 0
justificationP...shidaWidth > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2172 minKashida = qMin(minKashida, justificationPoints[nPoints].kashidaWidth);-
2173 maxJustify = qMax(maxJustify, justificationPoints[nPoints].type);-
2174 ++nPoints;-
2175 }
never executed: end of block
0
2176 }
never executed: end of block
0
2177 }
never executed: end of block
0
2178-
2179 QFixed leading = leadingSpaceWidth(line);-
2180 QFixed need = line.width - line.textWidth - leading;-
2181 if (need < 0
need < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2182-
2183 const_cast<QScriptLine &>(line).justified = true;-
2184 return;
never executed: return;
0
2185 }-
2186-
2187-
2188-
2189-
2190-
2191 if (maxJustify >= Justification_Arabic_Normal
maxJustify >= ..._Arabic_NormalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2192 while (need >= minKashida
need >= minKashidaDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2193 for (int type = maxJustify; need >= minKashida
need >= minKashidaDescription
TRUEnever evaluated
FALSEnever evaluated
&& type >= Justification_Arabic_Normal
type >= Justif..._Arabic_NormalDescription
TRUEnever evaluated
FALSEnever evaluated
; --type) {
0
2194 for (int i = 0; need >= minKashida
need >= minKashidaDescription
TRUEnever evaluated
FALSEnever evaluated
&& i < nPoints
i < nPointsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2195 if (justificationPoints[i].type == type
justificationP...].type == typeDescription
TRUEnever evaluated
FALSEnever evaluated
&& justificationPoints[i].kashidaWidth <= need
justificationP...aWidth <= needDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2196 justificationPoints[i].glyph.justifications->nKashidas++;-
2197-
2198 justificationPoints[i].glyph.justifications->space_18d6 += justificationPoints[i].kashidaWidth.value();-
2199 need -= justificationPoints[i].kashidaWidth;-
2200-
2201 }
never executed: end of block
0
2202 }
never executed: end of block
0
2203 }
never executed: end of block
0
2204 }
never executed: end of block
0
2205 }
never executed: end of block
0
2206 ((!(need >= 0)) ? qt_assert("need >= 0",__FILE__,2325) : qt_noop());-
2207 if (!need
!needDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2208 goto
never executed: goto end;
end;
never executed: goto end;
0
2209-
2210 maxJustify = qMin(maxJustify, int(Justification_Space));-
2211 for (int type = maxJustify; need != 0
need != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& type > 0
type > 0Description
TRUEnever evaluated
FALSEnever evaluated
; --type) {
0
2212 int n = 0;-
2213 for (int i = 0; i < nPoints
i < nPointsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2214 if (justificationPoints[i].type == type
justificationP...].type == typeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2215 ++
never executed: ++n;
n;
never executed: ++n;
0
2216 }
never executed: end of block
0
2217-
2218-
2219-
2220 if (!n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2221 continue;
never executed: continue;
0
2222-
2223 for (int i = 0; i < nPoints
i < nPointsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2224 if (justificationPoints[i].type == type
justificationP...].type == typeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2225 QFixed add = need/n;-
2226-
2227 justificationPoints[i].glyph.justifications[0].space_18d6 = add.value();-
2228 need -= add;-
2229 --n;-
2230 }
never executed: end of block
0
2231 }
never executed: end of block
0
2232-
2233 ((!(!need)) ? qt_assert("!need",__FILE__,2352) : qt_noop());-
2234 }
never executed: end of block
0
2235 end:
code before this statement never executed: end:
0
2236 const_cast<QScriptLine &>(line).justified = true;-
2237}
never executed: end of block
0
2238-
2239void QScriptLine::setDefaultHeight(QTextEngine *eng)-
2240{-
2241 QFont f;-
2242 QFontEngine *e;-
2243-
2244 if (eng->block.docHandle()
eng->block.docHandle()Description
TRUEnever evaluated
FALSEnever evaluated
&& eng->block.docHandle()->layout()
eng->block.doc...le()->layout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2245 f = eng->block.charFormat().font();-
2246-
2247 QPaintDevice *pdev = eng->block.docHandle()->layout()->paintDevice();-
2248 if (pdev
pdevDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2249 f = QFont(f, pdev);
never executed: f = QFont(f, pdev);
0
2250 e = f.d->engineForScript(QChar::Script_Common);-
2251 }
never executed: end of block
else {
0
2252 e = eng->fnt.d->engineForScript(QChar::Script_Common);-
2253 }
never executed: end of block
0
2254-
2255 QFixed other_ascent = e->ascent();-
2256 QFixed other_descent = e->descent();-
2257 QFixed other_leading = e->leading();-
2258 leading = qMax(leading + ascent, other_leading + other_ascent) - qMax(ascent, other_ascent);-
2259 ascent = qMax(ascent, other_ascent);-
2260 descent = qMax(descent, other_descent);-
2261}
never executed: end of block
0
2262-
2263QTextEngine::LayoutData::LayoutData()-
2264{-
2265 memory = 0;-
2266 allocated = 0;-
2267 memory_on_stack = false;-
2268 used = 0;-
2269 hasBidi = false;-
2270 layoutState = LayoutEmpty;-
2271 haveCharAttributes = false;-
2272 logClustersPtr = 0;-
2273 available_glyphs = 0;-
2274}
never executed: end of block
0
2275-
2276QTextEngine::LayoutData::LayoutData(const QString &str, void **stack_memory, int _allocated)-
2277 : string(str)-
2278{-
2279 allocated = _allocated;-
2280-
2281 int space_charAttributes = sizeof(QCharAttributes)*string.length()/sizeof(void*) + 1;-
2282 int space_logClusters = sizeof(unsigned short)*string.length()/sizeof(void*) + 1;-
2283 available_glyphs = ((int)allocated - space_charAttributes - space_logClusters)*(int)sizeof(void*)/(int)QGlyphLayout::SpaceNeeded;-
2284-
2285 if (available_glyphs < str.length()
available_glyp...< str.length()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2286-
2287 allocated = 0;-
2288-
2289 memory_on_stack = false;-
2290 memory = 0;-
2291 logClustersPtr = 0;-
2292 }
never executed: end of block
else {
0
2293 memory_on_stack = true;-
2294 memory = stack_memory;-
2295 logClustersPtr = (unsigned short *)(memory + space_charAttributes);-
2296-
2297 void *m = memory + space_charAttributes + space_logClusters;-
2298 glyphLayout = QGlyphLayout(reinterpret_cast<char *>(m), str.length());-
2299 glyphLayout.clear();-
2300 memset(memory, 0, space_charAttributes*sizeof(void *));-
2301 }
never executed: end of block
0
2302 used = 0;-
2303 hasBidi = false;-
2304 layoutState = LayoutEmpty;-
2305 haveCharAttributes = false;-
2306}
never executed: end of block
0
2307-
2308QTextEngine::LayoutData::~LayoutData()-
2309{-
2310 if (!memory_on_stack
!memory_on_stackDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2311 free(memory);
never executed: free(memory);
0
2312 memory = 0;-
2313}
never executed: end of block
0
2314-
2315bool QTextEngine::LayoutData::reallocate(int totalGlyphs)-
2316{-
2317 ((!(totalGlyphs >= glyphLayout.numGlyphs)) ? qt_assert("totalGlyphs >= glyphLayout.numGlyphs",__FILE__,2436) : qt_noop());-
2318 if (memory_on_stack
memory_on_stackDescription
TRUEnever evaluated
FALSEnever evaluated
&& available_glyphs >= totalGlyphs
available_glyp...>= totalGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2319 glyphLayout.grow(glyphLayout.data(), totalGlyphs);-
2320 return
never executed: return true;
true;
never executed: return true;
0
2321 }-
2322-
2323 int space_charAttributes = sizeof(QCharAttributes)*string.length()/sizeof(void*) + 1;-
2324 int space_logClusters = sizeof(unsigned short)*string.length()/sizeof(void*) + 1;-
2325 int space_glyphs = (totalGlyphs * QGlyphLayout::SpaceNeeded) / sizeof(void *) + 2;-
2326-
2327 int newAllocated = space_charAttributes + space_glyphs + space_logClusters;-
2328-
2329-
2330-
2331 if (space_charAttributes < 0
space_charAttributes < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| space_logClusters < 0
space_logClusters < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| space_glyphs < 0
space_glyphs < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| newAllocated < allocated
newAllocated < allocatedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2332 layoutState = LayoutFailed;-
2333 return
never executed: return false;
false;
never executed: return false;
0
2334 }-
2335-
2336 void **newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated*sizeof(void *));-
2337 if (!newMem
!newMemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2338 layoutState = LayoutFailed;-
2339 return
never executed: return false;
false;
never executed: return false;
0
2340 }-
2341 if (memory_on_stack
memory_on_stackDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2342 memcpy(newMem, memory, allocated*sizeof(void *));
never executed: memcpy(newMem, memory, allocated*sizeof(void *));
0
2343 memory = newMem;-
2344 memory_on_stack = false;-
2345-
2346 void **m = memory;-
2347 m += space_charAttributes;-
2348 logClustersPtr = (unsigned short *) m;-
2349 m += space_logClusters;-
2350-
2351 const int space_preGlyphLayout = space_charAttributes + space_logClusters;-
2352 if (allocated < space_preGlyphLayout
allocated < sp...preGlyphLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2353 memset(memory + allocated, 0, (space_preGlyphLayout - allocated)*sizeof(void *));
never executed: memset(memory + allocated, 0, (space_preGlyphLayout - allocated)*sizeof(void *));
0
2354-
2355 glyphLayout.grow(reinterpret_cast<char *>(m), totalGlyphs);-
2356-
2357 allocated = newAllocated;-
2358 return
never executed: return true;
true;
never executed: return true;
0
2359}-
2360-
2361-
2362void QGlyphLayout::grow(char *address, int totalGlyphs)-
2363{-
2364 QGlyphLayout oldLayout(address, numGlyphs);-
2365 QGlyphLayout newLayout(address, totalGlyphs);-
2366-
2367 if (numGlyphs
numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2368-
2369 memmove(newLayout.attributes, oldLayout.attributes, numGlyphs * sizeof(QGlyphAttributes));-
2370 memmove(newLayout.justifications, oldLayout.justifications, numGlyphs * sizeof(QGlyphJustification));-
2371 memmove(newLayout.advances, oldLayout.advances, numGlyphs * sizeof(QFixed));-
2372 memmove(newLayout.glyphs, oldLayout.glyphs, numGlyphs * sizeof(glyph_t));-
2373 }
never executed: end of block
0
2374-
2375-
2376 newLayout.clear(numGlyphs);-
2377-
2378 *this = newLayout;-
2379}
never executed: end of block
0
2380-
2381void QTextEngine::freeMemory()-
2382{-
2383 if (!stackEngine
!stackEngineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2384 delete layoutData;-
2385 layoutData = 0;-
2386 }
never executed: end of block
else {
0
2387 layoutData->used = 0;-
2388 layoutData->hasBidi = false;-
2389 layoutData->layoutState = LayoutEmpty;-
2390 layoutData->haveCharAttributes = false;-
2391 layoutData->items.clear();-
2392 }
never executed: end of block
0
2393 if (specialData
specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2394 specialData->resolvedFormats.clear();
never executed: specialData->resolvedFormats.clear();
0
2395 for (int i = 0; i < lines.size()
i < lines.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2396 lines[i].justified = 0;-
2397 lines[i].gridfitted = 0;-
2398 }
never executed: end of block
0
2399}
never executed: end of block
0
2400-
2401int QTextEngine::formatIndex(const QScriptItem *si) const-
2402{-
2403 if (specialData
specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
&& !specialData->resolvedFormats.isEmpty()
!specialData->...mats.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2404 QTextFormatCollection *collection = formatCollection();-
2405 ((!(collection)) ? qt_assert("collection",__FILE__,2524) : qt_noop());-
2406 return
never executed: return collection->indexForFormat(specialData->resolvedFormats.at(si - &layoutData->items[0]));
collection->indexForFormat(specialData->resolvedFormats.at(si - &layoutData->items[0]));
never executed: return collection->indexForFormat(specialData->resolvedFormats.at(si - &layoutData->items[0]));
0
2407 }-
2408-
2409 QTextDocumentPrivate *p = block.docHandle();-
2410 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2411 return
never executed: return -1;
-1;
never executed: return -1;
0
2412 int pos = si->position;-
2413 if (specialData
specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
&& si->position >= specialData->preeditPosition
si->position >...reeditPositionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2414 if (si->position < specialData->preeditPosition + specialData->preeditText.length()
si->position <...tText.length()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2415 pos = qMax(qMin(block.length(), specialData->preeditPosition) - 1, 0);
never executed: pos = qMax(qMin(block.length(), specialData->preeditPosition) - 1, 0);
0
2416 else-
2417 pos -= specialData->preeditText.length();
never executed: pos -= specialData->preeditText.length();
0
2418 }-
2419 QTextDocumentPrivate::FragmentIterator it = p->find(block.position() + pos);-
2420 return
never executed: return it.value()->format;
it.value()->format;
never executed: return it.value()->format;
0
2421}-
2422-
2423-
2424QTextCharFormat QTextEngine::format(const QScriptItem *si) const-
2425{-
2426 if (const
const QTextFor...atCollection()Description
TRUEnever evaluated
FALSEnever evaluated
QTextFormatCollection *collection = formatCollection()
const QTextFor...atCollection()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2427 return
never executed: return collection->charFormat(formatIndex(si));
collection->charFormat(formatIndex(si));
never executed: return collection->charFormat(formatIndex(si));
0
2428 return
never executed: return QTextCharFormat();
QTextCharFormat();
never executed: return QTextCharFormat();
0
2429}-
2430-
2431void QTextEngine::addRequiredBoundaries() const-
2432{-
2433 if (specialData
specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2434 for (int i = 0; i < specialData->formats.size()
i < specialDat...formats.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2435 const QTextLayout::FormatRange &r = specialData->formats.at(i);-
2436 setBoundary(r.start);-
2437 setBoundary(r.start + r.length);-
2438-
2439 }
never executed: end of block
0
2440 }
never executed: end of block
0
2441}
never executed: end of block
0
2442-
2443bool QTextEngine::atWordSeparator(int position) const-
2444{-
2445 const QChar c = layoutData->string.at(position);-
2446 switch (c.unicode()) {-
2447 case
never executed: case '.':
'.':
never executed: case '.':
0
2448 case
never executed: case ',':
',':
never executed: case ',':
0
2449 case
never executed: case '?':
'?':
never executed: case '?':
0
2450 case
never executed: case '!':
'!':
never executed: case '!':
0
2451 case
never executed: case '@':
'@':
never executed: case '@':
0
2452 case
never executed: case '#':
'#':
never executed: case '#':
0
2453 case
never executed: case '$':
'$':
never executed: case '$':
0
2454 case
never executed: case ':':
':':
never executed: case ':':
0
2455 case
never executed: case ';':
';':
never executed: case ';':
0
2456 case
never executed: case '-':
'-':
never executed: case '-':
0
2457 case
never executed: case '<':
'<':
never executed: case '<':
0
2458 case
never executed: case '>':
'>':
never executed: case '>':
0
2459 case
never executed: case '[':
'[':
never executed: case '[':
0
2460 case
never executed: case ']':
']':
never executed: case ']':
0
2461 case
never executed: case '(':
'(':
never executed: case '(':
0
2462 case
never executed: case ')':
')':
never executed: case ')':
0
2463 case
never executed: case '{':
'{':
never executed: case '{':
0
2464 case
never executed: case '}':
'}':
never executed: case '}':
0
2465 case
never executed: case '=':
'=':
never executed: case '=':
0
2466 case
never executed: case '/':
'/':
never executed: case '/':
0
2467 case
never executed: case '+':
'+':
never executed: case '+':
0
2468 case
never executed: case '%':
'%':
never executed: case '%':
0
2469 case
never executed: case '&':
'&':
never executed: case '&':
0
2470 case
never executed: case '^':
'^':
never executed: case '^':
0
2471 case
never executed: case '*':
'*':
never executed: case '*':
0
2472 case
never executed: case '\'':
'\'':
never executed: case '\'':
0
2473 case
never executed: case '"':
'"':
never executed: case '"':
0
2474 case
never executed: case '`':
'`':
never executed: case '`':
0
2475 case
never executed: case '~':
'~':
never executed: case '~':
0
2476 case
never executed: case '|':
'|':
never executed: case '|':
0
2477 case
never executed: case '\\':
'\\':
never executed: case '\\':
0
2478 return
never executed: return true;
true;
never executed: return true;
0
2479 default
never executed: default:
:
never executed: default:
0
2480 break;
never executed: break;
0
2481 }-
2482 return
never executed: return false;
false;
never executed: return false;
0
2483}-
2484-
2485void QTextEngine::setPreeditArea(int position, const QString &preeditText)-
2486{-
2487 if (preeditText.isEmpty()
preeditText.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2488 if (!specialData
!specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2489 return;
never executed: return;
0
2490 if (specialData->formats.isEmpty()
specialData->formats.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2491 delete specialData;-
2492 specialData = 0;-
2493 }
never executed: end of block
else {
0
2494 specialData->preeditText = QString();-
2495 specialData->preeditPosition = -1;-
2496 }
never executed: end of block
0
2497 } else {-
2498 if (!specialData
!specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2499 specialData = new SpecialData;
never executed: specialData = new SpecialData;
0
2500 specialData->preeditPosition = position;-
2501 specialData->preeditText = preeditText;-
2502 }
never executed: end of block
0
2503 invalidate();-
2504 clearLineData();-
2505}
never executed: end of block
0
2506-
2507void QTextEngine::setFormats(const QVector<QTextLayout::FormatRange> &formats)-
2508{-
2509 if (formats.isEmpty()
formats.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2510 if (!specialData
!specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2511 return;
never executed: return;
0
2512 if (specialData->preeditText.isEmpty()
specialData->p...Text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2513 delete specialData;-
2514 specialData = 0;-
2515 }
never executed: end of block
else {
0
2516 specialData->formats.clear();-
2517 }
never executed: end of block
0
2518 } else {-
2519 if (!specialData
!specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2520 specialData = new SpecialData;-
2521 specialData->preeditPosition = -1;-
2522 }
never executed: end of block
0
2523 specialData->formats = formats;-
2524 indexFormats();-
2525 }
never executed: end of block
0
2526 invalidate();-
2527 clearLineData();-
2528}
never executed: end of block
0
2529-
2530void QTextEngine::indexFormats()-
2531{-
2532 QTextFormatCollection *collection = formatCollection();-
2533 if (!collection
!collectionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2534 ((!(!block.docHandle())) ? qt_assert("!block.docHandle()",__FILE__,2653) : qt_noop());-
2535 specialData->formatCollection.reset(new QTextFormatCollection);-
2536 collection = specialData->formatCollection.data();-
2537 }
never executed: end of block
0
2538-
2539-
2540 for (int i = 0; i < specialData->formats.size()
i < specialDat...formats.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2541 QTextCharFormat &format = specialData->formats[i].format;-
2542 format = collection->charFormat(collection->indexForFormat(format));-
2543 }
never executed: end of block
0
2544}
never executed: end of block
0
2545-
2546-
2547-
2548-
2549-
2550static inline bool nextCharJoins(const QString &string, int pos)-
2551{-
2552 while (pos < string.length()
pos < string.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& string.at(pos).category() == QChar::Mark_NonSpacing
string.at(pos)...ark_NonSpacingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2553 ++
never executed: ++pos;
pos;
never executed: ++pos;
0
2554 if (pos == string.length()
pos == string.length()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2555 return
never executed: return false;
false;
never executed: return false;
0
2556 QChar::JoiningType joining = string.at(pos).joiningType();-
2557 return
never executed: return joining != QChar::Joining_None && joining != QChar::Joining_Transparent;
joining != QChar::Joining_None && joining != QChar::Joining_Transparent;
never executed: return joining != QChar::Joining_None && joining != QChar::Joining_Transparent;
0
2558}-
2559-
2560static inline bool prevCharJoins(const QString &string, int pos)-
2561{-
2562 while (pos > 0
pos > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& string.at(pos - 1).category() == QChar::Mark_NonSpacing
string.at(pos ...ark_NonSpacingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2563 --
never executed: --pos;
pos;
never executed: --pos;
0
2564 if (pos == 0
pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2565 return
never executed: return false;
false;
never executed: return false;
0
2566 QChar::JoiningType joining = string.at(pos - 1).joiningType();-
2567 return
never executed: return joining == QChar::Joining_Dual || joining == QChar::Joining_Causing;
joining == QChar::Joining_Dual || joining == QChar::Joining_Causing;
never executed: return joining == QChar::Joining_Dual || joining == QChar::Joining_Causing;
0
2568}-
2569-
2570static inline bool isRetainableControlCode(QChar c)-
2571{-
2572 return
never executed: return (c.unicode() >= 0x202a && c.unicode() <= 0x202e) || (c.unicode() >= 0x200e && c.unicode() <= 0x200f) || (c.unicode() >= 0x2066 && c.unicode() <= 0x2069);
(c.unicode() >= 0x202a && c.unicode() <= 0x202e)
never executed: return (c.unicode() >= 0x202a && c.unicode() <= 0x202e) || (c.unicode() >= 0x200e && c.unicode() <= 0x200f) || (c.unicode() >= 0x2066 && c.unicode() <= 0x2069);
0
2573 || (c.unicode() >= 0x200e && c.unicode() <= 0x200f)
never executed: return (c.unicode() >= 0x202a && c.unicode() <= 0x202e) || (c.unicode() >= 0x200e && c.unicode() <= 0x200f) || (c.unicode() >= 0x2066 && c.unicode() <= 0x2069);
0
2574 || (c.unicode() >= 0x2066 && c.unicode() <= 0x2069);
never executed: return (c.unicode() >= 0x202a && c.unicode() <= 0x202e) || (c.unicode() >= 0x200e && c.unicode() <= 0x200f) || (c.unicode() >= 0x2066 && c.unicode() <= 0x2069);
0
2575}-
2576-
2577static QString stringMidRetainingBidiCC(const QString &string,-
2578 const QString &ellidePrefix,-
2579 const QString &ellideSuffix,-
2580 int subStringFrom,-
2581 int subStringTo,-
2582 int midStart,-
2583 int midLength)-
2584{-
2585 QString prefix;-
2586 for (int i=subStringFrom; i<midStart
i<midStartDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2587 QChar c = string.at(i);-
2588 if (isRetainableControlCode(c)
isRetainableControlCode(c)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2589 prefix += c;
never executed: prefix += c;
0
2590 }
never executed: end of block
0
2591-
2592 QString suffix;-
2593 for (int i=midStart + midLength; i<subStringTo
i<subStringToDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2594 QChar c = string.at(i);-
2595 if (isRetainableControlCode(c)
isRetainableControlCode(c)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2596 suffix += c;
never executed: suffix += c;
0
2597 }
never executed: end of block
0
2598-
2599 return
never executed: return prefix + ellidePrefix + string.mid(midStart, midLength) + ellideSuffix + suffix;
prefix + ellidePrefix + string.mid(midStart, midLength) + ellideSuffix + suffix;
never executed: return prefix + ellidePrefix + string.mid(midStart, midLength) + ellideSuffix + suffix;
0
2600}-
2601-
2602QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags, int from, int count) const-
2603{-
2604-
2605-
2606 if (flags & Qt::TextShowMnemonic
flags & Qt::TextShowMnemonicDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2607 itemize();-
2608 QCharAttributes *attributes = const_cast<QCharAttributes *>(this->attributes());-
2609 if (!attributes
!attributesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2610 return
never executed: return QString();
QString();
never executed: return QString();
0
2611 for (int i = 0; i < layoutData->items.size()
i < layoutData->items.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2612 QScriptItem &si = layoutData->items[i];-
2613 if (!si.num_glyphs
!si.num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2614 shape(i);
never executed: shape(i);
0
2615-
2616 unsigned short *logClusters = this->logClusters(&si);-
2617 QGlyphLayout glyphs = shapedGlyphs(&si);-
2618-
2619 const int end = si.position + length(&si);-
2620 for (int i = si.position; i < end - 1
i < end - 1Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2621 if (layoutData->string.at(i) == QLatin1Char('&')
layoutData->st...atin1Char('&')Description
TRUEnever evaluated
FALSEnever evaluated
0
2622 && !attributes[i + 1].whiteSpace
!attributes[i + 1].whiteSpaceDescription
TRUEnever evaluated
FALSEnever evaluated
&& attributes[i + 1].graphemeBoundary
attributes[i +...aphemeBoundaryDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2623 const int gp = logClusters[i - si.position];-
2624 glyphs.attributes[gp].dontPrint = true;-
2625-
2626 attributes[i] = attributes[i + 1];-
2627 memset(attributes + i + 1, 0, sizeof(QCharAttributes));-
2628 if (layoutData->string.at(i + 1) == QLatin1Char('&')
layoutData->st...atin1Char('&')Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2629 ++
never executed: ++i;
i;
never executed: ++i;
0
2630 }
never executed: end of block
0
2631 }
never executed: end of block
0
2632 }
never executed: end of block
0
2633 }
never executed: end of block
0
2634-
2635 validate();-
2636-
2637 const int to = count >= 0
count >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& count <= layoutData->string.length() - from
count <= layou...ength() - fromDescription
TRUEnever evaluated
FALSEnever evaluated
0
2638 ? from + count-
2639 : layoutData->string.length();-
2640-
2641 if (mode == Qt::ElideNone
mode == Qt::ElideNoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2642 || this->width(from, layoutData->string.length()) <= width
this->width(fr...th()) <= widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2643 || to - from <= 1
to - from <= 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2644 return
never executed: return layoutData->string.mid(from, from - to);
layoutData->string.mid(from, from - to);
never executed: return layoutData->string.mid(from, from - to);
0
2645-
2646 QFixed ellipsisWidth;-
2647 QString ellipsisText;-
2648 {-
2649 QFontEngine *engine = fnt.d->engineForScript(QChar::Script_Common);-
2650-
2651 QChar ellipsisChar(0x2026);-
2652-
2653 glyph_t glyph = engine->glyphIndex(ellipsisChar.unicode());-
2654-
2655 QGlyphLayout glyphs;-
2656 glyphs.numGlyphs = 1;-
2657 glyphs.glyphs = &glyph;-
2658 glyphs.advances = &ellipsisWidth;-
2659-
2660 if (glyph != 0
glyph != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2661 engine->recalcAdvances(&glyphs, 0);-
2662-
2663 ellipsisText = ellipsisChar;-
2664 }
never executed: end of block
else {
0
2665 glyph = engine->glyphIndex('.');-
2666 if (glyph != 0
glyph != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2667 engine->recalcAdvances(&glyphs, 0);-
2668-
2669 ellipsisWidth *= 3;-
2670 ellipsisText = ([]() -> QString { enum { Size = sizeof(u"" "...")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "..." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}());
0
2671 }
never executed: end of block
0
2672 }
never executed: end of block
0
2673 }-
2674-
2675 const QFixed availableWidth = width - ellipsisWidth;-
2676 if (availableWidth < 0
availableWidth < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2677 return
never executed: return QString();
QString();
never executed: return QString();
0
2678-
2679 const QCharAttributes *attributes = this->attributes();-
2680 if (!attributes
!attributesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2681 return
never executed: return QString();
QString();
never executed: return QString();
0
2682-
2683 if (mode == Qt::ElideRight
mode == Qt::ElideRightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2684 QFixed currentWidth;-
2685 int pos;-
2686 int nextBreak = from;-
2687-
2688 do {-
2689 pos = nextBreak;-
2690-
2691 ++nextBreak;-
2692 while (nextBreak < layoutData->string.length()
nextBreak < la...tring.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& !attributes[nextBreak].graphemeBoundary
!attributes[ne...aphemeBoundaryDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2693 ++
never executed: ++nextBreak;
nextBreak;
never executed: ++nextBreak;
0
2694-
2695 currentWidth += this->width(pos, nextBreak - pos);-
2696 }
never executed: end of block
while (nextBreak < to
nextBreak < toDescription
TRUEnever evaluated
FALSEnever evaluated
0
2697 && currentWidth < availableWidth
currentWidth < availableWidthDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
2698-
2699 if (nextCharJoins(layoutData->string, pos)
nextCharJoins(...->string, pos)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2700 ellipsisText.prepend(QChar(0x200d) );
never executed: ellipsisText.prepend(QChar(0x200d) );
0
2701-
2702 return
never executed: return stringMidRetainingBidiCC(layoutData->string, QString(), ellipsisText, from, to, from, pos - from);
stringMidRetainingBidiCC(layoutData->string,
never executed: return stringMidRetainingBidiCC(layoutData->string, QString(), ellipsisText, from, to, from, pos - from);
0
2703 QString(), ellipsisText,
never executed: return stringMidRetainingBidiCC(layoutData->string, QString(), ellipsisText, from, to, from, pos - from);
0
2704 from, to,
never executed: return stringMidRetainingBidiCC(layoutData->string, QString(), ellipsisText, from, to, from, pos - from);
0
2705 from, pos - from);
never executed: return stringMidRetainingBidiCC(layoutData->string, QString(), ellipsisText, from, to, from, pos - from);
0
2706 } else if (mode == Qt::ElideLeft
mode == Qt::ElideLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2707 QFixed currentWidth;-
2708 int pos;-
2709 int nextBreak = to;-
2710-
2711 do {-
2712 pos = nextBreak;-
2713-
2714 --nextBreak;-
2715 while (nextBreak > 0
nextBreak > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& !attributes[nextBreak].graphemeBoundary
!attributes[ne...aphemeBoundaryDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2716 --
never executed: --nextBreak;
nextBreak;
never executed: --nextBreak;
0
2717-
2718 currentWidth += this->width(nextBreak, pos - nextBreak);-
2719 }
never executed: end of block
while (nextBreak > from
nextBreak > fromDescription
TRUEnever evaluated
FALSEnever evaluated
0
2720 && currentWidth < availableWidth
currentWidth < availableWidthDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
2721-
2722 if (prevCharJoins(layoutData->string, pos)
prevCharJoins(...->string, pos)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2723 ellipsisText.append(QChar(0x200d) );
never executed: ellipsisText.append(QChar(0x200d) );
0
2724-
2725 return
never executed: return stringMidRetainingBidiCC(layoutData->string, ellipsisText, QString(), from, to, pos, to - pos);
stringMidRetainingBidiCC(layoutData->string,
never executed: return stringMidRetainingBidiCC(layoutData->string, ellipsisText, QString(), from, to, pos, to - pos);
0
2726 ellipsisText, QString(),
never executed: return stringMidRetainingBidiCC(layoutData->string, ellipsisText, QString(), from, to, pos, to - pos);
0
2727 from, to,
never executed: return stringMidRetainingBidiCC(layoutData->string, ellipsisText, QString(), from, to, pos, to - pos);
0
2728 pos, to - pos);
never executed: return stringMidRetainingBidiCC(layoutData->string, ellipsisText, QString(), from, to, pos, to - pos);
0
2729 } else if (mode == Qt::ElideMiddle
mode == Qt::ElideMiddleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2730 QFixed leftWidth;-
2731 QFixed rightWidth;-
2732-
2733 int leftPos = from;-
2734 int nextLeftBreak = from;-
2735-
2736 int rightPos = to;-
2737 int nextRightBreak = to;-
2738-
2739 do {-
2740 leftPos = nextLeftBreak;-
2741 rightPos = nextRightBreak;-
2742-
2743 ++nextLeftBreak;-
2744 while (nextLeftBreak < layoutData->string.length()
nextLeftBreak ...tring.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& !attributes[nextLeftBreak].graphemeBoundary
!attributes[ne...aphemeBoundaryDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2745 ++
never executed: ++nextLeftBreak;
nextLeftBreak;
never executed: ++nextLeftBreak;
0
2746-
2747 --nextRightBreak;-
2748 while (nextRightBreak > from
nextRightBreak > fromDescription
TRUEnever evaluated
FALSEnever evaluated
&& !attributes[nextRightBreak].graphemeBoundary
!attributes[ne...aphemeBoundaryDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2749 --
never executed: --nextRightBreak;
nextRightBreak;
never executed: --nextRightBreak;
0
2750-
2751 leftWidth += this->width(leftPos, nextLeftBreak - leftPos);-
2752 rightWidth += this->width(nextRightBreak, rightPos - nextRightBreak);-
2753 }
never executed: end of block
while (nextLeftBreak < to
nextLeftBreak < toDescription
TRUEnever evaluated
FALSEnever evaluated
0
2754 && nextRightBreak > from
nextRightBreak > fromDescription
TRUEnever evaluated
FALSEnever evaluated
0
2755 && leftWidth + rightWidth < availableWidth
leftWidth + ri...availableWidthDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
2756-
2757 if (nextCharJoins(layoutData->string, leftPos)
nextCharJoins(...ring, leftPos)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2758 ellipsisText.prepend(QChar(0x200d) );
never executed: ellipsisText.prepend(QChar(0x200d) );
0
2759 if (prevCharJoins(layoutData->string, rightPos)
prevCharJoins(...ing, rightPos)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2760 ellipsisText.append(QChar(0x200d) );
never executed: ellipsisText.append(QChar(0x200d) );
0
2761-
2762 return
never executed: return layoutData->string.mid(from, leftPos - from) + ellipsisText + layoutData->string.mid(rightPos, to - rightPos);
layoutData->string.mid(from, leftPos - from) + ellipsisText + layoutData->string.mid(rightPos, to - rightPos);
never executed: return layoutData->string.mid(from, leftPos - from) + ellipsisText + layoutData->string.mid(rightPos, to - rightPos);
0
2763 }-
2764-
2765 return
never executed: return layoutData->string.mid(from, to - from);
layoutData->string.mid(from, to - from);
never executed: return layoutData->string.mid(from, to - from);
0
2766}-
2767-
2768void QTextEngine::setBoundary(int strPos) const-
2769{-
2770 const int item = findItem(strPos);-
2771 if (item < 0
item < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2772 return;
never executed: return;
0
2773-
2774 QScriptItem newItem = layoutData->items.at(item);-
2775 if (newItem.position != strPos
newItem.position != strPosDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2776 newItem.position = strPos;-
2777 layoutData->items.insert(item + 1, newItem);-
2778 }
never executed: end of block
0
2779}
never executed: end of block
0
2780-
2781QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const-
2782{-
2783 const QScriptItem &si = layoutData->items[item];-
2784-
2785 QFixed dpiScale = 1;-
2786 if (block.docHandle()
block.docHandle()Description
TRUEnever evaluated
FALSEnever evaluated
&& block.docHandle()->layout()
block.docHandle()->layout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2787 QPaintDevice *pdev = block.docHandle()->layout()->paintDevice();-
2788 if (pdev
pdevDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2789 dpiScale = QFixed::fromReal(pdev->logicalDpiY() / qreal(qt_defaultDpiY()));
never executed: dpiScale = QFixed::fromReal(pdev->logicalDpiY() / qreal(qt_defaultDpiY()));
0
2790 }
never executed: end of block
else {
0
2791 dpiScale = QFixed::fromReal(fnt.d->dpi / qreal(qt_defaultDpiY()));-
2792 }
never executed: end of block
0
2793-
2794 QList<QTextOption::Tab> tabArray = option.tabs();-
2795 if (!tabArray.isEmpty()
!tabArray.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2796 if (isRightToLeft()
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2797 QList<QTextOption::Tab> newTabs;-
2798 newTabs.reserve(tabArray.count());-
2799 QList<QTextOption::Tab>::Iterator iter = tabArray.begin();-
2800 while(iter != tabArray.end()
iter != tabArray.end()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2801 QTextOption::Tab tab = *iter;-
2802 if (tab.type == QTextOption::LeftTab
tab.type == QT...ption::LeftTabDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2803 tab.type = QTextOption::RightTab;
never executed: tab.type = QTextOption::RightTab;
0
2804 else if (tab.type == QTextOption::RightTab
tab.type == QT...tion::RightTabDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2805 tab.type = QTextOption::LeftTab;
never executed: tab.type = QTextOption::LeftTab;
0
2806 newTabs << tab;-
2807 ++iter;-
2808 }
never executed: end of block
0
2809 tabArray = newTabs;-
2810 }
never executed: end of block
0
2811 for (int i = 0; i < tabArray.size()
i < tabArray.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2812 QFixed tab = QFixed::fromReal(tabArray[i].position) * dpiScale;-
2813 if (tab > x
tab > xDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2814 QTextOption::Tab tabSpec = tabArray[i];-
2815 int tabSectionEnd = layoutData->string.count();-
2816 if (tabSpec.type == QTextOption::RightTab
tabSpec.type =...tion::RightTabDescription
TRUEnever evaluated
FALSEnever evaluated
|| tabSpec.type == QTextOption::CenterTab
tabSpec.type =...ion::CenterTabDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2817-
2818 tab = QFixed::fromReal(tabSpec.position);-
2819 for (int i=item + 1; i < layoutData->items.count()
i < layoutData->items.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
2820 const QScriptItem &item = layoutData->items[i];-
2821 if (item.analysis.flags == QScriptAnalysis::TabOrObject
item.analysis....s::TabOrObjectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2822 tabSectionEnd = item.position;-
2823 break;
never executed: break;
0
2824 }-
2825 }
never executed: end of block
0
2826 }
never executed: end of block
0
2827 else if (tabSpec.type == QTextOption::DelimiterTab
tabSpec.type =...::DelimiterTabDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2828-
2829 tabSectionEnd = qMax(si.position, layoutData->string.indexOf(tabSpec.delimiter, si.position) + 1);
never executed: tabSectionEnd = qMax(si.position, layoutData->string.indexOf(tabSpec.delimiter, si.position) + 1);
0
2830-
2831 if (tabSectionEnd > si.position
tabSectionEnd > si.positionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2832 QFixed length;-
2833-
2834 for (int i=item; i < layoutData->items.count()
i < layoutData->items.count()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
2835 QScriptItem &item = layoutData->items[i];-
2836 if (item.position > tabSectionEnd
item.position > tabSectionEndDescription
TRUEnever evaluated
FALSEnever evaluated
|| item.position <= si.position
item.position <= si.positionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2837 continue;
never executed: continue;
0
2838 shape(i);-
2839 if (item.analysis.flags == QScriptAnalysis::Object
item.analysis....alysis::ObjectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2840 length += item.width;-
2841 continue;
never executed: continue;
0
2842 }-
2843 QGlyphLayout glyphs = this->shapedGlyphs(&item);-
2844 const int end = qMin(item.position + item.num_glyphs, tabSectionEnd) - item.position;-
2845 for (int i=0; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
2846 length += glyphs.advances[i] * !glyphs.attributes[i].dontPrint;
never executed: length += glyphs.advances[i] * !glyphs.attributes[i].dontPrint;
0
2847 if (end + item.position == tabSectionEnd
end + item.pos... tabSectionEndDescription
TRUEnever evaluated
FALSEnever evaluated
&& tabSpec.type == QTextOption::DelimiterTab
tabSpec.type =...::DelimiterTabDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2848 length -= glyphs.advances[end] / 2 * !glyphs.attributes[end].dontPrint;
never executed: length -= glyphs.advances[end] / 2 * !glyphs.attributes[end].dontPrint;
0
2849 }
never executed: end of block
0
2850-
2851 switch (tabSpec.type) {-
2852 case
never executed: case QTextOption::CenterTab:
QTextOption::CenterTab:
never executed: case QTextOption::CenterTab:
0
2853 length /= 2;-
2854-
2855 case
never executed: case QTextOption::DelimiterTab:
QTextOption::DelimiterTab:
never executed: case QTextOption::DelimiterTab:
code before this statement never executed: case QTextOption::DelimiterTab:
0
2856-
2857 case
never executed: case QTextOption::RightTab:
QTextOption::RightTab:
never executed: case QTextOption::RightTab:
0
2858 tab = QFixed::fromReal(tabSpec.position) * dpiScale - length;-
2859 if (tab < x
tab < xDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2860 return
never executed: return QFixed();
QFixed();
never executed: return QFixed();
0
2861 break;
never executed: break;
0
2862 case
never executed: case QTextOption::LeftTab:
QTextOption::LeftTab:
never executed: case QTextOption::LeftTab:
0
2863 break;
never executed: break;
0
2864 }-
2865 }
never executed: end of block
0
2866 return
never executed: return tab - x;
tab - x;
never executed: return tab - x;
0
2867 }-
2868 }
never executed: end of block
0
2869 }
never executed: end of block
0
2870 QFixed tab = QFixed::fromReal(option.tabStop());-
2871 if (tab <= 0
tab <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2872 tab = 80;
never executed: tab = 80;
0
2873 tab *= dpiScale;-
2874 QFixed nextTabPos = ((x / tab).truncate() + 1) * tab;-
2875 QFixed tabWidth = nextTabPos - x;-
2876-
2877 return
never executed: return tabWidth;
tabWidth;
never executed: return tabWidth;
0
2878}-
2879-
2880namespace {-
2881class FormatRangeComparatorByStart {-
2882 const QVector<QTextLayout::FormatRange> &list;-
2883public:-
2884 FormatRangeComparatorByStart(const QVector<QTextLayout::FormatRange> &list) : list(list) { }
never executed: end of block
0
2885 bool operator()(int a, int b) {-
2886 return
never executed: return list.at(a).start < list.at(b).start;
list.at(a).start < list.at(b).start;
never executed: return list.at(a).start < list.at(b).start;
0
2887 }-
2888};-
2889class FormatRangeComparatorByEnd {-
2890 const QVector<QTextLayout::FormatRange> &list;-
2891public:-
2892 FormatRangeComparatorByEnd(const QVector<QTextLayout::FormatRange> &list) : list(list) { }
never executed: end of block
0
2893 bool operator()(int a, int b) {-
2894 return
never executed: return list.at(a).start + list.at(a).length < list.at(b).start + list.at(b).length;
list.at(a).start + list.at(a).length < list.at(b).start + list.at(b).length;
never executed: return list.at(a).start + list.at(a).length < list.at(b).start + list.at(b).length;
0
2895 }-
2896};-
2897}-
2898-
2899void QTextEngine::resolveFormats() const-
2900{-
2901 if (!specialData
!specialDataDescription
TRUEnever evaluated
FALSEnever evaluated
|| specialData->formats.isEmpty()
specialData->formats.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2902 return;
never executed: return;
0
2903 ((!(specialData->resolvedFormats.isEmpty())) ? qt_assert("specialData->resolvedFormats.isEmpty()",__FILE__,3022) : qt_noop());-
2904-
2905 QTextFormatCollection *collection = formatCollection();-
2906-
2907 QVector<QTextCharFormat> resolvedFormats(layoutData->items.count());-
2908-
2909 QVarLengthArray<int, 64> formatsSortedByStart;-
2910 formatsSortedByStart.reserve(specialData->formats.size());-
2911 for (int i = 0; i < specialData->formats.size()
i < specialDat...formats.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2912 if (specialData->formats.at(i).length >= 0
specialData->f...i).length >= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2913 formatsSortedByStart.append(i);
never executed: formatsSortedByStart.append(i);
0
2914 }
never executed: end of block
0
2915 QVarLengthArray<int, 64> formatsSortedByEnd = formatsSortedByStart;-
2916 std::sort(formatsSortedByStart.begin(), formatsSortedByStart.end(),-
2917 FormatRangeComparatorByStart(specialData->formats));-
2918 std::sort(formatsSortedByEnd.begin(), formatsSortedByEnd.end(),-
2919 FormatRangeComparatorByEnd(specialData->formats));-
2920-
2921 QVarLengthArray<int, 16> currentFormats;-
2922 const int *startIt = formatsSortedByStart.constBegin();-
2923 const int *endIt = formatsSortedByEnd.constBegin();-
2924-
2925 for (int i = 0; i < layoutData->items.count()
i < layoutData->items.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
2926 const QScriptItem *si = &layoutData->items.at(i);-
2927 int end = si->position + length(si);-
2928-
2929 while (startIt != formatsSortedByStart.constEnd()
startIt != for...art.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
2930 specialData->formats.at(*startIt).start <= si->position
specialData->f...= si->positionDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2931 currentFormats.insert(std::upper_bound(currentFormats.begin(), currentFormats.end(), *startIt),-
2932 *startIt);-
2933 ++startIt;-
2934 }
never executed: end of block
0
2935 while (endIt != formatsSortedByEnd.constEnd()
endIt != forma...End.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
2936 specialData->formats.at(*endIt).start + specialData->formats.at(*endIt).length < end
specialData->f...).length < endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2937 int *currentFormatIterator = std::lower_bound(currentFormats.begin(), currentFormats.end(), *endIt);-
2938 if (*
*endIt < *curr...FormatIteratorDescription
TRUEnever evaluated
FALSEnever evaluated
endIt < *currentFormatIterator
*endIt < *curr...FormatIteratorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2939 currentFormatIterator = currentFormats.end();
never executed: currentFormatIterator = currentFormats.end();
0
2940 currentFormats.remove(currentFormatIterator - currentFormats.begin());-
2941 ++endIt;-
2942 }
never executed: end of block
0
2943-
2944 QTextCharFormat &format = resolvedFormats[i];-
2945 if (block.docHandle()
block.docHandle()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2946-
2947-
2948 format = collection->charFormat(formatIndex(si));-
2949 }
never executed: end of block
0
2950 if (!currentFormats.isEmpty()
!currentFormats.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2951 for (int cur : currentFormats) {-
2952 const QTextLayout::FormatRange &range = specialData->formats.at(cur);-
2953 ((!(range.start <= si->position && range.start + range.length >= end)) ? qt_assert("range.start <= si->position && range.start + range.length >= end",__FILE__,3072) : qt_noop());-
2954 format.merge(range.format);-
2955 }
never executed: end of block
0
2956 format = collection->charFormat(collection->indexForFormat(format));-
2957 }
never executed: end of block
0
2958 }
never executed: end of block
0
2959-
2960 specialData->resolvedFormats = resolvedFormats;-
2961}
never executed: end of block
0
2962-
2963QFixed QTextEngine::leadingSpaceWidth(const QScriptLine &line)-
2964{-
2965 if (!line.hasTrailingSpaces
!line.hasTrailingSpacesDescription
TRUEnever evaluated
FALSEnever evaluated
0
2966 || (
(option.flags(...railingSpaces)Description
TRUEnever evaluated
FALSEnever evaluated
option.flags() & QTextOption::IncludeTrailingSpaces)
(option.flags(...railingSpaces)Description
TRUEnever evaluated
FALSEnever evaluated
0
2967 || !isRightToLeft()
!isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2968 return
never executed: return QFixed();
QFixed();
never executed: return QFixed();
0
2969-
2970 return
never executed: return width(line.from + line.length, line.trailingSpaces);
width(line.from + line.length, line.trailingSpaces);
never executed: return width(line.from + line.length, line.trailingSpaces);
0
2971}-
2972-
2973QFixed QTextEngine::alignLine(const QScriptLine &line)-
2974{-
2975 QFixed x = 0;-
2976 justify(line);-
2977-
2978 if (!line.justified
!line.justifiedDescription
TRUEnever evaluated
FALSEnever evaluated
&& line.width != (2147483647/256)
line.width != (2147483647/256)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2979 int align = option.alignment();-
2980 if (align & Qt::AlignJustify
align & Qt::AlignJustifyDescription
TRUEnever evaluated
FALSEnever evaluated
&& isRightToLeft()
isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2981 align = Qt::AlignRight;
never executed: align = Qt::AlignRight;
0
2982 if (align & Qt::AlignRight
align & Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2983 x = line.width - (line.textAdvance);
never executed: x = line.width - (line.textAdvance);
0
2984 else if (align & Qt::AlignHCenter
align & Qt::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2985 x = (line.width - line.textAdvance)/2;
never executed: x = (line.width - line.textAdvance)/2;
0
2986 }
never executed: end of block
0
2987 return
never executed: return x;
x;
never executed: return x;
0
2988}-
2989-
2990QFixed QTextEngine::offsetInLigature(const QScriptItem *si, int pos, int max, int glyph_pos)-
2991{-
2992 unsigned short *logClusters = this->logClusters(si);-
2993 const QGlyphLayout &glyphs = shapedGlyphs(si);-
2994-
2995 int offsetInCluster = 0;-
2996 for (int i = pos - 1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; i--) {
0
2997 if (logClusters[i] == glyph_pos
logClusters[i] == glyph_posDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2998 offsetInCluster++;
never executed: offsetInCluster++;
0
2999 else-
3000 break;
never executed: break;
0
3001 }-
3002-
3003-
3004-
3005 if (offsetInCluster > 0
offsetInCluster > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3006 int clusterLength = 0;-
3007 for (int i = pos - offsetInCluster; i < max
i < maxDescription
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
3008 if (logClusters[i] == glyph_pos
logClusters[i] == glyph_posDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3009 clusterLength++;
never executed: clusterLength++;
0
3010 else-
3011 break;
never executed: break;
0
3012 }-
3013 if (clusterLength
clusterLengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3014 return
never executed: return glyphs.advances[glyph_pos] * offsetInCluster / clusterLength;
glyphs.advances[glyph_pos] * offsetInCluster / clusterLength;
never executed: return glyphs.advances[glyph_pos] * offsetInCluster / clusterLength;
0
3015 }
never executed: end of block
0
3016-
3017 return
never executed: return 0;
0;
never executed: return 0;
0
3018}-
3019-
3020-
3021int QTextEngine::getClusterLength(unsigned short *logClusters,-
3022 const QCharAttributes *attributes,-
3023 int from, int to, int glyph_pos, int *start)-
3024{-
3025 int clusterLength = 0;-
3026 for (int i = from; i < to
i < toDescription
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
3027 if (logClusters[i] == glyph_pos
logClusters[i] == glyph_posDescription
TRUEnever evaluated
FALSEnever evaluated
&& attributes[i].graphemeBoundary
attributes[i].graphemeBoundaryDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3028 if (*
*start < 0Description
TRUEnever evaluated
FALSEnever evaluated
start < 0
*start < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3029 *
never executed: *start = i;
start = i;
never executed: *start = i;
0
3030 clusterLength++;-
3031 }
never executed: end of block
0
3032 else if (clusterLength
clusterLengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3033 break;
never executed: break;
0
3034 }
never executed: end of block
0
3035 return
never executed: return clusterLength;
clusterLength;
never executed: return clusterLength;
0
3036}-
3037-
3038int QTextEngine::positionInLigature(const QScriptItem *si, int end,-
3039 QFixed x, QFixed edge, int glyph_pos,-
3040 bool cursorOnCharacter)-
3041{-
3042 unsigned short *logClusters = this->logClusters(si);-
3043 int clusterStart = -1;-
3044 int clusterLength = 0;-
3045-
3046 if (si->analysis.script != QChar::Script_Common
si->analysis.s...:Script_CommonDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
3047 si->analysis.script != QChar::Script_Greek
si->analysis.s...::Script_GreekDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3048 if (glyph_pos == -1
glyph_pos == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3049 return
never executed: return si->position + end;
si->position + end;
never executed: return si->position + end;
0
3050 else {-
3051 int i;-
3052 for (i = 0; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
3053 if (logClusters[i] == glyph_pos
logClusters[i] == glyph_posDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3054 break;
never executed: break;
0
3055 return
never executed: return si->position + i;
si->position + i;
never executed: return si->position + i;
0
3056 }-
3057 }-
3058-
3059 if (glyph_pos == -1
glyph_pos == -1Description
TRUEnever evaluated
FALSEnever evaluated
&& end > 0
end > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3060 glyph_pos = logClusters[end - 1];
never executed: glyph_pos = logClusters[end - 1];
0
3061 else {-
3062 if (x <= edge
x <= edgeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3063 glyph_pos--;
never executed: glyph_pos--;
0
3064 }
never executed: end of block
0
3065-
3066 const QCharAttributes *attrs = attributes() + si->position;-
3067 logClusters = this->logClusters(si);-
3068 clusterLength = getClusterLength(logClusters, attrs, 0, end, glyph_pos, &clusterStart);-
3069-
3070 if (clusterLength
clusterLengthDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3071 const QGlyphLayout &glyphs = shapedGlyphs(si);-
3072 QFixed glyphWidth = glyphs.effectiveAdvance(glyph_pos);-
3073-
3074 QFixed perItemWidth = glyphWidth / clusterLength;-
3075 if (perItemWidth <= 0
perItemWidth <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3076 return
never executed: return si->position + clusterStart;
si->position + clusterStart;
never executed: return si->position + clusterStart;
0
3077 QFixed left = x > edge
x > edgeDescription
TRUEnever evaluated
FALSEnever evaluated
? edge : edge - glyphWidth;
0
3078 int n = ((x - left) / perItemWidth).floor().toInt();-
3079 QFixed dist = x - left - n * perItemWidth;-
3080 int closestItem = dist > (perItemWidth / 2)
dist > (perItemWidth / 2)Description
TRUEnever evaluated
FALSEnever evaluated
? n + 1 : n;
0
3081 if (cursorOnCharacter
cursorOnCharacterDescription
TRUEnever evaluated
FALSEnever evaluated
&& closestItem > 0
closestItem > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3082 closestItem--;
never executed: closestItem--;
0
3083 int pos = clusterStart + closestItem;-
3084-
3085 while (pos < end
pos < endDescription
TRUEnever evaluated
FALSEnever evaluated
&& !attrs[pos].graphemeBoundary
!attrs[pos].graphemeBoundaryDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3086 pos++;
never executed: pos++;
0
3087 return
never executed: return si->position + pos;
si->position + pos;
never executed: return si->position + pos;
0
3088 }-
3089 return
never executed: return si->position + end;
si->position + end;
never executed: return si->position + end;
0
3090}-
3091-
3092int QTextEngine::previousLogicalPosition(int oldPos) const-
3093{-
3094 const QCharAttributes *attrs = attributes();-
3095 int len = block.isValid()
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
? block.length() - 1
0
3096 : layoutData->string.length();-
3097 ((!(len <= layoutData->string.length())) ? qt_assert("len <= layoutData->string.length()",__FILE__,3216) : qt_noop());-
3098 if (!attrs
!attrsDescription
TRUEnever evaluated
FALSEnever evaluated
|| oldPos <= 0
oldPos <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| oldPos > len
oldPos > lenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3099 return
never executed: return oldPos;
oldPos;
never executed: return oldPos;
0
3100-
3101 oldPos--;-
3102 while (oldPos
oldPosDescription
TRUEnever evaluated
FALSEnever evaluated
&& !attrs[oldPos].graphemeBoundary
!attrs[oldPos]...aphemeBoundaryDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3103 oldPos--;
never executed: oldPos--;
0
3104 return
never executed: return oldPos;
oldPos;
never executed: return oldPos;
0
3105}-
3106-
3107int QTextEngine::nextLogicalPosition(int oldPos) const-
3108{-
3109 const QCharAttributes *attrs = attributes();-
3110 int len = block.isValid()
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
? block.length() - 1
0
3111 : layoutData->string.length();-
3112 ((!(len <= layoutData->string.length())) ? qt_assert("len <= layoutData->string.length()",__FILE__,3231) : qt_noop());-
3113 if (!attrs
!attrsDescription
TRUEnever evaluated
FALSEnever evaluated
|| oldPos < 0
oldPos < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| oldPos >= len
oldPos >= lenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3114 return
never executed: return oldPos;
oldPos;
never executed: return oldPos;
0
3115-
3116 oldPos++;-
3117 while (oldPos < len
oldPos < lenDescription
TRUEnever evaluated
FALSEnever evaluated
&& !attrs[oldPos].graphemeBoundary
!attrs[oldPos]...aphemeBoundaryDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3118 oldPos++;
never executed: oldPos++;
0
3119 return
never executed: return oldPos;
oldPos;
never executed: return oldPos;
0
3120}-
3121-
3122int QTextEngine::lineNumberForTextPosition(int pos)-
3123{-
3124 if (!layoutData
!layoutDataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3125 itemize();
never executed: itemize();
0
3126 if (pos == layoutData->string.length()
pos == layoutD...tring.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& lines.size()
lines.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3127 return
never executed: return lines.size() - 1;
lines.size() - 1;
never executed: return lines.size() - 1;
0
3128 for (int i = 0; i < lines.size()
i < lines.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
3129 const QScriptLine& line = lines[i];-
3130 if (line.from + line.length + line.trailingSpaces > pos
line.from + li...ngSpaces > posDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3131 return
never executed: return i;
i;
never executed: return i;
0
3132 }
never executed: end of block
0
3133 return
never executed: return -1;
-1;
never executed: return -1;
0
3134}-
3135-
3136void QTextEngine::insertionPointsForLine(int lineNum, QVector<int> &insertionPoints)-
3137{-
3138 QTextLineItemIterator iterator(this, lineNum);-
3139-
3140 insertionPoints.reserve(iterator.line.length);-
3141-
3142 bool lastLine = lineNum >= lines.size() - 1;-
3143-
3144 while (!iterator.atEnd()
!iterator.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3145 const QScriptItem &si = iterator.next();-
3146-
3147 int end = iterator.itemEnd;-
3148 if (lastLine
lastLineDescription
TRUEnever evaluated
FALSEnever evaluated
&& iterator.item == iterator.lastItem
iterator.item ...rator.lastItemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3149 ++
never executed: ++end;
end;
never executed: ++end;
0
3150 if (si.analysis.bidiLevel % 2
si.analysis.bidiLevel % 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3151 for (int i = end - 1; i >= iterator.itemStart
i >= iterator.itemStartDescription
TRUEnever evaluated
FALSEnever evaluated
; --i)
0
3152 insertionPoints.push_back(i);
never executed: insertionPoints.push_back(i);
0
3153 }
never executed: end of block
else {
0
3154 for (int i = iterator.itemStart; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
3155 insertionPoints.push_back(i);
never executed: insertionPoints.push_back(i);
0
3156 }
never executed: end of block
0
3157 }-
3158}
never executed: end of block
0
3159-
3160int QTextEngine::endOfLine(int lineNum)-
3161{-
3162 QVector<int> insertionPoints;-
3163 insertionPointsForLine(lineNum, insertionPoints);-
3164-
3165 if (insertionPoints.size() > 0
insertionPoints.size() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3166 return
never executed: return insertionPoints.constLast();
insertionPoints.constLast();
never executed: return insertionPoints.constLast();
0
3167 return
never executed: return 0;
0;
never executed: return 0;
0
3168}-
3169-
3170int QTextEngine::beginningOfLine(int lineNum)-
3171{-
3172 QVector<int> insertionPoints;-
3173 insertionPointsForLine(lineNum, insertionPoints);-
3174-
3175 if (insertionPoints.size() > 0
insertionPoints.size() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3176 return
never executed: return insertionPoints.constFirst();
insertionPoints.constFirst();
never executed: return insertionPoints.constFirst();
0
3177 return
never executed: return 0;
0;
never executed: return 0;
0
3178}-
3179-
3180int QTextEngine::positionAfterVisualMovement(int pos, QTextCursor::MoveOperation op)-
3181{-
3182 itemize();-
3183-
3184 bool moveRight = (op == QTextCursor::Right);-
3185 bool alignRight = isRightToLeft();-
3186 if (!layoutData->hasBidi
!layoutData->hasBidiDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3187 return
never executed: return moveRight ^ alignRight ? nextLogicalPosition(pos) : previousLogicalPosition(pos);
moveRight ^ alignRight ? nextLogicalPosition(pos) : previousLogicalPosition(pos);
never executed: return moveRight ^ alignRight ? nextLogicalPosition(pos) : previousLogicalPosition(pos);
0
3188-
3189 int lineNum = lineNumberForTextPosition(pos);-
3190 if (lineNum < 0
lineNum < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3191 return
never executed: return pos;
pos;
never executed: return pos;
0
3192-
3193 QVector<int> insertionPoints;-
3194 insertionPointsForLine(lineNum, insertionPoints);-
3195 int i, max = insertionPoints.size();-
3196 for (i = 0; i < max
i < maxDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
3197 if (pos == insertionPoints[i]
pos == insertionPoints[i]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3198 if (moveRight
moveRightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3199 if (i + 1 < max
i + 1 < maxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3200 return
never executed: return insertionPoints[i + 1];
insertionPoints[i + 1];
never executed: return insertionPoints[i + 1];
0
3201 }
never executed: end of block
else {
0
3202 if (i > 0
i > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3203 return
never executed: return insertionPoints[i - 1];
insertionPoints[i - 1];
never executed: return insertionPoints[i - 1];
0
3204 }
never executed: end of block
0
3205-
3206 if (moveRight ^ alignRight
moveRight ^ alignRightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3207 if (lineNum + 1 < lines.size()
lineNum + 1 < lines.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3208 return
never executed: return alignRight ? endOfLine(lineNum + 1) : beginningOfLine(lineNum + 1);
alignRight ? endOfLine(lineNum + 1) : beginningOfLine(lineNum + 1);
never executed: return alignRight ? endOfLine(lineNum + 1) : beginningOfLine(lineNum + 1);
0
3209 }
never executed: end of block
0
3210 else {-
3211 if (lineNum > 0
lineNum > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3212 return
never executed: return alignRight ? beginningOfLine(lineNum - 1) : endOfLine(lineNum - 1);
alignRight ? beginningOfLine(lineNum - 1) : endOfLine(lineNum - 1);
never executed: return alignRight ? beginningOfLine(lineNum - 1) : endOfLine(lineNum - 1);
0
3213 }
never executed: end of block
0
3214-
3215 break;
never executed: break;
0
3216 }-
3217-
3218 return
never executed: return pos;
pos;
never executed: return pos;
0
3219}-
3220-
3221void QTextEngine::addItemDecoration(QPainter *painter, const QLineF &line, ItemDecorationList *decorationList)-
3222{-
3223 if (delayDecorations
delayDecorationsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3224 decorationList->append(ItemDecoration(line.x1(), line.x2(), line.y1(), painter->pen()));-
3225 }
never executed: end of block
else {
0
3226 painter->drawLine(line);-
3227 }
never executed: end of block
0
3228}-
3229-
3230void QTextEngine::addUnderline(QPainter *painter, const QLineF &line)-
3231{-
3232-
3233 addItemDecoration(painter, line, &underlineList);-
3234}
never executed: end of block
0
3235-
3236void QTextEngine::addStrikeOut(QPainter *painter, const QLineF &line)-
3237{-
3238 addItemDecoration(painter, line, &strikeOutList);-
3239}
never executed: end of block
0
3240-
3241void QTextEngine::addOverline(QPainter *painter, const QLineF &line)-
3242{-
3243 addItemDecoration(painter, line, &overlineList);-
3244}
never executed: end of block
0
3245-
3246void QTextEngine::drawItemDecorationList(QPainter *painter, const ItemDecorationList &decorationList)-
3247{-
3248-
3249 if (decorationList.isEmpty()
decorationList.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3250 return;
never executed: return;
0
3251-
3252 for (const ItemDecoration &decoration : decorationList) {-
3253 painter->setPen(decoration.pen);-
3254 painter->drawLine(QLineF(decoration.x1, decoration.y, decoration.x2, decoration.y));-
3255 }
never executed: end of block
0
3256}
never executed: end of block
0
3257-
3258void QTextEngine::drawDecorations(QPainter *painter)-
3259{-
3260 QPen oldPen = painter->pen();-
3261-
3262 bool wasCompatiblePainting = painter->renderHints()-
3263 & QPainter::Qt4CompatiblePainting;-
3264-
3265 if (wasCompatiblePainting
wasCompatiblePaintingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3266 painter->setRenderHint(QPainter::Qt4CompatiblePainting, false);
never executed: painter->setRenderHint(QPainter::Qt4CompatiblePainting, false);
0
3267-
3268 adjustUnderlines();-
3269 drawItemDecorationList(painter, underlineList);-
3270 drawItemDecorationList(painter, strikeOutList);-
3271 drawItemDecorationList(painter, overlineList);-
3272-
3273 clearDecorations();-
3274-
3275 if (wasCompatiblePainting
wasCompatiblePaintingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3276 painter->setRenderHint(QPainter::Qt4CompatiblePainting);
never executed: painter->setRenderHint(QPainter::Qt4CompatiblePainting);
0
3277-
3278 painter->setPen(oldPen);-
3279}
never executed: end of block
0
3280-
3281void QTextEngine::clearDecorations()-
3282{-
3283 underlineList.clear();-
3284 strikeOutList.clear();-
3285 overlineList.clear();-
3286}
never executed: end of block
0
3287-
3288void QTextEngine::adjustUnderlines()-
3289{-
3290-
3291 if (underlineList.isEmpty()
underlineList.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3292 return;
never executed: return;
0
3293-
3294 ItemDecorationList::iterator start = underlineList.begin();-
3295 ItemDecorationList::iterator end = underlineList.end();-
3296 ItemDecorationList::iterator it = start;-
3297 qreal underlinePos = start->y;-
3298 qreal penWidth = start->pen.widthF();-
3299 qreal lastLineEnd = start->x1;-
3300-
3301 while (it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3302 if (qFuzzyCompare(lastLineEnd, it->x1)
qFuzzyCompare(...neEnd, it->x1)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3303 underlinePos = qMax(underlinePos, it->y);-
3304 penWidth = qMax(penWidth, it->pen.widthF());-
3305 }
never executed: end of block
else {
0
3306 adjustUnderlines(start, it, underlinePos, penWidth);-
3307 start = it;-
3308 underlinePos = start->y;-
3309 penWidth = start->pen.widthF();-
3310 }
never executed: end of block
0
3311 lastLineEnd = it->x2;-
3312 ++it;-
3313 }
never executed: end of block
0
3314-
3315 adjustUnderlines(start, end, underlinePos, penWidth);-
3316}
never executed: end of block
0
3317-
3318void QTextEngine::adjustUnderlines(ItemDecorationList::iterator start,-
3319 ItemDecorationList::iterator end,-
3320 qreal underlinePos, qreal penWidth)-
3321{-
3322 for (ItemDecorationList::iterator it = start; it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
3323 it->y = underlinePos;-
3324 it->pen.setWidthF(penWidth);-
3325 }
never executed: end of block
0
3326}
never executed: end of block
0
3327-
3328QStackTextEngine::QStackTextEngine(const QString &string, const QFont &f)-
3329 : QTextEngine(string, f),-
3330 _layoutData(string, _memory, MemSize)-
3331{-
3332 stackEngine = true;-
3333 layoutData = &_layoutData;-
3334}
never executed: end of block
0
3335-
3336QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format)-
3337 : justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format),-
3338 num_chars(0), chars(0), logClusters(0), f(0), fontEngine(0)-
3339{-
3340 f = font;-
3341 fontEngine = f->d->engineForScript(si.analysis.script);-
3342 ((!(fontEngine)) ? qt_assert("fontEngine",__FILE__,3461) : qt_noop());-
3343-
3344 initWithScriptItem(si);-
3345}
never executed: end of block
0
3346-
3347QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format)-
3348 : flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format),-
3349 num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe)-
3350{-
3351}
never executed: end of block
0
3352-
3353-
3354void QTextItemInt::initWithScriptItem(const QScriptItem &si)-
3355{-
3356-
3357-
3358 flags = 0;-
3359 if (si.analysis.bidiLevel %2
si.analysis.bidiLevel %2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3360 flags |= QTextItem::RightToLeft;
never executed: flags |= QTextItem::RightToLeft;
0
3361 ascent = si.ascent;-
3362 descent = si.descent;-
3363-
3364 if (charFormat.hasProperty(QTextFormat::TextUnderlineStyle)
charFormat.has...nderlineStyle)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3365 underlineStyle = charFormat.underlineStyle();-
3366 }
never executed: end of block
else if (charFormat.boolProperty(QTextFormat::FontUnderline)
charFormat.boo...FontUnderline)Description
TRUEnever evaluated
FALSEnever evaluated
0
3367 || f->d->underline
f->d->underlineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3368 underlineStyle = QTextCharFormat::SingleUnderline;-
3369 }
never executed: end of block
0
3370-
3371-
3372 if (underlineStyle == QTextCharFormat::SingleUnderline
underlineStyle...ingleUnderlineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3373 flags |= QTextItem::Underline;
never executed: flags |= QTextItem::Underline;
0
3374-
3375 if (f->d->overline
f->d->overlineDescription
TRUEnever evaluated
FALSEnever evaluated
|| charFormat.fontOverline()
charFormat.fontOverline()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3376 flags |= QTextItem::Overline;
never executed: flags |= QTextItem::Overline;
0
3377 if (f->d->strikeOut
f->d->strikeOutDescription
TRUEnever evaluated
FALSEnever evaluated
|| charFormat.fontStrikeOut()
charFormat.fontStrikeOut()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
3378 flags |= QTextItem::StrikeOut;
never executed: flags |= QTextItem::StrikeOut;
0
3379}
never executed: end of block
0
3380-
3381QTextItemInt QTextItemInt::midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const-
3382{-
3383 QTextItemInt ti = *this;-
3384 const int end = firstGlyphIndex + numGlyphs;-
3385 ti.glyphs = glyphs.mid(firstGlyphIndex, numGlyphs);-
3386 ti.fontEngine = fontEngine;-
3387-
3388 if (logClusters
logClustersDescription
TRUEnever evaluated
FALSEnever evaluated
&& chars
charsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3389 const int logClusterOffset = logClusters[0];-
3390 while (logClusters[ti.chars - chars] - logClusterOffset < firstGlyphIndex
logClusters[ti...irstGlyphIndexDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3391 ++
never executed: ++ti.chars;
ti.chars;
never executed: ++ti.chars;
0
3392-
3393 ti.logClusters += (ti.chars - chars);-
3394-
3395 ti.num_chars = 0;-
3396 int char_start = ti.chars - chars;-
3397 while (char_start + ti.num_chars < num_chars
char_start + t...rs < num_charsDescription
TRUEnever evaluated
FALSEnever evaluated
&& ti.logClusters[ti.num_chars] - logClusterOffset < end
ti.logClusters...erOffset < endDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3398 ++
never executed: ++ti.num_chars;
ti.num_chars;
never executed: ++ti.num_chars;
0
3399 }
never executed: end of block
0
3400 return
never executed: return ti;
ti;
never executed: return ti;
0
3401}-
3402-
3403-
3404QTransform qt_true_matrix(qreal w, qreal h, QTransform x)-
3405{-
3406 QRectF rect = x.mapRect(QRectF(0, 0, w, h));-
3407 return
never executed: return x * QTransform::fromTranslate(-rect.x(), -rect.y());
x * QTransform::fromTranslate(-rect.x(), -rect.y());
never executed: return x * QTransform::fromTranslate(-rect.x(), -rect.y());
0
3408}-
3409-
3410-
3411glyph_metrics_t glyph_metrics_t::transformed(const QTransform &matrix) const-
3412{-
3413 if (matrix.type() < QTransform::TxTranslate
matrix.type() ...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3414 return
never executed: return *this;
*this;
never executed: return *this;
0
3415-
3416 glyph_metrics_t m = *this;-
3417-
3418 qreal w = width.toReal();-
3419 qreal h = height.toReal();-
3420 QTransform xform = qt_true_matrix(w, h, matrix);-
3421-
3422 QRectF rect(0, 0, w, h);-
3423 rect = xform.mapRect(rect);-
3424 m.width = QFixed::fromReal(rect.width());-
3425 m.height = QFixed::fromReal(rect.height());-
3426-
3427 QLineF l = xform.map(QLineF(x.toReal(), y.toReal(), xoff.toReal(), yoff.toReal()));-
3428-
3429 m.x = QFixed::fromReal(l.x1());-
3430 m.y = QFixed::fromReal(l.y1());-
3431-
3432-
3433 m.xoff = QFixed::fromReal(l.dx());-
3434 m.yoff = QFixed::fromReal(l.dy());-
3435-
3436 return
never executed: return m;
m;
never executed: return m;
0
3437}-
3438-
3439QTextLineItemIterator::QTextLineItemIterator(QTextEngine *_eng, int _lineNum, const QPointF &pos,-
3440 const QTextLayout::FormatRange *_selection)-
3441 : eng(_eng),-
3442 line(eng->lines[_lineNum]),-
3443 si(0),-
3444 lineNum(_lineNum),-
3445 lineEnd(line.from + line.length),-
3446 firstItem(eng->findItem(line.from)),-
3447 lastItem(eng->findItem(lineEnd - 1, firstItem)),-
3448 nItems((firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0),-
3449 logicalItem(-1),-
3450 item(-1),-
3451 visualOrder(nItems),-
3452 selection(_selection)-
3453{-
3454 x = QFixed::fromReal(pos.x());-
3455-
3456 x += line.x;-
3457-
3458 x += eng->alignLine(line);-
3459-
3460 QVarLengthArray<uchar> levels(nItems);-
3461 for (int i = 0; i < nItems
i < nItemsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
3462 levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel;
never executed: levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel;
0
3463 QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data());-
3464-
3465 eng->shapeLine(line);-
3466}
never executed: end of block
0
3467-
3468QScriptItem &QTextLineItemIterator::next()-
3469{-
3470 x += itemWidth;-
3471-
3472 ++logicalItem;-
3473 item = visualOrder[logicalItem] + firstItem;-
3474 itemLength = eng->length(item);-
3475 si = &eng->layoutData->items[item];-
3476 if (!si->num_glyphs
!si->num_glyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3477 eng->shape(item);
never executed: eng->shape(item);
0
3478-
3479 itemStart = qMax(line.from, si->position);-
3480 itemEnd = qMin(lineEnd, si->position + itemLength);-
3481-
3482 if (si->analysis.flags >= QScriptAnalysis::TabOrObject
si->analysis.f...s::TabOrObjectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3483 glyphsStart = 0;-
3484 glyphsEnd = 1;-
3485 itemWidth = si->width;-
3486 return
never executed: return *si;
*si;
never executed: return *si;
0
3487 }-
3488-
3489 unsigned short *logClusters = eng->logClusters(si);-
3490 QGlyphLayout glyphs = eng->shapedGlyphs(si);-
3491-
3492 glyphsStart = logClusters[itemStart - si->position];-
3493 glyphsEnd = (
(itemEnd == si... + itemLength)Description
TRUEnever evaluated
FALSEnever evaluated
itemEnd == si->position + itemLength)
(itemEnd == si... + itemLength)Description
TRUEnever evaluated
FALSEnever evaluated
? si->num_glyphs : logClusters[itemEnd - si->position];
0
3494-
3495-
3496 if (si->position + itemLength >= lineEnd
si->position +...gth >= lineEndDescription
TRUEnever evaluated
FALSEnever evaluated
0
3497 && eng->layoutData->string.at(lineEnd - 1).unicode() == QChar::SoftHyphen
eng->layoutDat...ar::SoftHyphenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3498 glyphs.attributes[glyphsEnd - 1].dontPrint = false;
never executed: glyphs.attributes[glyphsEnd - 1].dontPrint = false;
0
3499-
3500 itemWidth = 0;-
3501 for (int g = glyphsStart; g < glyphsEnd
g < glyphsEndDescription
TRUEnever evaluated
FALSEnever evaluated
; ++g)
0
3502 itemWidth += glyphs.effectiveAdvance(g);
never executed: itemWidth += glyphs.effectiveAdvance(g);
0
3503-
3504 return
never executed: return *si;
*si;
never executed: return *si;
0
3505}-
3506-
3507bool QTextLineItemIterator::getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const-
3508{-
3509 *selectionX = *selectionWidth = 0;-
3510-
3511 if (!selection
!selectionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3512 return
never executed: return false;
false;
never executed: return false;
0
3513-
3514 if (si->analysis.flags >= QScriptAnalysis::TabOrObject
si->analysis.f...s::TabOrObjectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
3515 if (si->position >= selection->start + selection->length
si->position >...ection->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
3516 || si->position + itemLength <= selection->start
si->position +...lection->startDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3517 return
never executed: return false;
false;
never executed: return false;
0
3518-
3519 *selectionX = x;-
3520 *selectionWidth = itemWidth;-
3521 }
never executed: end of block
else {
0
3522 unsigned short *logClusters = eng->logClusters(si);-
3523 QGlyphLayout glyphs = eng->shapedGlyphs(si);-
3524-
3525 int from = qMax(itemStart, selection->start) - si->position;-
3526 int to = qMin(itemEnd, selection->start + selection->length) - si->position;-
3527 if (from >= to
from >= toDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
3528 return
never executed: return false;
false;
never executed: return false;
0
3529-
3530 int start_glyph = logClusters[from];-
3531 int end_glyph = (
(to == itemLength)Description
TRUEnever evaluated
FALSEnever evaluated
to == itemLength)
(to == itemLength)Description
TRUEnever evaluated
FALSEnever evaluated
? si->num_glyphs : logClusters[to];
0
3532 QFixed soff;-
3533 QFixed swidth;-
3534 if (si->analysis.bidiLevel %2
si->analysis.bidiLevel %2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
3535 for (int g = glyphsEnd - 1; g >= end_glyph
g >= end_glyphDescription
TRUEnever evaluated
FALSEnever evaluated
; --g)
0
3536 soff += glyphs.effectiveAdvance(g);
never executed: soff += glyphs.effectiveAdvance(g);
0
3537 for (int g = end_glyph - 1; g >= start_glyph
g >= start_glyphDescription
TRUEnever evaluated
FALSEnever evaluated
; --g)
0
3538 swidth += glyphs.effectiveAdvance(g);
never executed: swidth += glyphs.effectiveAdvance(g);
0
3539 }
never executed: end of block
else {
0
3540 for (int g = glyphsStart; g < start_glyph
g < start_glyphDescription
TRUEnever evaluated
FALSEnever evaluated
; ++g)
0
3541 soff += glyphs.effectiveAdvance(g);
never executed: soff += glyphs.effectiveAdvance(g);
0
3542 for (int g = start_glyph; g < end_glyph
g < end_glyphDescription
TRUEnever evaluated
FALSEnever evaluated
; ++g)
0
3543 swidth += glyphs.effectiveAdvance(g);
never executed: swidth += glyphs.effectiveAdvance(g);
0
3544 }
never executed: end of block
0
3545-
3546-
3547-
3548-
3549-
3550 QFixed leftOffsetInLigature = eng->offsetInLigature(si, from, to, start_glyph);-
3551 *selectionX = x + soff + leftOffsetInLigature;-
3552 *selectionWidth = swidth - leftOffsetInLigature;-
3553-
3554-
3555-
3556 *selectionWidth += eng->offsetInLigature(si, to, itemLength, end_glyph);-
3557 }
never executed: end of block
0
3558 return
never executed: return true;
true;
never executed: return true;
0
3559}-
3560-
3561-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9