diff options
Diffstat (limited to 'src/gui/text/qfont.cpp')
-rw-r--r-- | src/gui/text/qfont.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 9e4f61ebee..3b24039ea6 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1376,6 +1376,7 @@ void QFont::setStyleStrategy(StyleStrategy s) Predefined stretch values that follow the CSS naming convention. The higher the value, the more stretched the text is. + \value AnyStretch 0 Accept any stretch matched using the other QFont properties (added in Qt 5.8) \value UltraCondensed 50 \value ExtraCondensed 62 \value Condensed 75 @@ -1402,20 +1403,25 @@ int QFont::stretch() const /*! Sets the stretch factor for the font. - The stretch factor changes the width of all characters in the font - by \a factor percent. For example, setting \a factor to 150 + The stretch factor matches a condensed or expanded version of the font or + applies a stretch transform that changes the width of all characters + in the font by \a factor percent. For example, setting \a factor to 150 results in all characters in the font being 1.5 times (ie. 150%) - wider. The default stretch factor is 100. The minimum stretch - factor is 1, and the maximum stretch factor is 4000. + wider. The minimum stretch factor is 1, and the maximum stretch factor + is 4000. The default stretch factor is \c AnyStretch, which will accept + any stretch factor and not apply any transform on the font. The stretch factor is only applied to outline fonts. The stretch factor is ignored for bitmap fonts. + \note When matching a font with a native non-default stretch factor, + requesting a stretch of 100 will stretch it back to a medium width font. + \sa stretch(), QFont::Stretch */ void QFont::setStretch(int factor) { - if (factor < 1 || factor > 4000) { + if (factor < 0 || factor > 4000) { qWarning("QFont::setStretch: Parameter '%d' out of range", factor); return; } @@ -2001,7 +2007,7 @@ QString QFont::key() const QString QFont::toString() const { const QChar comma(QLatin1Char(',')); - return family() + comma + + QString fontDescription = family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + @@ -2011,6 +2017,12 @@ QString QFont::toString() const QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); + + QString fontStyle = styleName(); + if (!fontStyle.isEmpty()) + fontDescription += comma + fontStyle; + + return fontDescription; } /*! @@ -2054,7 +2066,7 @@ bool QFont::fromString(const QString &descrip) setUnderline(l[5].toInt()); setStrikeOut(l[6].toInt()); setFixedPitch(l[7].toInt()); - } else if (count == 10) { + } else if (count >= 10) { if (l[2].toInt() > 0) setPixelSize(l[2].toInt()); setStyleHint((StyleHint) l[3].toInt()); @@ -2063,7 +2075,10 @@ bool QFont::fromString(const QString &descrip) setUnderline(l[6].toInt()); setStrikeOut(l[7].toInt()); setFixedPitch(l[8].toInt()); + if (count == 11) + d->request.styleName = l[10].toString(); } + if (count >= 9 && !d->request.fixedPitch) // assume 'false' fixedPitch equals default d->request.ignorePitch = true; |