Index: autotests/src/inlinenote_test.cpp =================================================================== --- autotests/src/inlinenote_test.cpp +++ autotests/src/inlinenote_test.cpp @@ -64,7 +64,7 @@ QSize inlineNoteSize(const InlineNote& note) const override { if (note.position().column() == 5) { - const auto xWidth = QFontMetrics(note.font()).width(QStringLiteral("x")); + const auto xWidth = QFontMetrics(note.font()).boundingRect(QStringLiteral("x")).width(); return QSize(xWidth, note.lineHeight()); } else if (note.position().column() == 10) { return QSize(note.lineHeight(), note.lineHeight()); Index: src/printing/printpainter.cpp =================================================================== --- src/printing/printpainter.cpp +++ src/printing/printpainter.cpp @@ -174,7 +174,7 @@ QString s = QStringLiteral("%1 ").arg(m_doc->lines()); s.fill(QLatin1Char('5'), -1); // some non-fixed fonts haven't equally wide numbers // FIXME calculate which is actually the widest... - m_lineNumberWidth = m_renderer->currentFontMetrics().width(s); + m_lineNumberWidth = m_renderer->currentFontMetrics().boundingRect(s).width(); } void PrintPainter::paint(QPrinter *printer) const @@ -244,7 +244,7 @@ if (m_printLineNumbers) { // a small space between the line numbers and the text - int _adj = m_renderer->currentFontMetrics().width(QStringLiteral("5")); + int _adj = m_renderer->currentFontMetrics().horizontalAdvance(QStringLiteral("5")); // adjust available width and set horizontal start point for data pl.maxWidth -= m_lineNumberWidth + _adj; pl.xstart += m_lineNumberWidth + _adj; @@ -536,7 +536,8 @@ int _widest(0); for (const KTextEditor::Attribute::Ptr &attribute : qAsConst(_attributes)) { - _widest = qMax(QFontMetrics(attribute->font()).width(attribute->name().section(QLatin1Char(':'), 1, 1)), _widest); + const QString _name = attribute->name().section(QLatin1Char(':'), 1, 1); + _widest = qMax(QFontMetrics(attribute->font()).boundingRect(_name).width(), _widest); } const int _guideCols = _w / (_widest + pl.innerMargin); Index: src/render/katerenderer.cpp =================================================================== --- src/render/katerenderer.cpp +++ src/render/katerenderer.cpp @@ -322,7 +322,7 @@ paint.setRenderHint(QPainter::Antialiasing, false); const int height = fontHeight(); - const int width = config()->fontMetrics().width(chr); + const int width = config()->fontMetrics().boundingRect(chr).width(); const int offset = spaceWidth() * 0.1; QPoint points[8]; @@ -904,7 +904,7 @@ const QPainter::RenderHints backupRenderHints = paint.renderHints(); paint.setRenderHint(QPainter::Antialiasing, false); paint.setPen(config()->wordWrapMarkerColor()); - int _x = qreal(m_doc->config()->wordWrapAt()) * fm.width(QLatin1Char('x')) - xStart; + int _x = qreal(m_doc->config()->wordWrapAt()) * fm.horizontalAdvance(QLatin1Char('x')) - xStart; paint.drawLine(_x, 0, _x, lineHeight()); paint.setRenderHints(backupRenderHints); } @@ -1015,7 +1015,7 @@ qreal KateRenderer::spaceWidth() const { - return config()->fontMetrics().width(spaceChar); + return config()->fontMetrics().horizontalAdvance(spaceChar); } void KateRenderer::layoutLine(KateLineLayoutPtr lineLayout, int maxwidth, bool cacheLayout) const @@ -1040,7 +1040,7 @@ // Tab width QTextOption opt; opt.setFlags(QTextOption::IncludeTrailingSpaces); - opt.setTabStop(m_tabWidth * config()->fontMetrics().width(spaceChar)); + opt.setTabStopDistance(m_tabWidth * config()->fontMetrics().horizontalAdvance(spaceChar)); opt.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); // Find the first strong character in the string. Index: src/view/kateannotationitemdelegate.cpp =================================================================== --- src/view/kateannotationitemdelegate.cpp +++ src/view/kateannotationitemdelegate.cpp @@ -150,7 +150,7 @@ // based on old code written when just a hash was shown, could see an update // Loop to determine the widest numeric character in the current font. for (char c = '0'; c <= '9'; ++c) { - const qreal charWidth = ceil(option.contentFontMetrics.width(QLatin1Char(c))); + const qreal charWidth = ceil(option.contentFontMetrics.boundingRect(QLatin1Char(c)).width()); m_maxCharWidth = qMax(m_maxCharWidth, charWidth); } Index: src/view/katetextanimation.cpp =================================================================== --- src/view/katetextanimation.cpp +++ src/view/katetextanimation.cpp @@ -70,7 +70,7 @@ return QRectF(); } else { QRectF rect(pixelPos.x(), pixelPos.y(), - fm.width(m_view->view()->doc()->text(m_range)), lineHeight); + fm.boundingRect(m_view->view()->doc()->text(m_range)).width(), lineHeight); const QPointF center = rect.center(); const qreal factor = 1.0 + 0.5 * m_value; rect.setWidth(rect.width() * factor); Index: src/view/kateviewhelpers.cpp =================================================================== --- src/view/kateviewhelpers.cpp +++ src/view/kateviewhelpers.cpp @@ -1606,7 +1606,7 @@ // Loop to determine the widest numeric character in the current font. // 48 is ascii '0' for (int i = 48; i < 58; i++) { - const qreal charWidth = ceil(fm.width(QChar(i))); + const qreal charWidth = ceil(fm.boundingRect(QChar(i)).width()); m_maxCharWidth = qMax(m_maxCharWidth, charWidth); } Index: src/view/kateviewinternal.cpp =================================================================== --- src/view/kateviewinternal.cpp +++ src/view/kateviewinternal.cpp @@ -624,7 +624,7 @@ if (view()->config()->dynWrapAtStaticMarker() && view()->config()->dynWordWrap()) { // We need to transform char count to a pixel width, stolen from PrintPainter::updateCache() QString s; s.fill(QLatin1Char('5'), view()->doc()->config()->wordWrapAt()); - wrapWidth = qMin(width(), static_cast(renderer()->currentFontMetrics().width(s))); + wrapWidth = qMin(width(), static_cast(renderer()->currentFontMetrics().boundingRect(s).width())); } if (wrapWidth != cache()->viewWidth()) { @@ -687,7 +687,7 @@ m_columnScroll->setValue(startX()); // Approximate linescroll - m_columnScroll->setSingleStep(renderer()->config()->fontMetrics().width(QLatin1Char('a'))); + m_columnScroll->setSingleStep(renderer()->config()->fontMetrics().horizontalAdvance(QLatin1Char('a'))); m_columnScroll->setPageStep(width()); m_columnScroll->blockSignals(blocked); @@ -1513,7 +1513,7 @@ if (maxX && range.wrap()) { QChar lastCharInLine = doc()->kateTextLine(range.line())->at(range.endCol() - 1); - maxX -= renderer()->config()->fontMetrics().width(lastCharInLine); + maxX -= renderer()->config()->fontMetrics().horizontalAdvance(lastCharInLine); } return maxX;