| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qfontmetrics.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | extern 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); | - | ||||||||||||
| 10 | QFontMetrics::QFontMetrics(const QFont &font) | - | ||||||||||||
| 11 | : d(font.d.data())) | - | ||||||||||||
| 12 | { | - | ||||||||||||
| 13 | } never executed:  end of block | 0 | ||||||||||||
| 14 | QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice) | - | ||||||||||||
| 15 | { | - | ||||||||||||
| 16 |     int dpi = paintdevice
  | 0 | ||||||||||||
| 17 | const int screen = 0; | - | ||||||||||||
| 18 |     if (font.d->dpi != dpi
 
  | 0 | ||||||||||||
| 19 | d = new QFontPrivate(*font.d); | - | ||||||||||||
| 20 | d->dpi = dpi; | - | ||||||||||||
| 21 | d->screen = screen; | - | ||||||||||||
| 22 |     } never executed:   else {end of block | 0 | ||||||||||||
| 23 | d = font.d.data();; | - | ||||||||||||
| 24 |     } never executed:  end of block | 0 | ||||||||||||
| 25 | - | |||||||||||||
| 26 | } | - | ||||||||||||
| 27 | - | |||||||||||||
| 28 | - | |||||||||||||
| 29 | - | |||||||||||||
| 30 | - | |||||||||||||
| 31 | QFontMetrics::QFontMetrics(const QFontMetrics &fm) | - | ||||||||||||
| 32 | : d(fm.d.data())) | - | ||||||||||||
| 33 | { | - | ||||||||||||
| 34 | } never executed:  end of block | 0 | ||||||||||||
| 35 | - | |||||||||||||
| 36 | - | |||||||||||||
| 37 | - | |||||||||||||
| 38 | - | |||||||||||||
| 39 | - | |||||||||||||
| 40 | QFontMetrics::~QFontMetrics() | - | ||||||||||||
| 41 | { | - | ||||||||||||
| 42 | } | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | - | |||||||||||||
| 45 | - | |||||||||||||
| 46 | - | |||||||||||||
| 47 | QFontMetrics &QFontMetrics::operator=(const QFontMetrics &fm) | - | ||||||||||||
| 48 | { | - | ||||||||||||
| 49 | d = fm.d.data();; | - | ||||||||||||
| 50 |     return never executed:   *this;return *this;never executed:  return *this; | 0 | ||||||||||||
| 51 | } | - | ||||||||||||
| 52 | bool QFontMetrics::operator ==(const QFontMetrics &other) const | - | ||||||||||||
| 53 | { | - | ||||||||||||
| 54 | return d == other.d; | - | ||||||||||||
| 55 | } | - | ||||||||||||
| 56 | int QFontMetrics::ascent() const | - | ||||||||||||
| 57 | { | - | ||||||||||||
| 58 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 59 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,267273) : qt_noop()); | - | ||||||||||||
| 60 | return qRound(engine->ascent()); | - | ||||||||||||
| 61 | } | - | ||||||||||||
| 62 | int QFontMetrics::descent() const | - | ||||||||||||
| 63 | { | - | ||||||||||||
| 64 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 65 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,285291) : qt_noop()); | - | ||||||||||||
| 66 | return qRound(engine->descent()); | - | ||||||||||||
| 67 | } | - | ||||||||||||
| 68 | int QFontMetrics::height() const | - | ||||||||||||
| 69 | { | - | ||||||||||||
| 70 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 71 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,299305) : qt_noop()); | - | ||||||||||||
| 72 | return qRound(engine->ascent()) + qRound(engine->descent()); | - | ||||||||||||
| 73 | } | - | ||||||||||||
| 74 | int QFontMetrics::leading() const | - | ||||||||||||
| 75 | { | - | ||||||||||||
| 76 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 77 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,313319) : qt_noop()); | - | ||||||||||||
| 78 | return qRound(engine->leading()); | - | ||||||||||||
| 79 | } | - | ||||||||||||
| 80 | int QFontMetrics::lineSpacing() const | - | ||||||||||||
| 81 | { | - | ||||||||||||
| 82 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 83 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,327333) : qt_noop()); | - | ||||||||||||
| 84 | return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent()); | - | ||||||||||||
| 85 | } | - | ||||||||||||
| 86 | int QFontMetrics::minLeftBearing() const | - | ||||||||||||
| 87 | { | - | ||||||||||||
| 88 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 89 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,344350) : qt_noop()); | - | ||||||||||||
| 90 | return qRound(engine->minLeftBearing()); | - | ||||||||||||
| 91 | } | - | ||||||||||||
| 92 | int QFontMetrics::minRightBearing() const | - | ||||||||||||
| 93 | { | - | ||||||||||||
| 94 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 95 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,361367) : qt_noop()); | - | ||||||||||||
| 96 | return qRound(engine->minRightBearing()); | - | ||||||||||||
| 97 | } | - | ||||||||||||
| 98 | - | |||||||||||||
| 99 | - | |||||||||||||
| 100 | - | |||||||||||||
| 101 | - | |||||||||||||
| 102 | int QFontMetrics::maxWidth() const | - | ||||||||||||
| 103 | { | - | ||||||||||||
| 104 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 105 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,371377) : qt_noop()); | - | ||||||||||||
| 106 | return qRound(engine->maxCharWidth()); | - | ||||||||||||
| 107 | } | - | ||||||||||||
| 108 | - | |||||||||||||
| 109 | - | |||||||||||||
| 110 | - | |||||||||||||
| 111 | - | |||||||||||||
| 112 | - | |||||||||||||
| 113 | int QFontMetrics::xHeight() const | - | ||||||||||||
| 114 | { | - | ||||||||||||
| 115 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 116 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,382388) : qt_noop()); | - | ||||||||||||
| 117 | if (d->capital == QFont::SmallCaps) | - | ||||||||||||
| 118 | return qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent()); | - | ||||||||||||
| 119 | return qRound(engine->xHeight()); | - | ||||||||||||
| 120 | } | - | ||||||||||||
| 121 | - | |||||||||||||
| 122 | - | |||||||||||||
| 123 | - | |||||||||||||
| 124 | - | |||||||||||||
| 125 | - | |||||||||||||
| 126 | - | |||||||||||||
| 127 | int QFontMetrics::averageCharWidth() const | - | ||||||||||||
| 128 | { | - | ||||||||||||
| 129 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 130 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,396402) : qt_noop()); | - | ||||||||||||
| 131 | return qRound(engine->averageCharWidth()); | - | ||||||||||||
| 132 | } | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | - | |||||||||||||
| 135 | - | |||||||||||||
| 136 | - | |||||||||||||
| 137 | - | |||||||||||||
| 138 | bool QFontMetrics::inFont(QChar ch) const | - | ||||||||||||
| 139 | { | - | ||||||||||||
| 140 | return inFontUcs4(ch.unicode()); | - | ||||||||||||
| 141 | } | - | ||||||||||||
| 142 | - | |||||||||||||
| 143 | - | |||||||||||||
| 144 | - | |||||||||||||
| 145 | - | |||||||||||||
| 146 | - | |||||||||||||
| 147 | bool 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__,417423) : qt_noop()); | - | ||||||||||||
| 152 | if (engine->type() == QFontEngine::Box) | - | ||||||||||||
| 153 | return false; | - | ||||||||||||
| 154 | return engine->canRender(ucs4); | - | ||||||||||||
| 155 | } | - | ||||||||||||
| 156 | int QFontMetrics::leftBearing(QChar ch) const | - | ||||||||||||
| 157 | { | - | ||||||||||||
| 158 | const int script = ch.script(); | - | ||||||||||||
| 159 | QFontEngine *engine; | - | ||||||||||||
| 160 | if (d->capital == QFont::SmallCaps && ch.isLower()) | - | ||||||||||||
| 161 | engine = d->smallCapsFontPrivate()->engineForScript(script); | - | ||||||||||||
| 162 | else | - | ||||||||||||
| 163 | engine = d->engineForScript(script); | - | ||||||||||||
| 164 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,443449) : qt_noop()); | - | ||||||||||||
| 165 | if (engine->type() == QFontEngine::Box) | - | ||||||||||||
| 166 | return 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 qRound(lb); | - | ||||||||||||
| 175 | } | - | ||||||||||||
| 176 | int QFontMetrics::rightBearing(QChar ch) const | - | ||||||||||||
| 177 | { | - | ||||||||||||
| 178 | const int script = ch.script(); | - | ||||||||||||
| 179 | QFontEngine *engine; | - | ||||||||||||
| 180 | if (d->capital == QFont::SmallCaps && ch.isLower()) | - | ||||||||||||
| 181 | engine = d->smallCapsFontPrivate()->engineForScript(script); | - | ||||||||||||
| 182 | else | - | ||||||||||||
| 183 | engine = d->engineForScript(script); | - | ||||||||||||
| 184 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,476482) : qt_noop()); | - | ||||||||||||
| 185 | if (engine->type() == QFontEngine::Box) | - | ||||||||||||
| 186 | return 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 qRound(rb); | - | ||||||||||||
| 195 | } | - | ||||||||||||
| 196 | int QFontMetrics::width(const QString &text, int len) const | - | ||||||||||||
| 197 | { | - | ||||||||||||
| 198 | return width(text, len, 0); | - | ||||||||||||
| 199 | } | - | ||||||||||||
| 200 | - | |||||||||||||
| 201 | - | |||||||||||||
| 202 | - | |||||||||||||
| 203 | - | |||||||||||||
| 204 | int QFontMetrics::width(const QString &text, int len, int flags) const | - | ||||||||||||
| 205 | { | - | ||||||||||||
| 206 | int pos = text.indexOf(QLatin1Char('\x9c')); | - | ||||||||||||
| 207 |     if (pos != -1
  | 0 | ||||||||||||
| 208 |         len = (
 
  | 0 | ||||||||||||
| 209 |     } never executed:   else if (len < 0end of block
  | 0 | ||||||||||||
| 210 | len = text.length(); | - | ||||||||||||
| 211 |     } never executed:  end of block | 0 | ||||||||||||
| 212 |     if (len == 0
  | 0 | ||||||||||||
| 213 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||
| 214 | - | |||||||||||||
| 215 |     if (flags & Qt::TextBypassShaping
  | 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)
  | 0 | ||||||||||||
| 221 |             do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,526532) : qt_noop()); __builtin_unreachable(); } never executed:   while (0);end of block | 0 | ||||||||||||
| 222 | - | |||||||||||||
| 223 | QFixed width; | - | ||||||||||||
| 224 |         for (int i = 0; i < numGlyphs
  | 0 | ||||||||||||
| 225 |             width += glyphs.advances[i]; never executed:  width += glyphs.advances[i]; | 0 | ||||||||||||
| 226 |         return never executed:   qRound(width);return 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:   qRound(layout.width(0, len));return qRound(layout.width(0, len));never executed:  return qRound(layout.width(0, len)); | 0 | ||||||||||||
| 232 | } | - | ||||||||||||
| 233 | int QFontMetrics::width(QChar ch) const | - | ||||||||||||
| 234 | { | - | ||||||||||||
| 235 | if (QChar::category(ch.unicode()) == QChar::Mark_NonSpacing) | - | ||||||||||||
| 236 | return 0; | - | ||||||||||||
| 237 | - | |||||||||||||
| 238 | const int script = ch.script(); | - | ||||||||||||
| 239 | QFontEngine *engine; | - | ||||||||||||
| 240 | if (d->capital == QFont::SmallCaps && ch.isLower()) | - | ||||||||||||
| 241 | engine = d->smallCapsFontPrivate()->engineForScript(script); | - | ||||||||||||
| 242 | else | - | ||||||||||||
| 243 | engine = d->engineForScript(script); | - | ||||||||||||
| 244 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,573580) : 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 qRound(advance); | - | ||||||||||||
| 258 | } | - | ||||||||||||
| 259 | int QFontMetrics::charWidth(const QString &text, int pos) const | - | ||||||||||||
| 260 | { | - | ||||||||||||
| 261 | int width = 0; | - | ||||||||||||
| 262 | if (pos < 0 || pos > (int)text.length()) | - | ||||||||||||
| 263 | return width; | - | ||||||||||||
| 264 | - | |||||||||||||
| 265 | QChar ch = text.at(pos); | - | ||||||||||||
| 266 | const int script = ch.script(); | - | ||||||||||||
| 267 | if (script != QChar::Script_Common) { | - | ||||||||||||
| 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 | } else if (ch.category() != QChar::Mark_NonSpacing) { | - | ||||||||||||
| 277 | QFontEngine *engine; | - | ||||||||||||
| 278 | if (d->capital == QFont::SmallCaps && ch.isLower()) | - | ||||||||||||
| 279 | engine = d->smallCapsFontPrivate()->engineForScript(script); | - | ||||||||||||
| 280 | else | - | ||||||||||||
| 281 | engine = d->engineForScript(script); | - | ||||||||||||
| 282 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,625632) : 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 | } | - | ||||||||||||
| 297 | return width; | - | ||||||||||||
| 298 | } | - | ||||||||||||
| 299 | QRect QFontMetrics::boundingRect(const QString &text) const | - | ||||||||||||
| 300 | { | - | ||||||||||||
| 301 |     if (text.length() == 0
  | 0 | ||||||||||||
| 302 |         return never executed:   QRect();return 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:   QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));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 | ||||||||||||
| 309 | } | - | ||||||||||||
| 310 | QRect QFontMetrics::boundingRect(QChar ch) const | - | ||||||||||||
| 311 | { | - | ||||||||||||
| 312 | const int script = ch.script(); | - | ||||||||||||
| 313 | QFontEngine *engine; | - | ||||||||||||
| 314 | if (d->capital == QFont::SmallCaps && ch.isLower()) | - | ||||||||||||
| 315 | engine = d->smallCapsFontPrivate()->engineForScript(script); | - | ||||||||||||
| 316 | else | - | ||||||||||||
| 317 | engine = d->engineForScript(script); | - | ||||||||||||
| 318 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,700708) : 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 QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); | - | ||||||||||||
| 326 | } | - | ||||||||||||
| 327 | QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &text, int tabStops, | - | ||||||||||||
| 328 | int *tabArray) const | - | ||||||||||||
| 329 | { | - | ||||||||||||
| 330 | int tabArrayLen = 0; | - | ||||||||||||
| 331 | if (tabArray) | - | ||||||||||||
| 332 | while (tabArray[tabArrayLen]) | - | ||||||||||||
| 333 | tabArrayLen++; | - | ||||||||||||
| 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 rb.toAlignedRect(); | - | ||||||||||||
| 341 | } | - | ||||||||||||
| 342 | QSize QFontMetrics::size(int flags, const QString &text, int tabStops, int *tabArray) const | - | ||||||||||||
| 343 | { | - | ||||||||||||
| 344 | return boundingRect(QRect(0,0,0,0), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size(); | - | ||||||||||||
| 345 | } | - | ||||||||||||
| 346 | QRect QFontMetrics::tightBoundingRect(const QString &text) const | - | ||||||||||||
| 347 | { | - | ||||||||||||
| 348 |     if (text.length() == 0
  | 0 | ||||||||||||
| 349 |         return never executed:   QRect();return 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:   QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));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 | ||||||||||||
| 356 | } | - | ||||||||||||
| 357 | QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags) const | - | ||||||||||||
| 358 | { | - | ||||||||||||
| 359 | QString _text = text; | - | ||||||||||||
| 360 | if (!(flags & Qt::TextLongestVariant)) { | - | ||||||||||||
| 361 | int posA = 0; | - | ||||||||||||
| 362 | int posB = _text.indexOf(QLatin1Char('\x9c')); | - | ||||||||||||
| 363 | while (posB >= 0) { | - | ||||||||||||
| 364 | QString portion = _text.mid(posA, posB - posA); | - | ||||||||||||
| 365 | if (size(flags, portion).width() <= width) | - | ||||||||||||
| 366 | return portion; | - | ||||||||||||
| 367 | posA = posB + 1; | - | ||||||||||||
| 368 | posB = _text.indexOf(QLatin1Char('\x9c'), posA); | - | ||||||||||||
| 369 | } | - | ||||||||||||
| 370 | _text = _text.mid(posA); | - | ||||||||||||
| 371 | } | - | ||||||||||||
| 372 | QStackTextEngine engine(_text, QFont(d.data())); | - | ||||||||||||
| 373 | return engine.elidedText(mode, width, flags); | - | ||||||||||||
| 374 | } | - | ||||||||||||
| 375 | - | |||||||||||||
| 376 | - | |||||||||||||
| 377 | - | |||||||||||||
| 378 | - | |||||||||||||
| 379 | - | |||||||||||||
| 380 | - | |||||||||||||
| 381 | - | |||||||||||||
| 382 | int QFontMetrics::underlinePos() const | - | ||||||||||||
| 383 | { | - | ||||||||||||
| 384 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 385 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,894903) : qt_noop()); | - | ||||||||||||
| 386 | return qRound(engine->underlinePosition()); | - | ||||||||||||
| 387 | } | - | ||||||||||||
| 388 | - | |||||||||||||
| 389 | - | |||||||||||||
| 390 | - | |||||||||||||
| 391 | - | |||||||||||||
| 392 | - | |||||||||||||
| 393 | - | |||||||||||||
| 394 | - | |||||||||||||
| 395 | int QFontMetrics::overlinePos() const | - | ||||||||||||
| 396 | { | - | ||||||||||||
| 397 | return ascent() + 1; | - | ||||||||||||
| 398 | } | - | ||||||||||||
| 399 | - | |||||||||||||
| 400 | - | |||||||||||||
| 401 | - | |||||||||||||
| 402 | - | |||||||||||||
| 403 | - | |||||||||||||
| 404 | - | |||||||||||||
| 405 | - | |||||||||||||
| 406 | int QFontMetrics::strikeOutPos() const | - | ||||||||||||
| 407 | { | - | ||||||||||||
| 408 | int pos = ascent() / 3; | - | ||||||||||||
| 409 | return pos > 0 ? pos : 1; | - | ||||||||||||
| 410 | } | - | ||||||||||||
| 411 | - | |||||||||||||
| 412 | - | |||||||||||||
| 413 | - | |||||||||||||
| 414 | - | |||||||||||||
| 415 | - | |||||||||||||
| 416 | - | |||||||||||||
| 417 | - | |||||||||||||
| 418 | int QFontMetrics::lineWidth() const | - | ||||||||||||
| 419 | { | - | ||||||||||||
| 420 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 421 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,930939) : qt_noop()); | - | ||||||||||||
| 422 | return qRound(engine->lineThickness()); | - | ||||||||||||
| 423 | } | - | ||||||||||||
| 424 | QFontMetricsF::QFontMetricsF(const QFontMetrics &fontMetrics) | - | ||||||||||||
| 425 | : d(fontMetrics.d.data())) | - | ||||||||||||
| 426 | { | - | ||||||||||||
| 427 | } never executed:  end of block | 0 | ||||||||||||
| 428 | - | |||||||||||||
| 429 | - | |||||||||||||
| 430 | - | |||||||||||||
| 431 | - | |||||||||||||
| 432 | - | |||||||||||||
| 433 | - | |||||||||||||
| 434 | QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other) | - | ||||||||||||
| 435 | { | - | ||||||||||||
| 436 | d = other.d.data();; | - | ||||||||||||
| 437 |     return never executed:   *this;return *this;never executed:  return *this; | 0 | ||||||||||||
| 438 | } | - | ||||||||||||
| 439 | QFontMetricsF::QFontMetricsF(const QFont &font) | - | ||||||||||||
| 440 | : d(font.d.data())) | - | ||||||||||||
| 441 | { | - | ||||||||||||
| 442 | } never executed:  end of block | 0 | ||||||||||||
| 443 | QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice) | - | ||||||||||||
| 444 | { | - | ||||||||||||
| 445 |     int dpi = paintdevice
  | 0 | ||||||||||||
| 446 | const int screen = 0; | - | ||||||||||||
| 447 |     if (font.d->dpi != dpi
 
  | 0 | ||||||||||||
| 448 | d = new QFontPrivate(*font.d); | - | ||||||||||||
| 449 | d->dpi = dpi; | - | ||||||||||||
| 450 | d->screen = screen; | - | ||||||||||||
| 451 |     } never executed:   else {end of block | 0 | ||||||||||||
| 452 | d = font.d.data();; | - | ||||||||||||
| 453 |     } never executed:  end of block | 0 | ||||||||||||
| 454 | - | |||||||||||||
| 455 | } | - | ||||||||||||
| 456 | - | |||||||||||||
| 457 | - | |||||||||||||
| 458 | - | |||||||||||||
| 459 | - | |||||||||||||
| 460 | QFontMetricsF::QFontMetricsF(const QFontMetricsF &fm) | - | ||||||||||||
| 461 | : d(fm.d.data())) | - | ||||||||||||
| 462 | { | - | ||||||||||||
| 463 | } never executed:  end of block | 0 | ||||||||||||
| 464 | - | |||||||||||||
| 465 | - | |||||||||||||
| 466 | - | |||||||||||||
| 467 | - | |||||||||||||
| 468 | - | |||||||||||||
| 469 | QFontMetricsF::~QFontMetricsF() | - | ||||||||||||
| 470 | { | - | ||||||||||||
| 471 | } | - | ||||||||||||
| 472 | - | |||||||||||||
| 473 | - | |||||||||||||
| 474 | - | |||||||||||||
| 475 | - | |||||||||||||
| 476 | QFontMetricsF &QFontMetricsF::operator=(const QFontMetricsF &fm) | - | ||||||||||||
| 477 | { | - | ||||||||||||
| 478 | d = fm.d.data();; | - | ||||||||||||
| 479 |     return never executed:   *this;return *this;never executed:  return *this; | 0 | ||||||||||||
| 480 | } | - | ||||||||||||
| 481 | bool QFontMetricsF::operator ==(const QFontMetricsF &other) const | - | ||||||||||||
| 482 | { | - | ||||||||||||
| 483 | return d == other.d; | - | ||||||||||||
| 484 | } | - | ||||||||||||
| 485 | qreal QFontMetricsF::ascent() const | - | ||||||||||||
| 486 | { | - | ||||||||||||
| 487 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 488 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,11281137) : qt_noop()); | - | ||||||||||||
| 489 | return engine->ascent().toReal(); | - | ||||||||||||
| 490 | } | - | ||||||||||||
| 491 | qreal QFontMetricsF::descent() const | - | ||||||||||||
| 492 | { | - | ||||||||||||
| 493 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 494 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,11471156) : qt_noop()); | - | ||||||||||||
| 495 | return engine->descent().toReal(); | - | ||||||||||||
| 496 | } | - | ||||||||||||
| 497 | qreal QFontMetricsF::height() const | - | ||||||||||||
| 498 | { | - | ||||||||||||
| 499 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 500 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,11611170) : qt_noop()); | - | ||||||||||||
| 501 | - | |||||||||||||
| 502 | return (engine->ascent() + engine->descent()).toReal(); | - | ||||||||||||
| 503 | } | - | ||||||||||||
| 504 | qreal QFontMetricsF::leading() const | - | ||||||||||||
| 505 | { | - | ||||||||||||
| 506 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 507 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,11761185) : qt_noop()); | - | ||||||||||||
| 508 | return engine->leading().toReal(); | - | ||||||||||||
| 509 | } | - | ||||||||||||
| 510 | qreal QFontMetricsF::lineSpacing() const | - | ||||||||||||
| 511 | { | - | ||||||||||||
| 512 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 513 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,11901199) : qt_noop()); | - | ||||||||||||
| 514 | return (engine->leading() + engine->ascent() + engine->descent()).toReal(); | - | ||||||||||||
| 515 | } | - | ||||||||||||
| 516 | qreal QFontMetricsF::minLeftBearing() const | - | ||||||||||||
| 517 | { | - | ||||||||||||
| 518 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 519 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,12071216) : qt_noop()); | - | ||||||||||||
| 520 | return engine->minLeftBearing(); | - | ||||||||||||
| 521 | } | - | ||||||||||||
| 522 | qreal QFontMetricsF::minRightBearing() const | - | ||||||||||||
| 523 | { | - | ||||||||||||
| 524 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 525 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,12241233) : qt_noop()); | - | ||||||||||||
| 526 | return engine->minRightBearing(); | - | ||||||||||||
| 527 | } | - | ||||||||||||
| 528 | - | |||||||||||||
| 529 | - | |||||||||||||
| 530 | - | |||||||||||||
| 531 | - | |||||||||||||
| 532 | qreal QFontMetricsF::maxWidth() const | - | ||||||||||||
| 533 | { | - | ||||||||||||
| 534 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 535 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,12341243) : qt_noop()); | - | ||||||||||||
| 536 | return engine->maxCharWidth(); | - | ||||||||||||
| 537 | } | - | ||||||||||||
| 538 | - | |||||||||||||
| 539 | - | |||||||||||||
| 540 | - | |||||||||||||
| 541 | - | |||||||||||||
| 542 | - | |||||||||||||
| 543 | qreal QFontMetricsF::xHeight() const | - | ||||||||||||
| 544 | { | - | ||||||||||||
| 545 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 546 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,12451254) : qt_noop()); | - | ||||||||||||
| 547 | if (d->capital == QFont::SmallCaps) | - | ||||||||||||
| 548 | return d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal(); | - | ||||||||||||
| 549 | return engine->xHeight().toReal(); | - | ||||||||||||
| 550 | } | - | ||||||||||||
| 551 | - | |||||||||||||
| 552 | - | |||||||||||||
| 553 | - | |||||||||||||
| 554 | - | |||||||||||||
| 555 | - | |||||||||||||
| 556 | - | |||||||||||||
| 557 | qreal QFontMetricsF::averageCharWidth() const | - | ||||||||||||
| 558 | { | - | ||||||||||||
| 559 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 560 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,12591268) : qt_noop()); | - | ||||||||||||
| 561 | return engine->averageCharWidth().toReal(); | - | ||||||||||||
| 562 | } | - | ||||||||||||
| 563 | - | |||||||||||||
| 564 | - | |||||||||||||
| 565 | - | |||||||||||||
| 566 | - | |||||||||||||
| 567 | - | |||||||||||||
| 568 | bool QFontMetricsF::inFont(QChar ch) const | - | ||||||||||||
| 569 | { | - | ||||||||||||
| 570 | return inFontUcs4(ch.unicode()); | - | ||||||||||||
| 571 | } | - | ||||||||||||
| 572 | - | |||||||||||||
| 573 | - | |||||||||||||
| 574 | - | |||||||||||||
| 575 | - | |||||||||||||
| 576 | - | |||||||||||||
| 577 | - | |||||||||||||
| 578 | - | |||||||||||||
| 579 | bool 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__,12821291) : qt_noop()); | - | ||||||||||||
| 584 | if (engine->type() == QFontEngine::Box) | - | ||||||||||||
| 585 | return false; | - | ||||||||||||
| 586 | return engine->canRender(ucs4); | - | ||||||||||||
| 587 | } | - | ||||||||||||
| 588 | qreal QFontMetricsF::leftBearing(QChar ch) const | - | ||||||||||||
| 589 | { | - | ||||||||||||
| 590 | const int script = ch.script(); | - | ||||||||||||
| 591 | QFontEngine *engine; | - | ||||||||||||
| 592 | if (d->capital == QFont::SmallCaps && ch.isLower()) | - | ||||||||||||
| 593 | engine = d->smallCapsFontPrivate()->engineForScript(script); | - | ||||||||||||
| 594 | else | - | ||||||||||||
| 595 | engine = d->engineForScript(script); | - | ||||||||||||
| 596 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,13081317) : qt_noop()); | - | ||||||||||||
| 597 | if (engine->type() == QFontEngine::Box) | - | ||||||||||||
| 598 | return 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 lb; | - | ||||||||||||
| 607 | } | - | ||||||||||||
| 608 | qreal QFontMetricsF::rightBearing(QChar ch) const | - | ||||||||||||
| 609 | { | - | ||||||||||||
| 610 | const int script = ch.script(); | - | ||||||||||||
| 611 | QFontEngine *engine; | - | ||||||||||||
| 612 | if (d->capital == QFont::SmallCaps && ch.isLower()) | - | ||||||||||||
| 613 | engine = d->smallCapsFontPrivate()->engineForScript(script); | - | ||||||||||||
| 614 | else | - | ||||||||||||
| 615 | engine = d->engineForScript(script); | - | ||||||||||||
| 616 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,13411350) : qt_noop()); | - | ||||||||||||
| 617 | if (engine->type() == QFontEngine::Box) | - | ||||||||||||
| 618 | return 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 rb; | - | ||||||||||||
| 627 | - | |||||||||||||
| 628 | } | - | ||||||||||||
| 629 | qreal QFontMetricsF::width(const QString &text) const | - | ||||||||||||
| 630 | { | - | ||||||||||||
| 631 | int pos = text.indexOf(QLatin1Char('\x9c')); | - | ||||||||||||
| 632 |     int len = (
 
  | 0 | ||||||||||||
| 633 | - | |||||||||||||
| 634 | QStackTextEngine layout(text, QFont(d.data())); | - | ||||||||||||
| 635 | layout.ignoreBidi = true; | - | ||||||||||||
| 636 | layout.itemize(); | - | ||||||||||||
| 637 |     return never executed:   layout.width(0, len).toReal();return layout.width(0, len).toReal();never executed:  return layout.width(0, len).toReal(); | 0 | ||||||||||||
| 638 | } | - | ||||||||||||
| 639 | qreal QFontMetricsF::width(QChar ch) const | - | ||||||||||||
| 640 | { | - | ||||||||||||
| 641 | if (ch.category() == QChar::Mark_NonSpacing) | - | ||||||||||||
| 642 | return 0.; | - | ||||||||||||
| 643 | - | |||||||||||||
| 644 | const int script = ch.script(); | - | ||||||||||||
| 645 | QFontEngine *engine; | - | ||||||||||||
| 646 | if (d->capital == QFont::SmallCaps && ch.isLower()) | - | ||||||||||||
| 647 | engine = d->smallCapsFontPrivate()->engineForScript(script); | - | ||||||||||||
| 648 | else | - | ||||||||||||
| 649 | engine = d->engineForScript(script); | - | ||||||||||||
| 650 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,14101420) : 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 advance.toReal(); | - | ||||||||||||
| 664 | } | - | ||||||||||||
| 665 | QRectF QFontMetricsF::boundingRect(const QString &text) const | - | ||||||||||||
| 666 | { | - | ||||||||||||
| 667 | int len = text.length(); | - | ||||||||||||
| 668 |     if (len == 0
  | 0 | ||||||||||||
| 669 |         return never executed:   QRectF();return 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:   QRectF(gm.x.toReal(), gm.y.toReal(),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 | ||||||||||||
| 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 | } | - | ||||||||||||
| 678 | QRectF QFontMetricsF::boundingRect(QChar ch) const | - | ||||||||||||
| 679 | { | - | ||||||||||||
| 680 | const int script = ch.script(); | - | ||||||||||||
| 681 | QFontEngine *engine; | - | ||||||||||||
| 682 | if (d->capital == QFont::SmallCaps && ch.isLower()) | - | ||||||||||||
| 683 | engine = d->smallCapsFontPrivate()->engineForScript(script); | - | ||||||||||||
| 684 | else | - | ||||||||||||
| 685 | engine = d->engineForScript(script); | - | ||||||||||||
| 686 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,14801491) : 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 QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); | - | ||||||||||||
| 694 | } | - | ||||||||||||
| 695 | QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString& text, | - | ||||||||||||
| 696 | int tabStops, int *tabArray) const | - | ||||||||||||
| 697 | { | - | ||||||||||||
| 698 | int tabArrayLen = 0; | - | ||||||||||||
| 699 | if (tabArray) | - | ||||||||||||
| 700 | while (tabArray[tabArrayLen]) | - | ||||||||||||
| 701 | tabArrayLen++; | - | ||||||||||||
| 702 | - | |||||||||||||
| 703 | QRectF rb; | - | ||||||||||||
| 704 | qt_format_text(QFont(d.data()), rect, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, | - | ||||||||||||
| 705 | tabArrayLen, 0); | - | ||||||||||||
| 706 | return rb; | - | ||||||||||||
| 707 | } | - | ||||||||||||
| 708 | QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *tabArray) const | - | ||||||||||||
| 709 | { | - | ||||||||||||
| 710 | return boundingRect(QRectF(), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size(); | - | ||||||||||||
| 711 | } | - | ||||||||||||
| 712 | QRectF QFontMetricsF::tightBoundingRect(const QString &text) const | - | ||||||||||||
| 713 | { | - | ||||||||||||
| 714 |     if (text.length() == 0
  | 0 | ||||||||||||
| 715 |         return never executed:   QRect();return 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:   QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());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 | ||||||||||||
| 722 | } | - | ||||||||||||
| 723 | QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags) const | - | ||||||||||||
| 724 | { | - | ||||||||||||
| 725 | QString _text = text; | - | ||||||||||||
| 726 | if (!(flags & Qt::TextLongestVariant)) { | - | ||||||||||||
| 727 | int posA = 0; | - | ||||||||||||
| 728 | int posB = _text.indexOf(QLatin1Char('\x9c')); | - | ||||||||||||
| 729 | while (posB >= 0) { | - | ||||||||||||
| 730 | QString portion = _text.mid(posA, posB - posA); | - | ||||||||||||
| 731 | if (size(flags, portion).width() <= width) | - | ||||||||||||
| 732 | return portion; | - | ||||||||||||
| 733 | posA = posB + 1; | - | ||||||||||||
| 734 | posB = _text.indexOf(QLatin1Char('\x9c'), posA); | - | ||||||||||||
| 735 | } | - | ||||||||||||
| 736 | _text = _text.mid(posA); | - | ||||||||||||
| 737 | } | - | ||||||||||||
| 738 | QStackTextEngine engine(_text, QFont(d.data())); | - | ||||||||||||
| 739 | return engine.elidedText(mode, QFixed::fromReal(width), flags); | - | ||||||||||||
| 740 | } | - | ||||||||||||
| 741 | - | |||||||||||||
| 742 | - | |||||||||||||
| 743 | - | |||||||||||||
| 744 | - | |||||||||||||
| 745 | - | |||||||||||||
| 746 | - | |||||||||||||
| 747 | - | |||||||||||||
| 748 | qreal QFontMetricsF::underlinePos() const | - | ||||||||||||
| 749 | { | - | ||||||||||||
| 750 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 751 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,16781690) : qt_noop()); | - | ||||||||||||
| 752 | return engine->underlinePosition().toReal(); | - | ||||||||||||
| 753 | } | - | ||||||||||||
| 754 | - | |||||||||||||
| 755 | - | |||||||||||||
| 756 | - | |||||||||||||
| 757 | - | |||||||||||||
| 758 | - | |||||||||||||
| 759 | - | |||||||||||||
| 760 | - | |||||||||||||
| 761 | qreal QFontMetricsF::overlinePos() const | - | ||||||||||||
| 762 | { | - | ||||||||||||
| 763 | return ascent() + 1; | - | ||||||||||||
| 764 | } | - | ||||||||||||
| 765 | - | |||||||||||||
| 766 | - | |||||||||||||
| 767 | - | |||||||||||||
| 768 | - | |||||||||||||
| 769 | - | |||||||||||||
| 770 | - | |||||||||||||
| 771 | - | |||||||||||||
| 772 | qreal QFontMetricsF::strikeOutPos() const | - | ||||||||||||
| 773 | { | - | ||||||||||||
| 774 | return ascent() / 3.; | - | ||||||||||||
| 775 | } | - | ||||||||||||
| 776 | - | |||||||||||||
| 777 | - | |||||||||||||
| 778 | - | |||||||||||||
| 779 | - | |||||||||||||
| 780 | - | |||||||||||||
| 781 | - | |||||||||||||
| 782 | - | |||||||||||||
| 783 | qreal QFontMetricsF::lineWidth() const | - | ||||||||||||
| 784 | { | - | ||||||||||||
| 785 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
| 786 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,17131725) : qt_noop()); | - | ||||||||||||
| 787 | return engine->lineThickness().toReal(); | - | ||||||||||||
| 788 | } | - | ||||||||||||
| 789 | - | |||||||||||||
| 790 | - | |||||||||||||
| Switch to Source code | Preprocessed file |