summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qcssparser.cpp2
-rw-r--r--src/gui/text/qcssparser_p.h6
-rw-r--r--src/gui/text/qfont.cpp16
-rw-r--r--src/gui/text/qfont.h1
-rw-r--r--src/gui/text/qfont_p.h2
-rw-r--r--src/gui/text/qfontdatabase.cpp15
-rw-r--r--src/gui/text/qfontengine.cpp15
-rw-r--r--src/gui/text/qfontengine_ft.cpp55
-rw-r--r--src/gui/text/qfontengine_ft_p.h1
-rw-r--r--src/gui/text/qfontengine_p.h4
-rw-r--r--src/gui/text/qfontengine_qpf2.cpp5
-rw-r--r--src/gui/text/qfontengine_qpf2_p.h1
-rw-r--r--src/gui/text/qfontmetrics.cpp36
-rw-r--r--src/gui/text/qfontmetrics.h2
-rw-r--r--src/gui/text/qfontsubset.cpp2
-rw-r--r--src/gui/text/qrawfont.cpp17
-rw-r--r--src/gui/text/qrawfont.h1
-rw-r--r--src/gui/text/qtextcursor.cpp8
-rw-r--r--src/gui/text/qtextdocument_p.cpp10
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp18
-rw-r--r--src/gui/text/qtexthtmlparser.cpp6
-rw-r--r--src/gui/text/qtextodfwriter_p.h6
23 files changed, 161 insertions, 70 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 8894e4884b..4548b6f8b9 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -2111,7 +2111,7 @@ QString Scanner::preprocess(const QString &input, bool *hasEscapeSequences)
hexCount = qMin(hexCount, 6);
bool ok = false;
- ushort code = output.mid(hexStart, hexCount).toUShort(&ok, 16);
+ ushort code = output.midRef(hexStart, hexCount).toUShort(&ok, 16);
if (ok) {
output.replace(hexStart - 1, hexCount + 1, QChar(code));
i = hexStart;
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index f5cd5395b2..9f79e9934e 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -44,9 +44,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
//
// We mean it.
//
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 5e72e6969c..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;
}
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index b295e13f61..6f0dd27fbe 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -113,6 +113,7 @@ public:
};
enum Stretch {
+ AnyStretch = 0,
UltraCondensed = 50,
ExtraCondensed = 62,
Condensed = 75,
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index 21823dc12f..9e5d0b4329 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -71,7 +71,7 @@ struct QFontDef
inline QFontDef()
: pointSize(-1.0), pixelSize(-1),
styleStrategy(QFont::PreferDefault), styleHint(QFont::AnyStyle),
- weight(50), fixedPitch(false), style(QFont::StyleNormal), stretch(100),
+ weight(50), fixedPitch(false), style(QFont::StyleNormal), stretch(QFont::AnyStretch),
hintingPreference(QFont::PreferDefaultHinting), ignorePitch(true),
fixedPitchComputed(0), reserved(0)
{
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index ef09a0cacd..e8f29ce520 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -951,12 +951,14 @@ QFontEngine *loadSingleEngine(int script,
}
}
- // If the font data's native stretch matches the requested stretch we need to set stretch to 100
- // to avoid the fontengine synthesizing stretch. If they didn't match exactly we need to calculate
- // the new stretch factor. This only done if not matched by styleName.
+ // To avoid synthesized stretch we need a matching stretch to be 100 after this point.
+ // If stretch didn't match exactly we need to calculate the new stretch factor.
+ // This only done if not matched by styleName.
if (style->key.stretch != 0 && request.stretch != 0
&& (request.styleName.isEmpty() || request.styleName != style->styleName)) {
- def.stretch = (request.stretch * 100 + 50) / style->key.stretch;
+ def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+ } else {
+ def.stretch = 100;
}
engine = pfdb->fontEngine(def, size->handle);
@@ -1219,7 +1221,8 @@ static int match(int script, const QFontDef &request,
QtFontStyle::Key styleKey;
styleKey.style = request.style;
styleKey.weight = request.weight;
- styleKey.stretch = request.stretch;
+ // Prefer a stretch closest to 100.
+ styleKey.stretch = request.stretch ? request.stretch : 100;
char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p';
@@ -2740,8 +2743,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
}
if (req.pointSize < 0)
req.pointSize = req.pixelSize*72.0/d->dpi;
- if (req.stretch == 0)
- req.stretch = 100;
// respect the fallback families that might be passed through the request
const QStringList fallBackFamilies = familyList(req);
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index adc8f634dc..dbd47151bd 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -418,6 +418,13 @@ glyph_metrics_t QFontEngine::boundingBox(glyph_t glyph, const QTransform &matrix
return metrics;
}
+QFixed QFontEngine::calculatedCapHeight() const
+{
+ const glyph_t glyph = glyphIndex('H');
+ glyph_metrics_t bb = const_cast<QFontEngine *>(this)->boundingBox(glyph);
+ return bb.height;
+}
+
QFixed QFontEngine::xHeight() const
{
const glyph_t glyph = glyphIndex('x');
@@ -1703,6 +1710,11 @@ QFixed QFontEngineBox::ascent() const
return _size;
}
+QFixed QFontEngineBox::capHeight() const
+{
+ return _size;
+}
+
QFixed QFontEngineBox::descent() const
{
return 0;
@@ -2163,6 +2175,9 @@ glyph_metrics_t QFontEngineMulti::boundingBox(glyph_t glyph)
QFixed QFontEngineMulti::ascent() const
{ return engine(0)->ascent(); }
+QFixed QFontEngineMulti::capHeight() const
+{ return engine(0)->capHeight(); }
+
QFixed QFontEngineMulti::descent() const
{ return engine(0)->descent(); }
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 75e30b9552..46f5e6c070 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -414,6 +414,7 @@ QFontEngine::Properties QFreetypeFace::properties() const
p.italicAngle = 0;
p.capHeight = p.ascent;
p.lineWidth = face->underline_thickness;
+
return p;
}
@@ -585,8 +586,7 @@ static void convertRGBToARGB_helper(const uchar *src, uint *dst, int width, int
uchar green = src[x + 1];
uchar blue = src[x + 1 + offs];
LcdFilter::filterPixel(red, green, blue);
- // alpha = green
- *dd++ = (green << 24) | (red << 16) | (green << 8) | blue;
+ *dd++ = (0xFF << 24) | (red << 16) | (green << 8) | blue;
}
dst += width;
src += src_pitch;
@@ -611,8 +611,7 @@ static void convertRGBToARGB_V_helper(const uchar *src, uint *dst, int width, in
uchar green = src[x + src_pitch];
uchar blue = src[x + src_pitch + offs];
LcdFilter::filterPixel(red, green, blue);
- // alpha = green
- *dst++ = (green << 24) | (red << 16) | (green << 8) | blue;
+ *dst++ = (0XFF << 24) | (red << 16) | (green << 8) | blue;
}
src += 3*src_pitch;
}
@@ -1299,6 +1298,18 @@ QFixed QFontEngineFT::ascent() const
return v;
}
+QFixed QFontEngineFT::capHeight() const
+{
+ TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
+ if (os2 && os2->version >= 2) {
+ lockFace();
+ QFixed answer = QFixed::fromFixed(FT_MulFix(os2->sCapHeight, freetype->face->size->metrics.y_scale));
+ unlockFace();
+ return answer;
+ }
+ return calculatedCapHeight();
+}
+
QFixed QFontEngineFT::descent() const
{
QFixed v = QFixed::fromFixed(-metrics.descender);
@@ -1317,33 +1328,25 @@ QFixed QFontEngineFT::leading() const
QFixed QFontEngineFT::xHeight() const
{
- if (!isScalableBitmap()) {
- TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
- if (os2 && os2->sxHeight) {
- lockFace();
- QFixed answer = QFixed(os2->sxHeight * freetype->face->size->metrics.y_ppem) / emSquareSize();
- unlockFace();
- return answer;
- }
- } else {
- return QFixed(freetype->face->size->metrics.y_ppem) * scalableBitmapScaleFactor;
+ TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
+ if (os2 && os2->sxHeight) {
+ lockFace();
+ QFixed answer = QFixed(os2->sxHeight * freetype->face->size->metrics.y_ppem) / emSquareSize();
+ unlockFace();
+ return answer;
}
+
return QFontEngine::xHeight();
}
QFixed QFontEngineFT::averageCharWidth() const
{
- if (!isScalableBitmap()) {
- TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
- if (os2 && os2->xAvgCharWidth) {
- lockFace();
- QFixed answer = QFixed(os2->xAvgCharWidth * freetype->face->size->metrics.x_ppem) / emSquareSize();
- unlockFace();
- return answer;
- }
- } else {
- const qreal aspectRatio = (qreal)xsize / ysize;
- return QFixed::fromReal(fontDef.pixelSize * aspectRatio);
+ TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
+ if (os2 && os2->xAvgCharWidth) {
+ lockFace();
+ QFixed answer = QFixed(os2->xAvgCharWidth * freetype->face->size->metrics.x_ppem) / emSquareSize();
+ unlockFace();
+ return answer;
}
return QFontEngine::averageCharWidth();
@@ -1842,7 +1845,7 @@ static inline QImage alphaMapFromGlyphData(QFontEngineFT::Glyph *glyph, QFontEng
bytesPerLine = (glyph->width + 3) & ~3;
break;
case QFontEngine::Format_A32:
- format = QImage::Format_ARGB32;
+ format = QImage::Format_RGB32;
bytesPerLine = glyph->width * 4;
break;
default:
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 3cdf0cda47..5ca3721c71 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -209,6 +209,7 @@ private:
int synthesized() const Q_DECL_OVERRIDE;
QFixed ascent() const Q_DECL_OVERRIDE;
+ QFixed capHeight() const Q_DECL_OVERRIDE;
QFixed descent() const Q_DECL_OVERRIDE;
QFixed leading() const Q_DECL_OVERRIDE;
QFixed xHeight() const Q_DECL_OVERRIDE;
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index f3eeddab41..69331cb0bb 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -211,6 +211,7 @@ public:
glyph_metrics_t tightBoundingBox(const QGlyphLayout &glyphs);
virtual QFixed ascent() const = 0;
+ virtual QFixed capHeight() const = 0;
virtual QFixed descent() const = 0;
virtual QFixed leading() const = 0;
virtual QFixed xHeight() const;
@@ -348,6 +349,7 @@ protected:
QFixed lastRightBearing(const QGlyphLayout &glyphs, bool round = false);
inline void setUserData(const QVariant &userData) { m_userData = userData; }
+ QFixed calculatedCapHeight() const;
private:
struct GlyphCacheEntry {
@@ -414,6 +416,7 @@ public:
virtual QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
virtual QFixed ascent() const Q_DECL_OVERRIDE;
+ virtual QFixed capHeight() const Q_DECL_OVERRIDE;
virtual QFixed descent() const Q_DECL_OVERRIDE;
virtual QFixed leading() const Q_DECL_OVERRIDE;
virtual qreal maxCharWidth() const Q_DECL_OVERRIDE;
@@ -451,6 +454,7 @@ public:
virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0) Q_DECL_OVERRIDE;
virtual QFixed ascent() const Q_DECL_OVERRIDE;
+ virtual QFixed capHeight() const Q_DECL_OVERRIDE;
virtual QFixed descent() const Q_DECL_OVERRIDE;
virtual QFixed leading() const Q_DECL_OVERRIDE;
virtual QFixed xHeight() const Q_DECL_OVERRIDE;
diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp
index 2e4af09550..110d512d39 100644
--- a/src/gui/text/qfontengine_qpf2.cpp
+++ b/src/gui/text/qfontengine_qpf2.cpp
@@ -459,6 +459,11 @@ QFixed QFontEngineQPF2::ascent() const
return QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value<qreal>());
}
+QFixed QFontEngineQPF2::capHeight() const
+{
+ return calculatedCapHeight();
+}
+
QFixed QFontEngineQPF2::descent() const
{
return QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value<qreal>());
diff --git a/src/gui/text/qfontengine_qpf2_p.h b/src/gui/text/qfontengine_qpf2_p.h
index 50aac245c1..e5c38ffbaf 100644
--- a/src/gui/text/qfontengine_qpf2_p.h
+++ b/src/gui/text/qfontengine_qpf2_p.h
@@ -172,6 +172,7 @@ public:
glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE;
QFixed ascent() const Q_DECL_OVERRIDE;
+ QFixed capHeight() const Q_DECL_OVERRIDE;
QFixed descent() const Q_DECL_OVERRIDE;
QFixed leading() const Q_DECL_OVERRIDE;
qreal maxCharWidth() const Q_DECL_OVERRIDE;
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 2189923b25..aca59d0288 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -274,6 +274,24 @@ int QFontMetrics::ascent() const
return qRound(engine->ascent());
}
+/*!
+ Returns the cap height of the font.
+
+ \since 5.8
+
+ The cap height of a font is the height of a capital letter above
+ the baseline. It specifically is the height of capital letters
+ that are flat - such as H or I - as opposed to round letters such
+ as O, or pointed letters like A, both of which may display overshoot.
+
+ \sa ascent()
+*/
+int QFontMetrics::capHeight() const
+{
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
+ Q_ASSERT(engine != 0);
+ return qRound(engine->capHeight());
+}
/*!
Returns the descent of the font.
@@ -1138,6 +1156,24 @@ qreal QFontMetricsF::ascent() const
return engine->ascent().toReal();
}
+/*!
+ Returns the cap height of the font.
+
+ \since 5.8
+
+ The cap height of a font is the height of a capital letter above
+ the baseline. It specifically is the height of capital letters
+ that are flat - such as H or I - as opposed to round letters such
+ as O, or pointed letters like A, both of which may display overshoot.
+
+ \sa ascent()
+*/
+qreal QFontMetricsF::capHeight() const
+{
+ QFontEngine *engine = d->engineForScript(QChar::Script_Common);
+ Q_ASSERT(engine != 0);
+ return engine->capHeight().toReal();
+}
/*!
Returns the descent of the font.
diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h
index 22e51f29f7..3eac309092 100644
--- a/src/gui/text/qfontmetrics.h
+++ b/src/gui/text/qfontmetrics.h
@@ -73,6 +73,7 @@ public:
{ qSwap(d, other.d); }
int ascent() const;
+ int capHeight() const;
int descent() const;
int height() const;
int leading() const;
@@ -146,6 +147,7 @@ public:
void swap(QFontMetricsF &other) { qSwap(d, other.d); }
qreal ascent() const;
+ qreal capHeight() const;
qreal descent() const;
qreal height() const;
qreal leading() const;
diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp
index c8f0393084..49638832e0 100644
--- a/src/gui/text/qfontsubset.cpp
+++ b/src/gui/text/qfontsubset.cpp
@@ -740,7 +740,7 @@ static void convertPath(const QPainterPath &path, QVector<TTF_POINT> *points, QV
points->takeLast();
endPoints->append(points->size() - 1);
}
- // fall through
+ Q_FALLTHROUGH();
case QPainterPath::LineToElement:
p.flags = OnCurve;
break;
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index eadb65959a..8e6ffa5e94 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -325,6 +325,23 @@ qreal QRawFont::ascent() const
}
/*!
+ Returns the cap height of this QRawFont in pixel units.
+
+ \since 5.8
+
+ The cap height of a font is the height of a capital letter above
+ the baseline. It specifically is the height of capital letters
+ that are flat - such as H or I - as opposed to round letters such
+ as O, or pointed letters like A, both of which may display overshoot.
+
+ \sa QFontMetricsF::capHeight()
+*/
+qreal QRawFont::capHeight() const
+{
+ return d->isValid() ? d->fontEngine->capHeight().toReal() : 0.0;
+}
+
+/*!
Returns the descent of this QRawFont in pixel units.
\sa QFontMetricsF::descent()
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index 5791c6af16..0252e62370 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -118,6 +118,7 @@ public:
QFont::HintingPreference hintingPreference() const;
qreal ascent() const;
+ qreal capHeight() const;
qreal descent() const;
qreal leading() const;
qreal xHeight() const;
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index f824d1b369..f32c31d18e 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -438,7 +438,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
if (relativePos < blockIt.length()-1)
++position;
- // FALL THROUGH!
+ Q_FALLTHROUGH();
}
case QTextCursor::PreviousWord:
case QTextCursor::WordLeft:
@@ -590,9 +590,9 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
adjustX = false;
break;
}
- case QTextCursor::NextCell: // fall through
- case QTextCursor::PreviousCell: // fall through
- case QTextCursor::NextRow: // fall through
+ case QTextCursor::NextCell:
+ case QTextCursor::PreviousCell:
+ case QTextCursor::NextRow:
case QTextCursor::PreviousRow: {
QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position));
if (!table)
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 3537adba9e..7107c7c26e 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -131,7 +131,7 @@ static bool isValidBlockSeparator(QChar ch)
|| ch == QTextEndOfFrame;
}
-static bool noBlockInString(const QString &str)
+static bool noBlockInString(const QStringRef &str)
{
return !str.contains(QChar::ParagraphSeparator)
&& !str.contains(QTextBeginningOfFrame)
@@ -320,7 +320,7 @@ void QTextDocumentPrivate::setLayout(QAbstractTextDocumentLayout *layout)
void QTextDocumentPrivate::insert_string(int pos, uint strPos, uint length, int format, QTextUndoCommand::Operation op)
{
// ##### optimize when only appending to the fragment!
- Q_ASSERT(noBlockInString(text.mid(strPos, length)));
+ Q_ASSERT(noBlockInString(text.midRef(strPos, length)));
split(pos);
uint x = fragments.insert_single(pos, length);
@@ -476,7 +476,7 @@ void QTextDocumentPrivate::insert(int pos, const QString &str, int format)
if (str.size() == 0)
return;
- Q_ASSERT(noBlockInString(str));
+ Q_ASSERT(noBlockInString(QStringRef(&str)));
int strPos = text.length();
text.append(str);
@@ -494,7 +494,7 @@ int QTextDocumentPrivate::remove_string(int pos, uint length, QTextUndoCommand::
Q_ASSERT(blocks.size(b) > length);
Q_ASSERT(x && fragments.position(x) == (uint)pos && fragments.size(x) == length);
- Q_ASSERT(noBlockInString(text.mid(fragments.fragment(x)->stringPosition, length)));
+ Q_ASSERT(noBlockInString(text.midRef(fragments.fragment(x)->stringPosition, length)));
blocks.setSize(b, blocks.size(b)-length);
@@ -629,7 +629,7 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O
if (key+1 != blocks.position(b)) {
// qDebug("remove_string from %d length %d", key, X->size_array[0]);
- Q_ASSERT(noBlockInString(text.mid(X->stringPosition, X->size_array[0])));
+ Q_ASSERT(noBlockInString(text.midRef(X->stringPosition, X->size_array[0])));
w = remove_string(key, X->size_array[0], op);
if (needsInsert) {
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index 5727b34e86..079b2e01f7 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -827,7 +827,7 @@ bool QTextHtmlImporter::closeTag()
case Html_div:
if (closedNode->children.isEmpty())
break;
- // fall through
+ Q_FALLTHROUGH();
default:
if (closedNode->isBlock())
blockTagClosed = true;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index cad30b0c77..8a13455ee0 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -508,7 +508,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon
case QChar::DirAN:
if (eor >= 0)
appendItems(analysis, sor, eor, control, dir);
- // fall through
+ Q_FALLTHROUGH();
case QChar::DirR:
case QChar::DirAL:
dir = QChar::DirR; eor = current; status.eor = QChar::DirR; break;
@@ -564,7 +564,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon
status.eor = QChar::DirON;
dir = QChar::DirAN;
}
- // fall through
+ Q_FALLTHROUGH();
case QChar::DirEN:
case QChar::DirL:
eor = current;
@@ -744,7 +744,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon
status.last = QChar::DirL;
break;
}
- // fall through
+ Q_FALLTHROUGH();
default:
status.last = dirCurrent;
}
@@ -1664,7 +1664,7 @@ void QTextEngine::itemize() const
analysis->bidiLevel = control.baseLevel();
break;
}
- // fall through
+ Q_FALLTHROUGH();
default:
analysis->flags = QScriptAnalysis::None;
break;
@@ -2251,7 +2251,6 @@ void QTextEngine::justify(const QScriptLine &line)
case Justification_Prohibited:
break;
case Justification_Space:
- // fall through
case Justification_Arabic_Space:
if (kashida_pos >= 0) {
// qDebug("kashida position at %d in word", kashida_pos);
@@ -2264,7 +2263,7 @@ void QTextEngine::justify(const QScriptLine &line)
}
kashida_pos = -1;
kashida_type = Justification_Arabic_Normal;
- // fall through
+ Q_FALLTHROUGH();
case Justification_Character:
set(&justificationPoints[nPoints++], justification, g.mid(i), fontEngine(si));
maxJustify = qMax(maxJustify, justification);
@@ -2712,7 +2711,7 @@ static QString stringMidRetainingBidiCC(const QString &string,
suffix += c;
}
- return prefix + ellidePrefix + string.mid(midStart, midLength) + ellideSuffix + suffix;
+ return prefix + ellidePrefix + string.midRef(midStart, midLength) + ellideSuffix + suffix;
}
QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags, int from, int count) const
@@ -2875,7 +2874,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
if (prevCharJoins(layoutData->string, rightPos))
ellipsisText.append(QChar(0x200d) /* ZWJ */);
- return layoutData->string.mid(from, leftPos - from) + ellipsisText + layoutData->string.mid(rightPos, to - rightPos);
+ return layoutData->string.midRef(from, leftPos - from) + ellipsisText + layoutData->string.midRef(rightPos, to - rightPos);
}
return layoutData->string.mid(from, to - from);
@@ -2967,9 +2966,8 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const
switch (tabSpec.type) {
case QTextOption::CenterTab:
length /= 2;
- // fall through
+ Q_FALLTHROUGH();
case QTextOption::DelimiterTab:
- // fall through
case QTextOption::RightTab:
tab = QFixed::fromReal(tabSpec.position) * dpiScale - length;
if (tab < x) // default to tab taking no space
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 7bca50325c..7fac3331f1 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1871,7 +1871,7 @@ QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode
decls << decl;
if (node.id == Html_b || node.id == Html_strong)
break;
- // Delibrate fall through
+ Q_FALLTHROUGH();
case Html_big:
case Html_small:
if (node.id != Html_th) {
@@ -1892,7 +1892,7 @@ QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode
decls << decl;
break;
}
- // Delibrate fall through
+ Q_FALLTHROUGH();
case Html_center:
case Html_td:
decl = QCss::Declaration();
@@ -1969,7 +1969,7 @@ QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode
}
if (node.id != Html_pre)
break;
- // Delibrate fall through
+ Q_FALLTHROUGH();
case Html_br:
case Html_nobr:
decl = QCss::Declaration();
diff --git a/src/gui/text/qtextodfwriter_p.h b/src/gui/text/qtextodfwriter_p.h
index c1a5652760..d0dd7d2b5c 100644
--- a/src/gui/text/qtextodfwriter_p.h
+++ b/src/gui/text/qtextodfwriter_p.h
@@ -48,9 +48,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
//
// We mean it.
//