summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp14
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.h14
-rw-r--r--src/gui/text/qabstracttextdocumentlayout_p.h14
-rw-r--r--src/gui/text/qcssparser.cpp45
-rw-r--r--src/gui/text/qcssparser_p.h19
-rw-r--r--src/gui/text/qcssscanner.cpp14
-rw-r--r--src/gui/text/qdistancefield.cpp36
-rw-r--r--src/gui/text/qdistancefield_p.h15
-rw-r--r--src/gui/text/qfont.cpp89
-rw-r--r--src/gui/text/qfont.h36
-rw-r--r--src/gui/text/qfont_p.h18
-rw-r--r--src/gui/text/qfontdatabase.cpp280
-rw-r--r--src/gui/text/qfontdatabase.h21
-rw-r--r--src/gui/text/qfontengine.cpp236
-rw-r--r--src/gui/text/qfontengine_ft.cpp221
-rw-r--r--src/gui/text/qfontengine_ft_p.h101
-rw-r--r--src/gui/text/qfontengine_p.h148
-rw-r--r--src/gui/text/qfontengine_qpf2.cpp16
-rw-r--r--src/gui/text/qfontengine_qpf2_p.h50
-rw-r--r--src/gui/text/qfontengineglyphcache_p.h14
-rw-r--r--src/gui/text/qfontinfo.h16
-rw-r--r--src/gui/text/qfontmetrics.cpp17
-rw-r--r--src/gui/text/qfontmetrics.h14
-rw-r--r--src/gui/text/qfontsubset.cpp21
-rw-r--r--src/gui/text/qfontsubset_agl.cpp14
-rw-r--r--src/gui/text/qfontsubset_p.h14
-rw-r--r--src/gui/text/qfragmentmap.cpp14
-rw-r--r--src/gui/text/qfragmentmap_p.h16
-rw-r--r--src/gui/text/qglyphrun.cpp14
-rw-r--r--src/gui/text/qglyphrun.h14
-rw-r--r--src/gui/text/qglyphrun_p.h14
-rw-r--r--src/gui/text/qharfbuzzng.cpp81
-rw-r--r--src/gui/text/qharfbuzzng_p.h14
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp70
-rw-r--r--src/gui/text/qplatformfontdatabase.h17
-rw-r--r--src/gui/text/qrawfont.cpp14
-rw-r--r--src/gui/text/qrawfont.h14
-rw-r--r--src/gui/text/qrawfont_p.h14
-rw-r--r--src/gui/text/qstatictext.cpp60
-rw-r--r--src/gui/text/qstatictext.h14
-rw-r--r--src/gui/text/qstatictext_p.h35
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp14
-rw-r--r--src/gui/text/qsyntaxhighlighter.h14
-rw-r--r--src/gui/text/qtextcursor.cpp14
-rw-r--r--src/gui/text/qtextcursor.h14
-rw-r--r--src/gui/text/qtextcursor_p.h14
-rw-r--r--src/gui/text/qtextdocument.cpp267
-rw-r--r--src/gui/text/qtextdocument.h27
-rw-r--r--src/gui/text/qtextdocument_p.cpp16
-rw-r--r--src/gui/text/qtextdocument_p.h14
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp14
-rw-r--r--src/gui/text/qtextdocumentfragment.h14
-rw-r--r--src/gui/text/qtextdocumentfragment_p.h14
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp30
-rw-r--r--src/gui/text/qtextdocumentlayout_p.h36
-rw-r--r--src/gui/text/qtextdocumentwriter.cpp14
-rw-r--r--src/gui/text/qtextdocumentwriter.h14
-rw-r--r--src/gui/text/qtextengine.cpp145
-rw-r--r--src/gui/text/qtextengine_p.h14
-rw-r--r--src/gui/text/qtextformat.cpp40
-rw-r--r--src/gui/text/qtextformat.h18
-rw-r--r--src/gui/text/qtextformat_p.h14
-rw-r--r--src/gui/text/qtexthtmlparser.cpp311
-rw-r--r--src/gui/text/qtexthtmlparser_p.h14
-rw-r--r--src/gui/text/qtextimagehandler.cpp14
-rw-r--r--src/gui/text/qtextimagehandler_p.h18
-rw-r--r--src/gui/text/qtextlayout.cpp16
-rw-r--r--src/gui/text/qtextlayout.h14
-rw-r--r--src/gui/text/qtextlist.cpp14
-rw-r--r--src/gui/text/qtextlist.h14
-rw-r--r--src/gui/text/qtextobject.cpp14
-rw-r--r--src/gui/text/qtextobject.h14
-rw-r--r--src/gui/text/qtextobject_p.h14
-rw-r--r--src/gui/text/qtextodfwriter.cpp20
-rw-r--r--src/gui/text/qtextodfwriter_p.h14
-rw-r--r--src/gui/text/qtextoption.cpp14
-rw-r--r--src/gui/text/qtextoption.h14
-rw-r--r--src/gui/text/qtexttable.cpp19
-rw-r--r--src/gui/text/qtexttable.h14
-rw-r--r--src/gui/text/qtexttable_p.h18
-rw-r--r--src/gui/text/qzip.cpp20
-rw-r--r--src/gui/text/qzipreader_p.h14
-rw-r--r--src/gui/text/qzipwriter_p.h14
-rw-r--r--src/gui/text/text.pri2
84 files changed, 1856 insertions, 1427 deletions
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index 48065315ca..70be92535d 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h
index 27b3f85dea..27135b0476 100644
--- a/src/gui/text/qabstracttextdocumentlayout.h
+++ b/src/gui/text/qabstracttextdocumentlayout.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qabstracttextdocumentlayout_p.h b/src/gui/text/qabstracttextdocumentlayout_p.h
index 575f683da3..505135fa4b 100644
--- a/src/gui/text/qabstracttextdocumentlayout_p.h
+++ b/src/gui/text/qabstracttextdocumentlayout_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 8c2e40f319..3c98cb568d 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -41,7 +41,6 @@
#include <qfontmetrics.h>
#include <qbrush.h>
#include <qimagereader.h>
-#include "private/qfunctions_p.h"
#include <algorithm>
@@ -340,18 +339,18 @@ static const QCssKnownValue styleFeatures[NumKnownStyleFeatures - 1] = {
};
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCssKnownValue &prop1, const QCssKnownValue &prop2)
+static bool operator<(const QCssKnownValue &prop1, const QCssKnownValue &prop2)
{
return QString::compare(QString::fromLatin1(prop1.name), QLatin1String(prop2.name), Qt::CaseInsensitive) < 0;
}
#endif
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &name, const QCssKnownValue &prop)
+static bool operator<(const QString &name, const QCssKnownValue &prop)
{
return QString::compare(name, QLatin1String(prop.name), Qt::CaseInsensitive) < 0;
}
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCssKnownValue &prop, const QString &name)
+static bool operator<(const QCssKnownValue &prop, const QString &name)
{
return QString::compare(QLatin1String(prop.name), name, Qt::CaseInsensitive) < 0;
}
@@ -365,6 +364,29 @@ static quint64 findKnownValue(const QString &name, const QCssKnownValue *start,
return prop->id;
}
+static inline bool isInheritable(Property propertyId)
+{
+ switch (propertyId) {
+ case Font:
+ case FontFamily:
+ case FontSize:
+ case FontStyle:
+ case FontWeight:
+ case TextIndent:
+ case Whitespace:
+ case ListStyleType:
+ case ListStyle:
+ case TextAlignment:
+ case FontVariant:
+ case TextTransform:
+ case LineHeight:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
///////////////////////////////////////////////////////////////////////////////
// Value Extractor
ValueExtractor::ValueExtractor(const QVector<Declaration> &decls, const QPalette &pal)
@@ -2318,6 +2340,7 @@ bool Parser::parseProperty(Declaration *decl)
{
decl->d->property = lexem();
decl->d->propertyId = static_cast<Property>(findKnownValue(decl->d->property, properties, NumProperties));
+ decl->d->inheritable = isInheritable(decl->d->propertyId);
skipSpace();
return true;
}
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index 5e853c40d0..75802ba36a 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -426,12 +426,13 @@ struct Q_GUI_EXPORT Declaration
{
struct DeclarationData : public QSharedData
{
- inline DeclarationData() : propertyId(UnknownProperty), important(false) {}
+ inline DeclarationData() : propertyId(UnknownProperty), important(false), inheritable(false) {}
QString property;
Property propertyId;
QVector<Value> values;
QVariant parsed;
- bool important;
+ bool important:1;
+ bool inheritable:1;
};
QExplicitlySharedDataPointer<DeclarationData> d;
inline Declaration() : d(new DeclarationData()) {}
diff --git a/src/gui/text/qcssscanner.cpp b/src/gui/text/qcssscanner.cpp
index a7e24724d1..7505d27d80 100644
--- a/src/gui/text/qcssscanner.cpp
+++ b/src/gui/text/qcssscanner.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp
index b2d0298e04..4d189786a1 100644
--- a/src/gui/text/qdistancefield.cpp
+++ b/src/gui/text/qdistancefield.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -34,6 +34,7 @@
#include "qdistancefield_p.h"
#include <qmath.h>
#include <private/qdatabuffer_p.h>
+#include <private/qimage_p.h>
#include <private/qpathsimplifier_p.h>
QT_BEGIN_NAMESPACE
@@ -508,8 +509,8 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path
bits[i] = exteriorColor;
const qreal angleStep = qreal(15 * 3.141592653589793238 / 180);
- const QPoint rotation(qRound(cos(angleStep) * 0x4000),
- qRound(sin(angleStep) * 0x4000)); // 2:14 signed
+ const QPoint rotation(qRound(qCos(angleStep) * 0x4000),
+ qRound(qSin(angleStep) * 0x4000)); // 2:14 signed
const quint32 *indices = pathIndices.data();
QVarLengthArray<QPoint> normals;
@@ -543,7 +544,7 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path
QPoint n(to.y() - from.y(), from.x() - to.x());
if (n.x() == 0 && n.y() == 0)
continue;
- int scale = qRound((offs << 16) / sqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16
+ int scale = qRound((offs << 16) / qSqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16
n.rx() = n.x() * scale >> 8;
n.ry() = n.y() * scale >> 8;
normals.append(n);
@@ -832,6 +833,17 @@ QDistanceField::QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doub
setGlyph(fontEngine, glyph, doubleResolution);
}
+QDistanceField::QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution)
+{
+ QPainterPath dfPath = path;
+ dfPath.translate(-dfPath.boundingRect().topLeft());
+ dfPath.setFillRule(Qt::WindingFill);
+
+ d = QDistanceFieldData::create(dfPath, doubleResolution);
+ d->glyph = glyph;
+}
+
+
QDistanceField::QDistanceField(QDistanceFieldData *data)
: d(data)
{
@@ -987,12 +999,12 @@ QImage QDistanceField::toImage(QImage::Format format) const
if (isNull())
return QImage();
- QImage image(d->width, d->height, format == QImage::Format_Indexed8 ?
+ QImage image(d->width, d->height, qt_depthForFormat(format) == 8 ?
format : QImage::Format_ARGB32_Premultiplied);
if (image.isNull())
return image;
- if (format == QImage::Format_Indexed8) {
+ if (image.depth() == 8) {
for (int y = 0; y < d->height; ++y)
memcpy(image.scanLine(y), scanLine(y), d->width);
} else {
diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h
index 89eea0f6af..c376e93abe 100644
--- a/src/gui/text/qdistancefield_p.h
+++ b/src/gui/text/qdistancefield_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -97,6 +97,7 @@ public:
QDistanceField(int width, int height);
QDistanceField(const QRawFont &font, glyph_t glyph, bool doubleResolution = false);
QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false);
+ QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution = false);
QDistanceField(const QDistanceField &other);
bool isNull() const;
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index b867dc6ef2..a5fade99fd 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -166,14 +166,14 @@ Q_GUI_EXPORT int qt_defaultDpi()
QFontPrivate::QFontPrivate()
: engineData(0), dpi(qt_defaultDpi()), screen(0),
- rawMode(false), underline(false), overline(false), strikeOut(false), kerning(true),
+ underline(false), overline(false), strikeOut(false), kerning(true),
capital(0), letterSpacingIsAbsolute(false), scFont(0)
{
}
QFontPrivate::QFontPrivate(const QFontPrivate &other)
: request(other.request), engineData(0), dpi(other.dpi), screen(other.screen),
- rawMode(other.rawMode), underline(other.underline), overline(other.overline),
+ underline(other.underline), overline(other.overline),
strikeOut(other.strikeOut), kerning(other.kerning),
capital(other.capital), letterSpacingIsAbsolute(other.letterSpacingIsAbsolute),
letterSpacing(other.letterSpacing), wordSpacing(other.wordSpacing),
@@ -406,9 +406,6 @@ QFontEngineData::~QFontEngineData()
setPointSize() has a similar effect and provides device
independence.
- In X11 you can set a font using its system
- specific name with setRawName().
-
Loading fonts can be expensive, especially on X11. QFont contains
extensive optimizations to make the copying of QFont objects fast,
and to cache the results of the slow window system functions it
@@ -1033,10 +1030,14 @@ int QFont::weight() const
This enum contains the predefined font weights:
+ \value Thin 0
+ \value ExtraLight 12
\value Light 25
\value Normal 50
+ \value Medium 57
\value DemiBold 63
\value Bold 75
+ \value ExtraBold 81
\value Black 87
*/
@@ -1063,7 +1064,7 @@ void QFont::setWeight(int weight)
\fn bool QFont::bold() const
Returns \c true if weight() is a value greater than
- \l{Weight}{QFont::Normal}; otherwise returns \c false.
+ \l{Weight}{QFont::Medium}; otherwise returns \c false.
\sa weight(), setBold(), QFontInfo::bold()
*/
@@ -1567,8 +1568,11 @@ QFont::Capitalization QFont::capitalization() const
return static_cast<QFont::Capitalization> (d->capital);
}
-
+#if QT_DEPRECATED_SINCE(5, 5)
/*!
+ \fn void QFont::setRawMode(bool enable)
+ \deprecated
+
If \a enable is true, turns raw mode on; otherwise turns raw mode
off. This function only has an effect under X11.
@@ -1580,20 +1584,14 @@ QFont::Capitalization QFont::capitalization() const
return the values set in the QFont for all parameters, including
the family name).
- \warning Do not use raw mode unless you really, really need it! In
- most (if not all) cases, setRawName() is a much better choice.
+ \warning Enabling raw mode has no effect since Qt 5.0.
- \sa rawMode(), setRawName()
+ \sa rawMode()
*/
-void QFont::setRawMode(bool enable)
+void QFont::setRawMode(bool)
{
- if ((bool) d->rawMode == enable) return;
-
- // might change behavior, thus destroy engine data
- detach();
-
- d->rawMode = enable;
}
+#endif
/*!
Returns \c true if a window system font exactly matching the settings
@@ -1605,9 +1603,7 @@ bool QFont::exactMatch() const
{
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
- return (d->rawMode
- ? engine->type() != QFontEngine::Box
- : d->request.exactMatch(engine->fontDef));
+ return d->request.exactMatch(engine->fontDef);
}
/*!
@@ -1615,8 +1611,7 @@ bool QFont::exactMatch() const
false.
Two QFonts are considered equal if their font attributes are
- equal. If rawMode() is enabled for both fonts, only the family
- fields are compared.
+ equal.
\sa operator!=(), isCopyOf()
*/
@@ -1679,8 +1674,7 @@ bool QFont::operator<(const QFont &f) const
returns \c false.
Two QFonts are considered to be different if their font attributes
- are different. If rawMode() is enabled for both fonts, only the
- family fields are compared.
+ are different.
\sa operator==()
*/
@@ -1709,16 +1703,20 @@ bool QFont::isCopyOf(const QFont & f) const
return d == f.d;
}
+#if QT_DEPRECATED_SINCE(5, 5)
/*!
+ \deprecated
+
Returns \c true if raw mode is used for font name matching; otherwise
returns \c false.
- \sa setRawMode(), rawName()
+ \sa setRawMode()
*/
bool QFont::rawMode() const
{
- return d->rawMode;
+ return false;
}
+#endif
/*!
Returns a new QFont that has attributes copied from \a other that
@@ -1877,7 +1875,7 @@ QStringList QFont::substitutions()
return ret;
}
-
+#ifndef QT_NO_DATASTREAM
/* \internal
Internal function. Converts boolean font settings to an unsigned
8-bit number. Used for serialization etc.
@@ -1898,8 +1896,6 @@ static quint8 get_font_bits(int version, const QFontPrivate *f)
bits |= 0x08;
// if (f.hintSetByUser)
// bits |= 0x10;
- if (f->rawMode)
- bits |= 0x20;
if (version >= QDataStream::Qt_4_0) {
if (f->kerning)
bits |= 0x10;
@@ -1920,8 +1916,6 @@ static quint8 get_extended_font_bits(const QFontPrivate *f)
return bits;
}
-#ifndef QT_NO_DATASTREAM
-
/* \internal
Internal function. Sets boolean font settings from an unsigned
8-bit number. Used for serialization etc.
@@ -1935,7 +1929,6 @@ static void set_font_bits(int version, quint8 bits, QFontPrivate *f)
f->strikeOut = (bits & 0x04) != 0;
f->request.fixedPitch = (bits & 0x08) != 0;
// f->hintSetByUser = (bits & 0x10) != 0;
- f->rawMode = (bits & 0x20) != 0;
if (version >= QDataStream::Qt_4_0)
f->kerning = (bits & 0x10) != 0;
if ((bits & 0x80) != 0)
@@ -1982,7 +1975,7 @@ QString QFont::rawName() const
If Qt's internal font database cannot resolve the raw name, the
font becomes a raw font with \a name as its family.
- \sa rawName(), setRawMode(), setFamily()
+ \sa rawName(), setFamily()
*/
void QFont::setRawName(const QString &)
{
@@ -2019,7 +2012,7 @@ QString QFont::toString() const
QString::number((int) underline()) + comma +
QString::number((int) strikeOut()) + comma +
QString::number((int)fixedPitch()) + comma +
- QString::number((int) rawMode());
+ QString::number((int) false);
}
/*!
@@ -2063,7 +2056,6 @@ bool QFont::fromString(const QString &descrip)
setUnderline(l[5].toInt());
setStrikeOut(l[6].toInt());
setFixedPitch(l[7].toInt());
- setRawMode(l[8].toInt());
} else if (count == 10) {
if (l[2].toInt() > 0)
setPixelSize(l[2].toInt());
@@ -2073,7 +2065,6 @@ bool QFont::fromString(const QString &descrip)
setUnderline(l[6].toInt());
setStrikeOut(l[7].toInt());
setFixedPitch(l[8].toInt());
- setRawMode(l[9].toInt());
}
if (count >= 9 && !d->request.fixedPitch) // assume 'false' fixedPitch equals default
d->request.ignorePitch = true;
@@ -2163,7 +2154,7 @@ QString QFont::defaultFamily() const
happens. Please \l{bughowto.html}{report it as a bug} if
it does, preferably with a list of the fonts you have installed.
- \sa lastResortFamily(), rawName()
+ \sa lastResortFamily()
*/
QString QFont::lastResortFont() const
{
@@ -2622,7 +2613,10 @@ QFont::StyleHint QFontInfo::styleHint() const
return (QFont::StyleHint) engine->fontDef.styleHint;
}
+#if QT_DEPRECATED_SINCE(5, 5)
/*!
+ \deprecated
+
Returns \c true if the font is a raw mode font; otherwise returns
false.
@@ -2634,8 +2628,9 @@ QFont::StyleHint QFontInfo::styleHint() const
*/
bool QFontInfo::rawMode() const
{
- return d->rawMode;
+ return false;
}
+#endif
/*!
Returns \c true if the matched window system font is exactly the same
@@ -2647,9 +2642,7 @@ bool QFontInfo::exactMatch() const
{
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
Q_ASSERT(engine != 0);
- return (d->rawMode
- ? engine->type() != QFontEngine::Box
- : d->request.exactMatch(engine->fontDef));
+ return d->request.exactMatch(engine->fontDef);
}
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index 2a84fa680d..cc78ea7f45 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -49,7 +49,6 @@ class QVariant;
class Q_GUI_EXPORT QFont
{
Q_GADGET
- Q_ENUMS(StyleStrategy)
public:
enum StyleHint {
Helvetica, SansSerif = Helvetica,
@@ -78,6 +77,7 @@ public:
NoSubpixelAntialias = 0x0800,
NoFontMerging = 0x8000
};
+ Q_ENUM(StyleStrategy)
enum HintingPreference {
PreferDefaultHinting = 0,
@@ -86,12 +86,17 @@ public:
PreferFullHinting = 3
};
+ // Mapping OpenType weight value.
enum Weight {
- Light = 25,
- Normal = 50,
- DemiBold = 63,
- Bold = 75,
- Black = 87
+ Thin = 0, // 100
+ ExtraLight = 12, // 200
+ Light = 25, // 300
+ Normal = 50, // 400
+ Medium = 57, // 500
+ DemiBold = 63, // 600
+ Bold = 75, // 700
+ ExtraBold = 81, // 800
+ Black = 87 // 900
};
enum Style {
@@ -217,9 +222,10 @@ public:
void setHintingPreference(HintingPreference hintingPreference);
HintingPreference hintingPreference() const;
- // is raw mode still needed?
+#if QT_DEPRECATED_SINCE(5, 5)
bool rawMode() const;
void setRawMode(bool);
+#endif
// dupicated from QFontInfo
bool exactMatch() const;
@@ -313,7 +319,7 @@ Q_DECLARE_SHARED(QFont)
Q_GUI_EXPORT uint qHash(const QFont &font, uint seed = 0) Q_DECL_NOTHROW;
inline bool QFont::bold() const
-{ return weight() > Normal; }
+{ return weight() > Medium; }
inline void QFont::setBold(bool enable)
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index 0d5223821a..3f8241a80e 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -175,8 +175,6 @@ public:
int dpi;
int screen;
-
- uint rawMode : 1;
uint underline : 1;
uint overline : 1;
uint strikeOut : 1;
@@ -277,7 +275,7 @@ public:
private:
void increaseCost(uint cost);
void decreaseCost(uint cost);
- void timerEvent(QTimerEvent *event);
+ void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
static const uint min_cost;
uint total_cost, max_cost;
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index fcdb6ecca9..1a71042648 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -50,7 +50,6 @@
#include <QtCore/qmath.h>
#include <stdlib.h>
-#include <limits.h>
#include <algorithm>
@@ -84,60 +83,93 @@ static int getFontWeight(const QString &weightString)
{
QString s = weightString.toLower();
+ // Order here is important. We want to match the common cases first, but we
+ // must also take care to acknowledge the cost of our tests.
+ //
+ // As a result, we test in two orders; the order of commonness, and the
+ // order of "expense".
+ //
+ // A simple string test is the cheapest, so let's do that first.
// Test in decreasing order of commonness
- if (s == QLatin1String("normal")
- || s.compare(QCoreApplication::translate("QFontDatabase", "Normal"), Qt::CaseInsensitive) == 0)
+ if (s == QLatin1String("normal") || s == QLatin1String("regular"))
return QFont::Normal;
- if (s == QLatin1String("medium"))
- return qt_mediumFontWeight;
- if (s == QLatin1String("bold")
- || s.compare(QCoreApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive) == 0)
+ if (s == QLatin1String("bold"))
return QFont::Bold;
- if (s == QLatin1String("demibold") || s == QLatin1String("demi bold")
- || s.compare(QCoreApplication::translate("QFontDatabase", "Demi Bold"), Qt::CaseInsensitive) == 0)
+ if (s == QLatin1String("semibold") || s == QLatin1String("semi bold")
+ || s == QLatin1String("demibold") || s == QLatin1String("demi bold"))
return QFont::DemiBold;
- if (s == QLatin1String("black")
- || s.compare(QCoreApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
+ if (s == QLatin1String("medium"))
+ return QFont::Medium;
+ if (s == QLatin1String("black"))
return QFont::Black;
if (s == QLatin1String("light"))
return QFont::Light;
if (s == QLatin1String("thin"))
- return qt_thinFontWeight;
- if (s == QLatin1String("extralight"))
- return qt_extralightFontWeight;
-
- if (s.contains(QLatin1String("bold"))
- || s.contains(QCoreApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive)) {
- if (s.contains(QLatin1String("demi"))
- || s.compare(QCoreApplication::translate("QFontDatabase", "Demi"), Qt::CaseInsensitive) == 0)
- return (int) QFont::DemiBold;
- return (int) QFont::Bold;
+ return QFont::Thin;
+ const QStringRef s2 = s.midRef(2);
+ if (s.startsWith(QLatin1String("ex")) || s.startsWith(QLatin1String("ul"))) {
+ if (s2 == QLatin1String("tralight") || s == QLatin1String("tra light"))
+ return QFont::ExtraLight;
+ if (s2 == QLatin1String("trabold") || s2 == QLatin1String("tra bold"))
+ return QFont::ExtraBold;
}
- if (s.contains(QLatin1String("light"))
- || s.compare(QCoreApplication::translate("QFontDatabase", "Light"), Qt::CaseInsensitive) == 0)
- return (int) QFont::Light;
-
- if (s.contains(QLatin1String("black"))
- || s.compare(QCoreApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
- return (int) QFont::Black;
-
- return (int) QFont::Normal;
-}
-
-// convert 0 ~ 1000 integer to QFont::Weight
-QFont::Weight weightFromInteger(int weight)
-{
- if (weight < 400)
+ // Next up, let's see if contains() matches: slightly more expensive, but
+ // still fast enough.
+ if (s.contains(QLatin1String("bold"))) {
+ if (s.contains(QLatin1String("demi")))
+ return QFont::DemiBold;
+ return QFont::Bold;
+ }
+ if (s.contains(QLatin1String("light")))
return QFont::Light;
- else if (weight < 600)
+ if (s.contains(QLatin1String("black")))
+ return QFont::Black;
+
+ // Now, we perform string translations & comparisons with those.
+ // These are (very) slow compared to simple string ops, so we do these last.
+ // As using translated values for such things is not very common, this should
+ // not be too bad.
+ if (s.compare(QCoreApplication::translate("QFontDatabase", "Normal", "The Normal or Regular font weight"), Qt::CaseInsensitive) == 0)
return QFont::Normal;
- else if (weight < 700)
- return QFont::DemiBold;
- else if (weight < 800)
+ const QString translatedBold = QCoreApplication::translate("QFontDatabase", "Bold").toLower();
+ if (s == translatedBold)
return QFont::Bold;
- else
+ if (s.compare(QCoreApplication::translate("QFontDatabase", "Demi Bold"), Qt::CaseInsensitive) == 0)
+ return QFont::DemiBold;
+ if (s.compare(QCoreApplication::translate("QFontDatabase", "Medium", "The Medium font weight"), Qt::CaseInsensitive) == 0)
+ return QFont::Medium;
+ if (s.compare(QCoreApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
return QFont::Black;
+ const QString translatedLight = QCoreApplication::translate("QFontDatabase", "Light").toLower();
+ if (s == translatedLight)
+ return QFont::Light;
+ if (s.compare(QCoreApplication::translate("QFontDatabase", "Thin"), Qt::CaseInsensitive) == 0)
+ return QFont::Thin;
+ if (s.compare(QCoreApplication::translate("QFontDatabase", "Extra Light"), Qt::CaseInsensitive) == 0)
+ return QFont::ExtraLight;
+ if (s.compare(QCoreApplication::translate("QFontDatabase", "Extra Bold"), Qt::CaseInsensitive) == 0)
+ return QFont::ExtraBold;
+
+ // And now the contains() checks for the translated strings.
+ //: The word for "Extra" as in "Extra Bold, Extra Thin" used as a pattern for string searches
+ const QString translatedExtra = QCoreApplication::translate("QFontDatabase", "Extra").toLower();
+ if (s.contains(translatedBold)) {
+ //: The word for "Demi" as in "Demi Bold" used as a pattern for string searches
+ QString translatedDemi = QCoreApplication::translate("QFontDatabase", "Demi").toLower();
+ if (s .contains(translatedDemi))
+ return QFont::DemiBold;
+ if (s.contains(translatedExtra))
+ return QFont::ExtraBold;
+ return QFont::Bold;
+ }
+
+ if (s.contains(translatedLight)) {
+ if (s.contains(translatedExtra))
+ return QFont::ExtraLight;
+ return QFont::Light;
+ }
+ return QFont::Normal;
}
struct QtFontEncoding
@@ -221,12 +253,19 @@ QtFontStyle::Key::Key(const QString &styleString)
{
weight = getFontWeight(styleString);
- if (styleString.contains(QLatin1String("Italic"))
- || styleString.contains(QCoreApplication::translate("QFontDatabase", "Italic")))
- style = QFont::StyleItalic;
- else if (styleString.contains(QLatin1String("Oblique"))
- || styleString.contains(QCoreApplication::translate("QFontDatabase", "Oblique")))
- style = QFont::StyleOblique;
+ if (!styleString.isEmpty()) {
+ // First the straightforward no-translation checks, these are fast.
+ if (styleString.contains(QLatin1String("Italic")))
+ style = QFont::StyleItalic;
+ else if (styleString.contains(QLatin1String("Oblique")))
+ style = QFont::StyleOblique;
+
+ // Then the translation checks. These aren't as fast.
+ else if (styleString.contains(QCoreApplication::translate("QFontDatabase", "Italic")))
+ style = QFont::StyleItalic;
+ else if (styleString.contains(QCoreApplication::translate("QFontDatabase", "Oblique")))
+ style = QFont::StyleOblique;
+ }
}
QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add)
@@ -428,8 +467,6 @@ public:
bool isApplicationFont(const QString &fileName);
void invalidate();
-
- QStringList fallbackFamilies;
};
void QFontDatabasePrivate::invalidate()
@@ -624,18 +661,6 @@ static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDe
fontDef->ignorePitch = false;
}
-static void getEngineData(const QFontPrivate *d, const QFontDef &def)
-{
- // look for the requested font in the engine data cache
- d->engineData = QFontCache::instance()->findEngineData(def);
- if (!d->engineData) {
- // create a new one
- d->engineData = new QFontEngineData;
- QFontCache::instance()->insertEngineData(def, d->engineData);
- }
- d->engineData->ref.ref();
-}
-
static QStringList familyList(const QFontDef &req)
{
// list of families to try
@@ -765,7 +790,7 @@ static QStringList fallbackFamilies(const QString &family, QFont::Style style, Q
}
if (!contains) {
i = retList.erase(i);
- i--;
+ --i;
}
}
return retList;
@@ -800,7 +825,7 @@ static inline void load(const QString & = QString(), int = -1)
static
QFontEngine *loadSingleEngine(int script,
const QFontDef &request,
- QtFontFoundry *foundry,
+ QtFontFamily *family, QtFontFoundry *foundry,
QtFontStyle *style, QtFontSize *size)
{
Q_UNUSED(foundry);
@@ -819,6 +844,24 @@ QFontEngine *loadSingleEngine(int script,
QFontCache::Key key(def,script);
QFontEngine *engine = QFontCache::instance()->findEngine(key);
if (!engine) {
+ if (script != QChar::Script_Common) {
+ // fast path: check if engine was loaded for another script
+ key.script = QChar::Script_Common;
+ engine = QFontCache::instance()->findEngine(key);
+ key.script = script;
+ if (engine) {
+ Q_ASSERT(engine->type() != QFontEngine::Multi);
+ // Also check for OpenType tables when using complex scripts
+ if (Q_UNLIKELY(!engine->supportsScript(QChar::Script(script)))) {
+ qWarning(" OpenType support missing for script %d", script);
+ return 0;
+ }
+
+ QFontCache::instance()->insertEngine(key, engine);
+ return engine;
+ }
+ }
+
// 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.
@@ -838,6 +881,13 @@ QFontEngine *loadSingleEngine(int script,
}
QFontCache::instance()->insertEngine(key, engine);
+
+ if (!engine->symbol && script != QChar::Script_Common && (family->writingSystems[QFontDatabase::Latin] & QtFontFamily::Supported) != 0) {
+ // cache engine for Common script as well
+ key.script = QChar::Script_Common;
+ if (!QFontCache::instance()->findEngine(key))
+ QFontCache::instance()->insertEngine(key, engine);
+ }
}
}
return engine;
@@ -848,7 +898,7 @@ QFontEngine *loadEngine(int script, const QFontDef &request,
QtFontFamily *family, QtFontFoundry *foundry,
QtFontStyle *style, QtFontSize *size)
{
- QFontEngine *engine = loadSingleEngine(script, request, foundry, style, size);
+ QFontEngine *engine = loadSingleEngine(script, request, family, foundry, style, size);
Q_ASSERT(!engine || engine->type() != QFontEngine::Multi);
if (engine && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
// make sure that the db has all fallback families
@@ -863,10 +913,8 @@ QFontEngine *loadEngine(int script, const QFontDef &request,
}
QStringList fallbacks = request.fallBackFamilies;
- if (family && !family->fallbackFamilies.isEmpty())
+ if (family)
fallbacks += family->fallbackFamilies;
- else
- fallbacks += privateDb()->fallbackFamilies;
QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QChar::Script(script));
@@ -935,7 +983,7 @@ static
unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
const QtFontFamily *family, const QString &foundry_name,
QtFontStyle::Key styleKey, int pixelSize, char pitch,
- QtFontDesc *desc, int force_encoding_id, QString styleName = QString())
+ QtFontDesc *desc, int force_encoding_id, const QString &styleName = QString())
{
Q_UNUSED(force_encoding_id);
Q_UNUSED(script);
@@ -1117,7 +1165,10 @@ static int match(int script, const QFontDef &request,
load(family_name, script);
- const size_t writingSystem = std::find(scriptForWritingSystem, scriptForWritingSystem + QFontDatabase::WritingSystemsCount, script) - scriptForWritingSystem;
+ size_t writingSystem = std::find(scriptForWritingSystem, scriptForWritingSystem +
+ QFontDatabase::WritingSystemsCount, script) - scriptForWritingSystem;
+ if (writingSystem >= QFontDatabase::WritingSystemsCount)
+ writingSystem = QFontDatabase::Any;
QFontDatabasePrivate *db = privateDb();
for (int x = 0; x < db->count; ++x) {
@@ -1136,7 +1187,7 @@ static int match(int script, const QFontDef &request,
load(test.family->name, script);
// Check if family is supported in the script we want
- if (script != QChar::Script_Common && !(test.family->writingSystems[writingSystem] & QtFontFamily::Supported))
+ if (writingSystem != QFontDatabase::Any && !(test.family->writingSystems[writingSystem] & QtFontFamily::Supported))
continue;
// as we know the script is supported, we can be sure
@@ -1145,7 +1196,7 @@ static int match(int script, const QFontDef &request,
bestFoundry(script, score, request.styleStrategy,
test.family, foundry_name, styleKey, request.pixelSize, pitch,
&test, force_encoding_id, request.styleName);
- if (test.foundry == 0) {
+ if (test.foundry == 0 && !foundry_name.isEmpty()) {
// the specific foundry was not found, so look for
// any foundry matching our requirements
newscore = bestFoundry(script, score, request.styleStrategy, test.family,
@@ -1510,6 +1561,9 @@ bool QFontDatabase::isFixedPitch(const QString &family,
bool QFontDatabase::isBitmapScalable(const QString &family,
const QString &style) const
{
+ if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable())
+ return true;
+
bool bitmapScalable = false;
QString familyName, foundryName;
parseFontName(family, foundryName, familyName);
@@ -1518,11 +1572,10 @@ bool QFontDatabase::isBitmapScalable(const QString &family,
QT_PREPEND_NAMESPACE(load)(familyName);
- QtFontStyle::Key styleKey(style);
-
QtFontFamily *f = d->family(familyName);
if (!f) return bitmapScalable;
+ QtFontStyle::Key styleKey(style);
for (int j = 0; j < f->count; j++) {
QtFontFoundry *foundry = f->foundries[j];
if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
@@ -1551,6 +1604,9 @@ bool QFontDatabase::isBitmapScalable(const QString &family,
*/
bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &style) const
{
+ if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable())
+ return true;
+
bool smoothScalable = false;
QString familyName, foundryName;
parseFontName(family, foundryName, familyName);
@@ -1559,11 +1615,19 @@ bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &sty
QT_PREPEND_NAMESPACE(load)(familyName);
- QtFontStyle::Key styleKey(style);
-
QtFontFamily *f = d->family(familyName);
+ if (!f) {
+ for (int i = 0; i < d->count; i++) {
+ if (d->families[i]->matchesFamilyName(familyName)) {
+ f = d->families[i];
+ f->ensurePopulated();
+ break;
+ }
+ }
+ }
if (!f) return smoothScalable;
+ QtFontStyle::Key styleKey(style);
for (int j = 0; j < f->count; j++) {
QtFontFoundry *foundry = f->foundries[j];
if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
@@ -1616,8 +1680,6 @@ QList<int> QFontDatabase::pointSizes(const QString &family,
QT_PREPEND_NAMESPACE(load)(familyName);
- QtFontStyle::Key styleKey(styleName);
-
QList<int> sizes;
QtFontFamily *fam = d->family(familyName);
@@ -1626,6 +1688,7 @@ QList<int> QFontDatabase::pointSizes(const QString &family,
const int dpi = qt_defaultDpiY(); // embedded
+ QtFontStyle::Key styleKey(styleName);
for (int j = 0; j < fam->count; j++) {
QtFontFoundry *foundry = fam->foundries[j];
if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
@@ -1639,7 +1702,7 @@ QList<int> QFontDatabase::pointSizes(const QString &family,
for (int l = 0; l < style->count; l++) {
const QtFontSize *size = style->pixelSizes + l;
- if (size->pixelSize != 0 && size->pixelSize != USHRT_MAX) {
+ if (size->pixelSize != 0 && size->pixelSize != SMOOTH_SCALABLE) {
const uint pointSize = qRound(size->pixelSize * 72.0 / dpi);
if (! sizes.contains(pointSize))
sizes.append(pointSize);
@@ -1719,8 +1782,6 @@ QList<int> QFontDatabase::smoothSizes(const QString &family,
QT_PREPEND_NAMESPACE(load)(familyName);
- QtFontStyle::Key styleKey(styleName);
-
QList<int> sizes;
QtFontFamily *fam = d->family(familyName);
@@ -1729,6 +1790,7 @@ QList<int> QFontDatabase::smoothSizes(const QString &family,
const int dpi = qt_defaultDpiY(); // embedded
+ QtFontStyle::Key styleKey(styleName);
for (int j = 0; j < fam->count; j++) {
QtFontFoundry *foundry = fam->foundries[j];
if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
@@ -1742,7 +1804,7 @@ QList<int> QFontDatabase::smoothSizes(const QString &family,
for (int l = 0; l < style->count; l++) {
const QtFontSize *size = style->pixelSizes + l;
- if (size->pixelSize != 0 && size->pixelSize != USHRT_MAX) {
+ if (size->pixelSize != 0 && size->pixelSize != SMOOTH_SCALABLE) {
const uint pointSize = qRound(size->pixelSize * 72.0 / dpi);
if (! sizes.contains(pointSize))
sizes.append(pointSize);
@@ -1885,6 +1947,24 @@ bool QFontDatabase::hasFamily(const QString &family) const
/*!
+ \since 5.5
+
+ Returns \c true if and only if the \a family font family is private.
+
+ This happens, for instance, on OS X and iOS, where the system UI fonts are not
+ accessible to the user. For completeness, QFontDatabase::families() returns all
+ font families, including the private ones. You should use this function if you
+ are developing a font selection control in order to keep private fonts hidden.
+
+ \sa families()
+*/
+bool QFontDatabase::isPrivateFamily(const QString &family) const
+{
+ return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->isPrivateFontFamily(family);
+}
+
+
+/*!
Returns the names the \a writingSystem (e.g. for displaying to the
user in a dialog).
*/
@@ -2562,7 +2642,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
QFontDef req = d->request;
if (req.pixelSize == -1) {
- req.pixelSize = floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100;
+ req.pixelSize = std::floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100;
req.pixelSize = qRound(req.pixelSize);
}
if (req.pointSize < 0)
@@ -2572,19 +2652,27 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
if (req.stretch == 0)
req.stretch = 100;
+ if (!d->engineData) {
+ // look for the requested font in the engine data cache
+ d->engineData = QFontCache::instance()->findEngineData(req);
+ if (!d->engineData) {
+ // create a new one
+ d->engineData = new QFontEngineData;
+ QFontCache::instance()->insertEngineData(req, d->engineData);
+ }
+ d->engineData->ref.ref();
+ }
+
+ // the cached engineData could have already loaded the engine we want
+ if (d->engineData->engines[script])
+ return;
+
// Until we specifically asked not to, try looking for Multi font engine
// first, the last '1' indicates that we want Multi font engine instead
// of single ones
bool multi = !(req.styleStrategy & QFont::NoFontMerging);
QFontCache::Key key(req, script, multi ? 1 : 0);
- if (!d->engineData)
- getEngineData(d, req);
-
- // the cached engineData could have already loaded the engine we want
- if (d->engineData->engines[script])
- return;
-
QFontEngine *fe = QFontCache::instance()->findEngine(key);
// list of families to try
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index d7d8745f12..6d738d96be 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -51,8 +51,6 @@ class QFontDatabasePrivate;
class Q_GUI_EXPORT QFontDatabase
{
Q_GADGET
- Q_ENUMS(WritingSystem)
- Q_ENUMS(SystemFont)
public:
// do not re-order or delete entries from this enum without updating the
// QPF2 format and makeqpf!!
@@ -98,6 +96,7 @@ public:
WritingSystemsCount
};
+ Q_ENUM(WritingSystem)
enum SystemFont {
GeneralFont,
@@ -105,6 +104,7 @@ public:
TitleFont,
SmallestReadableFont
};
+ Q_ENUM(SystemFont)
static QList<int> standardSizes();
@@ -132,6 +132,7 @@ public:
int weight(const QString &family, const QString &style) const;
bool hasFamily(const QString &family) const;
+ bool isPrivateFamily(const QString &family) const;
static QString writingSystemName(WritingSystem writingSystem);
static QString writingSystemSample(WritingSystem writingSystem);
@@ -159,7 +160,7 @@ private:
friend class QFontPrivate;
friend class QFontDialog;
friend class QFontDialogPrivate;
- friend class QFontEngineMultiBasicImpl;
+ friend class QFontEngineMulti;
QFontDatabasePrivate *d;
};
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index b360ed5c85..b028d868b9 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -766,7 +766,7 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &t)
{
QImage i = alphaMapForGlyph(glyph);
if (t.type() > QTransform::TxTranslate)
- i = i.transformed(t).convertToFormat(QImage::Format_Indexed8);
+ i = i.transformed(t).convertToFormat(QImage::Format_Alpha8);
Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format...
return i;
@@ -779,7 +779,7 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, con
QImage i = alphaMapForGlyph(glyph, subPixelPosition);
if (t.type() > QTransform::TxTranslate)
- i = i.transformed(t).convertToFormat(QImage::Format_Indexed8);
+ i = i.transformed(t).convertToFormat(QImage::Format_Alpha8);
Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format...
return i;
@@ -790,12 +790,11 @@ QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition
QImage alphaMask = alphaMapForGlyph(glyph, t);
QImage rgbMask(alphaMask.width(), alphaMask.height(), QImage::Format_RGB32);
- QVector<QRgb> colorTable = alphaMask.colorTable();
for (int y=0; y<alphaMask.height(); ++y) {
uint *dst = (uint *) rgbMask.scanLine(y);
uchar *src = (uchar *) alphaMask.scanLine(y);
for (int x=0; x<alphaMask.width(); ++x) {
- int val = qAlpha(colorTable.at(src[x]));
+ int val = src[x];
dst[x] = qRgb(val, val, val);
}
}
@@ -876,20 +875,16 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph)
p.drawPath(path);
p.end();
- QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- indexed.setColorTable(colors);
+ QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8);
for (int y=0; y<im.height(); ++y) {
- uchar *dst = (uchar *) indexed.scanLine(y);
+ uchar *dst = (uchar *) alphaMap.scanLine(y);
uint *src = (uint *) im.scanLine(y);
for (int x=0; x<im.width(); ++x)
dst[x] = qAlpha(src[x]);
}
- return indexed;
+ return alphaMap;
}
void QFontEngine::removeGlyphFromCache(glyph_t)
@@ -1540,14 +1535,10 @@ bool QFontEngineBox::canRender(const QChar *, int) const
QImage QFontEngineBox::alphaMapForGlyph(glyph_t)
{
- QImage image(_size, _size, QImage::Format_Indexed8);
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- image.setColorTable(colors);
+ QImage image(_size, _size, QImage::Format_Alpha8);
image.fill(0);
- // can't use qpainter for index8; so use setPixel to draw our rectangle.
+ // FIXME: use qpainter
for (int i=2; i <= _size-3; ++i) {
image.setPixel(i, 2, 255);
image.setPixel(i, _size-3, 255);
@@ -1568,34 +1559,109 @@ static inline uchar highByte(glyph_t glyph)
static inline glyph_t stripped(glyph_t glyph)
{ return glyph & 0x00ffffff; }
-QFontEngineMulti::QFontEngineMulti(int engineCount)
- : QFontEngine(Multi)
+QFontEngineMulti::QFontEngineMulti(QFontEngine *engine, int script, const QStringList &fallbackFamilies)
+ : QFontEngine(Multi),
+ m_fallbackFamilies(fallbackFamilies),
+ m_script(script),
+ m_fallbackFamiliesQueried(!m_fallbackFamilies.isEmpty())
{
- engines.fill(0, engineCount);
- cache_cost = 0;
+ Q_ASSERT(engine && engine->type() != QFontEngine::Multi);
+
+ if (m_fallbackFamilies.isEmpty()) {
+ // defer obtaining the fallback families until loadEngine(1)
+ m_fallbackFamilies << QString();
+ }
+
+ m_engines.resize(m_fallbackFamilies.size() + 1);
+
+ engine->ref.ref();
+ m_engines[0] = engine;
+
+ fontDef = engine->fontDef;
+ cache_cost = engine->cache_cost;
}
QFontEngineMulti::~QFontEngineMulti()
{
- for (int i = 0; i < engines.size(); ++i) {
- QFontEngine *fontEngine = engines.at(i);
+ for (int i = 0; i < m_engines.size(); ++i) {
+ QFontEngine *fontEngine = m_engines.at(i);
if (fontEngine && !fontEngine->ref.deref())
delete fontEngine;
}
}
+void QFontEngineMulti::ensureFallbackFamiliesQueried()
+{
+ if (QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration()) {
+ const QStringList fallbackFamilies = integration->fontDatabase()->fallbacksForFamily(fontDef.family,
+ QFont::Style(fontDef.style),
+ QFont::AnyStyle,
+ QChar::Script(m_script));
+ setFallbackFamiliesList(fallbackFamilies);
+ }
+}
+
+void QFontEngineMulti::setFallbackFamiliesList(const QStringList &fallbackFamilies)
+{
+ Q_ASSERT(!m_fallbackFamiliesQueried);
+
+ m_fallbackFamilies = fallbackFamilies;
+ if (m_fallbackFamilies.isEmpty()) {
+ // turns out we lied about having any fallback at all
+ Q_ASSERT(m_engines.size() == 2); // see c-tor for details
+ QFontEngine *engine = m_engines.at(0);
+ engine->ref.ref();
+ m_engines[1] = engine;
+ m_fallbackFamilies << fontDef.family;
+ } else {
+ m_engines.resize(m_fallbackFamilies.size() + 1);
+ }
+
+ m_fallbackFamiliesQueried = true;
+}
+
+void QFontEngineMulti::ensureEngineAt(int at)
+{
+ if (!m_fallbackFamiliesQueried)
+ ensureFallbackFamiliesQueried();
+ Q_ASSERT(at < m_engines.size());
+ if (!m_engines.at(at)) {
+ QFontEngine *engine = loadEngine(at);
+ if (!engine)
+ engine = new QFontEngineBox(fontDef.pixelSize);
+ Q_ASSERT(engine && engine->type() != QFontEngine::Multi);
+ engine->ref.ref();
+ m_engines[at] = engine;
+ }
+}
+
+QFontEngine *QFontEngineMulti::loadEngine(int at)
+{
+ QFontDef request(fontDef);
+ request.styleStrategy |= QFont::NoFontMerging;
+ request.family = fallbackFamilyAt(at - 1);
+
+ if (QFontEngine *engine = QFontDatabase::findFont(m_script, /*fontprivate = */0, request, /*multi = */false)) {
+ engine->fontDef = request;
+ return engine;
+ }
+
+ return 0;
+}
+
glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const
{
glyph_t glyph = engine(0)->glyphIndex(ucs4);
if (glyph == 0 && ucs4 != QChar::LineSeparator) {
- const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
- for (int x = 1, n = qMin(engines.size(), 256); x < n; ++x) {
- QFontEngine *engine = engines.at(x);
+ if (!m_fallbackFamiliesQueried)
+ const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
+ for (int x = 1, n = qMin(m_engines.size(), 256); x < n; ++x) {
+ QFontEngine *engine = m_engines.at(x);
if (!engine) {
if (!shouldLoadFontEngineForCharacter(x, ucs4))
continue;
- const_cast<QFontEngineMulti *>(this)->loadEngine(x);
- engine = engines.at(x);
+ const_cast<QFontEngineMulti *>(this)->ensureEngineAt(x);
+ engine = m_engines.at(x);
}
Q_ASSERT(engine != 0);
if (engine->type() == Box)
@@ -1620,20 +1686,22 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len,
if (!engine(0)->stringToCMap(str, len, glyphs, nglyphs, flags))
return false;
- const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
int glyph_pos = 0;
QStringIterator it(str, str + len);
while (it.hasNext()) {
const uint ucs4 = it.peekNext();
if (glyphs->glyphs[glyph_pos] == 0 && ucs4 != QChar::LineSeparator) {
- for (int x = 1, n = qMin(engines.size(), 256); x < n; ++x) {
- if (engines.at(x) == 0 && !shouldLoadFontEngineForCharacter(x, ucs4))
- continue;
-
- QFontEngine *engine = engines.at(x);
+ if (!m_fallbackFamiliesQueried)
+ const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
+ for (int x = 1, n = qMin(m_engines.size(), 256); x < n; ++x) {
+ QFontEngine *engine = m_engines.at(x);
if (!engine) {
- const_cast<QFontEngineMulti *>(this)->loadEngine(x);
- engine = engines.at(x);
+ if (!shouldLoadFontEngineForCharacter(x, ucs4))
+ continue;
+ const_cast<QFontEngineMulti *>(this)->ensureEngineAt(x);
+ engine = m_engines.at(x);
+ if (!engine)
+ continue;
}
Q_ASSERT(engine != 0);
if (engine->type() == Box)
@@ -1888,7 +1956,6 @@ void QFontEngineMulti::doKerning(QGlyphLayout *glyphs, QFontEngine::ShaperFlags
glyph_metrics_t QFontEngineMulti::boundingBox(glyph_t glyph)
{
const int which = highByte(glyph);
- Q_ASSERT(which < engines.size());
return engine(which)->boundingBox(stripped(glyph));
}
@@ -1967,111 +2034,34 @@ bool QFontEngineMulti::canRender(const QChar *string, int len) const
QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph)
{
const int which = highByte(glyph);
- Q_ASSERT(which < engines.size());
return engine(which)->alphaMapForGlyph(stripped(glyph));
}
QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition)
{
const int which = highByte(glyph);
- Q_ASSERT(which < engines.size());
return engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition);
}
QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph, const QTransform &t)
{
const int which = highByte(glyph);
- Q_ASSERT(which < engines.size());
return engine(which)->alphaMapForGlyph(stripped(glyph), t);
}
QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)
{
const int which = highByte(glyph);
- Q_ASSERT(which < engines.size());
return engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition, t);
}
QImage QFontEngineMulti::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)
{
const int which = highByte(glyph);
- Q_ASSERT(which < engines.size());
return engine(which)->alphaRGBMapForGlyph(stripped(glyph), subPixelPosition, t);
}
/*
- Creates a new multi engine.
-
- This function takes ownership of the QFontEngine, increasing it's refcount.
-*/
-QFontEngineMultiBasicImpl::QFontEngineMultiBasicImpl(QFontEngine *fe, int _script, const QStringList &fallbacks)
- : QFontEngineMulti(fallbacks.size() + 1),
- fallbackFamilies(fallbacks), script(_script)
- , fallbacksQueried(true)
-{
- init(fe);
-}
-
-QFontEngineMultiBasicImpl::QFontEngineMultiBasicImpl(QFontEngine *fe, int _script)
- : QFontEngineMulti(2)
- , script(_script)
- , fallbacksQueried(false)
-{
- fallbackFamilies << QString();
- init(fe);
-}
-
-void QFontEngineMultiBasicImpl::init(QFontEngine *fe)
-{
- Q_ASSERT(fe && fe->type() != QFontEngine::Multi);
- engines[0] = fe;
- fe->ref.ref();
- fontDef = engines[0]->fontDef;
- cache_cost = fe->cache_cost;
-}
-
-void QFontEngineMultiBasicImpl::loadEngine(int at)
-{
- ensureFallbackFamiliesQueried();
- Q_ASSERT(at < engines.size());
- Q_ASSERT(engines.at(at) == 0);
- QFontDef request = fontDef;
- request.styleStrategy |= QFont::NoFontMerging;
- request.family = fallbackFamilies.at(at-1);
- engines[at] = QFontDatabase::findFont(script,
- /*fontprivate = */0,
- request, /*multi = */false);
- Q_ASSERT(engines[at]);
- engines[at]->ref.ref();
- engines[at]->fontDef = request;
-}
-void QFontEngineMultiBasicImpl::ensureFallbackFamiliesQueried()
-{
- if (fallbacksQueried)
- return;
- QStringList fallbacks = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fallbacksForFamily(engine(0)->fontDef.family, QFont::Style(engine(0)->fontDef.style)
- , QFont::AnyStyle, QChar::Script(script));
- setFallbackFamiliesList(fallbacks);
-}
-
-void QFontEngineMultiBasicImpl::setFallbackFamiliesList(const QStringList &fallbacks)
-{
- // Original FontEngine to restore after the fill.
- QFontEngine *fe = engines[0];
- fallbackFamilies = fallbacks;
- if (!fallbackFamilies.isEmpty()) {
- engines.fill(0, fallbackFamilies.size() + 1);
- engines[0] = fe;
- } else {
- // Turns out we lied about having any fallback at all.
- fallbackFamilies << fe->fontDef.family;
- engines[1] = fe;
- fe->ref.ref();
- }
- fallbacksQueried = true;
-}
-
-/*
This is used indirectly by Qt WebKit when using QTextLayout::setRawFont
The purpose of this is to provide the necessary font fallbacks when drawing complex
@@ -2079,7 +2069,7 @@ void QFontEngineMultiBasicImpl::setFallbackFamiliesList(const QStringList &fallb
the same raw font over and over again, we want to cache the corresponding multi font engine
as it may contain fallback font engines already.
*/
-QFontEngine* QFontEngineMultiBasicImpl::createMultiFontEngine(QFontEngine *fe, int script)
+QFontEngine *QFontEngineMulti::createMultiFontEngine(QFontEngine *fe, int script)
{
QFontEngine *engine = 0;
QFontCache::Key key(fe->fontDef, script, /*multi = */true);
@@ -2100,7 +2090,7 @@ QFontEngine* QFontEngineMultiBasicImpl::createMultiFontEngine(QFontEngine *fe, i
fc->updateHitCountAndTimeStamp(it.value());
break;
}
- it++;
+ ++it;
}
if (!engine) {
engine = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fontEngineMulti(fe, QChar::Script(script));
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 25156bf1e1..8176ede994 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -76,34 +76,6 @@
QT_BEGIN_NAMESPACE
-/*
- * Freetype 2.1.7 and earlier used width/height
- * for matching sizes in the BDF and PCF loaders.
- * This has been fixed for 2.1.8.
- */
-#if (FREETYPE_MAJOR*10000+FREETYPE_MINOR*100+FREETYPE_PATCH) >= 20105
-#define X_SIZE(face,i) ((face)->available_sizes[i].x_ppem)
-#define Y_SIZE(face,i) ((face)->available_sizes[i].y_ppem)
-#else
-#define X_SIZE(face,i) ((face)->available_sizes[i].width << 6)
-#define Y_SIZE(face,i) ((face)->available_sizes[i].height << 6)
-#endif
-
-/* FreeType 2.1.10 starts to provide FT_GlyphSlot_Embolden */
-#if (FREETYPE_MAJOR*10000+FREETYPE_MINOR*100+FREETYPE_PATCH) >= 20110
-#define Q_FT_GLYPHSLOT_EMBOLDEN(slot) FT_GlyphSlot_Embolden(slot)
-#else
-#define Q_FT_GLYPHSLOT_EMBOLDEN(slot)
-#endif
-
-/* FreeType 2.1.10 starts to provide FT_GlyphSlot_Oblique */
-#if (FREETYPE_MAJOR*10000+FREETYPE_MINOR*100+FREETYPE_PATCH) >= 20110
-#define Q_HAS_FT_GLYPHSLOT_OBLIQUE
-#define Q_FT_GLYPHSLOT_OBLIQUE(slot) FT_GlyphSlot_Oblique(slot)
-#else
-#define Q_FT_GLYPHSLOT_OBLIQUE(slot)
-#endif
-
#define FLOOR(x) ((x) & -64)
#define CEIL(x) (((x)+63) & -64)
#define TRUNC(x) ((x) >> 6)
@@ -297,7 +269,7 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id,
}
if (!FT_IS_SCALABLE(newFreetype->face) && newFreetype->face->num_fixed_sizes == 1)
- FT_Set_Char_Size (face, X_SIZE(newFreetype->face, 0), Y_SIZE(newFreetype->face, 0), 0, 0);
+ FT_Set_Char_Size(face, newFreetype->face->available_sizes[0].x_ppem, newFreetype->face->available_sizes[0].y_ppem, 0, 0);
FT_Set_Charmap(newFreetype->face, newFreetype->unicode_map);
QT_TRY {
@@ -357,18 +329,18 @@ void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize,
if (!(face->face_flags & FT_FACE_FLAG_SCALABLE)) {
int best = 0;
for (int i = 1; i < face->num_fixed_sizes; i++) {
- if (qAbs(*ysize - Y_SIZE(face,i)) <
- qAbs (*ysize - Y_SIZE(face, best)) ||
- (qAbs (*ysize - Y_SIZE(face, i)) ==
- qAbs (*ysize - Y_SIZE(face, best)) &&
- qAbs (*xsize - X_SIZE(face, i)) <
- qAbs (*xsize - X_SIZE(face, best)))) {
+ if (qAbs(*ysize - face->available_sizes[i].y_ppem) <
+ qAbs(*ysize - face->available_sizes[best].y_ppem) ||
+ (qAbs(*ysize - face->available_sizes[i].y_ppem) ==
+ qAbs(*ysize - face->available_sizes[best].y_ppem) &&
+ qAbs(*xsize - face->available_sizes[i].x_ppem) <
+ qAbs(*xsize - face->available_sizes[best].x_ppem))) {
best = i;
}
}
- if (FT_Set_Char_Size (face, X_SIZE(face, best), Y_SIZE(face, best), 0, 0) == 0) {
- *xsize = X_SIZE(face, best);
- *ysize = Y_SIZE(face, best);
+ if (FT_Set_Char_Size(face, face->available_sizes[best].x_ppem, face->available_sizes[best].y_ppem, 0, 0) == 0) {
+ *xsize = face->available_sizes[best].x_ppem;
+ *ysize = face->available_sizes[best].y_ppem;
} else {
int err = 1;
if (!(face->face_flags & FT_FACE_FLAG_SCALABLE) && ysize == 0 && face->num_fixed_sizes >= 1) {
@@ -538,7 +510,7 @@ void QFreetypeFace::addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoi
extern void qt_addBitmapToPath(qreal x0, qreal y0, const uchar *image_data, int bpl, int w, int h, QPainterPath *path);
-void QFreetypeFace::addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path, bool)
+void QFreetypeFace::addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path)
{
if (slot->format != FT_GLYPH_FORMAT_BITMAP
|| slot->bitmap.pixel_mode != FT_PIXEL_MODE_MONO)
@@ -719,14 +691,8 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
if (FT_IS_SCALABLE(face)) {
bool fake_oblique = (fontDef.style != QFont::StyleNormal) && !(face->style_flags & FT_STYLE_FLAG_ITALIC);
- if (fake_oblique) {
-#if !defined(Q_HAS_FT_GLYPHSLOT_OBLIQUE)
- matrix.xy = 0x10000*3/10;
- transform = true;
-#else
+ if (fake_oblique)
obliquen = true;
-#endif
- }
FT_Set_Transform(face, &matrix, 0);
freetype->matrix = matrix;
// fake bold
@@ -758,7 +724,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
*/
if (FT_IS_SCALABLE(face)) {
for (int i = 0; i < face->num_fixed_sizes; ++i) {
- if (xsize == X_SIZE(face, i) && ysize == Y_SIZE(face, i)) {
+ if (xsize == face->available_sizes[i].x_ppem && ysize == face->available_sizes[i].y_ppem) {
face->face_flags &= ~FT_FACE_FLAG_SCALABLE;
FT_Select_Size(face, i);
@@ -908,9 +874,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
FT_GlyphSlot slot = face->glyph;
- if (embolden) Q_FT_GLYPHSLOT_EMBOLDEN(slot);
+ if (embolden)
+ FT_GlyphSlot_Embolden(slot);
if (obliquen) {
- Q_FT_GLYPHSLOT_OBLIQUE(slot);
+ FT_GlyphSlot_Oblique(slot);
// While Embolden alters the metrics of the slot, oblique does not, so we need
// to fix this ourselves.
@@ -924,8 +891,6 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
FT_Matrix_Multiply(&m, &matrix);
}
- FT_Library library = qt_getFreetype();
-
info.xOff = TRUNC(ROUND(slot->advance.x));
info.yOff = 0;
@@ -963,12 +928,12 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
return g;
}
- uchar *glyph_buffer = 0;
int glyph_buffer_size = 0;
+ QScopedArrayPointer<uchar> glyph_buffer;
#if defined(QT_USE_FREETYPE_LCDFILTER)
bool useFreetypeRenderGlyph = false;
if (slot->format == FT_GLYPH_FORMAT_OUTLINE && (hsubpixel || vfactor != 1)) {
- err = FT_Library_SetLcdFilter(library, (FT_LcdFilter)lcdFilterType);
+ err = FT_Library_SetLcdFilter(slot->library, (FT_LcdFilter)lcdFilterType);
if (err == FT_Err_Ok)
useFreetypeRenderGlyph = true;
}
@@ -979,7 +944,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
if (err != FT_Err_Ok)
qWarning("render glyph failed err=%x face=%p, glyph=%d", err, face, glyph);
- FT_Library_SetLcdFilter(library, FT_LCD_FILTER_NONE);
+ FT_Library_SetLcdFilter(slot->library, FT_LCD_FILTER_NONE);
info.height = slot->bitmap.rows / vfactor;
info.width = hsubpixel ? slot->bitmap.width / 3 : slot->bitmap.width;
@@ -987,12 +952,12 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
info.y = slot->bitmap_top;
glyph_buffer_size = info.width * info.height * 4;
- glyph_buffer = new uchar[glyph_buffer_size];
+ glyph_buffer.reset(new uchar[glyph_buffer_size]);
if (hsubpixel)
- convertRGBToARGB(slot->bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_RGB, false);
+ convertRGBToARGB(slot->bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_RGB, false);
else if (vfactor != 1)
- convertRGBToARGB_V(slot->bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_VRGB, false);
+ convertRGBToARGB_V(slot->bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_VRGB, false);
} else
#endif
{
@@ -1063,26 +1028,30 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
|| ((signed char)(info.xOff) != info.xOff));
if (large_glyph) {
- delete [] glyph_buffer;
return 0;
}
int pitch = (format == Format_Mono ? ((info.width + 31) & ~31) >> 3 :
(format == Format_A8 ? (info.width + 3) & ~3 : info.width * 4));
- glyph_buffer_size = pitch * info.height;
- glyph_buffer = new uchar[glyph_buffer_size];
- memset(glyph_buffer, 0, glyph_buffer_size);
+ if (glyph_buffer_size < pitch * info.height) {
+ glyph_buffer_size = pitch * info.height;
+ glyph_buffer.reset(new uchar[glyph_buffer_size]);
+ }
+ memset(glyph_buffer.data(), 0, glyph_buffer_size);
if (slot->format == FT_GLYPH_FORMAT_OUTLINE) {
FT_Bitmap bitmap;
bitmap.rows = info.height*vfactor;
bitmap.width = hpixels;
bitmap.pitch = format == Format_Mono ? (((info.width + 31) & ~31) >> 3) : ((bitmap.width + 3) & ~3);
- if (!hsubpixel && vfactor == 1 && format != Format_A32)
- bitmap.buffer = glyph_buffer;
- else
- bitmap.buffer = new uchar[bitmap.rows*bitmap.pitch];
- memset(bitmap.buffer, 0, bitmap.rows*bitmap.pitch);
+ int bitmap_buffer_size = bitmap.rows * bitmap.pitch;
+ if (!hsubpixel && vfactor == 1 && format != Format_A32) {
+ Q_ASSERT(glyph_buffer_size <= bitmap_buffer_size);
+ bitmap.buffer = glyph_buffer.data();
+ } else {
+ bitmap.buffer = new uchar[bitmap_buffer_size];
+ memset(bitmap.buffer, 0, bitmap_buffer_size);
+ }
bitmap.pixel_mode = format == Format_Mono ? FT_PIXEL_MODE_MONO : FT_PIXEL_MODE_GRAY;
FT_Matrix matrix;
matrix.xx = (hsubpixel ? 3 : 1) << 16;
@@ -1091,11 +1060,11 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
FT_Outline_Transform(&slot->outline, &matrix);
FT_Outline_Translate (&slot->outline, (hsubpixel ? -3*left +(4<<6) : -left), -bottom*vfactor);
- FT_Outline_Get_Bitmap(library, &slot->outline, &bitmap);
+ FT_Outline_Get_Bitmap(slot->library, &slot->outline, &bitmap);
if (hsubpixel) {
Q_ASSERT (bitmap.pixel_mode == FT_PIXEL_MODE_GRAY);
Q_ASSERT(antialias);
- uchar *convoluted = new uchar[bitmap.rows*bitmap.pitch];
+ uchar *convoluted = new uchar[bitmap_buffer_size];
bool useLegacyLcdFilter = false;
#if defined(FC_LCD_FILTER) && defined(FT_LCD_FILTER_H)
useLegacyLcdFilter = (lcdFilterType == FT_LCD_FILTER_LEGACY);
@@ -1105,20 +1074,20 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
convoluteBitmap(bitmap.buffer, convoluted, bitmap.width, info.height, bitmap.pitch);
buffer = convoluted;
}
- convertRGBToARGB(buffer + 1, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != Subpixel_RGB, useLegacyLcdFilter);
+ convertRGBToARGB(buffer + 1, (uint *)glyph_buffer.data(), info.width, info.height, bitmap.pitch, subpixelType != Subpixel_RGB, useLegacyLcdFilter);
delete [] convoluted;
} else if (vfactor != 1) {
- convertRGBToARGB_V(bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != Subpixel_VRGB, true);
+ convertRGBToARGB_V(bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, bitmap.pitch, subpixelType != Subpixel_VRGB, true);
} else if (format == Format_A32 && bitmap.pixel_mode == FT_PIXEL_MODE_GRAY) {
- convertGRAYToARGB(bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch);
+ convertGRAYToARGB(bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, bitmap.pitch);
}
- if (bitmap.buffer != glyph_buffer)
+ if (bitmap.buffer != glyph_buffer.data())
delete [] bitmap.buffer;
} else if (slot->format == FT_GLYPH_FORMAT_BITMAP) {
Q_ASSERT(slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO);
uchar *src = slot->bitmap.buffer;
- uchar *dst = glyph_buffer;
+ uchar *dst = glyph_buffer.data();
int h = slot->bitmap.rows;
if (format == Format_Mono) {
int bytes = ((info.width + 7) & ~7) >> 3;
@@ -1163,7 +1132,6 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
}
} else {
qWarning("QFontEngine: Glyph neither outline nor bitmap format=%d", slot->format);
- delete [] glyph_buffer;
return 0;
}
}
@@ -1182,7 +1150,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
g->advance = info.xOff;
g->format = format;
delete [] g->data;
- g->data = glyph_buffer;
+ g->data = glyph_buffer.take();
if (set)
set->setGlyph(glyph, subPixelPosition, g);
@@ -1366,14 +1334,14 @@ static inline FT_Matrix QTransformToFTMatrix(const QTransform &matrix)
return m;
}
-QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransform &matrix)
+QFontEngineFT::QGlyphSet *QFontEngineFT::loadGlyphSet(const QTransform &matrix)
{
if (matrix.type() > QTransform::TxShear || !cacheEnabled)
return 0;
// FT_Set_Transform only supports scalable fonts
if (!FT_IS_SCALABLE(freetype->face))
- return 0;
+ return matrix.type() <= QTransform::TxTranslate ? &defaultGlyphSet : Q_NULLPTR;
FT_Matrix m = QTransformToFTMatrix(matrix);
@@ -1463,7 +1431,7 @@ void QFontEngineFT::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyph
for (int gl = 0; gl < glyphs.numGlyphs; gl++) {
FT_UInt glyph = positioned_glyphs[gl];
FT_Load_Glyph(face, glyph, FT_LOAD_TARGET_MONO);
- freetype->addBitmapToPath(face->glyph, positions[gl], path);
+ QFreetypeFace::addBitmapToPath(face->glyph, positions[gl], path);
}
unlockFace();
}
@@ -1482,8 +1450,10 @@ void QFontEngineFT::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int
FT_GlyphSlot g = face->glyph;
if (g->format != FT_GLYPH_FORMAT_OUTLINE)
continue;
- if (embolden) Q_FT_GLYPHSLOT_EMBOLDEN(g);
- if (obliquen) Q_FT_GLYPHSLOT_OBLIQUE(g);
+ if (embolden)
+ FT_GlyphSlot_Embolden(g);
+ if (obliquen)
+ FT_GlyphSlot_Oblique(g);
QFreetypeFace::addGlyphToPath(face, g, positions[gl], path, xsize, ysize);
}
unlockFace();
@@ -1775,7 +1745,7 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
format = QImage::Format_Mono;
break;
case Format_A8:
- format = QImage::Format_Indexed8;
+ format = QImage::Format_Alpha8;
break;
case Format_A32:
format = QImage::Format_ARGB32;
@@ -1786,17 +1756,12 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
};
QFontEngineFT::Glyph *glyph;
- QScopedPointer<QFontEngineFT::Glyph> glyphGuard;
if (cacheEnabled) {
- QFontEngineFT::QGlyphSet *gset = &defaultGlyphSet;
+ QGlyphSet *gset = loadGlyphSet(t);
QFontEngine::HintStyle hintStyle = default_hint_style;
if (t.type() >= QTransform::TxScale) {
// disable hinting if the glyphs are transformed
default_hint_style = HintNone;
- if (t.isAffine())
- gset = loadTransformedGlyphSet(t);
- else
- gset = 0;
}
if (gset) {
@@ -1806,15 +1771,13 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
freetype->matrix = m;
}
- if (!gset || gset->outline_drawing || !loadGlyph(gset, glyphIndex, subPixelPosition,
- neededFormat)) {
+ if (!gset || gset->outline_drawing || !(glyph = loadGlyph(gset, glyphIndex, subPixelPosition,
+ neededFormat))) {
default_hint_style = hintStyle;
return QFontEngine::lockedAlphaMapForGlyph(glyphIndex, subPixelPosition, neededFormat, t,
offset);
}
default_hint_style = hintStyle;
-
- glyph = gset->getGlyph(glyphIndex, subPixelPosition);
} else {
FT_Matrix m = matrix;
FT_Matrix extra = QTransformToFTMatrix(t);
@@ -1822,10 +1785,11 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
FT_Set_Transform(freetype->face, &m, 0);
freetype->matrix = m;
glyph = loadGlyph(0, glyphIndex, subPixelPosition, neededFormat);
- glyphGuard.reset(glyph);
}
if (glyph == 0 || glyph->data == 0 || glyph->width == 0 || glyph->height == 0) {
+ if (!cacheEnabled && glyph != &emptyGlyph)
+ delete glyph;
unlockFace();
return 0;
}
@@ -1850,8 +1814,10 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
*offset = QPoint(glyph->x, -glyph->y);
currentlyLockedAlphaMap = QImage(glyph->data, glyph->width, glyph->height, pitch, format);
- if (!glyphGuard.isNull())
+ if (!cacheEnabled && glyph != &emptyGlyph) {
currentlyLockedAlphaMap = currentlyLockedAlphaMap.copy();
+ delete glyph;
+ }
Q_ASSERT(!currentlyLockedAlphaMap.isNull());
QImageData *data = currentlyLockedAlphaMap.data_ptr();
@@ -1873,31 +1839,20 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g,
const QTransform &t,
bool fetchBoundingBox)
{
- FT_Face face = 0;
- QGlyphSet *glyphSet = 0;
- FT_Matrix ftMatrix = QTransformToFTMatrix(t);
- if (cacheEnabled) {
- if (t.type() > QTransform::TxTranslate && FT_IS_SCALABLE(freetype->face))
- glyphSet = loadTransformedGlyphSet(t);
- else
- glyphSet = &defaultGlyphSet;
- Q_ASSERT(glyphSet != 0);
- }
-
+ QGlyphSet *glyphSet = loadGlyphSet(t);
if (glyphSet != 0 && glyphSet->outline_drawing && !fetchBoundingBox)
return 0;
Glyph *glyph = glyphSet != 0 ? glyphSet->getGlyph(g, subPixelPosition) : 0;
- if (!glyph || glyph->format != format) {
- face = lockFace();
+ if (!glyph || glyph->format != format || (!fetchBoundingBox && !glyph->data)) {
+ lockFace();
FT_Matrix m = this->matrix;
+ FT_Matrix ftMatrix = glyphSet != 0 ? glyphSet->transformationMatrix : QTransformToFTMatrix(t);
FT_Matrix_Multiply(&ftMatrix, &m);
freetype->matrix = m;
glyph = loadGlyph(glyphSet, g, subPixelPosition, format, false);
- }
-
- if (face)
unlockFace();
+ }
return glyph;
}
@@ -1909,23 +1864,17 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition)
QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition, const QTransform &t)
{
- lockFace();
-
- QScopedPointer<Glyph> glyph(loadGlyphFor(g, subPixelPosition, antialias ? Format_A8 : Format_Mono, t));
+ Glyph *glyph = loadGlyphFor(g, subPixelPosition, antialias ? Format_A8 : Format_Mono, t);
if (!glyph || !glyph->data) {
- unlockFace();
+ if (!cacheEnabled && glyph != &emptyGlyph)
+ delete glyph;
return QFontEngine::alphaMapForGlyph(g);
}
const int pitch = antialias ? (glyph->width + 3) & ~3 : ((glyph->width + 31)/32) * 4;
- QImage img(glyph->width, glyph->height, antialias ? QImage::Format_Indexed8 : QImage::Format_Mono);
- if (antialias) {
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- img.setColorTable(colors);
- } else {
+ QImage img(glyph->width, glyph->height, antialias ? QImage::Format_Alpha8 : QImage::Format_Mono);
+ if (!antialias) {
QVector<QRgb> colors(2);
colors[0] = qRgba(0, 0, 0, 0);
colors[1] = qRgba(0, 0, 0, 255);
@@ -1936,9 +1885,9 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition, const
for (int y = 0; y < glyph->height; ++y)
memcpy(img.scanLine(y), &glyph->data[y * pitch], pitch);
}
- if (cacheEnabled)
- glyph.take();
- unlockFace();
+
+ if (!cacheEnabled && glyph != &emptyGlyph)
+ delete glyph;
return img;
}
@@ -1948,20 +1897,18 @@ QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, QFixed subPixelPosition, co
if (t.type() > QTransform::TxRotate)
return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, t);
- lockFace();
-
- QScopedPointer<Glyph> glyph(loadGlyphFor(g, subPixelPosition, Format_A32, t));
+ Glyph *glyph = loadGlyphFor(g, subPixelPosition, Format_A32, t);
if (!glyph || !glyph->data) {
- unlockFace();
+ if (!cacheEnabled && glyph != &emptyGlyph)
+ delete glyph;
return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, t);
}
QImage img(glyph->width, glyph->height, QImage::Format_RGB32);
memcpy(img.bits(), glyph->data, 4 * glyph->width * glyph->height);
- if (cacheEnabled)
- glyph.take();
- unlockFace();
+ if (!cacheEnabled && glyph != &emptyGlyph)
+ delete glyph;
return img;
}
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index b40893c445..e9d058d50c 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -102,7 +102,7 @@ public:
int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints);
static void addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoint &point, QPainterPath *path, FT_Fixed x_scale, FT_Fixed y_scale);
- static void addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path, bool = false);
+ static void addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path);
private:
friend class QFontEngineFT;
@@ -188,67 +188,67 @@ private:
mutable int fast_glyph_count;
};
- virtual QFontEngine::FaceId faceId() const;
- virtual QFontEngine::Properties properties() const;
- virtual QFixed emSquareSize() const;
- virtual bool supportsSubPixelPositions() const
+ virtual QFontEngine::FaceId faceId() const Q_DECL_OVERRIDE;
+ virtual QFontEngine::Properties properties() const Q_DECL_OVERRIDE;
+ virtual QFixed emSquareSize() const Q_DECL_OVERRIDE;
+ virtual bool supportsSubPixelPositions() const Q_DECL_OVERRIDE
{
return default_hint_style == HintLight ||
default_hint_style == HintNone;
}
- virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
- virtual int synthesized() const;
+ virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const Q_DECL_OVERRIDE;
+ virtual int synthesized() const Q_DECL_OVERRIDE;
- virtual QFixed ascent() const;
- virtual QFixed descent() const;
- virtual QFixed leading() const;
- virtual QFixed xHeight() const;
- virtual QFixed averageCharWidth() const;
+ virtual QFixed ascent() 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;
+ virtual QFixed averageCharWidth() const Q_DECL_OVERRIDE;
- virtual qreal maxCharWidth() const;
- virtual qreal minLeftBearing() const;
- virtual qreal minRightBearing() const;
- virtual QFixed lineThickness() const;
- virtual QFixed underlinePosition() const;
+ virtual qreal maxCharWidth() const Q_DECL_OVERRIDE;
+ virtual qreal minLeftBearing() const Q_DECL_OVERRIDE;
+ virtual qreal minRightBearing() const Q_DECL_OVERRIDE;
+ virtual QFixed lineThickness() const Q_DECL_OVERRIDE;
+ virtual QFixed underlinePosition() const Q_DECL_OVERRIDE;
- virtual glyph_t glyphIndex(uint ucs4) const;
- void doKerning(QGlyphLayout *, ShaperFlags) const;
+ virtual glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE;
+ void doKerning(QGlyphLayout *, ShaperFlags) const Q_DECL_OVERRIDE;
- virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
+ virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) Q_DECL_OVERRIDE;
- virtual bool supportsTransformation(const QTransform &transform) const;
+ virtual bool supportsTransformation(const QTransform &transform) const Q_DECL_OVERRIDE;
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
- QPainterPath *path, QTextItem::RenderFlags flags);
+ QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE;
virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs,
- QPainterPath *path, QTextItem::RenderFlags flags);
+ QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE;
- virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
+ virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE;
- virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
- virtual glyph_metrics_t boundingBox(glyph_t glyph);
- virtual glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix);
+ virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE;
+ virtual glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE;
+ virtual glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix) Q_DECL_OVERRIDE;
- virtual void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags flags) const;
- virtual QImage alphaMapForGlyph(glyph_t g) { return alphaMapForGlyph(g, 0); }
- virtual QImage alphaMapForGlyph(glyph_t, QFixed);
- QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t);
- virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
+ virtual void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags flags) const Q_DECL_OVERRIDE;
+ virtual QImage alphaMapForGlyph(glyph_t g) Q_DECL_OVERRIDE { return alphaMapForGlyph(g, 0); }
+ virtual QImage alphaMapForGlyph(glyph_t, QFixed) Q_DECL_OVERRIDE;
+ QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE;
+ virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE;
virtual glyph_metrics_t alphaMapBoundingBox(glyph_t glyph,
QFixed subPixelPosition,
const QTransform &matrix,
- QFontEngine::GlyphFormat format);
+ QFontEngine::GlyphFormat format) Q_DECL_OVERRIDE;
virtual QImage *lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition,
GlyphFormat neededFormat, const QTransform &t,
- QPoint *offset);
- virtual bool hasInternalCaching() const { return cacheEnabled; }
- virtual void unlockAlphaMapForGlyph();
+ QPoint *offset) Q_DECL_OVERRIDE;
+ virtual bool hasInternalCaching() const Q_DECL_OVERRIDE { return cacheEnabled; }
+ virtual void unlockAlphaMapForGlyph() Q_DECL_OVERRIDE;
- virtual void removeGlyphFromCache(glyph_t glyph);
- virtual int glyphMargin(QFontEngine::GlyphFormat /* format */) { return 0; }
+ virtual void removeGlyphFromCache(glyph_t glyph) Q_DECL_OVERRIDE;
+ virtual int glyphMargin(QFontEngine::GlyphFormat /* format */) Q_DECL_OVERRIDE { return 0; }
- virtual int glyphCount() const;
+ virtual int glyphCount() const Q_DECL_OVERRIDE;
enum Scaling {
Scaled,
@@ -268,7 +268,7 @@ private:
Glyph *loadGlyph(QGlyphSet *set, uint glyph, QFixed subPixelPosition, GlyphFormat = Format_None, bool fetchMetricsOnly = false) const;
Glyph *loadGlyphFor(glyph_t g, QFixed subPixelPosition, GlyphFormat format, const QTransform &t, bool fetchBoundingBox = false);
- QGlyphSet *loadTransformedGlyphSet(const QTransform &matrix);
+ QGlyphSet *loadGlyphSet(const QTransform &matrix);
QFontEngineFT(const QFontDef &fd);
virtual ~QFontEngineFT();
@@ -278,12 +278,12 @@ private:
bool init(FaceId faceId, bool antialias, GlyphFormat format,
QFreetypeFace *freetypeFace);
- virtual int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints);
+ virtual int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints) Q_DECL_OVERRIDE;
- virtual void setDefaultHintStyle(HintStyle style);
+ virtual void setDefaultHintStyle(HintStyle style) Q_DECL_OVERRIDE;
- virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
+ virtual QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
bool initFromFontEngine(const QFontEngineFT *fontEngine);
HintStyle defaultHintStyle() const { return default_hint_style; }
@@ -305,6 +305,7 @@ protected:
private:
friend class QFontEngineFTRawFont;
friend class QFontconfigDatabase;
+ friend class QBasicFontDatabase;
friend class QFontEngineMultiFontConfig;
int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const;
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 9364b82bed..2076fa4d80 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -78,10 +78,6 @@ enum HB_Compat_Error {
typedef void (*qt_destroy_func_t) (void *user_data);
typedef bool (*qt_get_font_table_func_t) (void *user_data, uint tag, uchar *buffer, uint *length);
-const QFont::Weight qt_mediumFontWeight = static_cast<QFont::Weight>(57);
-const QFont::Weight qt_extralightFontWeight = static_cast<QFont::Weight>(12);
-const QFont::Weight qt_thinFontWeight = static_cast<QFont::Weight>(0);
-
class Q_GUI_EXPORT QFontEngine
{
public:
@@ -351,26 +347,26 @@ public:
QFontEngineBox(int size);
~QFontEngineBox();
- virtual glyph_t glyphIndex(uint ucs4) const;
- virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
- virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const;
+ virtual glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE;
+ virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE;
+ virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const Q_DECL_OVERRIDE;
void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si);
- virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags);
-
- virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
- virtual glyph_metrics_t boundingBox(glyph_t glyph);
- virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
-
- virtual QFixed ascent() const;
- virtual QFixed descent() const;
- virtual QFixed leading() const;
- virtual qreal maxCharWidth() const;
- virtual qreal minLeftBearing() const { return 0; }
- virtual qreal minRightBearing() const { return 0; }
- virtual QImage alphaMapForGlyph(glyph_t);
+ virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE;
+
+ virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE;
+ virtual glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE;
+ virtual QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
+
+ virtual QFixed ascent() 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;
+ virtual qreal minLeftBearing() const Q_DECL_OVERRIDE { return 0; }
+ virtual qreal minRightBearing() const Q_DECL_OVERRIDE { return 0; }
+ virtual QImage alphaMapForGlyph(glyph_t) Q_DECL_OVERRIDE;
- virtual bool canRender(const QChar *string, int len) const;
+ virtual bool canRender(const QChar *string, int len) const Q_DECL_OVERRIDE;
inline int size() const { return _size; }
@@ -385,79 +381,61 @@ private:
class Q_GUI_EXPORT QFontEngineMulti : public QFontEngine
{
public:
- explicit QFontEngineMulti(int engineCount);
+ explicit QFontEngineMulti(QFontEngine *engine, int script, const QStringList &fallbackFamilies = QStringList());
~QFontEngineMulti();
- virtual glyph_t glyphIndex(uint ucs4) const;
- virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
-
- virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
- virtual glyph_metrics_t boundingBox(glyph_t glyph);
-
- virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const;
- virtual void doKerning(QGlyphLayout *, ShaperFlags) const;
- virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags);
- virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
+ virtual glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE;
+ virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE;
- virtual QFixed ascent() const;
- virtual QFixed descent() const;
- virtual QFixed leading() const;
- virtual QFixed xHeight() const;
- virtual QFixed averageCharWidth() const;
- virtual QImage alphaMapForGlyph(glyph_t);
- virtual QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition);
- virtual QImage alphaMapForGlyph(glyph_t, const QTransform &t);
- virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
- virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
+ virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE;
+ virtual glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE;
- virtual QFixed lineThickness() const;
- virtual QFixed underlinePosition() const;
- virtual qreal maxCharWidth() const;
- virtual qreal minLeftBearing() const;
- virtual qreal minRightBearing() const;
+ virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const Q_DECL_OVERRIDE;
+ virtual void doKerning(QGlyphLayout *, ShaperFlags) const Q_DECL_OVERRIDE;
+ virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE;
+ virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0) Q_DECL_OVERRIDE;
- virtual bool canRender(const QChar *string, int len) const;
+ virtual QFixed ascent() 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;
+ virtual QFixed averageCharWidth() const Q_DECL_OVERRIDE;
+ virtual QImage alphaMapForGlyph(glyph_t) Q_DECL_OVERRIDE;
+ virtual QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition) Q_DECL_OVERRIDE;
+ virtual QImage alphaMapForGlyph(glyph_t, const QTransform &t) Q_DECL_OVERRIDE;
+ virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE;
+ virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE;
- QFontEngine *engine(int at) const
- {Q_ASSERT(at < engines.size()); return engines.at(at); }
+ virtual QFixed lineThickness() const Q_DECL_OVERRIDE;
+ virtual QFixed underlinePosition() const Q_DECL_OVERRIDE;
+ virtual qreal maxCharWidth() const Q_DECL_OVERRIDE;
+ virtual qreal minLeftBearing() const Q_DECL_OVERRIDE;
+ virtual qreal minRightBearing() const Q_DECL_OVERRIDE;
- inline void ensureEngineAt(int at)
- {
- if (at >= engines.size() || engines.at(at) == 0)
- loadEngine(at);
- }
+ virtual bool canRender(const QChar *string, int len) const Q_DECL_OVERRIDE;
- virtual bool shouldLoadFontEngineForCharacter(int at, uint ucs4) const;
- virtual void setFallbackFamiliesList(const QStringList &) {}
+ inline int fallbackFamilyCount() const { return m_fallbackFamilies.size(); }
+ inline QString fallbackFamilyAt(int at) const { return m_fallbackFamilies.at(at); }
-protected:
- friend class QRawFont;
- virtual void loadEngine(int at) = 0;
- virtual void ensureFallbackFamiliesQueried() {}
- QVector<QFontEngine *> engines;
-};
+ void setFallbackFamiliesList(const QStringList &fallbackFamilies);
-class Q_GUI_EXPORT QFontEngineMultiBasicImpl : public QFontEngineMulti
-{
-public:
- QFontEngineMultiBasicImpl(QFontEngine *fe, int script, const QStringList &fallbacks);
- QFontEngineMultiBasicImpl(QFontEngine *fe, int script);
+ inline QFontEngine *engine(int at) const
+ { Q_ASSERT(at < m_engines.size()); return m_engines.at(at); }
- void loadEngine(int at);
- static QFontEngine* createMultiFontEngine(QFontEngine *fe, int script);
+ void ensureEngineAt(int at);
- int fallbackFamilyCount() const { return fallbackFamilies.size(); }
- QString fallbackFamilyAt(int at) const { return fallbackFamilies.at(at); }
+ static QFontEngine *createMultiFontEngine(QFontEngine *fe, int script);
+protected:
virtual void ensureFallbackFamiliesQueried();
- virtual void setFallbackFamiliesList(const QStringList &fallbacks);
+ virtual bool shouldLoadFontEngineForCharacter(int at, uint ucs4) const;
+ virtual QFontEngine *loadEngine(int at);
private:
- void init(QFontEngine *fe);
-
- mutable QStringList fallbackFamilies;
- int script;
- mutable bool fallbacksQueried;
+ QVector<QFontEngine *> m_engines;
+ QStringList m_fallbackFamilies;
+ const int m_script;
+ bool m_fallbackFamiliesQueried;
};
class QTestFontEngine : public QFontEngineBox
diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp
index 4785902c99..7e16983b6c 100644
--- a/src/gui/text/qfontengine_qpf2.cpp
+++ b/src/gui/text/qfontengine_qpf2.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -396,7 +396,7 @@ QImage QFontEngineQPF2::alphaMapForGlyph(glyph_t g)
const uchar *bits = ((const uchar *) glyph) + sizeof(Glyph);
- QImage image(bits,glyph->width, glyph->height, glyph->bytesPerLine, QImage::Format_Indexed8);
+ QImage image(bits,glyph->width, glyph->height, glyph->bytesPerLine, QImage::Format_Alpha8);
return image;
}
diff --git a/src/gui/text/qfontengine_qpf2_p.h b/src/gui/text/qfontengine_qpf2_p.h
index e8c3989b58..349fd483bf 100644
--- a/src/gui/text/qfontengine_qpf2_p.h
+++ b/src/gui/text/qfontengine_qpf2_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -152,29 +152,29 @@ public:
QFontEngineQPF2(const QFontDef &def, const QByteArray &data);
~QFontEngineQPF2();
- FaceId faceId() const { return face_id; }
- bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
+ FaceId faceId() const Q_DECL_OVERRIDE { return face_id; }
+ bool getSfntTableData(uint tag, uchar *buffer, uint *length) const Q_DECL_OVERRIDE;
- virtual glyph_t glyphIndex(uint ucs4) const;
- bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
- void recalcAdvances(QGlyphLayout *, ShaperFlags) const;
+ virtual glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE;
+ bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE;
+ void recalcAdvances(QGlyphLayout *, ShaperFlags) const Q_DECL_OVERRIDE;
- void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags);
- QImage alphaMapForGlyph(glyph_t t);
+ void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE;
+ QImage alphaMapForGlyph(glyph_t t) Q_DECL_OVERRIDE;
- glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
- glyph_metrics_t boundingBox(glyph_t glyph);
+ glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE;
+ glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE;
- QFixed ascent() const;
- QFixed descent() const;
- QFixed leading() const;
- qreal maxCharWidth() const;
- qreal minLeftBearing() const;
- qreal minRightBearing() const;
- QFixed underlinePosition() const;
- QFixed lineThickness() const;
+ QFixed ascent() const Q_DECL_OVERRIDE;
+ QFixed descent() const Q_DECL_OVERRIDE;
+ QFixed leading() const Q_DECL_OVERRIDE;
+ qreal maxCharWidth() const Q_DECL_OVERRIDE;
+ qreal minLeftBearing() const Q_DECL_OVERRIDE;
+ qreal minRightBearing() const Q_DECL_OVERRIDE;
+ QFixed underlinePosition() const Q_DECL_OVERRIDE;
+ QFixed lineThickness() const Q_DECL_OVERRIDE;
- virtual int glyphCount() const { return glyphMapEntries; }
+ virtual int glyphCount() const Q_DECL_OVERRIDE { return glyphMapEntries; }
bool isValid() const;
diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h
index 4a3345f9df..6cf4d2f1ba 100644
--- a/src/gui/text/qfontengineglyphcache_p.h
+++ b/src/gui/text/qfontengineglyphcache_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qfontinfo.h b/src/gui/text/qfontinfo.h
index 68647d6841..76addc9aa5 100644
--- a/src/gui/text/qfontinfo.h
+++ b/src/gui/text/qfontinfo.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -65,7 +65,9 @@ public:
bool strikeOut() const;
bool fixedPitch() const;
QFont::StyleHint styleHint() const;
+#if QT_DEPRECATED_SINCE(5, 5)
bool rawMode() const;
+#endif
bool exactMatch() const;
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index e010dd62ae..c2d4b64152 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -38,9 +38,6 @@
#include "qfont_p.h"
#include "qfontengine_p.h"
-#include <math.h>
-
-
QT_BEGIN_NAMESPACE
diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h
index c152ad21c7..12aa2dadb4 100644
--- a/src/gui/text/qfontmetrics.h
+++ b/src/gui/text/qfontmetrics.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp
index 160472cb5d..9f652084be 100644
--- a/src/gui/text/qfontsubset.cpp
+++ b/src/gui/text/qfontsubset.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -36,7 +36,6 @@
#include <qendian.h>
#include <qpainterpath.h>
#include "private/qpdf_p.h"
-#include "private/qfunctions_p.h"
#include "qfontsubset_agl.cpp"
@@ -421,7 +420,7 @@ static quint32 checksum(const QByteArray &table)
{
quint32 sum = 0;
int offset = 0;
- const uchar *d = (uchar *)table.constData();
+ const uchar *d = (const uchar *)table.constData();
while (offset <= table.size()-3) {
sum += qFromBigEndian<quint32>(d + offset);
offset += 4;
@@ -979,7 +978,7 @@ static QTtfGlyph generateGlyph(int index, const QPainterPath &path, qreal advanc
return glyph;
}
-Q_STATIC_GLOBAL_OPERATOR bool operator <(const QTtfGlyph &g1, const QTtfGlyph &g2)
+static bool operator <(const QTtfGlyph &g1, const QTtfGlyph &g2)
{
return g1.index < g2.index;
}
@@ -1057,7 +1056,7 @@ static QList<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QLis
return list;
}
-Q_STATIC_GLOBAL_OPERATOR bool operator <(const QTtfTable &t1, const QTtfTable &t2)
+static bool operator <(const QTtfTable &t1, const QTtfTable &t2)
{
return t1.tag < t2.tag;
}
diff --git a/src/gui/text/qfontsubset_agl.cpp b/src/gui/text/qfontsubset_agl.cpp
index 48924deff2..5ad1dea3ab 100644
--- a/src/gui/text/qfontsubset_agl.cpp
+++ b/src/gui/text/qfontsubset_agl.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qfontsubset_p.h b/src/gui/text/qfontsubset_p.h
index 2e9021d3f1..da8589de3f 100644
--- a/src/gui/text/qfontsubset_p.h
+++ b/src/gui/text/qfontsubset_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qfragmentmap.cpp b/src/gui/text/qfragmentmap.cpp
index 52c57d7722..1211547767 100644
--- a/src/gui/text/qfragmentmap.cpp
+++ b/src/gui/text/qfragmentmap.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h
index 012d3c25ce..4af2d2f772 100644
--- a/src/gui/text/qfragmentmap_p.h
+++ b/src/gui/text/qfragmentmap_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -249,6 +249,8 @@ uint QFragmentMapData<Fragment>::createFragment()
uint freePos = head->freelist;
if (freePos == head->allocated) {
// need to create some free space
+ if (freePos >= uint(MaxAllocSize) / fragmentSize)
+ qBadAlloc();
uint needed = qAllocMore((freePos+1)*fragmentSize, 0);
Q_ASSERT(needed/fragmentSize > head->allocated);
Fragment *newFragments = (Fragment *)realloc(fragments, needed);
diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp
index 72c1e764eb..e6d6863134 100644
--- a/src/gui/text/qglyphrun.cpp
+++ b/src/gui/text/qglyphrun.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h
index 7c9efa1d37..d3034b7546 100644
--- a/src/gui/text/qglyphrun.h
+++ b/src/gui/text/qglyphrun.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qglyphrun_p.h b/src/gui/text/qglyphrun_p.h
index d18d7129f9..1b9e25b188 100644
--- a/src/gui/text/qglyphrun_p.h
+++ b/src/gui/text/qglyphrun_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp
index 16c45e642b..102c62ea8a 100644
--- a/src/gui/text/qharfbuzzng.cpp
+++ b/src/gui/text/qharfbuzzng.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 Konstantin Ritt
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -94,6 +94,8 @@ static const hb_script_t _qtscript_to_hbscript[] = {
HB_SCRIPT_BUHID,
HB_SCRIPT_TAGBANWA,
HB_SCRIPT_COPTIC,
+
+ // Unicode 4.0 additions
HB_SCRIPT_LIMBU,
HB_SCRIPT_TAI_LE,
HB_SCRIPT_LINEAR_B,
@@ -102,6 +104,8 @@ static const hb_script_t _qtscript_to_hbscript[] = {
HB_SCRIPT_OSMANYA,
HB_SCRIPT_CYPRIOT,
HB_SCRIPT_BRAILLE,
+
+ // Unicode 4.1 additions
HB_SCRIPT_BUGINESE,
HB_SCRIPT_NEW_TAI_LUE,
HB_SCRIPT_GLAGOLITIC,
@@ -109,11 +113,15 @@ static const hb_script_t _qtscript_to_hbscript[] = {
HB_SCRIPT_SYLOTI_NAGRI,
HB_SCRIPT_OLD_PERSIAN,
HB_SCRIPT_KHAROSHTHI,
+
+ // Unicode 5.0 additions
HB_SCRIPT_BALINESE,
HB_SCRIPT_CUNEIFORM,
HB_SCRIPT_PHOENICIAN,
HB_SCRIPT_PHAGS_PA,
HB_SCRIPT_NKO,
+
+ // Unicode 5.1 additions
HB_SCRIPT_SUNDANESE,
HB_SCRIPT_LEPCHA,
HB_SCRIPT_OL_CHIKI,
@@ -125,6 +133,8 @@ static const hb_script_t _qtscript_to_hbscript[] = {
HB_SCRIPT_CARIAN,
HB_SCRIPT_LYDIAN,
HB_SCRIPT_CHAM,
+
+ // Unicode 5.2 additions
HB_SCRIPT_TAI_THAM,
HB_SCRIPT_TAI_VIET,
HB_SCRIPT_AVESTAN,
@@ -140,16 +150,45 @@ static const hb_script_t _qtscript_to_hbscript[] = {
HB_SCRIPT_INSCRIPTIONAL_PAHLAVI,
HB_SCRIPT_OLD_TURKIC,
HB_SCRIPT_KAITHI,
+
+ // Unicode 6.0 additions
HB_SCRIPT_BATAK,
HB_SCRIPT_BRAHMI,
HB_SCRIPT_MANDAIC,
+
+ // Unicode 6.1 additions
HB_SCRIPT_CHAKMA,
HB_SCRIPT_MEROITIC_CURSIVE,
HB_SCRIPT_MEROITIC_HIEROGLYPHS,
HB_SCRIPT_MIAO,
HB_SCRIPT_SHARADA,
HB_SCRIPT_SORA_SOMPENG,
- HB_SCRIPT_TAKRI
+ HB_SCRIPT_TAKRI,
+
+ // Unicode 7.0 additions
+ HB_SCRIPT_CAUCASIAN_ALBANIAN,
+ HB_SCRIPT_BASSA_VAH,
+ HB_SCRIPT_DUPLOYAN,
+ HB_SCRIPT_ELBASAN,
+ HB_SCRIPT_GRANTHA,
+ HB_SCRIPT_PAHAWH_HMONG,
+ HB_SCRIPT_KHOJKI,
+ HB_SCRIPT_LINEAR_A,
+ HB_SCRIPT_MAHAJANI,
+ HB_SCRIPT_MANICHAEAN,
+ HB_SCRIPT_MENDE_KIKAKUI,
+ HB_SCRIPT_MODI,
+ HB_SCRIPT_MRO,
+ HB_SCRIPT_OLD_NORTH_ARABIAN,
+ HB_SCRIPT_NABATAEAN,
+ HB_SCRIPT_PALMYRENE,
+ HB_SCRIPT_PAU_CIN_HAU,
+ HB_SCRIPT_OLD_PERMIC,
+ HB_SCRIPT_PSALTER_PAHLAVI,
+ HB_SCRIPT_SIDDHAM,
+ HB_SCRIPT_KHUDAWADI,
+ HB_SCRIPT_TIRHUTA,
+ HB_SCRIPT_WARANG_CITI
};
Q_STATIC_ASSERT(QChar::ScriptCount == sizeof(_qtscript_to_hbscript) / sizeof(_qtscript_to_hbscript[0]));
@@ -375,7 +414,7 @@ _hb_qt_font_get_glyph(hb_font_t * /*font*/, void *font_data,
hb_codepoint_t *glyph,
void * /*user_data*/)
{
- QFontEngine *fe = (QFontEngine *)font_data;
+ QFontEngine *fe = static_cast<QFontEngine *>(font_data);
Q_ASSERT(fe);
*glyph = fe->glyphIndex(unicode);
@@ -388,7 +427,7 @@ _hb_qt_font_get_glyph_h_advance(hb_font_t *font, void *font_data,
hb_codepoint_t glyph,
void * /*user_data*/)
{
- QFontEngine *fe = (QFontEngine *)font_data;
+ QFontEngine *fe = static_cast<QFontEngine *>(font_data);
Q_ASSERT(fe);
QFixed advance;
@@ -436,7 +475,7 @@ _hb_qt_font_get_glyph_h_kerning(hb_font_t *font, void *font_data,
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
void * /*user_data*/)
{
- QFontEngine *fe = (QFontEngine *)font_data;
+ QFontEngine *fe = static_cast<QFontEngine *>(font_data);
Q_ASSERT(fe);
glyph_t glyphs[2] = { first_glyph, second_glyph };
@@ -467,7 +506,7 @@ _hb_qt_font_get_glyph_extents(hb_font_t * /*font*/, void *font_data,
hb_glyph_extents_t *extents,
void * /*user_data*/)
{
- QFontEngine *fe = (QFontEngine *)font_data;
+ QFontEngine *fe = static_cast<QFontEngine *>(font_data);
Q_ASSERT(fe);
glyph_metrics_t gm = fe->boundingBox(glyph);
@@ -486,7 +525,7 @@ _hb_qt_font_get_glyph_contour_point(hb_font_t * /*font*/, void *font_data,
unsigned int point_index, hb_position_t *x, hb_position_t *y,
void * /*user_data*/)
{
- QFontEngine *fe = (QFontEngine *)font_data;
+ QFontEngine *fe = static_cast<QFontEngine *>(font_data);
Q_ASSERT(fe);
QFixed xpos, ypos;
@@ -573,7 +612,7 @@ hb_font_funcs_t *hb_qt_get_font_funcs()
static hb_blob_t *
_hb_qt_reference_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data)
{
- QFontEngine::FaceData *data = (QFontEngine::FaceData *)user_data;
+ QFontEngine::FaceData *data = static_cast<QFontEngine::FaceData *>(user_data);
Q_ASSERT(data);
qt_get_font_table_func_t get_font_table = data->get_font_table;
@@ -583,21 +622,21 @@ _hb_qt_reference_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data)
if (Q_UNLIKELY(!get_font_table(data->user_data, tag, 0, &length)))
return hb_blob_get_empty();
- char *buffer = (char *)malloc(length);
+ char *buffer = static_cast<char *>(malloc(length));
Q_CHECK_PTR(buffer);
if (Q_UNLIKELY(!get_font_table(data->user_data, tag, reinterpret_cast<uchar *>(buffer), &length)))
length = 0;
return hb_blob_create(const_cast<const char *>(buffer), length,
- HB_MEMORY_MODE_WRITABLE,
+ HB_MEMORY_MODE_READONLY,
buffer, free);
}
static inline hb_face_t *
_hb_qt_face_create(QFontEngine *fe)
{
- QFontEngine::FaceData *data = (QFontEngine::FaceData *)malloc(sizeof(QFontEngine::FaceData));
+ QFontEngine::FaceData *data = static_cast<QFontEngine::FaceData *>(malloc(sizeof(QFontEngine::FaceData)));
Q_CHECK_PTR(data);
data->user_data = fe->faceData.user_data;
data->get_font_table = fe->faceData.get_font_table;
@@ -618,7 +657,7 @@ static void
_hb_qt_face_release(void *user_data)
{
if (Q_LIKELY(user_data))
- hb_face_destroy((hb_face_t *)user_data);
+ hb_face_destroy(static_cast<hb_face_t *>(user_data));
}
hb_face_t *hb_qt_face_get_for_engine(QFontEngine *fe)
@@ -632,7 +671,7 @@ hb_face_t *hb_qt_face_get_for_engine(QFontEngine *fe)
fe->face_destroy_func = _hb_qt_face_release;
}
- return (hb_face_t *)fe->face_;
+ return static_cast<hb_face_t *>(fe->face_);
}
@@ -668,7 +707,7 @@ static void
_hb_qt_font_release(void *user_data)
{
if (Q_LIKELY(user_data))
- hb_font_destroy((hb_font_t *)user_data);
+ hb_font_destroy(static_cast<hb_font_t *>(user_data));
}
hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe)
@@ -682,7 +721,7 @@ hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe)
fe->font_destroy_func = _hb_qt_font_release;
}
- return (hb_font_t *)fe->font_;
+ return static_cast<hb_font_t *>(fe->font_);
}
QT_END_NAMESPACE
diff --git a/src/gui/text/qharfbuzzng_p.h b/src/gui/text/qharfbuzzng_p.h
index 64c99ef133..d5e11e6264 100644
--- a/src/gui/text/qharfbuzzng_p.h
+++ b/src/gui/text/qharfbuzzng_p.h
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 Konstantin Ritt
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index f18ddbab8a..5fa43948aa 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -34,6 +34,9 @@
#include "qplatformfontdatabase.h"
#include <QtGui/private/qfontengine_p.h>
#include <QtGui/private/qfontengine_qpf2_p.h>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QScreen>
+#include <qpa/qplatformscreen.h>
#include <QtCore/QLibraryInfo>
#include <QtCore/QDir>
@@ -314,7 +317,7 @@ void QPlatformFontDatabase::invalidate()
*/
QFontEngineMulti *QPlatformFontDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script)
{
- return new QFontEngineMultiBasicImpl(fontEngine, script);
+ return new QFontEngineMulti(fontEngine, script);
}
/*!
@@ -457,6 +460,15 @@ bool QPlatformFontDatabase::fontsAlwaysScalable() const
return ret;
}
+QFontEngine::SubpixelAntialiasingType QPlatformFontDatabase::subpixelAntialiasingTypeHint() const
+{
+ static int type = -1;
+ if (type == -1) {
+ if (QScreen *screen = QGuiApplication::primaryScreen())
+ type = screen->handle()->subpixelAntialiasingTypeHint();
+ }
+ return static_cast<QFontEngine::SubpixelAntialiasingType>(type);
+}
// ### copied to tools/makeqpf/qpf2.cpp
@@ -510,9 +522,11 @@ enum {
VietnameseCsbBit = 8,
SimplifiedChineseCsbBit = 18,
TraditionalChineseCsbBit = 20,
+ ThaiCsbBit = 16,
JapaneseCsbBit = 17,
KoreanCsbBit = 19,
- KoreanJohabCsbBit = 21
+ KoreanJohabCsbBit = 21,
+ SymbolCsbBit = 31
};
/*!
@@ -567,6 +581,11 @@ QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(q
hasScript = true;
//qDebug("font %s supports Arabic", familyName.latin1());
}
+ if (codePageRange[0] & (1 << ThaiCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::Thai);
+ hasScript = true;
+ //qDebug("font %s supports Thai", familyName.latin1());
+ }
if (codePageRange[0] & (1 << VietnameseCsbBit)) {
writingSystems.setSupported(QFontDatabase::Vietnamese);
hasScript = true;
@@ -592,6 +611,11 @@ QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(q
hasScript = true;
//qDebug("font %s supports Korean", familyName.latin1());
}
+ if (codePageRange[0] & (1 << SymbolCsbBit)) {
+ writingSystems = QSupportedWritingSystems();
+ hasScript = false;
+ }
+
if (!hasScript)
writingSystems.setSupported(QFontDatabase::Symbol);
@@ -599,6 +623,34 @@ QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(q
}
/*!
+ Helper function that returns the Qt font weight matching a given opentype integer value.
+
+ \since 5.5
+*/
+
+// convert 0 ~ 1000 integer to QFont::Weight
+QFont::Weight QPlatformFontDatabase::weightFromInteger(int weight)
+{
+ if (weight < 150)
+ return QFont::Thin;
+ if (weight < 250)
+ return QFont::ExtraLight;
+ if (weight < 350)
+ return QFont::Light;
+ if (weight < 450)
+ return QFont::Normal;
+ if (weight < 550)
+ return QFont::Medium;
+ if (weight < 650)
+ return QFont::DemiBold;
+ if (weight < 750)
+ return QFont::Bold;
+ if (weight < 850)
+ return QFont::ExtraBold;
+ return QFont::Black;
+}
+
+/*!
Helper function that register the \a alias for the \a familyName.
\since 5.2
diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h
index a75d55f91a..0615df65d6 100644
--- a/src/gui/text/qplatformfontdatabase.h
+++ b/src/gui/text/qplatformfontdatabase.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -49,6 +49,7 @@
#include <QtCore/QList>
#include <QtCore/QHash>
#include <QtGui/QFontDatabase>
+#include <QtGui/private/qfontengine_p.h>
#include <QtGui/private/qfont_p.h>
QT_BEGIN_NAMESPACE
@@ -107,9 +108,11 @@ public:
virtual QString resolveFontFamilyAlias(const QString &family) const;
virtual bool fontsAlwaysScalable() const;
virtual QList<int> standardSizes() const;
+ QFontEngine::SubpixelAntialiasingType subpixelAntialiasingTypeHint() const;
// helper
static QSupportedWritingSystems writingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2]);
+ static QFont::Weight weightFromInteger(int weight);
//callback
static void registerQPF2Font(const QByteArray &dataArray, void *handle);
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index d21138e7ac..2631cf8d17 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index 031dd056a7..3798555de5 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qrawfont_p.h b/src/gui/text/qrawfont_p.h
index 96ba3fd026..b3becccfd7 100644
--- a/src/gui/text/qrawfont_p.h
+++ b/src/gui/text/qrawfont_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index a7868f36ab..fc95a859e7 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -393,7 +393,7 @@ QSizeF QStaticText::size() const
}
QStaticTextPrivate::QStaticTextPrivate()
- : textWidth(-1.0), items(0), itemCount(0), glyphPool(0), positionPool(0), charPool(0),
+ : textWidth(-1.0), items(0), itemCount(0), glyphPool(0), positionPool(0),
needsRelayout(true), useBackendOptimizations(false), textFormat(Qt::AutoText),
untransformedCoordinates(false)
{
@@ -401,7 +401,7 @@ QStaticTextPrivate::QStaticTextPrivate()
QStaticTextPrivate::QStaticTextPrivate(const QStaticTextPrivate &other)
: text(other.text), font(other.font), textWidth(other.textWidth), matrix(other.matrix),
- items(0), itemCount(0), glyphPool(0), positionPool(0), charPool(0), textOption(other.textOption),
+ items(0), itemCount(0), glyphPool(0), positionPool(0), textOption(other.textOption),
needsRelayout(true), useBackendOptimizations(other.useBackendOptimizations),
textFormat(other.textFormat), untransformedCoordinates(other.untransformedCoordinates)
{
@@ -412,7 +412,6 @@ QStaticTextPrivate::~QStaticTextPrivate()
delete[] items;
delete[] glyphPool;
delete[] positionPool;
- delete[] charPool;
}
QStaticTextPrivate *QStaticTextPrivate::get(const QStaticText *q)
@@ -431,7 +430,7 @@ namespace {
{
}
- virtual void updateState(const QPaintEngineState &newState)
+ virtual void updateState(const QPaintEngineState &newState) Q_DECL_OVERRIDE
{
if (newState.state() & QPaintEngine::DirtyPen
&& newState.pen().color() != m_currentColor) {
@@ -440,15 +439,13 @@ namespace {
}
}
- virtual void drawTextItem(const QPointF &position, const QTextItem &textItem)
+ virtual void drawTextItem(const QPointF &position, const QTextItem &textItem) Q_DECL_OVERRIDE
{
const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
QStaticTextItem currentItem;
currentItem.setFontEngine(ti.fontEngine);
currentItem.font = ti.font();
- currentItem.charOffset = m_chars.size();
- currentItem.numChars = ti.num_chars;
currentItem.glyphOffset = m_glyphs.size(); // Store offset into glyph pool
currentItem.positionOffset = m_glyphs.size(); // Offset into position pool
currentItem.useBackendOptimizations = m_useBackendOptimizations;
@@ -468,7 +465,6 @@ namespace {
m_glyphs.resize(m_glyphs.size() + size);
m_positions.resize(m_glyphs.size());
- m_chars.resize(m_chars.size() + ti.num_chars);
glyph_t *glyphsDestination = m_glyphs.data() + currentItem.glyphOffset;
memcpy(glyphsDestination, glyphs.constData(), sizeof(glyph_t) * currentItem.numGlyphs);
@@ -476,21 +472,18 @@ namespace {
QFixedPoint *positionsDestination = m_positions.data() + currentItem.positionOffset;
memcpy(positionsDestination, positions.constData(), sizeof(QFixedPoint) * currentItem.numGlyphs);
- QChar *charsDestination = m_chars.data() + currentItem.charOffset;
- memcpy(charsDestination, ti.chars, sizeof(QChar) * currentItem.numChars);
-
m_items.append(currentItem);
}
- virtual void drawPolygon(const QPointF *, int , PolygonDrawMode )
+ virtual void drawPolygon(const QPointF *, int , PolygonDrawMode ) Q_DECL_OVERRIDE
{
/* intentionally empty */
}
- virtual bool begin(QPaintDevice *) { return true; }
- virtual bool end() { return true; }
- virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) {}
- virtual Type type() const
+ virtual bool begin(QPaintDevice *) Q_DECL_OVERRIDE { return true; }
+ virtual bool end() Q_DECL_OVERRIDE { return true; }
+ virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) Q_DECL_OVERRIDE {}
+ virtual Type type() const Q_DECL_OVERRIDE
{
return User;
}
@@ -510,16 +503,10 @@ namespace {
return m_glyphs;
}
- QVector<QChar> chars() const
- {
- return m_chars;
- }
-
private:
QVector<QStaticTextItem> m_items;
QVector<QFixedPoint> m_positions;
QVector<glyph_t> m_glyphs;
- QVector<QChar> m_chars;
bool m_dirtyPen;
bool m_useBackendOptimizations;
@@ -541,7 +528,7 @@ namespace {
delete m_paintEngine;
}
- int metric(PaintDeviceMetric m) const
+ int metric(PaintDeviceMetric m) const Q_DECL_OVERRIDE
{
int val;
switch (m) {
@@ -575,7 +562,7 @@ namespace {
return val;
}
- virtual QPaintEngine *paintEngine() const
+ virtual QPaintEngine *paintEngine() const Q_DECL_OVERRIDE
{
return m_paintEngine;
}
@@ -595,11 +582,6 @@ namespace {
return m_paintEngine->items();
}
- QVector<QChar> chars() const
- {
- return m_paintEngine->chars();
- }
-
private:
DrawTextItemRecorder *m_paintEngine;
};
@@ -677,7 +659,6 @@ void QStaticTextPrivate::init()
delete[] items;
delete[] glyphPool;
delete[] positionPool;
- delete[] charPool;
position = QPointF(0, 0);
@@ -693,7 +674,6 @@ void QStaticTextPrivate::init()
QVector<QStaticTextItem> deviceItems = device.items();
QVector<QFixedPoint> positions = device.positions();
QVector<glyph_t> glyphs = device.glyphs();
- QVector<QChar> chars = device.chars();
itemCount = deviceItems.size();
items = new QStaticTextItem[itemCount];
@@ -704,15 +684,11 @@ void QStaticTextPrivate::init()
positionPool = new QFixedPoint[positions.size()];
memcpy(positionPool, positions.constData(), positions.size() * sizeof(QFixedPoint));
- charPool = new QChar[chars.size()];
- memcpy(charPool, chars.constData(), chars.size() * sizeof(QChar));
-
for (int i=0; i<itemCount; ++i) {
items[i] = deviceItems.at(i);
items[i].glyphs = glyphPool + items[i].glyphOffset;
items[i].glyphPositions = positionPool + items[i].positionOffset;
- items[i].chars = charPool + items[i].charOffset;
}
needsRelayout = false;
diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h
index f2357e562c..d2825e73ac 100644
--- a/src/gui/text/qstatictext.h
+++ b/src/gui/text/qstatictext.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h
index 29db8836d9..088e49e2fc 100644
--- a/src/gui/text/qstatictext_p.h
+++ b/src/gui/text/qstatictext_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -70,7 +70,7 @@ public:
class Q_GUI_EXPORT QStaticTextItem
{
public:
- QStaticTextItem() : chars(0), numChars(0), useBackendOptimizations(false),
+ QStaticTextItem() : useBackendOptimizations(false),
userDataNeedsUpdate(0), usesRawFont(0),
m_fontEngine(0), m_userData(0) {}
@@ -83,9 +83,7 @@ public:
{
glyphPositions = other.glyphPositions;
glyphs = other.glyphs;
- chars = other.chars;
numGlyphs = other.numGlyphs;
- numChars = other.numChars;
font = other.font;
color = other.color;
useBackendOptimizations = other.useBackendOptimizations;
@@ -125,28 +123,22 @@ public:
glyph_t *glyphs; // 4 bytes per glyph
int glyphOffset;
};
- union {
- QChar *chars; // 2 bytes per glyph
- int charOffset;
- };
// =================
- // 14 bytes per glyph
+ // 12 bytes per glyph
- // 12 bytes for pointers
+ // 8 bytes for pointers
int numGlyphs; // 4 bytes per item
- int numChars; // 4 bytes per item
QFont font; // 8 bytes per item
QColor color; // 10 bytes per item
char useBackendOptimizations : 1; // 1 byte per item
char userDataNeedsUpdate : 1; //
char usesRawFont : 1; //
- // ================
- // 51 bytes per item
private: // Needs special handling in setters, so private to avoid abuse
QFontEngine *m_fontEngine; // 4 bytes per item
QStaticTextUserData *m_userData; // 8 bytes per item
-
+ // ================
+ // 43 bytes per item
};
class QStaticText;
@@ -179,7 +171,6 @@ public:
glyph_t *glyphPool; // 4 bytes per text
QFixedPoint *positionPool; // 4 bytes per text
- QChar *charPool; // 4 bytes per text
QTextOption textOption; // 28 bytes per text
@@ -188,7 +179,7 @@ public:
unsigned char textFormat : 2;
unsigned char untransformedCoordinates : 1;
// ================
- // 195 bytes per text
+ // 191 bytes per text
static QStaticTextPrivate *get(const QStaticText *q);
};
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index 7924dff5e9..162c646a98 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h
index b71e3a6b8e..56b9020d2c 100644
--- a/src/gui/text/qsyntaxhighlighter.h
+++ b/src/gui/text/qsyntaxhighlighter.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index b1205a8c85..a151c515a3 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h
index 4dc11b54bf..f04055603c 100644
--- a/src/gui/text/qtextcursor.h
+++ b/src/gui/text/qtextcursor.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextcursor_p.h b/src/gui/text/qtextcursor_p.h
index a0b157227e..51fb92d37c 100644
--- a/src/gui/text/qtextcursor_p.h
+++ b/src/gui/text/qtextcursor_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 77e0fec80d..e8dd663354 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -40,6 +40,7 @@
#include "qtextlist.h"
#include <qdebug.h>
#include <qregexp.h>
+#include <qregularexpression.h>
#include <qvarlengtharray.h>
#include <qtextcodec.h>
#include <qthread.h>
@@ -1244,6 +1245,39 @@ void QTextDocument::setHtml(const QString &html)
\sa metaInformation(), setMetaInformation()
*/
+static bool findInBlock(const QTextBlock &block, const QString &expression, int offset,
+ QTextDocument::FindFlags options, QTextCursor *cursor)
+{
+ QString text = block.text();
+ text.replace(QChar::Nbsp, QLatin1Char(' '));
+ Qt::CaseSensitivity sensitivity = options & QTextDocument::FindCaseSensitively ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ int idx = -1;
+
+ while (offset >= 0 && offset <= text.length()) {
+ idx = (options & QTextDocument::FindBackward) ?
+ text.lastIndexOf(expression, offset, sensitivity) : text.indexOf(expression, offset, sensitivity);
+ if (idx == -1)
+ return false;
+
+ if (options & QTextDocument::FindWholeWords) {
+ const int start = idx;
+ const int end = start + expression.length();
+ if ((start != 0 && text.at(start - 1).isLetterOrNumber())
+ || (end != text.length() && text.at(end).isLetterOrNumber())) {
+ //if this is not a whole word, continue the search in the string
+ offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1;
+ idx = -1;
+ continue;
+ }
+ }
+ //we have a hit, return the cursor for that.
+ *cursor = QTextCursor(block.docHandle(), block.position() + idx);
+ cursor->setPosition(cursor->position() + expression.length(), QTextCursor::KeepAnchor);
+ return true;
+ }
+ return false;
+}
+
/*!
\fn QTextCursor QTextDocument::find(const QString &subString, int position, FindFlags options) const
@@ -1262,16 +1296,44 @@ void QTextDocument::setHtml(const QString &html)
*/
QTextCursor QTextDocument::find(const QString &subString, int from, FindFlags options) const
{
- QRegExp expr(subString);
- expr.setPatternSyntax(QRegExp::FixedString);
- expr.setCaseSensitivity((options & QTextDocument::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
+ Q_D(const QTextDocument);
+
+ if (subString.isEmpty())
+ return QTextCursor();
+
+ int pos = from;
+ //the cursor is positioned between characters, so for a backward search
+ //do not include the character given in the position.
+ if (options & FindBackward) {
+ --pos ;
+ if (pos < subString.size())
+ return QTextCursor();
+ }
- return find(expr, from, options);
+ QTextCursor cursor;
+ QTextBlock block = d->blocksFind(pos);
+ int blockOffset = pos - block.position();
+
+ if (!(options & FindBackward)) {
+ while (block.isValid()) {
+ if (findInBlock(block, subString, blockOffset, options, &cursor))
+ return cursor;
+ block = block.next();
+ blockOffset = 0;
+ }
+ } else {
+ while (block.isValid()) {
+ if (findInBlock(block, subString, blockOffset, options, &cursor))
+ return cursor;
+ block = block.previous();
+ blockOffset = block.length() - 2;
+ }
+ }
+
+ return QTextCursor();
}
/*!
- \fn QTextCursor QTextDocument::find(const QString &subString, const QTextCursor &cursor, FindFlags options) const
-
Finds the next occurrence of the string, \a subString, in the document.
The search starts at the position of the given \a cursor, and proceeds
forwards through the document unless specified otherwise in the search
@@ -1286,25 +1348,23 @@ QTextCursor QTextDocument::find(const QString &subString, int from, FindFlags op
By default the search is case-sensitive, and can match text anywhere in the
document.
*/
-QTextCursor QTextDocument::find(const QString &subString, const QTextCursor &from, FindFlags options) const
+QTextCursor QTextDocument::find(const QString &subString, const QTextCursor &cursor, FindFlags options) const
{
int pos = 0;
- if (!from.isNull()) {
+ if (!cursor.isNull()) {
if (options & QTextDocument::FindBackward)
- pos = from.selectionStart();
+ pos = cursor.selectionStart();
else
- pos = from.selectionEnd();
+ pos = cursor.selectionEnd();
}
- QRegExp expr(subString);
- expr.setPatternSyntax(QRegExp::FixedString);
- expr.setCaseSensitivity((options & QTextDocument::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
- return find(expr, pos, options);
+ return find(subString, pos, options);
}
+#ifndef QT_NO_REGEXP
static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int offset,
- QTextDocument::FindFlags options, QTextCursor &cursor)
+ QTextDocument::FindFlags options, QTextCursor *cursor)
{
QRegExp expr(expression);
QString text = block.text();
@@ -1329,22 +1389,18 @@ static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int
}
}
//we have a hit, return the cursor for that.
- break;
+ *cursor = QTextCursor(block.docHandle(), block.position() + idx);
+ cursor->setPosition(cursor->position() + expr.matchedLength(), QTextCursor::KeepAnchor);
+ return true;
}
- if (idx == -1)
- return false;
- cursor = QTextCursor(block.docHandle(), block.position() + idx);
- cursor.setPosition(cursor.position() + expr.matchedLength(), QTextCursor::KeepAnchor);
- return true;
+ return false;
}
/*!
- \fn QTextCursor QTextDocument::find(const QRegExp & expr, int position, FindFlags options) const
-
\overload
Finds the next occurrence, matching the regular expression, \a expr, in the document.
- The search starts at the given \a position, and proceeds forwards
+ The search starts at the given \a from position, and proceeds forwards
through the document unless specified otherwise in the search options.
The \a options control the type of search performed. The FindCaseSensitively
option is ignored for this overload, use QRegExp::caseSensitivity instead.
@@ -1352,7 +1408,7 @@ static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int
Returns a cursor with the match selected if a match was found; otherwise
returns a null cursor.
- If the \a position is 0 (the default) the search begins from the beginning
+ If the \a from position is 0 (the default) the search begins from the beginning
of the document; otherwise it begins at the specified position.
*/
QTextCursor QTextDocument::find(const QRegExp & expr, int from, FindFlags options) const
@@ -1373,19 +1429,17 @@ QTextCursor QTextDocument::find(const QRegExp & expr, int from, FindFlags option
QTextCursor cursor;
QTextBlock block = d->blocksFind(pos);
-
+ int blockOffset = pos - block.position();
if (!(options & FindBackward)) {
- int blockOffset = qMax(0, pos - block.position());
while (block.isValid()) {
- if (findInBlock(block, expr, blockOffset, options, cursor))
+ if (findInBlock(block, expr, blockOffset, options, &cursor))
return cursor;
- blockOffset = 0;
block = block.next();
+ blockOffset = 0;
}
} else {
- int blockOffset = pos - block.position();
while (block.isValid()) {
- if (findInBlock(block, expr, blockOffset, options, cursor))
+ if (findInBlock(block, expr, blockOffset, options, &cursor))
return cursor;
block = block.previous();
blockOffset = block.length() - 1;
@@ -1396,10 +1450,10 @@ QTextCursor QTextDocument::find(const QRegExp & expr, int from, FindFlags option
}
/*!
- \fn QTextCursor QTextDocument::find(const QRegExp &expr, const QTextCursor &cursor, FindFlags options) const
+ \overload
Finds the next occurrence, matching the regular expression, \a expr, in the document.
- The search starts at the position of the given \a cursor, and proceeds
+ The search starts at the position of the given from \a cursor, and proceeds
forwards through the document unless specified otherwise in the search
options. The \a options control the type of search performed. The FindCaseSensitively
option is ignored for this overload, use QRegExp::caseSensitivity instead.
@@ -1407,24 +1461,147 @@ QTextCursor QTextDocument::find(const QRegExp & expr, int from, FindFlags option
Returns a cursor with the match selected if a match was found; otherwise
returns a null cursor.
- If the given \a cursor has a selection, the search begins after the
+ If the given \a from cursor has a selection, the search begins after the
selection; otherwise it begins at the cursor's position.
By default the search is case-sensitive, and can match text anywhere in the
document.
*/
-QTextCursor QTextDocument::find(const QRegExp &expr, const QTextCursor &from, FindFlags options) const
+QTextCursor QTextDocument::find(const QRegExp &expr, const QTextCursor &cursor, FindFlags options) const
{
int pos = 0;
- if (!from.isNull()) {
+ if (!cursor.isNull()) {
if (options & QTextDocument::FindBackward)
- pos = from.selectionStart();
+ pos = cursor.selectionStart();
else
- pos = from.selectionEnd();
+ pos = cursor.selectionEnd();
}
return find(expr, pos, options);
}
+#endif // QT_REGEXP
+
+#ifndef QT_NO_REGULAREXPRESSION
+static bool findInBlock(const QTextBlock &block, const QRegularExpression &expression, int offset,
+ QTextDocument::FindFlags options, QTextCursor *cursor)
+{
+ QRegularExpression expr(expression);
+ if (!(options & QTextDocument::FindCaseSensitively))
+ expr.setPatternOptions(expr.patternOptions() | QRegularExpression::CaseInsensitiveOption);
+ else
+ expr.setPatternOptions(expr.patternOptions() & ~QRegularExpression::CaseInsensitiveOption);
+
+ QString text = block.text();
+ text.replace(QChar::Nbsp, QLatin1Char(' '));
+ QRegularExpressionMatch match;
+ int idx = -1;
+
+ while (offset >= 0 && offset <= text.length()) {
+ idx = (options & QTextDocument::FindBackward) ?
+ text.lastIndexOf(expr, offset, &match) : text.indexOf(expr, offset, &match);
+ if (idx == -1)
+ return false;
+
+ if (options & QTextDocument::FindWholeWords) {
+ const int start = idx;
+ const int end = start + match.capturedLength();
+ if ((start != 0 && text.at(start - 1).isLetterOrNumber())
+ || (end != text.length() && text.at(end).isLetterOrNumber())) {
+ //if this is not a whole word, continue the search in the string
+ offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1;
+ idx = -1;
+ continue;
+ }
+ }
+ //we have a hit, return the cursor for that.
+ *cursor = QTextCursor(block.docHandle(), block.position() + idx);
+ cursor->setPosition(cursor->position() + match.capturedLength(), QTextCursor::KeepAnchor);
+ return true;
+ }
+ return false;
+}
+
+/*!
+ \since 5.5
+
+ Finds the next occurrence, matching the regular expression, \a expr, in the document.
+ The search starts at the given \a from position, and proceeds forwards
+ through the document unless specified otherwise in the search options.
+ The \a options control the type of search performed.
+
+ Returns a cursor with the match selected if a match was found; otherwise
+ returns a null cursor.
+
+ If the \a from position is 0 (the default) the search begins from the beginning
+ of the document; otherwise it begins at the specified position.
+*/
+QTextCursor QTextDocument::find(const QRegularExpression &expr, int from, FindFlags options) const
+{
+ Q_D(const QTextDocument);
+
+ if (!expr.isValid())
+ return QTextCursor();
+
+ int pos = from;
+ //the cursor is positioned between characters, so for a backward search
+ //do not include the character given in the position.
+ if (options & FindBackward) {
+ --pos ;
+ if (pos < 0)
+ return QTextCursor();
+ }
+
+ QTextCursor cursor;
+ QTextBlock block = d->blocksFind(pos);
+ int blockOffset = pos - block.position();
+ if (!(options & FindBackward)) {
+ while (block.isValid()) {
+ if (findInBlock(block, expr, blockOffset, options, &cursor))
+ return cursor;
+ block = block.next();
+ blockOffset = 0;
+ }
+ } else {
+ while (block.isValid()) {
+ if (findInBlock(block, expr, blockOffset, options, &cursor))
+ return cursor;
+ block = block.previous();
+ blockOffset = block.length() - 1;
+ }
+ }
+
+ return QTextCursor();
+}
+
+/*!
+ \since 5.5
+
+ Finds the next occurrence, matching the regular expression, \a expr, in the document.
+ The search starts at the position of the given \a cursor, and proceeds
+ forwards through the document unless specified otherwise in the search
+ options. The \a options control the type of search performed.
+
+ Returns a cursor with the match selected if a match was found; otherwise
+ returns a null cursor.
+
+ If the given \a cursor has a selection, the search begins after the
+ selection; otherwise it begins at the cursor's position.
+
+ By default the search is case-sensitive, and can match text anywhere in the
+ document.
+*/
+QTextCursor QTextDocument::find(const QRegularExpression &expr, const QTextCursor &cursor, FindFlags options) const
+{
+ int pos = 0;
+ if (!cursor.isNull()) {
+ if (options & QTextDocument::FindBackward)
+ pos = cursor.selectionStart();
+ else
+ pos = cursor.selectionEnd();
+ }
+ return find(expr, pos, options);
+}
+#endif // QT_NO_REGULAREXPRESSION
/*!
\fn QTextObject *QTextDocument::createObject(const QTextFormat &format)
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index 2329a9e721..ca80a88033 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -63,7 +63,6 @@ class QTextCursor;
template<typename T> class QVector;
-#ifndef Q_QDOC // Workaround for QTBUG-35230
namespace Qt
{
Q_GUI_EXPORT bool mightBeRichText(const QString&);
@@ -73,7 +72,6 @@ namespace Qt
Q_GUI_EXPORT QTextCodec *codecForHtml(const QByteArray &ba);
#endif
}
-#endif // Q_QDOC
class Q_GUI_EXPORT QAbstractUndoItem
{
@@ -160,10 +158,17 @@ public:
Q_DECLARE_FLAGS(FindFlags, FindFlag)
QTextCursor find(const QString &subString, int from = 0, FindFlags options = 0) const;
- QTextCursor find(const QString &subString, const QTextCursor &from, FindFlags options = 0) const;
+ QTextCursor find(const QString &subString, const QTextCursor &cursor, FindFlags options = 0) const;
+#ifndef QT_NO_REGEXP
QTextCursor find(const QRegExp &expr, int from = 0, FindFlags options = 0) const;
- QTextCursor find(const QRegExp &expr, const QTextCursor &from, FindFlags options = 0) const;
+ QTextCursor find(const QRegExp &expr, const QTextCursor &cursor, FindFlags options = 0) const;
+#endif
+
+#ifndef QT_NO_REGULAREXPRESSION
+ QTextCursor find(const QRegularExpression &expr, int from = 0, FindFlags options = 0) const;
+ QTextCursor find(const QRegularExpression &expr, const QTextCursor &cursor, FindFlags options = 0) const;
+#endif
QTextFrame *frameAt(int pos) const;
QTextFrame *rootFrame() const;
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 8ff15106e3..587844c1dd 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -125,14 +125,12 @@ static bool isValidBlockSeparator(QChar ch)
|| ch == QTextEndOfFrame;
}
-#if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS)
static bool noBlockInString(const QString &str)
{
return !str.contains(QChar::ParagraphSeparator)
&& !str.contains(QTextBeginningOfFrame)
&& !str.contains(QTextEndOfFrame);
}
-#endif
bool QTextUndoCommand::tryMerge(const QTextUndoCommand &other)
{
diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h
index b36a184f8d..bcef3b2c9e 100644
--- a/src/gui/text/qtextdocument_p.h
+++ b/src/gui/text/qtextdocument_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index 18b72c5b33..71e24efc4d 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextdocumentfragment.h b/src/gui/text/qtextdocumentfragment.h
index 15a20d6dac..ae90baf4d8 100644
--- a/src/gui/text/qtextdocumentfragment.h
+++ b/src/gui/text/qtextdocumentfragment.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextdocumentfragment_p.h b/src/gui/text/qtextdocumentfragment_p.h
index 53a9bfcebe..22b39bc1e5 100644
--- a/src/gui/text/qtextdocumentfragment_p.h
+++ b/src/gui/text/qtextdocumentfragment_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 74371d77c0..db8a792be7 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -383,12 +383,12 @@ struct QCheckPoint
};
Q_DECLARE_TYPEINFO(QCheckPoint, Q_PRIMITIVE_TYPE);
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCheckPoint &checkPoint, QFixed y)
+static bool operator<(const QCheckPoint &checkPoint, QFixed y)
{
return checkPoint.y < y;
}
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCheckPoint &checkPoint, int pos)
+static bool operator<(const QCheckPoint &checkPoint, int pos)
{
return checkPoint.positionInFrame < pos;
}
@@ -396,17 +396,17 @@ Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCheckPoint &checkPoint, int pos)
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
//The STL implementation of MSVC 2008 requires the definitions
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCheckPoint &checkPoint1, const QCheckPoint &checkPoint2)
+static bool operator<(const QCheckPoint &checkPoint1, const QCheckPoint &checkPoint2)
{
return checkPoint1.y < checkPoint2.y;
}
-Q_STATIC_GLOBAL_OPERATOR bool operator<(QFixed y, const QCheckPoint &checkPoint)
+static bool operator<(QFixed y, const QCheckPoint &checkPoint)
{
return y < checkPoint.y;
}
-Q_STATIC_GLOBAL_OPERATOR bool operator<(int pos, const QCheckPoint &checkPoint)
+static bool operator<(int pos, const QCheckPoint &checkPoint)
{
return pos < checkPoint.positionInFrame;
}
@@ -1290,7 +1290,7 @@ void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *pain
const QTextLayout *tl = bl.layout();
QRectF r = tl->boundingRect();
r.translate(offset + tl->position());
- if (context.clip.isValid() && (r.bottom() < context.clip.y() || r.top() > context.clip.bottom()))
+ if (!bl.isVisible() || (context.clip.isValid() && (r.bottom() < context.clip.y() || r.top() > context.clip.bottom())))
return;
// LDEBUG << debug_indent << "drawBlock" << bl.position() << "at" << offset << "br" << tl->boundingRect();
@@ -2580,6 +2580,8 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
QTextLayoutStruct *layoutStruct, int layoutFrom, int layoutTo, const QTextBlockFormat *previousBlockFormat)
{
Q_Q(QTextDocumentLayout);
+ if (!bl.isVisible())
+ return;
QTextLayout *tl = bl.layout();
const int blockLength = bl.length();
@@ -3265,7 +3267,7 @@ QRectF QTextDocumentLayoutPrivate::frameBoundingRectInternal(QTextFrame *frame)
QRectF QTextDocumentLayout::blockBoundingRect(const QTextBlock &block) const
{
Q_D(const QTextDocumentLayout);
- if (d->docPrivate->pageSize.isNull() || !block.isValid())
+ if (d->docPrivate->pageSize.isNull() || !block.isValid() || !block.isVisible())
return QRectF();
d->ensureLayoutedByPosition(block.position() + block.length());
QTextFrame *frame = d->document->frameAt(block.position());
diff --git a/src/gui/text/qtextdocumentlayout_p.h b/src/gui/text/qtextdocumentlayout_p.h
index f72a177d13..e42443ee87 100644
--- a/src/gui/text/qtextdocumentlayout_p.h
+++ b/src/gui/text/qtextdocumentlayout_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -66,11 +66,11 @@ public:
explicit QTextDocumentLayout(QTextDocument *doc);
// from the abstract layout
- void draw(QPainter *painter, const PaintContext &context);
- int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const;
+ void draw(QPainter *painter, const PaintContext &context) Q_DECL_OVERRIDE;
+ int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const Q_DECL_OVERRIDE;
- int pageCount() const;
- QSizeF documentSize() const;
+ int pageCount() const Q_DECL_OVERRIDE;
+ QSizeF documentSize() const Q_DECL_OVERRIDE;
void setCursorWidth(int width);
int cursorWidth() const;
@@ -81,8 +81,8 @@ public:
// internal for QTextEdit's NoWrap mode
void setViewport(const QRectF &viewport);
- virtual QRectF frameBoundingRect(QTextFrame *frame) const;
- virtual QRectF blockBoundingRect(const QTextBlock &block) const;
+ virtual QRectF frameBoundingRect(QTextFrame *frame) const Q_DECL_OVERRIDE;
+ virtual QRectF blockBoundingRect(const QTextBlock &block) const Q_DECL_OVERRIDE;
QRectF tableBoundingRect(QTextTable *table) const;
QRectF tableCellBoundingRect(QTextTable *table, const QTextTableCell &cell) const;
@@ -97,12 +97,12 @@ public:
bool contentHasAlignment() const;
protected:
- void documentChanged(int from, int oldLength, int length);
- void resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format);
- void positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format);
+ void documentChanged(int from, int oldLength, int length) Q_DECL_OVERRIDE;
+ void resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) Q_DECL_OVERRIDE;
+ void positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) Q_DECL_OVERRIDE;
void drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item,
- int posInDocument, const QTextFormat &format);
- virtual void timerEvent(QTimerEvent *e);
+ int posInDocument, const QTextFormat &format) Q_DECL_OVERRIDE;
+ virtual void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
private:
QRectF doLayout(int from, int oldLength, int length);
void layoutFinished();
diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp
index b6cc44cdeb..9c430ea67b 100644
--- a/src/gui/text/qtextdocumentwriter.cpp
+++ b/src/gui/text/qtextdocumentwriter.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextdocumentwriter.h b/src/gui/text/qtextdocumentwriter.h
index 8235eeedc9..76bf3e9b24 100644
--- a/src/gui/text/qtextdocumentwriter.h
+++ b/src/gui/text/qtextdocumentwriter.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 8f874e0245..10a61d3c84 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -881,16 +881,22 @@ static inline void qt_getJustificationOpportunities(const ushort *string, int le
int spaceAs;
switch (si.analysis.script) {
+ case QChar::Script_Arabic:
+ case QChar::Script_Syriac:
case QChar::Script_Nko:
case QChar::Script_Mandaic:
case QChar::Script_Mongolian:
case QChar::Script_PhagsPa:
+ case QChar::Script_Manichaean:
+ case QChar::Script_PsalterPahlavi:
// same as default but inter character justification takes precedence
spaceAs = Justification_Arabic_Space;
break;
+ case QChar::Script_Tibetan:
case QChar::Script_Hiragana:
case QChar::Script_Katakana:
+ case QChar::Script_Bopomofo:
case QChar::Script_Han:
// same as default but inter character justification is the only option
spaceAs = Justification_Character;
@@ -979,7 +985,7 @@ void QTextEngine::shapeText(int item) const
string = reinterpret_cast<const ushort *>(casedString.constData());
}
- if (!ensureSpace(itemLength)) {
+ if (Q_UNLIKELY(!ensureSpace(itemLength))) {
Q_UNREACHABLE(); // ### report OOM error somehow
return;
}
@@ -1051,12 +1057,12 @@ void QTextEngine::shapeText(int item) const
}
#ifdef QT_ENABLE_HARFBUZZ_NG
- if (qt_useHarfbuzzNG())
+ if (Q_LIKELY(qt_useHarfbuzzNG()))
si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled);
else
#endif
si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled);
- if (si.num_glyphs == 0) {
+ if (Q_UNLIKELY(si.num_glyphs == 0)) {
Q_UNREACHABLE(); // ### report shaping errors somehow
return;
}
@@ -1067,7 +1073,7 @@ void QTextEngine::shapeText(int item) const
QGlyphLayout glyphs = shapedGlyphs(&si);
#ifdef QT_ENABLE_HARFBUZZ_NG
- if (qt_useHarfbuzzNG())
+ if (Q_LIKELY(qt_useHarfbuzzNG()))
qt_getJustificationOpportunities(string, itemLength, si, glyphs, logClusters(&si));
#endif
@@ -1116,10 +1122,12 @@ QT_END_INCLUDE_NAMESPACE
int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const
{
+ uint glyphs_shaped = 0;
+
hb_buffer_t *buffer = hb_buffer_create();
hb_buffer_set_unicode_funcs(buffer, hb_qt_get_unicode_funcs());
hb_buffer_pre_allocate(buffer, itemLength);
- if (!hb_buffer_allocation_successful(buffer)) {
+ if (Q_UNLIKELY(!hb_buffer_allocation_successful(buffer))) {
hb_buffer_destroy(buffer);
return 0;
}
@@ -1129,18 +1137,13 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
props.script = hb_qt_script_to_script(QChar::Script(si.analysis.script));
// ### props.language = hb_language_get_default_for_script(props.script);
- uint glyphs_shaped = 0;
- int remaining_glyphs = itemLength;
-
for (int k = 0; k < itemBoundaries.size(); k += 3) {
- uint item_pos = itemBoundaries[k];
- uint item_length = (k + 4 < itemBoundaries.size() ? itemBoundaries[k + 3] : itemLength) - item_pos;
- uint item_glyph_pos = itemBoundaries[k + 1];
- uint engineIdx = itemBoundaries[k + 2];
+ const uint item_pos = itemBoundaries[k];
+ const uint item_length = (k + 4 < itemBoundaries.size() ? itemBoundaries[k + 3] : itemLength) - item_pos;
+ const uint engineIdx = itemBoundaries[k + 2];
- QFontEngine *actualFontEngine = fontEngine;
- if (fontEngine->type() == QFontEngine::Multi)
- actualFontEngine = static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx);
+ QFontEngine *actualFontEngine = fontEngine->type() != QFontEngine::Multi ? fontEngine
+ : static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx);
// prepare buffer
@@ -1153,35 +1156,35 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
uint buffer_flags = HB_BUFFER_FLAG_DEFAULT;
// Symbol encoding used to encode various crap in the 32..255 character code range,
// and thus might override U+00AD [SHY]; avoid hiding default ignorables
- if (actualFontEngine->symbol)
+ if (Q_UNLIKELY(actualFontEngine->symbol))
buffer_flags |= HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES;
hb_buffer_set_flags(buffer, hb_buffer_flags_t(buffer_flags));
// shape
- bool shapedOk = false;
- if (hb_font_t *hb_font = hb_qt_font_get_for_engine(actualFontEngine)) {
+ {
+ hb_font_t *hb_font = hb_qt_font_get_for_engine(actualFontEngine);
+ Q_ASSERT(hb_font);
hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0); // ###
const hb_feature_t features[1] = {
{ HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) }
};
const int num_features = 1;
- shapedOk = hb_shape_full(hb_font, buffer, features, num_features, 0);
- }
- if (!shapedOk) {
- hb_buffer_destroy(buffer);
- return 0;
- }
- if (si.analysis.bidiLevel % 2)
- hb_buffer_reverse(buffer);
+ bool shapedOk = hb_shape_full(hb_font, buffer, features, num_features, 0);
+ if (Q_UNLIKELY(!shapedOk)) {
+ hb_buffer_destroy(buffer);
+ return 0;
+ }
- remaining_glyphs -= item_glyph_pos;
+ if (Q_UNLIKELY(HB_DIRECTION_IS_BACKWARD(props.direction)))
+ hb_buffer_reverse(buffer);
+ }
- // ensure we have enough space for shaped glyphs and metrics
const uint num_glyphs = hb_buffer_get_length(buffer);
- if (num_glyphs == 0 || !ensureSpace(glyphs_shaped + num_glyphs + remaining_glyphs)) {
+ // ensure we have enough space for shaped glyphs and metrics
+ if (Q_UNLIKELY(num_glyphs == 0 || !ensureSpace(glyphs_shaped + num_glyphs))) {
hb_buffer_destroy(buffer);
return 0;
}
@@ -1195,29 +1198,16 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
uint str_pos = 0;
uint last_cluster = ~0u;
uint last_glyph_pos = glyphs_shaped;
- for (uint i = 0; i < num_glyphs; ++i) {
- g.glyphs[i] = infos[i].codepoint;
-
- g.advances[i] = QFixed::fromFixed(positions[i].x_advance);
- g.offsets[i].x = QFixed::fromFixed(positions[i].x_offset);
- g.offsets[i].y = QFixed::fromFixed(positions[i].y_offset);
-
- uint cluster = infos[i].cluster;
- if (last_cluster != cluster) {
- if (Q_UNLIKELY(g.glyphs[i] == 0)) {
- // hide characters that should normally be invisible
- switch (string[item_pos + str_pos]) {
- case QChar::LineFeed:
- case 0x000c: // FormFeed
- case QChar::CarriageReturn:
- case QChar::LineSeparator:
- case QChar::ParagraphSeparator:
- g.attributes[i].dontPrint = true;
- break;
- default:
- break;
- }
- }
+ for (uint i = 0; i < num_glyphs; ++i, ++infos, ++positions) {
+ g.glyphs[i] = infos->codepoint;
+
+ g.advances[i] = QFixed::fromFixed(positions->x_advance);
+ g.offsets[i].x = QFixed::fromFixed(positions->x_offset);
+ g.offsets[i].y = QFixed::fromFixed(positions->y_offset);
+
+ uint cluster = infos->cluster;
+ if (Q_LIKELY(last_cluster != cluster)) {
+ g.attributes[i].clusterStart = true;
// fix up clusters so that the cluster indices will be monotonic
// and thus we never return out-of-order indices
@@ -1225,13 +1215,38 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
log_clusters[str_pos++] = last_glyph_pos;
last_glyph_pos = i + glyphs_shaped;
last_cluster = cluster;
- g.attributes[i].clusterStart = true;
+
+ // hide characters that should normally be invisible
+ switch (string[item_pos + str_pos]) {
+ case QChar::LineFeed:
+ case 0x000c: // FormFeed
+ case QChar::CarriageReturn:
+ case QChar::LineSeparator:
+ case QChar::ParagraphSeparator:
+ g.attributes[i].dontPrint = true;
+ break;
+ case QChar::SoftHyphen:
+ if (!actualFontEngine->symbol) {
+ // U+00AD [SOFT HYPHEN] is a default ignorable codepoint,
+ // so we replace its glyph and metrics with ones for
+ // U+002D [HYPHEN-MINUS] and make it visible if it appears at line-break
+ g.glyphs[i] = actualFontEngine->glyphIndex('-');
+ if (Q_LIKELY(g.glyphs[i] != 0)) {
+ QGlyphLayout tmp = g.mid(i, 1);
+ actualFontEngine->recalcAdvances(&tmp, 0);
+ }
+ g.attributes[i].dontPrint = true;
+ }
+ break;
+ default:
+ break;
+ }
}
}
while (str_pos < item_length)
log_clusters[str_pos++] = last_glyph_pos;
- if (engineIdx != 0) {
+ if (Q_UNLIKELY(engineIdx != 0)) {
for (quint32 i = 0; i < num_glyphs; ++i)
g.glyphs[i] |= (engineIdx << 24);
}
@@ -1621,10 +1636,10 @@ void QTextEngine::itemize() const
for (int i = 0; i < length; ++i) {
switch (analysis[i].script) {
case QChar::Script_Latin:
- case QChar::Script_Han:
case QChar::Script_Hiragana:
case QChar::Script_Katakana:
case QChar::Script_Bopomofo:
+ case QChar::Script_Han:
analysis[i].script = QChar::Script_Common;
break;
default:
@@ -1710,7 +1725,7 @@ bool QTextEngine::isRightToLeft() const
itemize();
// this places the cursor in the right position depending on the keyboard layout
if (layoutData->string.isEmpty())
- return qApp ? qApp->inputMethod()->inputDirection() == Qt::RightToLeft : false;
+ return QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft;
return layoutData->string.isRightToLeft();
}
@@ -1959,7 +1974,7 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
if (feCache.prevFontEngine && feCache.prevFontEngine->type() == QFontEngine::Multi && feCache.prevScript == script) {
engine = feCache.prevFontEngine;
} else {
- engine = QFontEngineMultiBasicImpl::createMultiFontEngine(rawFont.d->fontEngine, script);
+ engine = QFontEngineMulti::createMultiFontEngine(rawFont.d->fontEngine, script);
feCache.prevFontEngine = engine;
feCache.prevScript = script;
engine->ref.ref();
@@ -1974,7 +1989,7 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
} else {
QFontEngine *scEngine = rawFont.d->fontEngine->cloneWithSize(smallCapsFraction * rawFont.pixelSize());
scEngine->ref.ref();
- scaledEngine = QFontEngineMultiBasicImpl::createMultiFontEngine(scEngine, script);
+ scaledEngine = QFontEngineMulti::createMultiFontEngine(scEngine, script);
scaledEngine->ref.ref();
feCache.prevScaledFontEngine = scaledEngine;
// If scEngine is not ref'ed by scaledEngine, make sure it is deallocated and not leaked.
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index ac7015639b..8037fd5f6d 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 0bffbcc802..c60d0cc775 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -258,20 +258,6 @@ private:
friend QDataStream &operator>>(QDataStream &, QTextFormat &);
};
-// this is only safe because sizeof(int) == sizeof(float)
-static inline uint hash(float d)
-{
-#ifdef Q_CC_GNU
- // this is a GCC extension and isn't guaranteed to work in other compilers
- // the reinterpret_cast below generates a strict-aliasing warning with GCC
- union { float f; uint u; } cvt;
- cvt.f = d;
- return cvt.u;
-#else
- return reinterpret_cast<uint&>(d);
-#endif
-}
-
static inline uint hash(const QColor &color)
{
return (color.isValid()) ? color.rgba() : 0x234109;
@@ -279,7 +265,7 @@ static inline uint hash(const QColor &color)
static inline uint hash(const QPen &pen)
{
- return hash(pen.color()) + hash(pen.widthF());
+ return hash(pen.color()) + qHash(pen.widthF());
}
static inline uint hash(const QBrush &brush)
@@ -292,7 +278,7 @@ static inline uint variantHash(const QVariant &variant)
// simple and fast hash functions to differentiate between type and value
switch (variant.userType()) { // sorted by occurrence frequency
case QVariant::String: return qHash(variant.toString());
- case QVariant::Double: return hash(variant.toDouble());
+ case QVariant::Double: return qHash(variant.toDouble());
case QVariant::Int: return 0x811890 + variant.toInt();
case QVariant::Brush:
return 0x01010101 + hash(qvariant_cast<QBrush>(variant));
@@ -303,7 +289,7 @@ static inline uint variantHash(const QVariant &variant)
case QVariant::Color: return hash(qvariant_cast<QColor>(variant));
case QVariant::TextLength:
return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue());
- case QMetaType::Float: return hash(variant.toFloat());
+ case QMetaType::Float: return qHash(variant.toFloat());
case QVariant::Invalid: return 0;
default: break;
}
@@ -3472,14 +3458,16 @@ void QTextFormatCollection::setDefaultFont(const QFont &f)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QTextLength &l)
{
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QTextLength(QTextLength::Type(" << l.type() << "))";
- return dbg.space();
+ return dbg;
}
QDebug operator<<(QDebug dbg, const QTextFormat &f)
{
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QTextFormat(QTextFormat::FormatType(" << f.type() << "))";
- return dbg.space();
+ return dbg;
}
#endif
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index 94c5b83cc0..6c1b75aa35 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -126,7 +126,6 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QTextFormat &);
class Q_GUI_EXPORT QTextFormat
{
Q_GADGET
- Q_ENUMS(FormatType Property ObjectTypes)
public:
enum FormatType {
InvalidFormat = -1,
@@ -140,6 +139,7 @@ public:
UserFormat = 100
};
+ Q_ENUM(FormatType)
enum Property {
ObjectIndex = 0x0,
@@ -257,6 +257,7 @@ public:
// --
UserProperty = 0x100000
};
+ Q_ENUM(Property)
enum ObjectTypes {
NoObject,
@@ -266,6 +267,7 @@ public:
UserObject = 0x1000
};
+ Q_ENUM(ObjectTypes)
enum PageBreakFlag {
PageBreak_Auto = 0,
diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h
index 72cd56cbbb..29656bbafe 100644
--- a/src/gui/text/qtextformat_p.h
+++ b/src/gui/text/qtextformat_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index e1a7781722..f8f41bb53d 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -45,7 +45,6 @@
#include "qtextdocument_p.h"
#include "qtextcursor.h"
#include "qfont_p.h"
-#include "private/qfunctions_p.h"
#include <algorithm>
@@ -323,12 +322,12 @@ bool operator<(const QTextHtmlEntity &entity1, const QTextHtmlEntity &entity2)
}
#endif
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &entityStr, const QTextHtmlEntity &entity)
+static bool operator<(const QString &entityStr, const QTextHtmlEntity &entity)
{
return entityStr < QLatin1String(entity.name);
}
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QTextHtmlEntity &entity, const QString &entityStr)
+static bool operator<(const QTextHtmlEntity &entity, const QString &entityStr)
{
return QLatin1String(entity.name) < entityStr;
}
@@ -443,18 +442,18 @@ static const QTextHtmlElement elements[Html_NumElements]= {
};
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QTextHtmlElement &e1, const QTextHtmlElement &e2)
+static bool operator<(const QTextHtmlElement &e1, const QTextHtmlElement &e2)
{
return QLatin1String(e1.name) < QLatin1String(e2.name);
}
#endif
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &str, const QTextHtmlElement &e)
+static bool operator<(const QString &str, const QTextHtmlElement &e)
{
return str < QLatin1String(e.name);
}
-Q_STATIC_GLOBAL_OPERATOR bool operator<(const QTextHtmlElement &e, const QString &str)
+static bool operator<(const QTextHtmlElement &e, const QString &str)
{
return QLatin1String(e.name) < str;
}
@@ -1051,25 +1050,14 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent
// set element specific attributes
switch (id) {
case Html_a:
- charFormat.setAnchor(true);
for (int i = 0; i < attributes.count(); i += 2) {
const QString key = attributes.at(i);
if (key.compare(QLatin1String("href"), Qt::CaseInsensitive) == 0
&& !attributes.at(i + 1).isEmpty()) {
hasHref = true;
- charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
- charFormat.setForeground(QGuiApplication::palette().link());
}
}
-
- break;
- case Html_em:
- case Html_i:
- case Html_cite:
- case Html_address:
- case Html_var:
- case Html_dfn:
- charFormat.setFontItalic(true);
+ charFormat.setAnchor(true);
break;
case Html_big:
charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(1));
@@ -1077,36 +1065,27 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent
case Html_small:
charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(-1));
break;
- case Html_strong:
- case Html_b:
- charFormat.setFontWeight(QFont::Bold);
- break;
case Html_h1:
- charFormat.setFontWeight(QFont::Bold);
charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(3));
margin[QTextHtmlParser::MarginTop] = 18;
margin[QTextHtmlParser::MarginBottom] = 12;
break;
case Html_h2:
- charFormat.setFontWeight(QFont::Bold);
charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(2));
margin[QTextHtmlParser::MarginTop] = 16;
margin[QTextHtmlParser::MarginBottom] = 12;
break;
case Html_h3:
- charFormat.setFontWeight(QFont::Bold);
charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(1));
margin[QTextHtmlParser::MarginTop] = 14;
margin[QTextHtmlParser::MarginBottom] = 12;
break;
case Html_h4:
- charFormat.setFontWeight(QFont::Bold);
charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(0));
margin[QTextHtmlParser::MarginTop] = 12;
margin[QTextHtmlParser::MarginBottom] = 12;
break;
case Html_h5:
- charFormat.setFontWeight(QFont::Bold);
charFormat.setProperty(QTextFormat::FontSizeAdjustment, int(-1));
margin[QTextHtmlParser::MarginTop] = 12;
margin[QTextHtmlParser::MarginBottom] = 4;
@@ -1115,11 +1094,7 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent
margin[QTextHtmlParser::MarginTop] = 12;
margin[QTextHtmlParser::MarginBottom] = 12;
break;
- case Html_center:
- blockFormat.setAlignment(Qt::AlignCenter);
- break;
case Html_ul:
- listStyle = QTextListFormat::ListDisc;
// nested lists don't have margins, except for the toplevel one
if (!isNestedList(parser)) {
margin[QTextHtmlParser::MarginTop] = 12;
@@ -1128,7 +1103,6 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent
// no left margin as we use indenting instead
break;
case Html_ol:
- listStyle = QTextListFormat::ListDecimal;
// nested lists don't have margins, except for the toplevel one
if (!isNestedList(parser)) {
margin[QTextHtmlParser::MarginTop] = 12;
@@ -1136,26 +1110,12 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent
}
// no left margin as we use indenting instead
break;
- case Html_code:
- case Html_tt:
- case Html_kbd:
- case Html_samp:
- charFormat.setFontFamily(QString::fromLatin1("Courier New,courier"));
- // <tt> uses a fixed font, so set the property
- charFormat.setFontFixedPitch(true);
- break;
case Html_br:
text = QChar(QChar::LineSeparator);
- wsm = QTextHtmlParserNode::WhiteSpacePre;
break;
- // ##### sub / sup
case Html_pre:
- charFormat.setFontFamily(QString::fromLatin1("Courier New,courier"));
- wsm = WhiteSpacePre;
margin[QTextHtmlParser::MarginTop] = 12;
margin[QTextHtmlParser::MarginBottom] = 12;
- // <pre> uses a fixed font
- charFormat.setFontFixedPitch(true);
break;
case Html_blockquote:
margin[QTextHtmlParser::MarginTop] = 12;
@@ -1170,28 +1130,6 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent
case Html_dd:
margin[QTextHtmlParser::MarginLeft] = 30;
break;
- case Html_u:
- charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
- break;
- case Html_s:
- charFormat.setFontStrikeOut(true);
- break;
- case Html_nobr:
- wsm = WhiteSpaceNoWrap;
- break;
- case Html_th:
- charFormat.setFontWeight(QFont::Bold);
- blockFormat.setAlignment(Qt::AlignCenter);
- break;
- case Html_td:
- blockFormat.setAlignment(Qt::AlignLeft);
- break;
- case Html_sub:
- charFormat.setVerticalAlignment(QTextCharFormat::AlignSubScript);
- break;
- case Html_sup:
- charFormat.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
- break;
default: break;
}
}
@@ -1346,6 +1284,14 @@ void QTextHtmlParserNode::applyCssDeclarations(const QVector<QCss::Declaration>
case QCss::QtListNumberSuffix:
textListNumberSuffix = decl.d->values.first().variant.toString();
break;
+ case QCss::TextAlignment:
+ switch (identifier) {
+ case QCss::Value_Left: blockFormat.setAlignment(Qt::AlignLeft); break;
+ case QCss::Value_Center: blockFormat.setAlignment(Qt::AlignCenter); break;
+ case QCss::Value_Right: blockFormat.setAlignment(Qt::AlignRight); break;
+ default: break;
+ }
+ break;
default: break;
}
}
@@ -1713,14 +1659,14 @@ public:
inline QTextHtmlStyleSelector(const QTextHtmlParser *parser)
: parser(parser) { nameCaseSensitivity = Qt::CaseInsensitive; }
- virtual QStringList nodeNames(NodePtr node) const;
- virtual QString attribute(NodePtr node, const QString &name) const;
- virtual bool hasAttributes(NodePtr node) const;
- virtual bool isNullNode(NodePtr node) const;
- virtual NodePtr parentNode(NodePtr node) const;
- virtual NodePtr previousSiblingNode(NodePtr node) const;
- virtual NodePtr duplicateNode(NodePtr node) const;
- virtual void freeNode(NodePtr node) const;
+ virtual QStringList nodeNames(NodePtr node) const Q_DECL_OVERRIDE;
+ virtual QString attribute(NodePtr node, const QString &name) const Q_DECL_OVERRIDE;
+ virtual bool hasAttributes(NodePtr node) const Q_DECL_OVERRIDE;
+ virtual bool isNullNode(NodePtr node) const Q_DECL_OVERRIDE;
+ virtual NodePtr parentNode(NodePtr node) const Q_DECL_OVERRIDE;
+ virtual NodePtr previousSiblingNode(NodePtr node) const Q_DECL_OVERRIDE;
+ virtual NodePtr duplicateNode(NodePtr node) const Q_DECL_OVERRIDE;
+ virtual void freeNode(NodePtr node) const Q_DECL_OVERRIDE;
private:
const QTextHtmlParser *parser;
@@ -1834,6 +1780,189 @@ void QTextHtmlParser::importStyleSheet(const QString &href)
}
}
+QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode &node)
+{
+ QVector<QCss::Declaration> decls;
+ QCss::Declaration decl;
+ QCss::Value val;
+ switch (node.id) {
+ case Html_a:
+ case Html_u: {
+ bool needsUnderline = (node.id == Html_u) ? true : false;
+ if (node.id == Html_a) {
+ for (int i = 0; i < node.attributes.count(); i += 2) {
+ const QString key = node.attributes.at(i);
+ if (key.compare(QLatin1String("href"), Qt::CaseInsensitive) == 0
+ && !node.attributes.at(i + 1).isEmpty()) {
+ needsUnderline = true;
+ decl.d->property = QLatin1String("color");
+ decl.d->propertyId = QCss::Color;
+ val.type = QCss::Value::Color;
+ val.variant = QVariant(QGuiApplication::palette().link());
+ decl.d->values = QVector<QCss::Value>() << val;
+ decl.d->inheritable = true;
+ decls << decl;
+ break;
+ }
+ }
+ }
+ if (needsUnderline) {
+ decl = QCss::Declaration();
+ decl.d->property = QLatin1String("text-decoration");
+ decl.d->propertyId = QCss::TextDecoration;
+ val.type = QCss::Value::KnownIdentifier;
+ val.variant = QVariant(QCss::Value_Underline);
+ decl.d->values = QVector<QCss::Value>() << val;
+ decl.d->inheritable = true;
+ decls << decl;
+ }
+ break;
+ }
+ case Html_b:
+ case Html_strong:
+ case Html_h1:
+ case Html_h2:
+ case Html_h3:
+ case Html_h4:
+ case Html_h5:
+ case Html_th:
+ decl = QCss::Declaration();
+ decl.d->property = QLatin1String("font-weight");
+ decl.d->propertyId = QCss::FontWeight;
+ val.type = QCss::Value::KnownIdentifier;
+ val.variant = QVariant(QCss::Value_Bold);
+ decl.d->values = QVector<QCss::Value>() << val;
+ decl.d->inheritable = true;
+ decls << decl;
+ if (node.id == Html_b || node.id == Html_strong)
+ break;
+ // Delibrate fall through
+ case Html_big:
+ case Html_small:
+ if (node.id != Html_th) {
+ decl = QCss::Declaration();
+ decl.d->property = QLatin1String("font-size");
+ decl.d->propertyId = QCss::FontSize;
+ decl.d->inheritable = false;
+ val.type = QCss::Value::KnownIdentifier;
+ switch (node.id) {
+ case Html_h1: val.variant = QVariant(QCss::Value_XXLarge); break;
+ case Html_h2: val.variant = QVariant(QCss::Value_XLarge); break;
+ case Html_h3: case Html_big: val.variant = QVariant(QCss::Value_Large); break;
+ case Html_h4: val.variant = QVariant(QCss::Value_Medium); break;
+ case Html_h5: case Html_small: val.variant = QVariant(QCss::Value_Small); break;
+ default: break;
+ }
+ decl.d->values = QVector<QCss::Value>() << val;
+ decls << decl;
+ break;
+ }
+ // Delibrate fall through
+ case Html_center:
+ case Html_td:
+ decl = QCss::Declaration();
+ decl.d->property = QLatin1String("text-align");
+ decl.d->propertyId = QCss::TextAlignment;
+ val.type = QCss::Value::KnownIdentifier;
+ val.variant = (node.id == Html_td) ? QVariant(QCss::Value_Left) : QVariant(QCss::Value_Center);
+ decl.d->values = QVector<QCss::Value>() << val;
+ decl.d->inheritable = true;
+ decls << decl;
+ break;
+ case Html_s:
+ decl = QCss::Declaration();
+ decl.d->property = QLatin1String("text-decoration");
+ decl.d->propertyId = QCss::TextDecoration;
+ val.type = QCss::Value::KnownIdentifier;
+ val.variant = QVariant(QCss::Value_LineThrough);
+ decl.d->values = QVector<QCss::Value>() << val;
+ decl.d->inheritable = true;
+ decls << decl;
+ break;
+ case Html_em:
+ case Html_i:
+ case Html_cite:
+ case Html_address:
+ case Html_var:
+ case Html_dfn:
+ decl = QCss::Declaration();
+ decl.d->property = QLatin1String("font-style");
+ decl.d->propertyId = QCss::FontStyle;
+ val.type = QCss::Value::KnownIdentifier;
+ val.variant = QVariant(QCss::Value_Italic);
+ decl.d->values = QVector<QCss::Value>() << val;
+ decl.d->inheritable = true;
+ decls << decl;
+ break;
+ case Html_sub:
+ case Html_sup:
+ decl = QCss::Declaration();
+ decl.d->property = QLatin1String("vertical-align");
+ decl.d->propertyId = QCss::VerticalAlignment;
+ val.type = QCss::Value::KnownIdentifier;
+ val.variant = (node.id == Html_sub) ? QVariant(QCss::Value_Sub) : QVariant(QCss::Value_Super);
+ decl.d->values = QVector<QCss::Value>() << val;
+ decl.d->inheritable = true;
+ decls << decl;
+ break;
+ case Html_ul:
+ case Html_ol:
+ decl = QCss::Declaration();
+ decl.d->property = QLatin1String("list-style");
+ decl.d->propertyId = QCss::ListStyle;
+ val.type = QCss::Value::KnownIdentifier;
+ val.variant = (node.id == Html_ul) ? QVariant(QCss::Value_Disc) : QVariant(QCss::Value_Decimal);
+ decl.d->values = QVector<QCss::Value>() << val;
+ decl.d->inheritable = true;
+ decls << decl;
+ break;
+ case Html_code:
+ case Html_tt:
+ case Html_kbd:
+ case Html_samp:
+ case Html_pre: {
+ decl = QCss::Declaration();
+ decl.d->property = QLatin1String("font-family");
+ decl.d->propertyId = QCss::FontFamily;
+ QVector<QCss::Value> values;
+ val.type = QCss::Value::String;
+ val.variant = QLatin1String("Courier New");
+ values << val;
+ val.type = QCss::Value::TermOperatorComma;
+ val.variant = QVariant();
+ values << val;
+ val.type = QCss::Value::String;
+ val.variant = QLatin1String("courier");
+ values << val;
+ decl.d->values = values;
+ decl.d->inheritable = true;
+ decls << decl;
+ }
+ if (node.id != Html_pre)
+ break;
+ // Delibrate fall through
+ case Html_br:
+ case Html_nobr:
+ decl = QCss::Declaration();
+ decl.d->property = QLatin1String("whitespace");
+ decl.d->propertyId = QCss::Whitespace;
+ val.type = QCss::Value::KnownIdentifier;
+ switch (node.id) {
+ case Html_br: val.variant = QVariant(QCss::Value_PreWrap); break;
+ case Html_nobr: val.variant = QVariant(QCss::Value_NoWrap); break;
+ case Html_pre: val.variant = QVariant(QCss::Value_Pre); break;
+ default: break;
+ }
+ decl.d->values = QVector<QCss::Value>() << val;
+ decl.d->inheritable = true;
+ decls << decl;
+ break;
+ default:
+ break;
+ }
+ return decls;
+}
+
QVector<QCss::Declaration> QTextHtmlParser::declarationsForNode(int node) const
{
QVector<QCss::Declaration> decls;
@@ -1861,8 +1990,20 @@ QVector<QCss::Declaration> QTextHtmlParser::declarationsForNode(int node) const
const char *extraPseudo = 0;
if (nodes.at(node).id == Html_a && nodes.at(node).hasHref)
extraPseudo = "link";
- decls = selector.declarationsForNode(n, extraPseudo);
-
+ // Ensure that our own style is taken into consideration
+ decls = standardDeclarationForNode(nodes.at(node));
+ decls += selector.declarationsForNode(n, extraPseudo);
+ n = selector.parentNode(n);
+ while (!selector.isNullNode(n)) {
+ QVector<QCss::Declaration> inheritedDecls;
+ inheritedDecls = selector.declarationsForNode(n, extraPseudo);
+ for (int i = 0; i < inheritedDecls.size(); ++i) {
+ const QCss::Declaration &decl = inheritedDecls.at(i);
+ if (decl.d->inheritable)
+ decls.prepend(decl);
+ }
+ n = selector.parentNode(n);
+ }
return decls;
}
diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h
index 976a1a918c..460e32d5bb 100644
--- a/src/gui/text/qtexthtmlparser_p.h
+++ b/src/gui/text/qtexthtmlparser_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index 37c18e3624..e85890baf2 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextimagehandler_p.h b/src/gui/text/qtextimagehandler_p.h
index c986c81f8b..5cdbe99530 100644
--- a/src/gui/text/qtextimagehandler_p.h
+++ b/src/gui/text/qtextimagehandler_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -60,8 +60,8 @@ class Q_GUI_EXPORT QTextImageHandler : public QObject,
public:
explicit QTextImageHandler(QObject *parent = 0);
- virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format);
- virtual void drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format);
+ virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) Q_DECL_OVERRIDE;
+ virtual void drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) Q_DECL_OVERRIDE;
QImage image(QTextDocument *doc, const QTextImageFormat &imageFormat);
};
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 52d2ba0d54..cab9f6ae61 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -2091,7 +2091,9 @@ static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine,
qreal minY = 0;
qreal maxY = 0;
QVector<quint32> glyphs;
+ glyphs.reserve(glyphsArray.size());
QVector<QPointF> positions;
+ positions.reserve(glyphsArray.size());
for (int i=0; i<glyphsArray.size(); ++i) {
glyphs.append(glyphsArray.at(i) & 0xffffff);
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index 1e0ab9b5c9..47dcd388e2 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextlist.cpp b/src/gui/text/qtextlist.cpp
index 13da035043..884b5f178b 100644
--- a/src/gui/text/qtextlist.cpp
+++ b/src/gui/text/qtextlist.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextlist.h b/src/gui/text/qtextlist.h
index 61f4885e42..12de39be17 100644
--- a/src/gui/text/qtextlist.h
+++ b/src/gui/text/qtextlist.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index d155e31f31..425126d474 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index 5a0e2c60a6..9ad912d992 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h
index 16a8164464..19d1dadd5f 100644
--- a/src/gui/text/qtextobject_p.h
+++ b/src/gui/text/qtextobject_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index ef7bbb44ff..6b17a264b1 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -88,7 +88,7 @@ public:
if (contentStream)
contentStream->close();
}
- virtual void addFile(const QString &, const QString &, const QByteArray &)
+ virtual void addFile(const QString &, const QString &, const QByteArray &) Q_DECL_OVERRIDE
{
// we ignore this...
}
@@ -131,7 +131,7 @@ public:
zip.close();
}
- virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes)
+ virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes) Q_DECL_OVERRIDE
{
zip.addFile(fileName, bytes);
addFile(fileName, mimeType);
@@ -278,7 +278,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc
writer.writeStartElement(textNS, QString::fromLatin1("p"));
writer.writeAttribute(textNS, QString::fromLatin1("style-name"), QString::fromLatin1("p%1")
.arg(block.blockFormatIndex()));
- for (QTextBlock::Iterator frag= block.begin(); !frag.atEnd(); frag++) {
+ for (QTextBlock::Iterator frag = block.begin(); !frag.atEnd(); ++frag) {
writer.writeCharacters(QString()); // Trick to make sure that the span gets no linefeed in front of it.
writer.writeStartElement(textNS, QString::fromLatin1("span"));
diff --git a/src/gui/text/qtextodfwriter_p.h b/src/gui/text/qtextodfwriter_p.h
index 5c06511c14..20805a8d27 100644
--- a/src/gui/text/qtextodfwriter_p.h
+++ b/src/gui/text/qtextodfwriter_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp
index dc38b1a105..dbafcfd58e 100644
--- a/src/gui/text/qtextoption.cpp
+++ b/src/gui/text/qtextoption.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h
index 694adc5cb9..b2e4476927 100644
--- a/src/gui/text/qtextoption.h
+++ b/src/gui/text/qtextoption.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index c2cc822ad6..e5acccb55b 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -37,7 +37,6 @@
#include <qdebug.h>
#include "qtexttable_p.h"
#include "qvarlengtharray.h"
-#include "private/qfunctions_p.h"
#include <algorithm>
#include <stdlib.h>
@@ -371,12 +370,12 @@ struct QFragmentFindHelper
const QTextDocumentPrivate::FragmentMap &fragmentMap;
};
-Q_STATIC_GLOBAL_INLINE_OPERATOR bool operator<(int fragment, const QFragmentFindHelper &helper)
+static inline bool operator<(int fragment, const QFragmentFindHelper &helper)
{
return helper.fragmentMap.position(fragment) < helper.pos;
}
-Q_STATIC_GLOBAL_INLINE_OPERATOR bool operator<(const QFragmentFindHelper &helper, int fragment)
+static inline bool operator<(const QFragmentFindHelper &helper, int fragment)
{
return helper.pos < helper.fragmentMap.position(fragment);
}
diff --git a/src/gui/text/qtexttable.h b/src/gui/text/qtexttable.h
index 5d2467e3a0..6ceb1fdd0f 100644
--- a/src/gui/text/qtexttable.h
+++ b/src/gui/text/qtexttable.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h
index 0459242ae9..58a4b7d32d 100644
--- a/src/gui/text/qtexttable_p.h
+++ b/src/gui/text/qtexttable_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -58,8 +58,8 @@ public:
~QTextTablePrivate();
static QTextTable *createTable(QTextDocumentPrivate *, int pos, int rows, int cols, const QTextTableFormat &tableFormat);
- void fragmentAdded(QChar type, uint fragment);
- void fragmentRemoved(QChar type, uint fragment);
+ void fragmentAdded(QChar type, uint fragment) Q_DECL_OVERRIDE;
+ void fragmentRemoved(QChar type, uint fragment) Q_DECL_OVERRIDE;
void update() const;
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index 90db029a12..9f561dcb02 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -194,7 +194,7 @@ static int inflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourc
z_stream stream;
int err;
- stream.next_in = (Bytef*)source;
+ stream.next_in = const_cast<Bytef*>(source);
stream.avail_in = (uInt)sourceLen;
if ((uLong)stream.avail_in != sourceLen)
return Z_BUF_ERROR;
@@ -229,7 +229,7 @@ static int deflate (Bytef *dest, ulong *destLen, const Bytef *source, ulong sour
z_stream stream;
int err;
- stream.next_in = (Bytef*)source;
+ stream.next_in = const_cast<Bytef*>(source);
stream.avail_in = (uInt)sourceLen;
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
@@ -1008,7 +1008,7 @@ QByteArray QZipReader::fileData(const QString &fileName) const
do {
baunzip.resize(len);
res = inflate((uchar*)baunzip.data(), &len,
- (uchar*)compressed.constData(), compressed_size);
+ (const uchar*)compressed.constData(), compressed_size);
switch (res) {
case Z_OK:
diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h
index c950c2505a..df7e2d26e9 100644
--- a/src/gui/text/qzipreader_p.h
+++ b/src/gui/text/qzipreader_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/qzipwriter_p.h b/src/gui/text/qzipwriter_p.h
index e4e4e7fa37..bd8d0b423d 100644
--- a/src/gui/text/qzipwriter_p.h
+++ b/src/gui/text/qzipwriter_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index 091129f5be..61e239f678 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -86,7 +86,7 @@ HEADERS += \
contains(QT_CONFIG, harfbuzz)|contains(QT_CONFIG, system-harfbuzz) {
DEFINES += QT_ENABLE_HARFBUZZ_NG
- include($$PWD/../../3rdparty/harfbuzzng.pri)
+ include($$PWD/../../3rdparty/harfbuzz_dependency.pri)
SOURCES += text/qharfbuzzng.cpp
HEADERS += text/qharfbuzzng_p.h