From ee2ad9df701b27790e2ab72e99111d255fde42ed Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 2 Aug 2017 11:38:10 +0200 Subject: Add QFontMetrics(F)::horizontalAdvance() function A source of constant confusion is the QFontMetrics::width() function, which does not return the bounding width of the text, but the advance width. We deprecate this and add horizontalAdvance() instead, to avoid the confusion in the future. Note that there was an internal width() overload which was only there for the purpose of supporting the Qt::TextBypassShaping flag. This flag has already been replaced by public API, so no such overload is added. Instead, we deprecate the TextBypassShaping flag as well, which makes sense, since a replacement has been made. Also note that there was a consistency problem with QFontMetrics and QFontMetricsF, which are supposed to be interchangeable. The QFontMetrics::width() functions for strings took an optional int length argument, while the floating point version did not. This error is corrected in the advance() functions. [ChangeLog][QtGui][Text] Added QFontMetrics::horizontalAdvance() and QFontMetricsF::horizontalAdvance() to replace the confusingly named width() function. The latter has now been deprecated. Change-Id: I0dfda43aa65c8235be32c62fade82cae05b29c79 Reviewed-by: Lars Knoll --- src/gui/painting/qpainter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/painting/qpainter.cpp') diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index b95f9b18aa..6876a72e6e 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5850,7 +5850,7 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif if (!d->engine || str.isEmpty() || pen().style() == Qt::NoPen) return; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_DEPRECATED_SINCE(5, 11) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (tf & Qt::TextBypassShaping) { // Skip complex shaping, shape using glyph advances only int len = str.length(); -- cgit v1.2.3