qfontmetrics.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qfontmetrics.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6extern void qt_format_text(const QFont& font, const QRectF &_r,-
7 int tf, const QString &text, QRectF *brect,-
8 int tabStops, int *tabArray, int tabArrayLen,-
9 QPainter *painter);-
10QFontMetrics::QFontMetrics(const QFont &font)-
11 : d(font.d)-
12{-
13}
never executed: end of block
0
14QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice)-
15{-
16 int dpi = paintdevice
paintdeviceDescription
TRUEnever evaluated
FALSEnever evaluated
? paintdevice->logicalDpiY() : qt_defaultDpi();
0
17 const int screen = 0;-
18 if (font.d->dpi != dpi
font.d->dpi != dpiDescription
TRUEnever evaluated
FALSEnever evaluated
|| font.d->screen != screen
font.d->screen != screenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
19 d = new QFontPrivate(*font.d);-
20 d->dpi = dpi;-
21 d->screen = screen;-
22 }
never executed: end of block
else {
0
23 d = font.d;-
24 }
never executed: end of block
0
25-
26}-
27-
28-
29-
30-
31QFontMetrics::QFontMetrics(const QFontMetrics &fm)-
32 : d(fm.d)-
33{-
34}
never executed: end of block
0
35-
36-
37-
38-
39-
40QFontMetrics::~QFontMetrics()-
41{-
42}-
43-
44-
45-
46-
47QFontMetrics &QFontMetrics::operator=(const QFontMetrics &fm)-
48{-
49 d = fm.d;-
50 return
never executed: return *this;
*this;
never executed: return *this;
0
51}-
52bool QFontMetrics::operator ==(const QFontMetrics &other) const-
53{-
54 return
never executed: return d == other.d;
d == other.d;
never executed: return d == other.d;
0
55}-
56int QFontMetrics::ascent() const-
57{-
58 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
59 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,273) : qt_noop());-
60 return
never executed: return qRound(engine->ascent());
qRound(engine->ascent());
never executed: return qRound(engine->ascent());
0
61}-
62int QFontMetrics::descent() const-
63{-
64 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
65 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,291) : qt_noop());-
66 return
never executed: return qRound(engine->descent());
qRound(engine->descent());
never executed: return qRound(engine->descent());
0
67}-
68int QFontMetrics::height() const-
69{-
70 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
71 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,305) : qt_noop());-
72 return
never executed: return qRound(engine->ascent()) + qRound(engine->descent());
qRound(engine->ascent()) + qRound(engine->descent());
never executed: return qRound(engine->ascent()) + qRound(engine->descent());
0
73}-
74int QFontMetrics::leading() const-
75{-
76 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
77 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,319) : qt_noop());-
78 return
never executed: return qRound(engine->leading());
qRound(engine->leading());
never executed: return qRound(engine->leading());
0
79}-
80int QFontMetrics::lineSpacing() const-
81{-
82 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
83 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,333) : qt_noop());-
84 return
never executed: return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent());
qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent());
never executed: return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent());
0
85}-
86int QFontMetrics::minLeftBearing() const-
87{-
88 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
89 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,350) : qt_noop());-
90 return
never executed: return qRound(engine->minLeftBearing());
qRound(engine->minLeftBearing());
never executed: return qRound(engine->minLeftBearing());
0
91}-
92int QFontMetrics::minRightBearing() const-
93{-
94 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
95 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,367) : qt_noop());-
96 return
never executed: return qRound(engine->minRightBearing());
qRound(engine->minRightBearing());
never executed: return qRound(engine->minRightBearing());
0
97}-
98-
99-
100-
101-
102int QFontMetrics::maxWidth() const-
103{-
104 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
105 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,377) : qt_noop());-
106 return
never executed: return qRound(engine->maxCharWidth());
qRound(engine->maxCharWidth());
never executed: return qRound(engine->maxCharWidth());
0
107}-
108-
109-
110-
111-
112-
113int QFontMetrics::xHeight() const-
114{-
115 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
116 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,388) : qt_noop());-
117 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
118 return
never executed: return qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent());
qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent());
never executed: return qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent());
0
119 return
never executed: return qRound(engine->xHeight());
qRound(engine->xHeight());
never executed: return qRound(engine->xHeight());
0
120}-
121-
122-
123-
124-
125-
126-
127int QFontMetrics::averageCharWidth() const-
128{-
129 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
130 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,402) : qt_noop());-
131 return
never executed: return qRound(engine->averageCharWidth());
qRound(engine->averageCharWidth());
never executed: return qRound(engine->averageCharWidth());
0
132}-
133-
134-
135-
136-
137-
138bool QFontMetrics::inFont(QChar ch) const-
139{-
140 return
never executed: return inFontUcs4(ch.unicode());
inFontUcs4(ch.unicode());
never executed: return inFontUcs4(ch.unicode());
0
141}-
142-
143-
144-
145-
146-
147bool QFontMetrics::inFontUcs4(uint ucs4) const-
148{-
149 const int script = QChar::script(ucs4);-
150 QFontEngine *engine = d->engineForScript(script);-
151 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,423) : qt_noop());-
152 if (engine->type() == QFontEngine::Box
engine->type()...ontEngine::BoxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
153 return
never executed: return false;
false;
never executed: return false;
0
154 return
never executed: return engine->canRender(ucs4);
engine->canRender(ucs4);
never executed: return engine->canRender(ucs4);
0
155}-
156int QFontMetrics::leftBearing(QChar ch) const-
157{-
158 const int script = ch.script();-
159 QFontEngine *engine;-
160 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
&& ch.isLower()
ch.isLower()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
161 engine = d->smallCapsFontPrivate()->engineForScript(script);
never executed: engine = d->smallCapsFontPrivate()->engineForScript(script);
0
162 else-
163 engine = d->engineForScript(script);
never executed: engine = d->engineForScript(script);
0
164 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,449) : qt_noop());-
165 if (engine->type() == QFontEngine::Box
engine->type()...ontEngine::BoxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
166 return
never executed: return 0;
0;
never executed: return 0;
0
167-
168 d->alterCharForCapitalization(ch);-
169-
170 glyph_t glyph = engine->glyphIndex(ch.unicode());-
171-
172 qreal lb;-
173 engine->getGlyphBearings(glyph, &lb);-
174 return
never executed: return qRound(lb);
qRound(lb);
never executed: return qRound(lb);
0
175}-
176int QFontMetrics::rightBearing(QChar ch) const-
177{-
178 const int script = ch.script();-
179 QFontEngine *engine;-
180 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
&& ch.isLower()
ch.isLower()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
181 engine = d->smallCapsFontPrivate()->engineForScript(script);
never executed: engine = d->smallCapsFontPrivate()->engineForScript(script);
0
182 else-
183 engine = d->engineForScript(script);
never executed: engine = d->engineForScript(script);
0
184 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,482) : qt_noop());-
185 if (engine->type() == QFontEngine::Box
engine->type()...ontEngine::BoxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
186 return
never executed: return 0;
0;
never executed: return 0;
0
187-
188 d->alterCharForCapitalization(ch);-
189-
190 glyph_t glyph = engine->glyphIndex(ch.unicode());-
191-
192 qreal rb;-
193 engine->getGlyphBearings(glyph, 0, &rb);-
194 return
never executed: return qRound(rb);
qRound(rb);
never executed: return qRound(rb);
0
195}-
196int QFontMetrics::width(const QString &text, int len) const-
197{-
198 return
never executed: return width(text, len, 0);
width(text, len, 0);
never executed: return width(text, len, 0);
0
199}-
200-
201-
202-
203-
204int QFontMetrics::width(const QString &text, int len, int flags) const-
205{-
206 int pos = text.indexOf(QLatin1Char('\x9c'));-
207 if (pos != -1
pos != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
208 len = (
(len < 0)Description
TRUEnever evaluated
FALSEnever evaluated
len < 0)
(len < 0)Description
TRUEnever evaluated
FALSEnever evaluated
? pos : qMin(pos, len);
0
209 }
never executed: end of block
else if (len < 0
len < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
210 len = text.length();-
211 }
never executed: end of block
0
212 if (len == 0
len == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
213 return
never executed: return 0;
0;
never executed: return 0;
0
214-
215 if (flags & Qt::TextBypassShaping
flags & Qt::TextBypassShapingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
216-
217 int numGlyphs = len;-
218 QVarLengthGlyphLayoutArray glyphs(numGlyphs);-
219 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
220 if (!engine->stringToCMap(text.data(), len, &glyphs, &numGlyphs, 0)
!engine->strin...&numGlyphs, 0)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
221 do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,532) : qt_noop()); __builtin_unreachable(); }
never executed: end of block
while (0);
0
222-
223 QFixed width;-
224 for (int i = 0; i < numGlyphs
i < numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
225 width += glyphs.advances[i];
never executed: width += glyphs.advances[i];
0
226 return
never executed: return qRound(width);
qRound(width);
never executed: return qRound(width);
0
227 }-
228-
229 QStackTextEngine layout(text, QFont(d.data()));-
230 layout.ignoreBidi = true;-
231 return
never executed: return qRound(layout.width(0, len));
qRound(layout.width(0, len));
never executed: return qRound(layout.width(0, len));
0
232}-
233int QFontMetrics::width(QChar ch) const-
234{-
235 if (QChar::category(ch.unicode()) == QChar::Mark_NonSpacing
QChar::categor...ark_NonSpacingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
236 return
never executed: return 0;
0;
never executed: return 0;
0
237-
238 const int script = ch.script();-
239 QFontEngine *engine;-
240 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
&& ch.isLower()
ch.isLower()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
241 engine = d->smallCapsFontPrivate()->engineForScript(script);
never executed: engine = d->smallCapsFontPrivate()->engineForScript(script);
0
242 else-
243 engine = d->engineForScript(script);
never executed: engine = d->engineForScript(script);
0
244 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,580) : qt_noop());-
245-
246 d->alterCharForCapitalization(ch);-
247-
248 glyph_t glyph = engine->glyphIndex(ch.unicode());-
249 QFixed advance;-
250-
251 QGlyphLayout glyphs;-
252 glyphs.numGlyphs = 1;-
253 glyphs.glyphs = &glyph;-
254 glyphs.advances = &advance;-
255 engine->recalcAdvances(&glyphs, 0);-
256-
257 return
never executed: return qRound(advance);
qRound(advance);
never executed: return qRound(advance);
0
258}-
259int QFontMetrics::charWidth(const QString &text, int pos) const-
260{-
261 int width = 0;-
262 if (pos < 0
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| pos > (int)text.length()
pos > (int)text.length()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
263 return
never executed: return width;
width;
never executed: return width;
0
264-
265 QChar ch = text.at(pos);-
266 const int script = ch.script();-
267 if (script != QChar::Script_Common
script != QChar::Script_CommonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
268-
269 int from = qMax(0, pos - 8);-
270 int to = qMin(text.length(), pos + 8);-
271 QString cstr = QString::fromRawData(text.unicode() + from, to - from);-
272 QStackTextEngine layout(cstr, QFont(d.data()));-
273 layout.ignoreBidi = true;-
274 layout.itemize();-
275 width = qRound(layout.width(pos-from, 1));-
276 }
never executed: end of block
else if (ch.category() != QChar::Mark_NonSpacing
ch.category() ...ark_NonSpacingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
277 QFontEngine *engine;-
278 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
&& ch.isLower()
ch.isLower()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
279 engine = d->smallCapsFontPrivate()->engineForScript(script);
never executed: engine = d->smallCapsFontPrivate()->engineForScript(script);
0
280 else-
281 engine = d->engineForScript(script);
never executed: engine = d->engineForScript(script);
0
282 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,632) : qt_noop());-
283-
284 d->alterCharForCapitalization(ch);-
285-
286 glyph_t glyph = engine->glyphIndex(ch.unicode());-
287 QFixed advance;-
288-
289 QGlyphLayout glyphs;-
290 glyphs.numGlyphs = 1;-
291 glyphs.glyphs = &glyph;-
292 glyphs.advances = &advance;-
293 engine->recalcAdvances(&glyphs, 0);-
294-
295 width = qRound(advance);-
296 }
never executed: end of block
0
297 return
never executed: return width;
width;
never executed: return width;
0
298}-
299QRect QFontMetrics::boundingRect(const QString &text) const-
300{-
301 if (text.length() == 0
text.length() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
302 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
303-
304 QStackTextEngine layout(text, QFont(d.data()));-
305 layout.ignoreBidi = true;-
306 layout.itemize();-
307 glyph_metrics_t gm = layout.boundingBox(0, text.length());-
308 return
never executed: return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
never executed: return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
0
309}-
310QRect QFontMetrics::boundingRect(QChar ch) const-
311{-
312 const int script = ch.script();-
313 QFontEngine *engine;-
314 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
&& ch.isLower()
ch.isLower()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
315 engine = d->smallCapsFontPrivate()->engineForScript(script);
never executed: engine = d->smallCapsFontPrivate()->engineForScript(script);
0
316 else-
317 engine = d->engineForScript(script);
never executed: engine = d->engineForScript(script);
0
318 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,708) : qt_noop());-
319-
320 d->alterCharForCapitalization(ch);-
321-
322 glyph_t glyph = engine->glyphIndex(ch.unicode());-
323-
324 glyph_metrics_t gm = engine->boundingBox(glyph);-
325 return
never executed: return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
never executed: return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
0
326}-
327QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &text, int tabStops,-
328 int *tabArray) const-
329{-
330 int tabArrayLen = 0;-
331 if (tabArray
tabArrayDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
332 while (tabArray[tabArrayLen]
tabArray[tabArrayLen]Description
TRUEnever evaluated
FALSEnever evaluated
)
0
333 tabArrayLen++;
never executed: tabArrayLen++;
0
334-
335 QRectF rb;-
336 QRectF rr(rect);-
337 qt_format_text(QFont(d.data()), rr, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray,-
338 tabArrayLen, 0);-
339-
340 return
never executed: return rb.toAlignedRect();
rb.toAlignedRect();
never executed: return rb.toAlignedRect();
0
341}-
342QSize QFontMetrics::size(int flags, const QString &text, int tabStops, int *tabArray) const-
343{-
344 return
never executed: return boundingRect(QRect(0,0,0,0), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size();
boundingRect(QRect(0,0,0,0), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size();
never executed: return boundingRect(QRect(0,0,0,0), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size();
0
345}-
346QRect QFontMetrics::tightBoundingRect(const QString &text) const-
347{-
348 if (text.length() == 0
text.length() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
349 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
350-
351 QStackTextEngine layout(text, QFont(d.data()));-
352 layout.ignoreBidi = true;-
353 layout.itemize();-
354 glyph_metrics_t gm = layout.tightBoundingBox(0, text.length());-
355 return
never executed: return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
never executed: return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
0
356}-
357QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags) const-
358{-
359 QString _text = text;-
360 if (!(flags & Qt::TextLongestVariant)
!(flags & Qt::...ongestVariant)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
361 int posA = 0;-
362 int posB = _text.indexOf(QLatin1Char('\x9c'));-
363 while (posB >= 0
posB >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
364 QString portion = _text.mid(posA, posB - posA);-
365 if (size(flags, portion).width() <= width
size(flags, po...dth() <= widthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
366 return
never executed: return portion;
portion;
never executed: return portion;
0
367 posA = posB + 1;-
368 posB = _text.indexOf(QLatin1Char('\x9c'), posA);-
369 }
never executed: end of block
0
370 _text = _text.mid(posA);-
371 }
never executed: end of block
0
372 QStackTextEngine engine(_text, QFont(d.data()));-
373 return
never executed: return engine.elidedText(mode, width, flags);
engine.elidedText(mode, width, flags);
never executed: return engine.elidedText(mode, width, flags);
0
374}-
375-
376-
377-
378-
379-
380-
381-
382int QFontMetrics::underlinePos() const-
383{-
384 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
385 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,903) : qt_noop());-
386 return
never executed: return qRound(engine->underlinePosition());
qRound(engine->underlinePosition());
never executed: return qRound(engine->underlinePosition());
0
387}-
388-
389-
390-
391-
392-
393-
394-
395int QFontMetrics::overlinePos() const-
396{-
397 return
never executed: return ascent() + 1;
ascent() + 1;
never executed: return ascent() + 1;
0
398}-
399-
400-
401-
402-
403-
404-
405-
406int QFontMetrics::strikeOutPos() const-
407{-
408 int pos = ascent() / 3;-
409 return
never executed: return pos > 0 ? pos : 1;
pos > 0 ? pos : 1;
never executed: return pos > 0 ? pos : 1;
0
410}-
411-
412-
413-
414-
415-
416-
417-
418int QFontMetrics::lineWidth() const-
419{-
420 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
421 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,939) : qt_noop());-
422 return
never executed: return qRound(engine->lineThickness());
qRound(engine->lineThickness());
never executed: return qRound(engine->lineThickness());
0
423}-
424QFontMetricsF::QFontMetricsF(const QFontMetrics &fontMetrics)-
425 : d(fontMetrics.d)-
426{-
427}
never executed: end of block
0
428-
429-
430-
431-
432-
433-
434QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other)-
435{-
436 d = other.d;-
437 return
never executed: return *this;
*this;
never executed: return *this;
0
438}-
439QFontMetricsF::QFontMetricsF(const QFont &font)-
440 : d(font.d)-
441{-
442}
never executed: end of block
0
443QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice)-
444{-
445 int dpi = paintdevice
paintdeviceDescription
TRUEnever evaluated
FALSEnever evaluated
? paintdevice->logicalDpiY() : qt_defaultDpi();
0
446 const int screen = 0;-
447 if (font.d->dpi != dpi
font.d->dpi != dpiDescription
TRUEnever evaluated
FALSEnever evaluated
|| font.d->screen != screen
font.d->screen != screenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
448 d = new QFontPrivate(*font.d);-
449 d->dpi = dpi;-
450 d->screen = screen;-
451 }
never executed: end of block
else {
0
452 d = font.d;-
453 }
never executed: end of block
0
454-
455}-
456-
457-
458-
459-
460QFontMetricsF::QFontMetricsF(const QFontMetricsF &fm)-
461 : d(fm.d)-
462{-
463}
never executed: end of block
0
464-
465-
466-
467-
468-
469QFontMetricsF::~QFontMetricsF()-
470{-
471}-
472-
473-
474-
475-
476QFontMetricsF &QFontMetricsF::operator=(const QFontMetricsF &fm)-
477{-
478 d = fm.d;-
479 return
never executed: return *this;
*this;
never executed: return *this;
0
480}-
481bool QFontMetricsF::operator ==(const QFontMetricsF &other) const-
482{-
483 return
never executed: return d == other.d;
d == other.d;
never executed: return d == other.d;
0
484}-
485qreal QFontMetricsF::ascent() const-
486{-
487 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
488 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1137) : qt_noop());-
489 return
never executed: return engine->ascent().toReal();
engine->ascent().toReal();
never executed: return engine->ascent().toReal();
0
490}-
491qreal QFontMetricsF::descent() const-
492{-
493 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
494 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1156) : qt_noop());-
495 return
never executed: return engine->descent().toReal();
engine->descent().toReal();
never executed: return engine->descent().toReal();
0
496}-
497qreal QFontMetricsF::height() const-
498{-
499 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
500 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1170) : qt_noop());-
501-
502 return
never executed: return (engine->ascent() + engine->descent()).toReal();
(engine->ascent() + engine->descent()).toReal();
never executed: return (engine->ascent() + engine->descent()).toReal();
0
503}-
504qreal QFontMetricsF::leading() const-
505{-
506 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
507 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1185) : qt_noop());-
508 return
never executed: return engine->leading().toReal();
engine->leading().toReal();
never executed: return engine->leading().toReal();
0
509}-
510qreal QFontMetricsF::lineSpacing() const-
511{-
512 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
513 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1199) : qt_noop());-
514 return
never executed: return (engine->leading() + engine->ascent() + engine->descent()).toReal();
(engine->leading() + engine->ascent() + engine->descent()).toReal();
never executed: return (engine->leading() + engine->ascent() + engine->descent()).toReal();
0
515}-
516qreal QFontMetricsF::minLeftBearing() const-
517{-
518 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
519 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1216) : qt_noop());-
520 return
never executed: return engine->minLeftBearing();
engine->minLeftBearing();
never executed: return engine->minLeftBearing();
0
521}-
522qreal QFontMetricsF::minRightBearing() const-
523{-
524 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
525 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1233) : qt_noop());-
526 return
never executed: return engine->minRightBearing();
engine->minRightBearing();
never executed: return engine->minRightBearing();
0
527}-
528-
529-
530-
531-
532qreal QFontMetricsF::maxWidth() const-
533{-
534 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
535 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1243) : qt_noop());-
536 return
never executed: return engine->maxCharWidth();
engine->maxCharWidth();
never executed: return engine->maxCharWidth();
0
537}-
538-
539-
540-
541-
542-
543qreal QFontMetricsF::xHeight() const-
544{-
545 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
546 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1254) : qt_noop());-
547 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
548 return
never executed: return d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal();
d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal();
never executed: return d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal();
0
549 return
never executed: return engine->xHeight().toReal();
engine->xHeight().toReal();
never executed: return engine->xHeight().toReal();
0
550}-
551-
552-
553-
554-
555-
556-
557qreal QFontMetricsF::averageCharWidth() const-
558{-
559 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
560 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1268) : qt_noop());-
561 return
never executed: return engine->averageCharWidth().toReal();
engine->averageCharWidth().toReal();
never executed: return engine->averageCharWidth().toReal();
0
562}-
563-
564-
565-
566-
567-
568bool QFontMetricsF::inFont(QChar ch) const-
569{-
570 return
never executed: return inFontUcs4(ch.unicode());
inFontUcs4(ch.unicode());
never executed: return inFontUcs4(ch.unicode());
0
571}-
572-
573-
574-
575-
576-
577-
578-
579bool QFontMetricsF::inFontUcs4(uint ucs4) const-
580{-
581 const int script = QChar::script(ucs4);-
582 QFontEngine *engine = d->engineForScript(script);-
583 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1291) : qt_noop());-
584 if (engine->type() == QFontEngine::Box
engine->type()...ontEngine::BoxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
585 return
never executed: return false;
false;
never executed: return false;
0
586 return
never executed: return engine->canRender(ucs4);
engine->canRender(ucs4);
never executed: return engine->canRender(ucs4);
0
587}-
588qreal QFontMetricsF::leftBearing(QChar ch) const-
589{-
590 const int script = ch.script();-
591 QFontEngine *engine;-
592 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
&& ch.isLower()
ch.isLower()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
593 engine = d->smallCapsFontPrivate()->engineForScript(script);
never executed: engine = d->smallCapsFontPrivate()->engineForScript(script);
0
594 else-
595 engine = d->engineForScript(script);
never executed: engine = d->engineForScript(script);
0
596 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1317) : qt_noop());-
597 if (engine->type() == QFontEngine::Box
engine->type()...ontEngine::BoxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
598 return
never executed: return 0;
0;
never executed: return 0;
0
599-
600 d->alterCharForCapitalization(ch);-
601-
602 glyph_t glyph = engine->glyphIndex(ch.unicode());-
603-
604 qreal lb;-
605 engine->getGlyphBearings(glyph, &lb);-
606 return
never executed: return lb;
lb;
never executed: return lb;
0
607}-
608qreal QFontMetricsF::rightBearing(QChar ch) const-
609{-
610 const int script = ch.script();-
611 QFontEngine *engine;-
612 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
&& ch.isLower()
ch.isLower()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
613 engine = d->smallCapsFontPrivate()->engineForScript(script);
never executed: engine = d->smallCapsFontPrivate()->engineForScript(script);
0
614 else-
615 engine = d->engineForScript(script);
never executed: engine = d->engineForScript(script);
0
616 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1350) : qt_noop());-
617 if (engine->type() == QFontEngine::Box
engine->type()...ontEngine::BoxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
618 return
never executed: return 0;
0;
never executed: return 0;
0
619-
620 d->alterCharForCapitalization(ch);-
621-
622 glyph_t glyph = engine->glyphIndex(ch.unicode());-
623-
624 qreal rb;-
625 engine->getGlyphBearings(glyph, 0, &rb);-
626 return
never executed: return rb;
rb;
never executed: return rb;
0
627-
628}-
629qreal QFontMetricsF::width(const QString &text) const-
630{-
631 int pos = text.indexOf(QLatin1Char('\x9c'));-
632 int len = (
(pos != -1)Description
TRUEnever evaluated
FALSEnever evaluated
pos != -1)
(pos != -1)Description
TRUEnever evaluated
FALSEnever evaluated
? pos : text.length();
0
633-
634 QStackTextEngine layout(text, QFont(d.data()));-
635 layout.ignoreBidi = true;-
636 layout.itemize();-
637 return
never executed: return layout.width(0, len).toReal();
layout.width(0, len).toReal();
never executed: return layout.width(0, len).toReal();
0
638}-
639qreal QFontMetricsF::width(QChar ch) const-
640{-
641 if (ch.category() == QChar::Mark_NonSpacing
ch.category() ...ark_NonSpacingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
642 return
never executed: return 0.;
0.;
never executed: return 0.;
0
643-
644 const int script = ch.script();-
645 QFontEngine *engine;-
646 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
&& ch.isLower()
ch.isLower()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
647 engine = d->smallCapsFontPrivate()->engineForScript(script);
never executed: engine = d->smallCapsFontPrivate()->engineForScript(script);
0
648 else-
649 engine = d->engineForScript(script);
never executed: engine = d->engineForScript(script);
0
650 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1420) : qt_noop());-
651-
652 d->alterCharForCapitalization(ch);-
653-
654 glyph_t glyph = engine->glyphIndex(ch.unicode());-
655 QFixed advance;-
656-
657 QGlyphLayout glyphs;-
658 glyphs.numGlyphs = 1;-
659 glyphs.glyphs = &glyph;-
660 glyphs.advances = &advance;-
661 engine->recalcAdvances(&glyphs, 0);-
662-
663 return
never executed: return advance.toReal();
advance.toReal();
never executed: return advance.toReal();
0
664}-
665QRectF QFontMetricsF::boundingRect(const QString &text) const-
666{-
667 int len = text.length();-
668 if (len == 0
len == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
669 return
never executed: return QRectF();
QRectF();
never executed: return QRectF();
0
670-
671 QStackTextEngine layout(text, QFont(d.data()));-
672 layout.ignoreBidi = true;-
673 layout.itemize();-
674 glyph_metrics_t gm = layout.boundingBox(0, len);-
675 return
never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
QRectF(gm.x.toReal(), gm.y.toReal(),
never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
0
676 gm.width.toReal(), gm.height.toReal());
never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
0
677}-
678QRectF QFontMetricsF::boundingRect(QChar ch) const-
679{-
680 const int script = ch.script();-
681 QFontEngine *engine;-
682 if (d->capital == QFont::SmallCaps
d->capital == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
&& ch.isLower()
ch.isLower()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
683 engine = d->smallCapsFontPrivate()->engineForScript(script);
never executed: engine = d->smallCapsFontPrivate()->engineForScript(script);
0
684 else-
685 engine = d->engineForScript(script);
never executed: engine = d->engineForScript(script);
0
686 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1491) : qt_noop());-
687-
688 d->alterCharForCapitalization(ch);-
689-
690 glyph_t glyph = engine->glyphIndex(ch.unicode());-
691-
692 glyph_metrics_t gm = engine->boundingBox(glyph);-
693 return
never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
0
694}-
695QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString& text,-
696 int tabStops, int *tabArray) const-
697{-
698 int tabArrayLen = 0;-
699 if (tabArray
tabArrayDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
700 while (tabArray[tabArrayLen]
tabArray[tabArrayLen]Description
TRUEnever evaluated
FALSEnever evaluated
)
0
701 tabArrayLen++;
never executed: tabArrayLen++;
0
702-
703 QRectF rb;-
704 qt_format_text(QFont(d.data()), rect, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray,-
705 tabArrayLen, 0);-
706 return
never executed: return rb;
rb;
never executed: return rb;
0
707}-
708QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *tabArray) const-
709{-
710 return
never executed: return boundingRect(QRectF(), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size();
boundingRect(QRectF(), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size();
never executed: return boundingRect(QRectF(), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size();
0
711}-
712QRectF QFontMetricsF::tightBoundingRect(const QString &text) const-
713{-
714 if (text.length() == 0
text.length() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
715 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
716-
717 QStackTextEngine layout(text, QFont(d.data()));-
718 layout.ignoreBidi = true;-
719 layout.itemize();-
720 glyph_metrics_t gm = layout.tightBoundingBox(0, text.length());-
721 return
never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
0
722}-
723QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags) const-
724{-
725 QString _text = text;-
726 if (!(flags & Qt::TextLongestVariant)
!(flags & Qt::...ongestVariant)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
727 int posA = 0;-
728 int posB = _text.indexOf(QLatin1Char('\x9c'));-
729 while (posB >= 0
posB >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
730 QString portion = _text.mid(posA, posB - posA);-
731 if (size(flags, portion).width() <= width
size(flags, po...dth() <= widthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
732 return
never executed: return portion;
portion;
never executed: return portion;
0
733 posA = posB + 1;-
734 posB = _text.indexOf(QLatin1Char('\x9c'), posA);-
735 }
never executed: end of block
0
736 _text = _text.mid(posA);-
737 }
never executed: end of block
0
738 QStackTextEngine engine(_text, QFont(d.data()));-
739 return
never executed: return engine.elidedText(mode, QFixed::fromReal(width), flags);
engine.elidedText(mode, QFixed::fromReal(width), flags);
never executed: return engine.elidedText(mode, QFixed::fromReal(width), flags);
0
740}-
741-
742-
743-
744-
745-
746-
747-
748qreal QFontMetricsF::underlinePos() const-
749{-
750 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
751 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1690) : qt_noop());-
752 return
never executed: return engine->underlinePosition().toReal();
engine->underlinePosition().toReal();
never executed: return engine->underlinePosition().toReal();
0
753}-
754-
755-
756-
757-
758-
759-
760-
761qreal QFontMetricsF::overlinePos() const-
762{-
763 return
never executed: return ascent() + 1;
ascent() + 1;
never executed: return ascent() + 1;
0
764}-
765-
766-
767-
768-
769-
770-
771-
772qreal QFontMetricsF::strikeOutPos() const-
773{-
774 return
never executed: return ascent() / 3.;
ascent() / 3.;
never executed: return ascent() / 3.;
0
775}-
776-
777-
778-
779-
780-
781-
782-
783qreal QFontMetricsF::lineWidth() const-
784{-
785 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
786 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1725) : qt_noop());-
787 return
never executed: return engine->lineThickness().toReal();
engine->lineThickness().toReal();
never executed: return engine->lineThickness().toReal();
0
788}-
789-
790-
Switch to Source codePreprocessed file

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