diff options
Diffstat (limited to 'src/quick/items/qquicktext.cpp')
-rw-r--r-- | src/quick/items/qquicktext.cpp | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 80321cf5d1..2bfb4501fc 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -69,6 +69,7 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(DBG_HOVER_TRACE) const QChar QQuickTextPrivate::elideChar = QChar(0x2026); @@ -321,7 +322,7 @@ void QQuickText::imageDownloadFinished() if (d->extra.isAllocated() && d->extra->nbActiveDownloads == 0) { bool needToUpdateLayout = false; - foreach (QQuickStyledTextImgTag *img, d->extra->visibleImgTags) { + for (QQuickStyledTextImgTag *img : qAsConst(d->extra->visibleImgTags)) { if (!img->size.isValid()) { img->size = img->pix->implicitSize(); needToUpdateLayout = true; @@ -1114,7 +1115,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal QList<QQuickStyledTextImgTag *> imagesInLine; if (extra.isAllocated()) { - foreach (QQuickStyledTextImgTag *image, extra->imgTags) { + for (QQuickStyledTextImgTag *image : qAsConst(extra->imgTags)) { if (image->position >= line.textStart() && image->position < line.textStart() + line.textLength()) { @@ -1151,7 +1152,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal } } - foreach (QQuickStyledTextImgTag *image, imagesInLine) { + for (QQuickStyledTextImgTag *image : qAsConst(imagesInLine)) { totalLineHeight = qMax(totalLineHeight, textTop + image->pos.y() + image->size.height()); const int leadX = line.cursorToX(image->position); const int trailX = line.cursorToX(image->position, QTextLine::Trailing); @@ -1431,6 +1432,39 @@ QQuickText::~QQuickText() Text { text: "Hello"; font.capitalization: Font.AllLowercase } \endqml */ + +/*! + \qmlproperty enumeration QtQuick::Text::font.hintingPreference + \since 5.8 + + Sets the preferred hinting on the text. This is a hint to the underlying text rendering system + to use a certain level of hinting, and has varying support across platforms. See the table in + the documentation for QFont::HintingPreference for more details. + + \note This property only has an effect when used together with render type Text.NativeRendering. + + \list + \value Font.PreferDefaultHinting - Use the default hinting level for the target platform. + \value Font.PreferNoHinting - If possible, render text without hinting the outlines + of the glyphs. The text layout will be typographically accurate, using the same metrics + as are used e.g. when printing. + \value Font.PreferVerticalHinting - If possible, render text with no horizontal hinting, + but align glyphs to the pixel grid in the vertical direction. The text will appear + crisper on displays where the density is too low to give an accurate rendering + of the glyphs. But since the horizontal metrics of the glyphs are unhinted, the text's + layout will be scalable to higher density devices (such as printers) without impacting + details such as line breaks. + \value Font.PreferFullHinting - If possible, render text with hinting in both horizontal and + vertical directions. The text will be altered to optimize legibility on the target + device, but since the metrics will depend on the target size of the text, the positions + of glyphs, line breaks, and other typographical detail will not scale, meaning that a + text layout may look different on devices with different pixel densities. + \endlist + + \qml + Text { text: "Hello"; renderType: Text.NativeRendering; font.hintingPreference: Font.PreferVerticalHinting } + \endqml +*/ QFont QQuickText::font() const { Q_D(const QQuickText); @@ -2308,7 +2342,7 @@ QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data node->addTextLayout(QPointF(dx, dy), d->elideLayout, color, d->style, styleColor, linkColor); if (d->extra.isAllocated()) { - foreach (QQuickStyledTextImgTag *img, d->extra->visibleImgTags) { + for (QQuickStyledTextImgTag *img : qAsConst(d->extra->visibleImgTags)) { QQuickPixmap *pix = img->pix; if (pix && pix->isReady()) node->addImage(QRectF(img->pos.x() + dx, img->pos.y() + dy, pix->width(), pix->height()), pix->image()); @@ -2562,7 +2596,8 @@ QString QQuickTextPrivate::anchorAt(const QTextLayout *layout, const QPointF &mo QTextLine line = layout->lineAt(i); if (line.naturalTextRect().contains(mousePos)) { int charPos = line.xToCursor(mousePos.x(), QTextLine::CursorOnCharacter); - foreach (const QTextLayout::FormatRange &formatRange, layout->formats()) { + const auto formats = layout->formats(); + for (const QTextLayout::FormatRange &formatRange : formats) { if (formatRange.format.isAnchor() && charPos >= formatRange.start && charPos < formatRange.start + formatRange.length) { @@ -2691,6 +2726,7 @@ QString QQuickText::hoveredLink() const void QQuickTextPrivate::processHoverEvent(QHoverEvent *event) { Q_Q(QQuickText); + qCDebug(DBG_HOVER_TRACE) << q; QString link; if (isLinkHoveredConnected()) { if (event->type() != QEvent::HoverLeave) |