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