summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qabstractfontengine_p.h32
-rw-r--r--src/gui/text/qabstractfontengine_qws.cpp30
-rw-r--r--src/gui/text/qabstractfontengine_qws.h30
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp32
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.h31
-rw-r--r--src/gui/text/qabstracttextdocumentlayout_p.h30
-rw-r--r--src/gui/text/qcssparser.cpp45
-rw-r--r--src/gui/text/qcssparser_p.h30
-rw-r--r--src/gui/text/qcssscanner.cpp116
-rw-r--r--src/gui/text/qfont.cpp134
-rw-r--r--src/gui/text/qfont.h36
-rw-r--r--src/gui/text/qfont_mac.cpp30
-rw-r--r--src/gui/text/qfont_p.h32
-rw-r--r--src/gui/text/qfont_qws.cpp30
-rw-r--r--src/gui/text/qfont_s60.cpp97
-rw-r--r--src/gui/text/qfont_win.cpp30
-rw-r--r--src/gui/text/qfont_x11.cpp30
-rw-r--r--src/gui/text/qfontdatabase.cpp311
-rw-r--r--src/gui/text/qfontdatabase.h34
-rw-r--r--src/gui/text/qfontdatabase_mac.cpp61
-rw-r--r--src/gui/text/qfontdatabase_qws.cpp306
-rw-r--r--src/gui/text/qfontdatabase_s60.cpp463
-rw-r--r--src/gui/text/qfontdatabase_win.cpp44
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp165
-rw-r--r--src/gui/text/qfontengine.cpp152
-rw-r--r--src/gui/text/qfontengine_ft.cpp170
-rw-r--r--src/gui/text/qfontengine_ft_p.h34
-rw-r--r--src/gui/text/qfontengine_mac.mm117
-rw-r--r--src/gui/text/qfontengine_p.h52
-rw-r--r--src/gui/text/qfontengine_qpf.cpp74
-rw-r--r--src/gui/text/qfontengine_qpf_p.h31
-rw-r--r--src/gui/text/qfontengine_qws.cpp40
-rw-r--r--src/gui/text/qfontengine_s60.cpp336
-rw-r--r--src/gui/text/qfontengine_s60_p.h149
-rw-r--r--src/gui/text/qfontengine_win.cpp250
-rw-r--r--src/gui/text/qfontengine_win_p.h34
-rw-r--r--src/gui/text/qfontengine_x11.cpp35
-rw-r--r--src/gui/text/qfontengine_x11_p.h30
-rw-r--r--src/gui/text/qfontengineglyphcache_p.h30
-rw-r--r--src/gui/text/qfontinfo.h33
-rw-r--r--src/gui/text/qfontmetrics.cpp121
-rw-r--r--src/gui/text/qfontmetrics.h35
-rw-r--r--src/gui/text/qfontsubset.cpp30
-rw-r--r--src/gui/text/qfontsubset_p.h30
-rw-r--r--src/gui/text/qfragmentmap.cpp30
-rw-r--r--src/gui/text/qfragmentmap_p.h51
-rw-r--r--src/gui/text/qpfutil.cpp30
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp34
-rw-r--r--src/gui/text/qsyntaxhighlighter.h30
-rw-r--r--src/gui/text/qtextcontrol.cpp143
-rw-r--r--src/gui/text/qtextcontrol_p.h34
-rw-r--r--src/gui/text/qtextcontrol_p_p.h35
-rw-r--r--src/gui/text/qtextcursor.cpp47
-rw-r--r--src/gui/text/qtextcursor.h30
-rw-r--r--src/gui/text/qtextcursor_p.h30
-rw-r--r--src/gui/text/qtextdocument.cpp108
-rw-r--r--src/gui/text/qtextdocument.h33
-rw-r--r--src/gui/text/qtextdocument_p.cpp193
-rw-r--r--src/gui/text/qtextdocument_p.h42
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp32
-rw-r--r--src/gui/text/qtextdocumentfragment.h30
-rw-r--r--src/gui/text/qtextdocumentfragment_p.h30
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp53
-rw-r--r--src/gui/text/qtextdocumentlayout_p.h30
-rw-r--r--src/gui/text/qtextdocumentwriter.cpp32
-rw-r--r--src/gui/text/qtextdocumentwriter.h30
-rw-r--r--src/gui/text/qtextengine.cpp111
-rw-r--r--src/gui/text/qtextengine_mac.cpp110
-rw-r--r--src/gui/text/qtextengine_p.h48
-rw-r--r--src/gui/text/qtextformat.cpp140
-rw-r--r--src/gui/text/qtextformat.h30
-rw-r--r--src/gui/text/qtextformat_p.h34
-rw-r--r--src/gui/text/qtexthtmlparser.cpp30
-rw-r--r--src/gui/text/qtexthtmlparser_p.h30
-rw-r--r--src/gui/text/qtextimagehandler.cpp30
-rw-r--r--src/gui/text/qtextimagehandler_p.h30
-rw-r--r--src/gui/text/qtextlayout.cpp275
-rw-r--r--src/gui/text/qtextlayout.h34
-rw-r--r--src/gui/text/qtextlist.cpp32
-rw-r--r--src/gui/text/qtextlist.h30
-rw-r--r--src/gui/text/qtextobject.cpp48
-rw-r--r--src/gui/text/qtextobject.h30
-rw-r--r--src/gui/text/qtextobject_p.h30
-rw-r--r--src/gui/text/qtextodfwriter.cpp47
-rw-r--r--src/gui/text/qtextodfwriter_p.h30
-rw-r--r--src/gui/text/qtextoption.cpp48
-rw-r--r--src/gui/text/qtextoption.h30
-rw-r--r--src/gui/text/qtexttable.cpp45
-rw-r--r--src/gui/text/qtexttable.h30
-rw-r--r--src/gui/text/qtexttable_p.h30
-rw-r--r--src/gui/text/qzip.cpp40
-rw-r--r--src/gui/text/qzipreader_p.h30
-rw-r--r--src/gui/text/qzipwriter_p.h30
-rw-r--r--src/gui/text/text.pri34
94 files changed, 4163 insertions, 2372 deletions
diff --git a/src/gui/text/qabstractfontengine_p.h b/src/gui/text/qabstractfontengine_p.h
index ac3ee9dfb..b5580c1d5 100644
--- a/src/gui/text/qabstractfontengine_p.h
+++ b/src/gui/text/qabstractfontengine_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -91,7 +91,7 @@ public:
virtual Type type() const { return Proxy; }
virtual const char *name() const { return "proxy engine"; }
-#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
+#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN)
virtual void draw(QPaintEngine *, qreal, qreal, const QTextItemInt &);
#endif
diff --git a/src/gui/text/qabstractfontengine_qws.cpp b/src/gui/text/qabstractfontengine_qws.cpp
index 9559008c8..a58a4cfde 100644
--- a/src/gui/text/qabstractfontengine_qws.cpp
+++ b/src/gui/text/qabstractfontengine_qws.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qabstractfontengine_qws.h b/src/gui/text/qabstractfontengine_qws.h
index 3fdb5cf34..4f00b3c7c 100644
--- a/src/gui/text/qabstractfontengine_qws.h
+++ b/src/gui/text/qabstractfontengine_qws.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index 8b21c8fdc..62420b5e6 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
\brief The QAbstractTextDocumentLayout class is an abstract base
class used to implement custom layouts for QTextDocuments.
- \ingroup text
+ \ingroup richtext-processing
The standard layout provided by Qt can handle simple word processing
including inline images, lists and tables.
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h
index a50ce6461..438b291c0 100644
--- a/src/gui/text/qabstracttextdocumentlayout.h
+++ b/src/gui/text/qabstracttextdocumentlayout.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -122,6 +122,7 @@ protected:
QTextCharFormat format(int pos);
private:
+ friend class QTextControl;
friend class QTextDocument;
friend class QTextDocumentPrivate;
friend class QTextEngine;
diff --git a/src/gui/text/qabstracttextdocumentlayout_p.h b/src/gui/text/qabstracttextdocumentlayout_p.h
index 78304f30d..4e1ccd474 100644
--- a/src/gui/text/qabstracttextdocumentlayout_p.h
+++ b/src/gui/text/qabstracttextdocumentlayout_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index d3dcf5088..93b9fc6c1 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,6 +48,7 @@
#include <qfontmetrics.h>
#include <qbrush.h>
#include <qimagereader.h>
+#include "private/qfunctions_p.h"
#ifndef QT_NO_CSSPARSER
@@ -340,12 +341,12 @@ static const QCssKnownValue styleFeatures[NumKnownStyleFeatures - 1] = {
{ "none", StyleFeature_None }
};
-static bool operator<(const QString &name, const QCssKnownValue &prop)
+Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &name, const QCssKnownValue &prop)
{
return QString::compare(name, QLatin1String(prop.name), Qt::CaseInsensitive) < 0;
}
-static bool operator<(const QCssKnownValue &prop, const QString &name)
+Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCssKnownValue &prop, const QString &name)
{
return QString::compare(QLatin1String(prop.name), name, Qt::CaseInsensitive) < 0;
}
@@ -1128,19 +1129,22 @@ static bool setFontWeightFromValue(const Value &value, QFont *font)
static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font, int start = 0)
{
QString family;
+ bool shouldAddSpace = false;
for (int i = start; i < values.count(); ++i) {
const Value &v = values.at(i);
if (v.type == Value::TermOperatorComma) {
family += QLatin1Char(',');
+ shouldAddSpace = false;
continue;
}
const QString str = v.variant.toString();
if (str.isEmpty())
break;
+ if (shouldAddSpace)
+ family += QLatin1Char(' ');
family += str;
- family += QLatin1Char(' ');
+ shouldAddSpace = true;
}
- family = family.simplified();
if (family.isEmpty())
return false;
font->setFamily(family);
@@ -1170,7 +1174,7 @@ static void parseShorthandFontProperty(const QVector<Value> &values, QFont *font
{
font->setStyle(QFont::StyleNormal);
font->setWeight(QFont::Normal);
- *fontSizeAdjustment = 0;
+ *fontSizeAdjustment = -255;
int i = 0;
while (i < values.count()) {
@@ -2125,6 +2129,7 @@ void Parser::init(const QString &css, bool isFile)
hasEscapeSequences = false;
symbols.resize(0);
+ symbols.reserve(8);
Scanner::scan(Scanner::preprocess(styleSheet, &hasEscapeSequences), &symbols);
index = 0;
errorIndex = -1;
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index 6f7344565..b299e2185 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qcssscanner.cpp b/src/gui/text/qcssscanner.cpp
index 6256b7bf7..babc6f5c7 100644
--- a/src/gui/text/qcssscanner.cpp
+++ b/src/gui/text/qcssscanner.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -46,7 +46,7 @@ public:
QCssScanner_Generated(const QString &inp);
inline QChar next() {
- return (pos < input.length()) ? input.at(pos++).toLower() : QChar();
+ return (pos < input.length()) ? input.at(pos++) : QChar();
}
int handleCommentStart();
int lex();
@@ -73,7 +73,7 @@ int QCssScanner_Generated::lex()
int lastAcceptingPos = -1;
int token = -1;
QChar ch;
-
+
// initial state
ch = next();
if (ch.unicode() >= 9 && ch.unicode() <= 10)
@@ -146,7 +146,7 @@ int QCssScanner_Generated::lex()
}
if (ch.unicode() == 95)
goto state_24;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_24;
if (ch.unicode() == 123)
goto state_25;
@@ -196,7 +196,7 @@ int QCssScanner_Generated::lex()
goto state_32;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_30;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_30;
if (ch.unicode() >= 123)
goto state_30;
@@ -211,7 +211,7 @@ int QCssScanner_Generated::lex()
goto state_34;
if (ch.unicode() == 95)
goto state_33;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_33;
goto out;
state_5:
@@ -232,7 +232,7 @@ int QCssScanner_Generated::lex()
goto state_37;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_35;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_35;
if (ch.unicode() >= 123)
goto state_35;
@@ -255,7 +255,7 @@ int QCssScanner_Generated::lex()
goto state_22;
if (ch.unicode() == 95)
goto state_24;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_24;
goto out;
state_12:
@@ -290,7 +290,7 @@ int QCssScanner_Generated::lex()
goto state_45;
if (ch.unicode() == 95)
goto state_46;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_46;
goto out;
state_17:
@@ -310,7 +310,7 @@ int QCssScanner_Generated::lex()
goto state_49;
if (ch.unicode() == 95)
goto state_50;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_50;
goto out;
state_22:
@@ -340,7 +340,7 @@ int QCssScanner_Generated::lex()
goto state_54;
if (ch.unicode() == 95)
goto state_53;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_53;
goto out;
state_25:
@@ -400,7 +400,7 @@ int QCssScanner_Generated::lex()
goto state_32;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_30;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_30;
if (ch.unicode() >= 123)
goto state_30;
@@ -440,7 +440,7 @@ int QCssScanner_Generated::lex()
goto state_62;
if (ch.unicode() == 95)
goto state_61;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_61;
goto out;
state_34:
@@ -474,7 +474,7 @@ int QCssScanner_Generated::lex()
goto state_37;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_35;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_35;
if (ch.unicode() >= 123)
goto state_35;
@@ -523,7 +523,7 @@ int QCssScanner_Generated::lex()
goto state_45;
if (ch.unicode() == 95)
goto state_46;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_46;
goto out;
state_41:
@@ -536,7 +536,7 @@ int QCssScanner_Generated::lex()
goto state_45;
if (ch.unicode() == 95)
goto state_46;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_46;
goto out;
state_43:
@@ -560,7 +560,7 @@ int QCssScanner_Generated::lex()
goto state_45;
if (ch.unicode() == 95)
goto state_46;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_46;
goto out;
state_45:
@@ -588,7 +588,7 @@ int QCssScanner_Generated::lex()
goto state_72;
if (ch.unicode() == 95)
goto state_71;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_71;
goto out;
state_47:
@@ -602,7 +602,7 @@ int QCssScanner_Generated::lex()
goto state_49;
if (ch.unicode() == 95)
goto state_50;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_50;
goto out;
state_49:
@@ -630,7 +630,7 @@ int QCssScanner_Generated::lex()
goto state_76;
if (ch.unicode() == 95)
goto state_75;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_75;
goto out;
state_51:
@@ -647,7 +647,7 @@ int QCssScanner_Generated::lex()
goto state_54;
if (ch.unicode() == 95)
goto state_53;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_53;
goto out;
state_52:
@@ -668,7 +668,7 @@ int QCssScanner_Generated::lex()
goto state_54;
if (ch.unicode() == 95)
goto state_53;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_53;
goto out;
state_54:
@@ -702,7 +702,7 @@ int QCssScanner_Generated::lex()
goto state_32;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_30;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_30;
if (ch.unicode() >= 123)
goto state_30;
@@ -725,7 +725,7 @@ int QCssScanner_Generated::lex()
goto state_32;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_30;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_30;
if (ch.unicode() >= 123)
goto state_30;
@@ -748,7 +748,7 @@ int QCssScanner_Generated::lex()
goto state_32;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_30;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_30;
if (ch.unicode() >= 123)
goto state_30;
@@ -773,7 +773,7 @@ int QCssScanner_Generated::lex()
goto state_32;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_30;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_30;
if (ch.unicode() >= 123)
goto state_30;
@@ -790,7 +790,7 @@ int QCssScanner_Generated::lex()
goto state_62;
if (ch.unicode() == 95)
goto state_61;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_61;
goto out;
state_62:
@@ -818,7 +818,7 @@ int QCssScanner_Generated::lex()
goto state_62;
if (ch.unicode() == 95)
goto state_61;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_61;
goto out;
state_64:
@@ -839,7 +839,7 @@ int QCssScanner_Generated::lex()
goto state_37;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_35;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_35;
if (ch.unicode() >= 123)
goto state_35;
@@ -862,7 +862,7 @@ int QCssScanner_Generated::lex()
goto state_37;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_35;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_35;
if (ch.unicode() >= 123)
goto state_35;
@@ -885,7 +885,7 @@ int QCssScanner_Generated::lex()
goto state_37;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_35;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_35;
if (ch.unicode() >= 123)
goto state_35;
@@ -910,7 +910,7 @@ int QCssScanner_Generated::lex()
goto state_37;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_35;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_35;
if (ch.unicode() >= 123)
goto state_35;
@@ -929,7 +929,7 @@ int QCssScanner_Generated::lex()
goto state_45;
if (ch.unicode() == 95)
goto state_46;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_46;
goto out;
state_70:
@@ -944,7 +944,7 @@ int QCssScanner_Generated::lex()
goto state_72;
if (ch.unicode() == 95)
goto state_71;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_71;
goto out;
state_71:
@@ -959,7 +959,7 @@ int QCssScanner_Generated::lex()
goto state_72;
if (ch.unicode() == 95)
goto state_71;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_71;
goto out;
state_72:
@@ -994,7 +994,7 @@ int QCssScanner_Generated::lex()
goto state_76;
if (ch.unicode() == 95)
goto state_75;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_75;
goto out;
state_75:
@@ -1009,7 +1009,7 @@ int QCssScanner_Generated::lex()
goto state_76;
if (ch.unicode() == 95)
goto state_75;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_75;
goto out;
state_76:
@@ -1039,7 +1039,7 @@ int QCssScanner_Generated::lex()
goto state_54;
if (ch.unicode() == 95)
goto state_53;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_53;
goto out;
state_78:
@@ -1060,7 +1060,7 @@ int QCssScanner_Generated::lex()
goto state_32;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_30;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_30;
if (ch.unicode() >= 123)
goto state_30;
@@ -1077,7 +1077,7 @@ int QCssScanner_Generated::lex()
goto state_62;
if (ch.unicode() == 95)
goto state_61;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_61;
goto out;
state_80:
@@ -1098,7 +1098,7 @@ int QCssScanner_Generated::lex()
goto state_37;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
goto state_35;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_35;
if (ch.unicode() >= 123)
goto state_35;
@@ -1115,7 +1115,7 @@ int QCssScanner_Generated::lex()
goto state_72;
if (ch.unicode() == 95)
goto state_71;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_71;
goto out;
state_83:
@@ -1130,12 +1130,12 @@ int QCssScanner_Generated::lex()
goto state_76;
if (ch.unicode() == 95)
goto state_75;
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || ch.unicode() >= 256)
+ if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
goto state_75;
goto out;
found:
lastAcceptingPos = pos;
-
+
out:
if (lastAcceptingPos != -1) {
lexemLength = lastAcceptingPos - lexemStart;
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index d838f4520..f1cd6bbbf 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -72,6 +72,9 @@
#include "qfontengine_qpf_p.h"
#endif
#endif
+#ifdef Q_OS_SYMBIAN
+#include "qt_s60_p.h"
+#endif
#include <QMutexLocker>
@@ -169,6 +172,8 @@ Q_GUI_EXPORT int qt_defaultDpiX()
if (!subScreens.isEmpty())
screen = subScreens.at(0);
dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4)));
+#elif defined(Q_OS_SYMBIAN)
+ dpi = S60->defaultDpiX;
#endif // Q_WS_X11
return dpi;
@@ -195,6 +200,8 @@ Q_GUI_EXPORT int qt_defaultDpiY()
if (!subScreens.isEmpty())
screen = subScreens.at(0);
dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4)));
+#elif defined(Q_OS_SYMBIAN)
+ dpi = S60->defaultDpiY;
#endif // Q_WS_X11
return dpi;
@@ -210,7 +217,6 @@ QFontPrivate::QFontPrivate()
rawMode(false), underline(false), overline(false), strikeOut(false), kerning(true),
capital(0), letterSpacingIsAbsolute(false), scFont(0)
{
- ref = 1;
#ifdef Q_WS_X11
if (QX11Info::display())
screen = QX11Info::appScreen();
@@ -230,7 +236,6 @@ QFontPrivate::QFontPrivate(const QFontPrivate &other)
letterSpacing(other.letterSpacing), wordSpacing(other.wordSpacing),
scFont(other.scFont)
{
- ref = 1;
#ifdef Q_WS_WIN
hdc = other.hdc;
#endif
@@ -307,7 +312,7 @@ QFontPrivate *QFontPrivate::smallCapsFontPrivate() const
font.setPointSizeF(pointSize * .7);
else
font.setPixelSize((font.pixelSize() * 7 + 5) / 10);
- scFont = font.d;
+ scFont = font.d.data();
if (scFont != this)
scFont->ref.ref();
return scFont;
@@ -408,11 +413,11 @@ QFontEngineData::~QFontEngineData()
\brief The QFont class specifies a font used for drawing text.
- \ingroup multimedia
+ \ingroup painting
\ingroup appearance
\ingroup shared
- \ingroup text
- \mainclass
+ \ingroup richtext-processing
+
When you create a QFont object you specify various attributes that
you want the font to have. Qt will use the font with the specified
@@ -718,8 +723,7 @@ QFont::QFont(const QFont &font, QPaintDevice *pd)
d->dpi = dpi;
d->screen = screen;
} else {
- d = font.d;
- d->ref.ref();
+ d = font.d.data();
}
#ifdef Q_WS_WIN
if (pd->devType() == QInternal::Printer && pd->getDC())
@@ -731,10 +735,8 @@ QFont::QFont(const QFont &font, QPaintDevice *pd)
\internal
*/
QFont::QFont(QFontPrivate *data)
- : resolve_mask(QFont::AllPropertiesResolved)
+ : d(data), resolve_mask(QFont::AllPropertiesResolved)
{
- d = data;
- d->ref.ref();
}
/*! \internal
@@ -746,13 +748,13 @@ void QFont::detach()
if (d->engineData)
d->engineData->ref.deref();
d->engineData = 0;
- if (d->scFont && d->scFont != d)
+ if (d->scFont && d->scFont != d.data())
d->scFont->ref.deref();
d->scFont = 0;
return;
}
- qAtomicDetach(d);
+ d.detach();
}
/*!
@@ -761,16 +763,17 @@ void QFont::detach()
\sa QApplication::setFont(), QApplication::font()
*/
QFont::QFont()
- :d(QApplication::font().d), resolve_mask(0)
+ : d(QApplication::font().d.data()), resolve_mask(0)
{
- d->ref.ref();
}
/*!
Constructs a font object with the specified \a family, \a
pointSize, \a weight and \a italic settings.
- If \a pointSize is <= 0, it is set to 12.
+ If \a pointSize is zero or negative, the point size of the font
+ is set to a system-dependent default value. Generally, this is
+ 12 points, except on Symbian where it is 7 points.
The \a family name may optionally also include a foundry name,
e.g. "Helvetica [Cronyx]". If the \a family is
@@ -783,12 +786,14 @@ QFont::QFont()
setStyleHint() QApplication::font()
*/
QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
- :d(new QFontPrivate)
+ : d(new QFontPrivate()), resolve_mask(QFont::FamilyResolved)
{
- resolve_mask = QFont::FamilyResolved;
-
if (pointSize <= 0) {
+#ifdef Q_OS_SYMBIAN
+ pointSize = 7;
+#else
pointSize = 12;
+#endif
} else {
resolve_mask |= QFont::SizeResolved;
}
@@ -810,10 +815,8 @@ QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
Constructs a font that is a copy of \a font.
*/
QFont::QFont(const QFont &font)
+ : d(font.d.data()), resolve_mask(font.resolve_mask)
{
- d = font.d;
- d->ref.ref();
- resolve_mask = font.resolve_mask;
}
/*!
@@ -821,8 +824,6 @@ QFont::QFont(const QFont &font)
*/
QFont::~QFont()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -830,7 +831,7 @@ QFont::~QFont()
*/
QFont &QFont::operator=(const QFont &font)
{
- qAtomicAssign(d, font.d);
+ d = font.d.data();
resolve_mask = font.resolve_mask;
return *this;
}
@@ -1612,7 +1613,8 @@ bool QFont::operator==(const QFont &f) const
&& f.d->underline == d->underline
&& f.d->overline == d->overline
&& f.d->strikeOut == d->strikeOut
- && f.d->kerning == d->kerning));
+ && f.d->kerning == d->kerning
+ && f.d->capital == d->capital));
}
@@ -1644,6 +1646,7 @@ bool QFont::operator<(const QFont &f) const
#ifdef Q_WS_X11
if (r1.addStyle != r2.addStyle) return r1.addStyle < r2.addStyle;
#endif // Q_WS_X11
+ if (f.d->capital != d->capital) return f.d->capital < d->capital;
int f1attrs = (f.d->underline << 3) + (f.d->overline << 2) + (f.d->strikeOut<<1) + f.d->kerning;
int f2attrs = (d->underline << 3) + (d->overline << 2) + (d->strikeOut<<1) + d->kerning;
@@ -1713,7 +1716,7 @@ QFont QFont::resolve(const QFont &other) const
QFont font(*this);
font.detach();
- font.d->resolve(resolve_mask, other.d);
+ font.d->resolve(resolve_mask, other.d.data());
return font;
}
@@ -2166,11 +2169,11 @@ QDataStream &operator<<(QDataStream &s, const QFont &font)
s << (quint8) font.d->request.styleStrategy;
s << (quint8) 0
<< (quint8) font.d->request.weight
- << get_font_bits(s.version(), font.d);
+ << get_font_bits(s.version(), font.d.data());
if (s.version() >= QDataStream::Qt_4_3)
s << (quint16)font.d->request.stretch;
if (s.version() >= QDataStream::Qt_4_4)
- s << get_extended_font_bits(font.d);
+ s << get_extended_font_bits(font.d.data());
if (s.version() >= QDataStream::Qt_4_5) {
s << font.d->letterSpacing.value();
s << font.d->wordSpacing.value();
@@ -2189,9 +2192,6 @@ QDataStream &operator<<(QDataStream &s, const QFont &font)
*/
QDataStream &operator>>(QDataStream &s, QFont &font)
{
- if (!font.d->ref.deref())
- delete font.d;
-
font.d = new QFontPrivate;
font.resolve_mask = QFont::AllPropertiesResolved;
@@ -2233,7 +2233,7 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
font.d->request.styleStrategy = styleStrategy;
font.d->request.weight = weight;
- set_font_bits(s.version(), bits, font.d);
+ set_font_bits(s.version(), bits, font.d.data());
if (s.version() >= QDataStream::Qt_4_3) {
quint16 stretch;
@@ -2244,7 +2244,7 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
if (s.version() >= QDataStream::Qt_4_4) {
quint8 extendedBits;
s >> extendedBits;
- set_extended_font_bits(extendedBits, font.d);
+ set_extended_font_bits(extendedBits, font.d.data());
}
if (s.version() >= QDataStream::Qt_4_5) {
int value;
@@ -2270,9 +2270,8 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
\brief The QFontInfo class provides general information about fonts.
- \ingroup multimedia
+ \ingroup appearance
\ingroup shared
- \ingroup text
The QFontInfo class provides the same access functions as QFont,
e.g. family(), pointSize(), italic(), weight(), fixedPitch(),
@@ -2326,23 +2325,23 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
that is not screen-compatible.
*/
QFontInfo::QFontInfo(const QFont &font)
- : d(font.d)
-{ d->ref.ref(); }
+ : d(font.d.data())
+{
+}
/*!
Constructs a copy of \a fi.
*/
QFontInfo::QFontInfo(const QFontInfo &fi)
- : d(fi.d)
-{ d->ref.ref(); }
+ : d(fi.d.data())
+{
+}
/*!
Destroys the font info object.
*/
QFontInfo::~QFontInfo()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -2350,7 +2349,7 @@ QFontInfo::~QFontInfo()
*/
QFontInfo &QFontInfo::operator=(const QFontInfo &fi)
{
- qAtomicAssign(d, fi.d);
+ d = fi.d.data();
return *this;
}
@@ -2599,7 +2598,14 @@ QFontCache *QFontCache::instance()
void QFontCache::cleanup()
{
- theFontCache()->setLocalData(0);
+ QThreadStorage<QFontCache *> *cache = 0;
+ QT_TRY {
+ cache = theFontCache();
+ } QT_CATCH (const std::bad_alloc &) {
+ // no cache - just ignore
+ }
+ if (cache && cache->hasLocalData())
+ cache->setLocalData(0);
}
#endif // QT_NO_THREAD
@@ -2612,8 +2618,8 @@ QFontCache::QFontCache()
QFontCache::~QFontCache()
{
{
- EngineDataCache::Iterator it = engineDataCache.begin(),
- end = engineDataCache.end();
+ EngineDataCache::ConstIterator it = engineDataCache.constBegin(),
+ end = engineDataCache.constEnd();
while (it != end) {
if (it.value()->ref == 0)
delete it.value();
@@ -2623,12 +2629,12 @@ QFontCache::~QFontCache()
++it;
}
}
- EngineCache::Iterator it = engineCache.begin(),
- end = engineCache.end();
+ EngineCache::ConstIterator it = engineCache.constBegin(),
+ end = engineCache.constEnd();
while (it != end) {
if (--it.value().data->cache_count == 0) {
if (it.value().data->ref == 0) {
- FC_DEBUG("QFontCache::~QFontCache: deleting engine %p key=(%d / %g %d %d %d %d)",
+ FC_DEBUG("QFontCache::~QFontCache: deleting engine %p key=(%d / %g %g %d %d %d)",
it.value().data, it.key().script, it.key().def.pointSize,
it.key().def.pixelSize, it.key().def.weight, it.key().def.style,
it.key().def.fixedPitch);
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index b7c253b33..d73e1c493 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -44,6 +44,7 @@
#include <QtGui/qwindowdefs.h>
#include <QtCore/qstring.h>
+#include <QtCore/qsharedpointer.h>
#if defined(Q_WS_X11) || defined(Q_WS_QWS)
typedef struct FT_FaceRec_* FT_Face;
@@ -306,13 +307,16 @@ private:
friend class QPainterPath;
friend class QTextItemInt;
friend class QPicturePaintEngine;
+ friend class QPainterReplayer;
+ friend class QPaintBufferEngine;
+ friend class QCommandLinkButtonPrivate;
#ifndef QT_NO_DATASTREAM
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QFont &);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QFont &);
#endif
- QFontPrivate *d;
+ QExplicitlySharedDataPointer<QFontPrivate> d;
uint resolve_mask;
};
diff --git a/src/gui/text/qfont_mac.cpp b/src/gui/text/qfont_mac.cpp
index ba0e9d7ea..5a0faf9c6 100644
--- a/src/gui/text/qfont_mac.cpp
+++ b/src/gui/text/qfont_mac.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index 7899d2e5f..144a82d16 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -86,7 +86,7 @@ struct QFontDef
#endif // Q_WS_X11
qreal pointSize;
- int pixelSize;
+ qreal pixelSize;
uint styleStrategy : 16;
uint styleHint : 8;
diff --git a/src/gui/text/qfont_qws.cpp b/src/gui/text/qfont_qws.cpp
index 64e96d4e5..87c5b0520 100644
--- a/src/gui/text/qfont_qws.cpp
+++ b/src/gui/text/qfont_qws.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfont_s60.cpp b/src/gui/text/qfont_s60.cpp
new file mode 100644
index 000000000..0375fdb34
--- /dev/null
+++ b/src/gui/text/qfont_s60.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qfont.h"
+#include "qt_s60_p.h"
+#include "qpixmap_s60_p.h"
+#include "qmutex.h"
+
+QT_BEGIN_NAMESPACE
+
+#if 1
+#ifdef QT_NO_FREETYPE
+Q_GLOBAL_STATIC(QMutex, lastResortFamilyMutex);
+#endif // QT_NO_FREETYPE
+
+QString QFont::lastResortFamily() const
+{
+#ifdef QT_NO_FREETYPE
+ QMutexLocker locker(lastResortFamilyMutex());
+ static QString family;
+ if (family.isEmpty()) {
+
+ QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
+
+ CFont *font;
+ const TInt err = S60->screenDevice()->GetNearestFontInTwips(font, TFontSpec());
+ Q_ASSERT(err == KErrNone);
+ const TFontSpec spec = font->FontSpecInTwips();
+ family = QString((const QChar *)spec.iTypeface.iName.Ptr(), spec.iTypeface.iName.Length());
+ S60->screenDevice()->ReleaseFont(font);
+
+ lock.relock();
+ }
+ return family;
+#else
+ // For the FreeType case we just hard code the face name, since otherwise on
+ // East Asian systems we may get a name for a stroke based (non-ttf) font.
+
+ // TODO: Get the type face name in a proper way
+
+ const bool isJapaneseOrChineseSystem =
+ User::Language() == ELangJapanese || User::Language() == ELangPrcChinese;
+
+ return QLatin1String(isJapaneseOrChineseSystem?"Heisei Kaku Gothic S60":"Series 60 Sans");
+#endif // QT_NO_FREETYPE
+}
+#else // 0
+QString QFont::lastResortFamily() const
+{
+ return QLatin1String("Series 60 Sans");
+}
+#endif // 0
+
+QString QFont::defaultFamily() const
+{
+ return lastResortFamily();
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/text/qfont_win.cpp b/src/gui/text/qfont_win.cpp
index 738043188..4b9e1b8da 100644
--- a/src/gui/text/qfont_win.cpp
+++ b/src/gui/text/qfont_win.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfont_x11.cpp b/src/gui/text/qfont_x11.cpp
index 86b035018..49e5d853a 100644
--- a/src/gui/text/qfont_x11.cpp
+++ b/src/gui/text/qfont_x11.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 03ecc84b7..7e93aa0b7 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -56,6 +56,11 @@
#include <stdlib.h>
#include <limits.h>
+#if (defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
+# include <ft2build.h>
+# include FT_TRUETYPE_TABLES_H
+#endif
+
// #define QFONTDATABASE_DEBUG
#ifdef QFONTDATABASE_DEBUG
# define FD_DEBUG qDebug
@@ -76,9 +81,16 @@
QT_BEGIN_NAMESPACE
+#define SMOOTH_SCALABLE 0xffff
+
extern int qt_defaultDpiY(); // in qfont.cpp
-Q_GUI_EXPORT bool qt_enable_test_font = false;
+bool qt_enable_test_font = false;
+
+Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont(bool value)
+{
+ qt_enable_test_font = value;
+}
static int getFontWeight(const QString &weightString)
{
@@ -141,10 +153,10 @@ struct QtFontSize
QtFontEncoding *encodingID(int id, uint xpoint = 0, uint xres = 0,
uint yres = 0, uint avgwidth = 0, bool add = false);
#endif // Q_WS_X11
-#ifdef Q_WS_QWS
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
QByteArray fileName;
int fileIndex;
-#endif
+#endif // defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
};
@@ -160,10 +172,13 @@ QtFontEncoding *QtFontSize::encodingID(int id, uint xpoint, uint xres,
if (!add) return 0;
- if (!(count % 4))
- encodings = (QtFontEncoding *)
+ if (!(count % 4)) {
+ QtFontEncoding *newEncodings = (QtFontEncoding *)
realloc(encodings,
(((count+4) >> 2) << 2) * sizeof(QtFontEncoding));
+ Q_CHECK_PTR(newEncodings);
+ encodings = newEncodings;
+ }
encodings[count].encoding = id;
encodings[count].xpoint = xpoint;
encodings[count].xres = xres;
@@ -215,12 +230,14 @@ struct QtFontStyle
delete [] weightName;
delete [] setwidthName;
#endif
-#if defined(Q_WS_X11) || defined(Q_WS_QWS)
- while (count--) {
+#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
+ while (count) {
+ // bitfield count-- in while condition does not work correctly in mwccsym2
+ count--;
#ifdef Q_WS_X11
free(pixelSizes[count].encodings);
#endif
-#ifdef Q_WS_QWS
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
pixelSizes[count].fileName.~QByteArray();
#endif
}
@@ -238,7 +255,7 @@ struct QtFontStyle
const char *weightName;
const char *setwidthName;
#endif // Q_WS_X11
-#ifdef Q_WS_QWS
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
bool antialiased;
#endif
@@ -267,16 +284,19 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add)
if (!add)
return 0;
- if (!(count % 8))
- pixelSizes = (QtFontSize *)
+ if (!(count % 8)) {
+ QtFontSize *newPixelSizes = (QtFontSize *)
realloc(pixelSizes,
(((count+8) >> 3) << 3) * sizeof(QtFontSize));
+ Q_CHECK_PTR(newPixelSizes);
+ pixelSizes = newPixelSizes;
+ }
pixelSizes[count].pixelSize = size;
#ifdef Q_WS_X11
pixelSizes[count].count = 0;
pixelSizes[count].encodings = 0;
#endif
-#ifdef Q_WS_QWS
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
new (&pixelSizes[count].fileName) QByteArray;
pixelSizes[count].fileIndex = 0;
#endif
@@ -314,19 +334,23 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, bool create)
else
high = pos;
pos = (high + low) / 2;
- };
+ }
pos = low;
}
if (!create)
return 0;
// qDebug("adding key (weight=%d, style=%d, oblique=%d stretch=%d) at %d", key.weight, key.style, key.oblique, key.stretch, pos);
- if (!(count % 8))
- styles = (QtFontStyle **)
+ if (!(count % 8)) {
+ QtFontStyle **newStyles = (QtFontStyle **)
realloc(styles, (((count+8) >> 3) << 3) * sizeof(QtFontStyle *));
+ Q_CHECK_PTR(newStyles);
+ styles = newStyles;
+ }
+ QtFontStyle *style = new QtFontStyle(key);
memmove(styles + pos + 1, styles + pos, (count-pos)*sizeof(QtFontStyle *));
- styles[pos] = new QtFontStyle(key);
+ styles[pos] = style;
count++;
return styles[pos];
}
@@ -358,7 +382,7 @@ struct QtFontFamily
fixedPitchComputed(false),
#endif
name(n), count(0), foundries(0)
-#if defined(Q_WS_QWS)
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
, bogusWritingSystems(false)
#endif
{
@@ -388,7 +412,7 @@ struct QtFontFamily
#endif
QString name;
-#ifdef Q_WS_X11
+#if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
QByteArray fontFilename;
int fontFileIndex;
#endif
@@ -398,7 +422,7 @@ struct QtFontFamily
int count;
QtFontFoundry **foundries;
-#ifdef Q_WS_QWS
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
bool bogusWritingSystems;
QStringList fallbackFamilies;
#endif
@@ -431,10 +455,13 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create)
if (!create)
return 0;
- if (!(count % 8))
- foundries = (QtFontFoundry **)
+ if (!(count % 8)) {
+ QtFontFoundry **newFoundries = (QtFontFoundry **)
realloc(foundries,
(((count+8) >> 3) << 3) * sizeof(QtFontFoundry *));
+ Q_CHECK_PTR(newFoundries);
+ foundries = newFoundries;
+ }
foundries[count] = new QtFontFoundry(f);
return foundries[count++];
@@ -442,7 +469,7 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create)
// ### copied to tools/makeqpf/qpf2.cpp
-#if (defined(Q_WS_QWS) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA))
+#if (defined(Q_WS_QWS) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA))
// see the Unicode subset bitfields in the MSDN docs
static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {
// Any,
@@ -506,7 +533,13 @@ static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {
// Vietnamese,
{ 0, 127 }, // same as latin1
// Other,
- { 126, 127 }
+ { 126, 127 },
+ // Ogham,
+ { 78, 127 },
+ // Runic,
+ { 79, 127 },
+ // Nko,
+ { 14, 127 },
};
#define SimplifiedChineseCsbBit 18
@@ -563,6 +596,15 @@ static QList<QFontDatabase::WritingSystem> determineWritingSystemsFromTrueTypeBi
}
#endif
+#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
+// class with virtual destructor, derived in qfontdatabase_s60.cpp
+class QFontDatabaseS60Store
+{
+public:
+ virtual ~QFontDatabaseS60Store() {}
+};
+#endif
+
class QFontDatabasePrivate
{
public:
@@ -571,6 +613,9 @@ public:
#if defined(Q_WS_QWS)
, stream(0)
#endif
+#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
+ , s60Store(0)
+#endif
{ }
~QFontDatabasePrivate() {
free();
@@ -582,6 +627,12 @@ public:
::free(families);
families = 0;
count = 0;
+#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
+ if (s60Store) {
+ delete s60Store;
+ s60Store = 0;
+ }
+#endif
// don't clear the memory fonts!
}
@@ -609,17 +660,22 @@ public:
#if defined(Q_WS_QWS)
bool loadFromCache(const QString &fontPath);
+ void addQPF2File(const QByteArray &file);
+#endif // Q_WS_QWS
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
void addFont(const QString &familyname, const char *foundryname, int weight,
bool italic, int pixelSize, const QByteArray &file, int fileIndex,
bool antialiased,
const QList<QFontDatabase::WritingSystem> &writingSystems = QList<QFontDatabase::WritingSystem>());
- void addQPF2File(const QByteArray &file);
#ifndef QT_NO_FREETYPE
QStringList addTTFile(const QByteArray &file, const QByteArray &fontData = QByteArray());
+#endif // QT_NO_FREETYPE
#endif
-
+#if defined(Q_WS_QWS)
QDataStream *stream;
QStringList fallbackFamilies;
+#elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
+ const QFontDatabaseS60Store *s60Store;
#endif
};
@@ -643,7 +699,7 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create)
else
low = pos;
pos = (high + low) / 2;
- };
+ }
if (!res)
return families[pos];
}
@@ -654,17 +710,133 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create)
pos++;
// qDebug("adding family %s at %d total=%d", f.latin1(), pos, count);
- if (!(count % 8))
- families = (QtFontFamily **)
+ if (!(count % 8)) {
+ QtFontFamily **newFamilies = (QtFontFamily **)
realloc(families,
(((count+8) >> 3) << 3) * sizeof(QtFontFamily *));
+ Q_CHECK_PTR(newFamilies);
+ families = newFamilies;
+ }
+ QtFontFamily *family = new QtFontFamily(f);
memmove(families + pos + 1, families + pos, (count-pos)*sizeof(QtFontFamily *));
- families[pos] = new QtFontFamily(f);
+ families[pos] = family;
count++;
return families[pos];
}
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
+void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize,
+ const QByteArray &file, int fileIndex, bool antialiased,
+ const QList<QFontDatabase::WritingSystem> &writingSystems)
+{
+// qDebug() << "Adding font" << familyname << weight << italic << pixelSize << file << fileIndex << antialiased;
+ QtFontStyle::Key styleKey;
+ styleKey.style = italic ? QFont::StyleItalic : QFont::StyleNormal;
+ styleKey.weight = weight;
+ styleKey.stretch = 100;
+ QtFontFamily *f = family(familyname, true);
+
+ if (writingSystems.isEmpty()) {
+ for (int ws = 1; ws < QFontDatabase::WritingSystemsCount; ++ws) {
+ f->writingSystems[ws] = QtFontFamily::Supported;
+ }
+ f->bogusWritingSystems = true;
+ } else {
+ for (int i = 0; i < writingSystems.count(); ++i) {
+ f->writingSystems[writingSystems.at(i)] = QtFontFamily::Supported;
+ }
+ }
+
+ QtFontFoundry *foundry = f->foundry(QString::fromLatin1(foundryname), true);
+ QtFontStyle *style = foundry->style(styleKey, true);
+ style->smoothScalable = (pixelSize == 0);
+ style->antialiased = antialiased;
+ QtFontSize *size = style->pixelSize(pixelSize?pixelSize:SMOOTH_SCALABLE, true);
+ size->fileName = file;
+ size->fileIndex = fileIndex;
+
+#if defined(Q_WS_QWS)
+ if (stream) {
+ *stream << familyname << foundry->name << weight << quint8(italic) << pixelSize
+ << file << fileIndex << quint8(antialiased);
+ *stream << quint8(writingSystems.count());
+ for (int i = 0; i < writingSystems.count(); ++i)
+ *stream << quint8(writingSystems.at(i));
+ }
+#else // ..in case of defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
+ f->fontFilename = file;
+ f->fontFileIndex = fileIndex;
+#endif
+}
+#endif
+
+#if (defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
+QStringList QFontDatabasePrivate::addTTFile(const QByteArray &file, const QByteArray &fontData)
+{
+ QStringList families;
+ extern FT_Library qt_getFreetype();
+ FT_Library library = qt_getFreetype();
+
+ int index = 0;
+ int numFaces = 0;
+ do {
+ FT_Face face;
+ FT_Error error;
+ if (!fontData.isEmpty()) {
+ error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
+ } else {
+ error = FT_New_Face(library, file, index, &face);
+ }
+ if (error != FT_Err_Ok) {
+ qDebug() << "FT_New_Face failed with index" << index << ":" << hex << error;
+ break;
+ }
+ numFaces = face->num_faces;
+
+ int weight = QFont::Normal;
+ bool italic = face->style_flags & FT_STYLE_FLAG_ITALIC;
+
+ if (face->style_flags & FT_STYLE_FLAG_BOLD)
+ weight = QFont::Bold;
+
+ QList<QFontDatabase::WritingSystem> writingSystems;
+ // detect symbol fonts
+ for (int i = 0; i < face->num_charmaps; ++i) {
+ FT_CharMap cm = face->charmaps[i];
+ if (cm->encoding == ft_encoding_adobe_custom
+ || cm->encoding == ft_encoding_symbol) {
+ writingSystems.append(QFontDatabase::Symbol);
+ break;
+ }
+ }
+ if (writingSystems.isEmpty()) {
+ TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
+ if (os2) {
+ quint32 unicodeRange[4] = {
+ os2->ulUnicodeRange1, os2->ulUnicodeRange2, os2->ulUnicodeRange3, os2->ulUnicodeRange4
+ };
+ quint32 codePageRange[2] = {
+ os2->ulCodePageRange1, os2->ulCodePageRange2
+ };
+
+ writingSystems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
+ //for (int i = 0; i < writingSystems.count(); ++i)
+ // qDebug() << QFontDatabase::writingSystemName(writingSystems.at(i));
+ }
+ }
+
+ QString family = QString::fromAscii(face->family_name);
+ families.append(family);
+ addFont(family, /*foundry*/ "", weight, italic,
+ /*pixelsize*/ 0, file, index, /*antialias*/ true, writingSystems);
+
+ FT_Done_Face(face);
+ ++index;
+ } while (index < numFaces);
+ return families;
+}
+#endif
static const int scriptForWritingSystem[] = {
QUnicodeTables::Common, // Any
@@ -707,7 +879,8 @@ static const int scriptForWritingSystem[] = {
QUnicodeTables::Common, // Braille
QUnicodeTables::Common, // Symbol
QUnicodeTables::Ogham, // Ogham
- QUnicodeTables::Runic // Runic
+ QUnicodeTables::Runic, // Runic
+ QUnicodeTables::Nko // Nko
};
@@ -715,12 +888,12 @@ static const int scriptForWritingSystem[] = {
static inline bool requiresOpenType(int writingSystem)
{
return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala)
- || writingSystem == QFontDatabase::Khmer);
+ || writingSystem == QFontDatabase::Khmer || writingSystem == QFontDatabase::Nko);
}
static inline bool scriptRequiresOpenType(int script)
{
return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala)
- || script == QUnicodeTables::Khmer);
+ || script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko);
}
#endif
@@ -783,7 +956,7 @@ struct QtFontDesc
#if !defined(Q_WS_MAC)
static void match(int script, const QFontDef &request,
const QString &family_name, const QString &foundry_name, int force_encoding_id,
- QtFontDesc *desc, const QList<int> &blacklistedFamilies = QList<int>());
+ QtFontDesc *desc, const QList<int> &blacklistedFamilies = QList<int>(), bool forceXLFD=false);
#if defined(Q_WS_X11) || defined(Q_WS_QWS)
static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef)
@@ -814,7 +987,7 @@ static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDe
#endif
#endif
-#if defined(Q_WS_X11) || defined(Q_WS_WIN)
+#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
static void getEngineData(const QFontPrivate *d, const QFontCache::Key &key)
{
// look for the requested font in the engine data cache
@@ -866,8 +1039,6 @@ QMutex *qt_fontdatabase_mutex()
return fontDatabaseMutex();
}
-#define SMOOTH_SCALABLE 0xffff
-
QT_BEGIN_INCLUDE_NAMESPACE
#if defined(Q_WS_X11)
# include "qfontdatabase_x11.cpp"
@@ -877,6 +1048,8 @@ QT_BEGIN_INCLUDE_NAMESPACE
# include "qfontdatabase_win.cpp"
#elif defined(Q_WS_QWS)
# include "qfontdatabase_qws.cpp"
+#elif defined(Q_OS_SYMBIAN)
+# include "qfontdatabase_s60.cpp"
#endif
QT_END_INCLUDE_NAMESPACE
@@ -1150,7 +1323,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
*/
static void match(int script, const QFontDef &request,
const QString &family_name, const QString &foundry_name, int force_encoding_id,
- QtFontDesc *desc, const QList<int> &blacklistedFamilies)
+ QtFontDesc *desc, const QList<int> &blacklistedFamilies, bool forceXLFD)
{
Q_UNUSED(force_encoding_id);
@@ -1165,7 +1338,7 @@ static void match(int script, const QFontDef &request,
" family: %s [%s], script: %d\n"
" weight: %d, style: %d\n"
" stretch: %d\n"
- " pixelSize: %d\n"
+ " pixelSize: %g\n"
" pitch: %c",
family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(),
foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(),
@@ -1185,7 +1358,12 @@ static void match(int script, const QFontDef &request,
unsigned int score = ~0u;
+#ifdef Q_WS_X11
+ load(family_name, script, forceXLFD);
+#else
+ Q_UNUSED(forceXLFD);
load(family_name, script);
+#endif
QFontDatabasePrivate *db = privateDb();
for (int x = 0; x < db->count; ++x) {
@@ -1295,9 +1473,7 @@ QString QFontDatabase::styleString(const QFontInfo &fontInfo)
\brief The QFontDatabase class provides information about the fonts available in the underlying window system.
- \ingroup environment
- \ingroup multimedia
- \ingroup text
+ \ingroup appearance
The most common uses of this class are to query the database for
the list of font families() and for the pointSizes() and styles()
@@ -1389,6 +1565,7 @@ QFontDatabase::QFontDatabase()
\value Other (the same as Symbol)
\value Ogham
\value Runic
+ \value Nko
\omitvalue WritingSystemsCount
*/
@@ -2063,6 +2240,9 @@ QString QFontDatabase::writingSystemName(WritingSystem writingSystem)
case Runic:
name = QT_TRANSLATE_NOOP("QFontDatabase", "Runic");
break;
+ case Nko:
+ name = QT_TRANSLATE_NOOP("QFontDatabase", "N'Ko");
+ break;
default:
Q_ASSERT_X(false, "QFontDatabase::writingSystemName", "invalid 'writingSystem' parameter");
break;
@@ -2254,7 +2434,16 @@ QString QFontDatabase::writingSystemSample(WritingSystem writingSystem)
sample += QChar(0xac2f);
break;
case Vietnamese:
+ {
+ static const char vietnameseUtf8[] = {
+ char(0xef), char(0xbb), char(0xbf), char(0xe1), char(0xbb), char(0x97),
+ char(0xe1), char(0xbb), char(0x99),
+ char(0xe1), char(0xbb), char(0x91),
+ char(0xe1), char(0xbb), char(0x93),
+ };
+ sample += QString::fromUtf8(vietnameseUtf8, sizeof(vietnameseUtf8));
break;
+ }
case Ogham:
sample += QChar(0x1681);
sample += QChar(0x1682);
@@ -2267,6 +2456,12 @@ QString QFontDatabase::writingSystemSample(WritingSystem writingSystem)
sample += QChar(0x16a2);
sample += QChar(0x16a3);
break;
+ case Nko:
+ sample += QChar(0x7ca);
+ sample += QChar(0x7cb);
+ sample += QChar(0x7cc);
+ sample += QChar(0x7cd);
+ break;
default:
break;
}
@@ -2418,7 +2613,7 @@ QStringList QFontDatabase::applicationFontFamilies(int id)
\sa removeApplicationFont(), addApplicationFont(), addApplicationFontFromData()
*/
-/*!
+/*!
\fn bool QFontDatabase::supportsThreadedFontRendering()
\since 4.4
@@ -2427,7 +2622,7 @@ QStringList QFontDatabase::applicationFontFamilies(int id)
means that all QPainter::drawText() calls outside the GUI thread
will not produce readable output.
- \sa threads.html#painting-in-threads
+ \sa {Thread-Support in Qt Modules#Painting In Threads}{Painting In Threads}
*/
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index 1adde03ad..37b5860e1 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -108,6 +108,7 @@ public:
Ogham,
Runic,
+ Nko,
WritingSystemsCount
};
@@ -151,7 +152,7 @@ public:
private:
static void createDatabase();
static void parseFontName(const QString &name, QString &foundry, QString &family);
-#if defined(Q_WS_QWS)
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
static QFontEngine *findFont(int script, const QFontPrivate *fp, const QFontDef &request);
#endif
static void load(const QFontPrivate *d, int script);
@@ -165,6 +166,7 @@ private:
friend class QFontDialogPrivate;
friend class QFontEngineMultiXLFD;
friend class QFontEngineMultiQWS;
+ friend class QFontEngineMultiS60;
QFontDatabasePrivate *d;
};
diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp
index c3407105d..25840036b 100644
--- a/src/gui/text/qfontdatabase_mac.cpp
+++ b/src/gui/text/qfontdatabase_mac.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -308,6 +308,21 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
if (familyRef) {
fontRef = ATSFontFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
goto FamilyFound;
+ } else {
+#if defined(QT_MAC_USE_COCOA)
+ // ATS and CT disagrees on what the family name should be,
+ // use CT to look up the font if ATS fails.
+ QCFString familyName = QString::fromAscii(family_name);
+ QCFType<CTFontRef> CTfontRef = CTFontCreateWithName(familyName, 12, NULL);
+ QCFType<CTFontDescriptorRef> fontDescriptor = CTFontCopyFontDescriptor(CTfontRef);
+ QCFString displayName = (CFStringRef)CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontDisplayNameAttribute);
+
+ familyRef = ATSFontFamilyFindFromName(displayName, kATSOptionFlagsDefault);
+ if (familyRef) {
+ fontRef = ATSFontFindFromName(displayName, kATSOptionFlagsDefault);
+ goto FamilyFound;
+ }
+#endif
}
}
}
@@ -456,11 +471,27 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
return;
fnt->families.clear();
+#if defined(QT_MAC_USE_COCOA)
+ // Make sure that the family name set on the font matches what
+ // kCTFontFamilyNameAttribute returns in initializeDb().
+ // So far the best solution seems find the installed font
+ // using CoreText and get the family name from it.
+ // (ATSFontFamilyGetName appears to be the correct API, but also
+ // returns the font display name.)
+ for(int i = 0; i < containedFonts.size(); ++i) {
+ QCFString fontPostScriptName;
+ ATSFontGetPostScriptName(containedFonts[i], kATSOptionFlagsDefault, &fontPostScriptName);
+ QCFType<CTFontDescriptorRef> font = CTFontDescriptorCreateWithNameAndSize(fontPostScriptName, 14);
+ QCFString familyName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
+ fnt->families.append(familyName);
+ }
+#else
for(int i = 0; i < containedFonts.size(); ++i) {
QCFString family;
ATSFontGetName(containedFonts[i], kATSOptionFlagsDefault, &family);
fnt->families.append(family);
}
+#endif
fnt->handle = handle;
}
diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp
index 9d2e83b2e..d29fd274e 100644
--- a/src/gui/text/qfontdatabase_qws.cpp
+++ b/src/gui/text/qfontdatabase_qws.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@
#include <ft2build.h>
#include FT_FREETYPE_H
-#include FT_TRUETYPE_TABLES_H
#endif
#include "qfontengine_qpf_p.h"
@@ -83,44 +82,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
const quint8 DatabaseVersion = 4;
-void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize,
- const QByteArray &file, int fileIndex, bool antialiased,
- const QList<QFontDatabase::WritingSystem> &writingSystems)
-{
-// qDebug() << "Adding font" << familyname << weight << italic << pixelSize << file << fileIndex << antialiased;
- QtFontStyle::Key styleKey;
- styleKey.style = italic ? QFont::StyleItalic : QFont::StyleNormal;
- styleKey.weight = weight;
- styleKey.stretch = 100;
- QtFontFamily *f = family(familyname, true);
-
- if (writingSystems.isEmpty()) {
- for (int ws = 1; ws < QFontDatabase::WritingSystemsCount; ++ws) {
- f->writingSystems[ws] = QtFontFamily::Supported;
- }
- f->bogusWritingSystems = true;
- } else {
- for (int i = 0; i < writingSystems.count(); ++i) {
- f->writingSystems[writingSystems.at(i)] = QtFontFamily::Supported;
- }
- }
-
- QtFontFoundry *foundry = f->foundry(QString::fromLatin1(foundryname), true);
- QtFontStyle *style = foundry->style(styleKey, true);
- style->smoothScalable = (pixelSize == 0);
- style->antialiased = antialiased;
- QtFontSize *size = style->pixelSize(pixelSize?pixelSize:SMOOTH_SCALABLE, true);
- size->fileName = file;
- size->fileIndex = fileIndex;
-
- if (stream) {
- *stream << familyname << foundry->name << weight << quint8(italic) << pixelSize
- << file << fileIndex << quint8(antialiased);
- *stream << quint8(writingSystems.count());
- for (int i = 0; i < writingSystems.count(); ++i)
- *stream << quint8(writingSystems.at(i));
- }
-}
+// QFontDatabasePrivate::addFont() went into qfontdatabase.cpp
#ifndef QT_NO_QWS_QPF2
void QFontDatabasePrivate::addQPF2File(const QByteArray &file)
@@ -180,74 +142,9 @@ void QFontDatabasePrivate::addQPF2File(const QByteArray &file)
QT_CLOSE(f);
#endif
}
-#endif
+#endif // QT_NO_QWS_QPF2
-#ifndef QT_NO_FREETYPE
-QStringList QFontDatabasePrivate::addTTFile(const QByteArray &file, const QByteArray &fontData)
-{
- QStringList families;
- extern FT_Library qt_getFreetype();
- FT_Library library = qt_getFreetype();
-
- int index = 0;
- int numFaces = 0;
- do {
- FT_Face face;
- FT_Error error;
- if (!fontData.isEmpty()) {
- error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
- } else {
- error = FT_New_Face(library, file, index, &face);
- }
- if (error != FT_Err_Ok) {
- qDebug() << "FT_New_Face failed with index" << index << ":" << hex << error;
- break;
- }
- numFaces = face->num_faces;
-
- int weight = QFont::Normal;
- bool italic = face->style_flags & FT_STYLE_FLAG_ITALIC;
-
- if (face->style_flags & FT_STYLE_FLAG_BOLD)
- weight = QFont::Bold;
-
- QList<QFontDatabase::WritingSystem> writingSystems;
- // detect symbol fonts
- for (int i = 0; i < face->num_charmaps; ++i) {
- FT_CharMap cm = face->charmaps[i];
- if (cm->encoding == ft_encoding_adobe_custom
- || cm->encoding == ft_encoding_symbol) {
- writingSystems.append(QFontDatabase::Symbol);
- break;
- }
- }
- if (writingSystems.isEmpty()) {
- TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
- if (os2) {
- quint32 unicodeRange[4] = {
- os2->ulUnicodeRange1, os2->ulUnicodeRange2, os2->ulUnicodeRange3, os2->ulUnicodeRange4
- };
- quint32 codePageRange[2] = {
- os2->ulCodePageRange1, os2->ulCodePageRange2
- };
-
- writingSystems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
- //for (int i = 0; i < writingSystems.count(); ++i)
- // qDebug() << QFontDatabase::writingSystemName(writingSystems.at(i));
- }
- }
-
- QString family = QString::fromAscii(face->family_name);
- families.append(family);
- addFont(family, /*foundry*/ "", weight, italic,
- /*pixelsize*/ 0, file, index, /*antialias*/ true, writingSystems);
-
- FT_Done_Face(face);
- ++index;
- } while (index < numFaces);
- return families;
-}
-#endif
+// QFontDatabasePrivate::addTTFile() went into qfontdatabase.cpp
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt);
@@ -671,8 +568,8 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
QFontEngineQPF *fe = new QFontEngineQPF(request, res.data(), res.size());
if (fe->isValid())
return fe;
- qDebug() << "fontengine is not valid! " << size->fileName;
delete fe;
+ qDebug() << "fontengine is not valid! " << size->fileName;
} else {
qDebug() << "Resource not valid" << size->fileName;
}
@@ -682,8 +579,8 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
QFontEngineQPF *fe = new QFontEngineQPF(request, f);
if (fe->isValid())
return fe;
- qDebug() << "fontengine is not valid!";
delete fe; // will close f
+ qDebug() << "fontengine is not valid!";
}
#endif
} else
@@ -701,70 +598,67 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
bool shareFonts = !dontShareFonts;
#endif
- QFontEngine *engine = 0;
+ QScopedPointer<QFontEngine> engine;
#ifndef QT_NO_LIBRARY
QFontEngineFactoryInterface *factory = qobject_cast<QFontEngineFactoryInterface *>(loader()->instance(foundry->name));
- if (factory) {
- QFontEngineInfo info;
- info.setFamily(request.family);
- info.setPixelSize(request.pixelSize);
- info.setStyle(QFont::Style(request.style));
- info.setWeight(request.weight);
- // #### antialiased
-
- QAbstractFontEngine *customEngine = factory->create(info);
- if (customEngine) {
- engine = new QProxyFontEngine(customEngine, def);
-
- if (shareFonts) {
- QVariant hint = customEngine->fontProperty(QAbstractFontEngine::CacheGlyphsHint);
- if (hint.isValid())
- shareFonts = hint.toBool();
- else
- shareFonts = (pixelSize < 64);
- }
+ if (factory) {
+ QFontEngineInfo info;
+ info.setFamily(request.family);
+ info.setPixelSize(request.pixelSize);
+ info.setStyle(QFont::Style(request.style));
+ info.setWeight(request.weight);
+ // #### antialiased
+
+ QAbstractFontEngine *customEngine = factory->create(info);
+ if (customEngine) {
+ engine.reset(new QProxyFontEngine(customEngine, def));
+
+ if (shareFonts) {
+ QVariant hint = customEngine->fontProperty(QAbstractFontEngine::CacheGlyphsHint);
+ if (hint.isValid())
+ shareFonts = hint.toBool();
+ else
+ shareFonts = (pixelSize < 64);
}
+ }
}
#endif // QT_NO_LIBRARY
- if (!engine && !file.isEmpty() && QFile::exists(file) || privateDb()->isApplicationFont(file)) {
+ if ((engine.isNull() && !file.isEmpty() && QFile::exists(file)) || privateDb()->isApplicationFont(file)) {
QFontEngine::FaceId faceId;
faceId.filename = file.toLocal8Bit();
faceId.index = size->fileIndex;
#ifndef QT_NO_FREETYPE
- QFontEngineFT *fte = new QFontEngineFT(def);
+ QScopedPointer<QFontEngineFT> fte(new QFontEngineFT(def));
if (fte->init(faceId, style->antialiased,
style->antialiased ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono)) {
#ifdef QT_NO_QWS_QPF2
- return fte;
+ return fte.take();
#else
- engine = fte;
// try to distinguish between bdf and ttf fonts we can pre-render
// and don't try to share outline fonts
shareFonts = shareFonts
&& !fte->defaultGlyphs()->outline_drawing
&& !fte->getSfntTable(MAKE_TAG('h', 'e', 'a', 'd')).isEmpty();
+ engine.reset(fte.take());
#endif
- } else {
- delete fte;
}
#endif // QT_NO_FREETYPE
}
- if (engine) {
+ if (!engine.isNull()) {
#if !defined(QT_NO_QWS_QPF2) && !defined(QT_FONTS_ARE_RESOURCES)
if (shareFonts) {
- QFontEngineQPF *fe = new QFontEngineQPF(def, -1, engine);
- engine = 0;
+ QScopedPointer<QFontEngineQPF> fe(new QFontEngineQPF(def, -1, engine.data()));
+ engine.take();
if (fe->isValid())
- return fe;
+ return fe.take();
qWarning("Initializing QFontEngineQPF failed for %s", qPrintable(file));
- engine = fe->takeRenderingEngine();
- delete fe;
+ engine.reset(fe->takeRenderingEngine());
}
#endif
- return engine;
+ return engine.take();
}
} else
{
@@ -791,20 +685,22 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp,
QtFontFamily *family, QtFontFoundry *foundry,
QtFontStyle *style, QtFontSize *size)
{
- QFontEngine *fe = loadSingleEngine(script, fp, request, family, foundry,
- style, size);
- if (fe
+ QScopedPointer<QFontEngine> engine(loadSingleEngine(script, fp, request, family, foundry,
+ style, size));
+ if (!engine.isNull()
&& script == QUnicodeTables::Common
- && !(request.styleStrategy & QFont::NoFontMerging) && !fe->symbol) {
+ && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
QStringList fallbacks = privateDb()->fallbackFamilies;
if (family && !family->fallbackFamilies.isEmpty())
fallbacks = family->fallbackFamilies;
- fe = new QFontEngineMultiQWS(fe, script, fallbacks);
+ QFontEngine *fe = new QFontEngineMultiQWS(engine.data(), script, fallbacks);
+ engine.take();
+ engine.reset(fe);
}
- return fe;
+ return engine.take();
}
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
@@ -866,21 +762,21 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
if (!privateDb()->count)
initializeDb();
- QFontEngine *fe = 0;
+ QScopedPointer<QFontEngine> fe;
if (fp) {
if (fp->rawMode) {
- fe = loadEngine(script, fp, request, 0, 0, 0, 0
- );
+ fe.reset(loadEngine(script, fp, request, 0, 0, 0, 0));
// if we fail to load the rawmode font, use a 12pixel box engine instead
- if (! fe) fe = new QFontEngineBox(12);
- return fe;
+ if (fe.isNull())
+ fe.reset(new QFontEngineBox(12));
+ return fe.take();
}
QFontCache::Key key(request, script);
- fe = QFontCache::instance()->findEngine(key);
- if (fe)
- return fe;
+ fe.reset(QFontCache::instance()->findEngine(key));
+ if (! fe.isNull())
+ return fe.take();
}
QString family_name, foundry_name;
@@ -904,11 +800,11 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) {
- fe = new QTestFontEngine(request.pixelSize);
+ fe.reset(new QTestFontEngine(request.pixelSize));
fe->fontDef = request;
}
- if (!fe)
+ if (fe.isNull())
{
QtFontDesc desc;
match(script, request, family_name, foundry_name, force_encoding_id, &desc);
@@ -929,16 +825,28 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
'p', 0
);
- fe = loadEngine(script, fp, request, desc.family, desc.foundry, desc.style, desc.size
- );
+ fe.reset(loadEngine(script, fp, request, desc.family, desc.foundry, desc.style, desc.size
+ ));
} else {
FM_DEBUG(" NO MATCH FOUND\n");
}
- if (fe)
+ if (! fe.isNull())
initFontDef(desc, request, &fe->fontDef);
}
- if (fe) {
+#ifndef QT_NO_FREETYPE
+ if (! fe.isNull()) {
+ if (scriptRequiresOpenType(script) && fe->type() == QFontEngine::Freetype) {
+ HB_Face hbFace = static_cast<QFontEngineFT *>(fe.data())->harfbuzzFace();
+ if (!hbFace || !hbFace->supported_scripts[script]) {
+ FM_DEBUG(" OpenType support missing for script\n");
+ fe.reset(0);
+ }
+ }
+ }
+#endif
+
+ if (! fe.isNull()) {
if (fp) {
QFontDef def = request;
if (def.family.isEmpty()) {
@@ -946,32 +854,21 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
def.family = def.family.left(def.family.indexOf(QLatin1Char(',')));
}
QFontCache::Key key(def, script);
- QFontCache::instance()->insertEngine(key, fe);
+ QFontCache::instance()->insertEngine(key, fe.data());
}
-
-#ifndef QT_NO_FREETYPE
- if (scriptRequiresOpenType(script) && fe->type() == QFontEngine::Freetype) {
- HB_Face hbFace = static_cast<QFontEngineFT *>(fe)->harfbuzzFace();
- if (!hbFace || !hbFace->supported_scripts[script]) {
- FM_DEBUG(" OpenType support missing for script\n");
- delete fe;
- fe = 0;
- }
- }
-#endif
}
- if (!fe) {
+ if (fe.isNull()) {
if (!request.family.isEmpty())
return 0;
FM_DEBUG("returning box engine");
- fe = new QFontEngineBox(request.pixelSize);
+ fe.reset(new QFontEngineBox(request.pixelSize));
if (fp) {
QFontCache::Key key(request, script);
- QFontCache::instance()->insertEngine(key, fe);
+ QFontCache::instance()->insertEngine(key, fe.data());
}
}
@@ -981,7 +878,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
fe->fontDef.pointSize = request.pointSize;
}
- return fe;
+ return fe.take();
}
void QFontDatabase::load(const QFontPrivate *d, int script)
@@ -1002,7 +899,13 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
if (!d->engineData) {
// create a new one
d->engineData = new QFontEngineData;
- QFontCache::instance()->insertEngineData(key, d->engineData);
+ QT_TRY {
+ QFontCache::instance()->insertEngineData(key, d->engineData);
+ } QT_CATCH(...) {
+ delete d->engineData;
+ d->engineData = 0;
+ QT_RETHROW;
+ }
} else {
d->engineData->ref.ref();
}
@@ -1011,8 +914,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
// the cached engineData could have already loaded the engine we want
if (d->engineData->engines[script]) return;
- // load the font
- QFontEngine *engine = 0;
// double scale = 1.0; // ### TODO: fix the scale calculations
// list of families to try
@@ -1044,20 +945,15 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
// null family means find the first font matching the specified script
family_list << QString();
+ // load the font
+ QFontEngine *engine = 0;
QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();
- for (; ! engine && it != end; ++it) {
+ for (; !engine && it != end; ++it) {
req.family = *it;
engine = QFontDatabase::findFont(script, d, req);
- if (engine) {
- if (engine->type() != QFontEngine::Box)
- break;
-
- if (! req.family.isEmpty())
- engine = 0;
-
- continue;
- }
+ if (engine && (engine->type()==QFontEngine::Box) && !req.family.isEmpty())
+ engine = 0;
}
engine->ref.ref();
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp
new file mode 100644
index 000000000..bf8af92be
--- /dev/null
+++ b/src/gui/text/qfontdatabase_s60.cpp
@@ -0,0 +1,463 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qapplication_p.h>
+#include "qdir.h"
+#include "qfont_p.h"
+#include "qfontengine_s60_p.h"
+#include "qabstractfileengine.h"
+#include "qdesktopservices.h"
+#include "qpixmap_s60_p.h"
+#include "qt_s60_p.h"
+#include "qendian.h"
+#include <private/qcore_symbian_p.h>
+#if defined(QT_NO_FREETYPE)
+#include <OPENFONT.H>
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <graphics/openfontrasterizer.h> // COpenFontRasterizer has moved to a new header file
+#endif // SYMBIAN_ENABLE_SPLIT_HEADERS
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QFileInfoList alternativeFilePaths(const QString &path, const QStringList &nameFilters,
+ QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort,
+ bool uniqueFileNames = true)
+{
+ QFileInfoList result;
+
+ // Prepare a 'soft to hard' drive list: W:, X: ... A:, Z:
+ QStringList driveStrings;
+ foreach (const QFileInfo &drive, QDir::drives())
+ driveStrings.append(drive.absolutePath());
+ driveStrings.sort();
+ const QString zDriveString(QLatin1String("Z:/"));
+ driveStrings.removeAll(zDriveString);
+ driveStrings.prepend(zDriveString);
+
+ QStringList uniqueFileNameList;
+ for (int i = driveStrings.count() - 1; i >= 0; --i) {
+ const QDir dirOnDrive(driveStrings.at(i) + path);
+ const QFileInfoList entriesOnDrive = dirOnDrive.entryInfoList(nameFilters, filters, sort);
+ if (uniqueFileNames) {
+ foreach(const QFileInfo &entry, entriesOnDrive) {
+ if (!uniqueFileNameList.contains(entry.fileName())) {
+ uniqueFileNameList.append(entry.fileName());
+ result.append(entry);
+ }
+ }
+ } else {
+ result.append(entriesOnDrive);
+ }
+ }
+ return result;
+}
+
+#if defined(QT_NO_FREETYPE)
+class QFontDatabaseS60StoreImplementation : public QFontDatabaseS60Store
+{
+public:
+ QFontDatabaseS60StoreImplementation();
+ ~QFontDatabaseS60StoreImplementation();
+
+ const QFontEngineS60Extensions *extension(const QString &typeface) const;
+
+private:
+ RHeap* m_heap;
+ CFontStore *m_store;
+ COpenFontRasterizer *m_rasterizer;
+ mutable QHash<QString, const QFontEngineS60Extensions *> m_extensions;
+};
+
+QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation()
+{
+ m_heap = User::ChunkHeap(NULL, 0x1000, 0x100000);
+ QT_TRAP_THROWING(
+ m_store = CFontStore::NewL(m_heap);
+ m_rasterizer = COpenFontRasterizer::NewL(TUid::Uid(0x101F7F5E));
+ CleanupStack::PushL(m_rasterizer);
+ m_store->InstallRasterizerL(m_rasterizer);
+ CleanupStack::Pop(m_rasterizer););
+
+ QStringList filters;
+ filters.append(QString::fromLatin1("*.ttf"));
+ filters.append(QString::fromLatin1("*.ccc"));
+ const QFileInfoList fontFiles = alternativeFilePaths(QString::fromLatin1("resource\\Fonts"), filters);
+ foreach (const QFileInfo &fontFileInfo, fontFiles) {
+ const QString fontFile = QDir::toNativeSeparators(fontFileInfo.absoluteFilePath());
+ TPtrC fontFilePtr(qt_QString2TPtrC(fontFile));
+ QT_TRAP_THROWING(m_store->AddFileL(fontFilePtr));
+ }
+}
+QFontDatabaseS60StoreImplementation::~QFontDatabaseS60StoreImplementation()
+{
+ typedef QHash<QString, const QFontEngineS60Extensions *>::iterator iterator;
+ for (iterator p = m_extensions.begin(); p != m_extensions.end(); ++p) {
+ m_store->ReleaseFont((*p)->fontOwner());
+ delete *p;
+ }
+
+ delete m_store;
+ m_heap->Close();
+}
+
+#ifndef FNTSTORE_H_INLINES_SUPPORT_FMM
+/*
+ Workaround: fntstore.h has an inlined function 'COpenFont* CBitmapFont::OpenFont()'
+ that returns a private data member. The header will change between SDKs. But Qt has
+ to build on any SDK version and run on other versions of Symbian OS.
+ This function performs the needed pointer arithmetic to get the right COpenFont*
+*/
+COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont)
+{
+ const TInt offsetIOpenFont = 92; // '_FOFF(CBitmapFont, iOpenFont)' ..if iOpenFont weren't private
+ const TUint valueIOpenFont = *(TUint*)PtrAdd(aBitmapFont, offsetIOpenFont);
+ return (valueIOpenFont & 1) ?
+ (COpenFont*)PtrAdd(aBitmapFont, valueIOpenFont & ~1) : // New behavior: iOpenFont is offset
+ (COpenFont*)valueIOpenFont; // Old behavior: iOpenFont is pointer
+}
+#endif // FNTSTORE_H_INLINES_SUPPORT_FMM
+
+const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(const QString &typeface) const
+{
+ if (!m_extensions.contains(typeface)) {
+ CFont* font = NULL;
+ TFontSpec spec(qt_QString2TPtrC(typeface), 1);
+ spec.iHeight = 1;
+ const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec);
+ Q_ASSERT(err == KErrNone && font);
+ const CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font);
+ COpenFont *openFont =
+#ifdef FNTSTORE_H_INLINES_SUPPORT_FMM
+ bitmapFont->openFont();
+#else
+ OpenFontFromBitmapFont(bitmapFont);
+#endif // FNTSTORE_H_INLINES_SUPPORT_FMM
+ m_extensions.insert(typeface, new QFontEngineS60Extensions(font, openFont));
+ }
+ return m_extensions.value(typeface);
+}
+#else
+class QFontEngineFTS60 : public QFontEngineFT
+{
+public:
+ QFontEngineFTS60(const QFontDef &fd);
+};
+
+QFontEngineFTS60::QFontEngineFTS60(const QFontDef &fd)
+ : QFontEngineFT(fd)
+{
+ default_hint_style = HintFull;
+}
+#endif // defined(QT_NO_FREETYPE)
+
+/*
+ QFontEngineS60::pixelsToPoints, QFontEngineS60::pointsToPixels, QFontEngineMultiS60::QFontEngineMultiS60
+ and QFontEngineMultiS60::QFontEngineMultiS60 should be in qfontengine_s60.cpp. But since also the
+ Freetype based font rendering need them, they are here.
+*/
+qreal QFontEngineS60::pixelsToPoints(qreal pixels, Qt::Orientation orientation)
+{
+ return (orientation == Qt::Horizontal?
+ S60->screenDevice()->HorizontalPixelsToTwips(pixels)
+ :S60->screenDevice()->VerticalPixelsToTwips(pixels)) / KTwipsPerPoint;
+}
+
+qreal QFontEngineS60::pointsToPixels(qreal points, Qt::Orientation orientation)
+{
+ const int twips = points * KTwipsPerPoint;
+ return orientation == Qt::Horizontal?
+ S60->screenDevice()->HorizontalTwipsToPixels(twips)
+ :S60->screenDevice()->VerticalTwipsToPixels(twips);
+}
+
+QFontEngineMultiS60::QFontEngineMultiS60(QFontEngine *first, int script, const QStringList &fallbackFamilies)
+ : QFontEngineMulti(fallbackFamilies.size() + 1)
+ , m_script(script)
+ , m_fallbackFamilies(fallbackFamilies)
+{
+ engines[0] = first;
+ first->ref.ref();
+ fontDef = engines[0]->fontDef;
+}
+
+void QFontEngineMultiS60::loadEngine(int at)
+{
+ Q_ASSERT(at < engines.size());
+ Q_ASSERT(engines.at(at) == 0);
+
+ QFontDef request = fontDef;
+ request.styleStrategy |= QFont::NoFontMerging;
+ request.family = m_fallbackFamilies.at(at-1);
+ engines[at] = QFontDatabase::findFont(m_script,
+ /*fontprivate*/0,
+ request);
+ Q_ASSERT(engines[at]);
+}
+
+static void initializeDb()
+{
+ QFontDatabasePrivate *db = privateDb();
+ if(!db || db->count)
+ return;
+
+#if defined(QT_NO_FREETYPE)
+ if (!db->s60Store)
+ db->s60Store = new QFontDatabaseS60StoreImplementation;
+
+ QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
+
+ const int numTypeFaces = QS60Data::screenDevice()->NumTypefaces();
+ const QFontDatabaseS60StoreImplementation *store = dynamic_cast<const QFontDatabaseS60StoreImplementation*>(db->s60Store);
+ Q_ASSERT(store);
+ bool fontAdded = false;
+ for (int i = 0; i < numTypeFaces; i++) {
+ TTypefaceSupport typefaceSupport;
+ QS60Data::screenDevice()->TypefaceSupport(typefaceSupport, i);
+ CFont *font; // We have to get a font instance in order to know all the details
+ TFontSpec fontSpec(typefaceSupport.iTypeface.iName, 11);
+ if (QS60Data::screenDevice()->GetNearestFontInPixels(font, fontSpec) != KErrNone)
+ continue;
+ if (font->TypeUid() == KCFbsFontUid) {
+ TOpenFontFaceAttrib faceAttrib;
+ const CFbsFont *cfbsFont = dynamic_cast<const CFbsFont *>(font);
+ Q_ASSERT(cfbsFont);
+ cfbsFont->GetFaceAttrib(faceAttrib);
+
+ QtFontStyle::Key styleKey;
+ styleKey.style = faceAttrib.IsItalic()?QFont::StyleItalic:QFont::StyleNormal;
+ styleKey.weight = faceAttrib.IsBold()?QFont::Bold:QFont::Normal;
+
+ QString familyName((const QChar *)typefaceSupport.iTypeface.iName.Ptr(), typefaceSupport.iTypeface.iName.Length());
+ QtFontFamily *family = db->family(familyName, true);
+ family->fixedPitch = faceAttrib.IsMonoWidth();
+ QtFontFoundry *foundry = family->foundry(QString(), true);
+ QtFontStyle *style = foundry->style(styleKey, true);
+ style->smoothScalable = typefaceSupport.iIsScalable;
+ style->pixelSize(0, true);
+
+ const QFontEngineS60Extensions *extension = store->extension(familyName);
+ const QByteArray os2Table = extension->getSfntTable(MAKE_TAG('O', 'S', '/', '2'));
+ const unsigned char* data = reinterpret_cast<const unsigned char*>(os2Table.constData());
+ const unsigned char* ulUnicodeRange = data + 42;
+ quint32 unicodeRange[4] = {
+ qFromBigEndian<quint32>(ulUnicodeRange),
+ qFromBigEndian<quint32>(ulUnicodeRange + 4),
+ qFromBigEndian<quint32>(ulUnicodeRange + 8),
+ qFromBigEndian<quint32>(ulUnicodeRange + 12)
+ };
+ const unsigned char* ulCodePageRange = data + 78;
+ quint32 codePageRange[2] = {
+ qFromBigEndian<quint32>(ulCodePageRange),
+ qFromBigEndian<quint32>(ulCodePageRange + 4)
+ };
+ const QList<QFontDatabase::WritingSystem> writingSystems =
+ determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
+ foreach (const QFontDatabase::WritingSystem system, writingSystems)
+ family->writingSystems[system] = QtFontFamily::Supported;
+
+ fontAdded = true;
+ }
+ QS60Data::screenDevice()->ReleaseFont(font);
+ }
+
+ Q_ASSERT(fontAdded);
+
+ lock.relock();
+
+#else // defined(QT_NO_FREETYPE)
+ QDir dir(QDesktopServices::storageLocation(QDesktopServices::FontsLocation));
+ dir.setNameFilters(QStringList() << QLatin1String("*.ttf")
+ << QLatin1String("*.ttc") << QLatin1String("*.pfa")
+ << QLatin1String("*.pfb"));
+ for (int i = 0; i < int(dir.count()); ++i) {
+ const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
+ db->addTTFile(file);
+ }
+#endif // defined(QT_NO_FREETYPE)
+}
+
+static inline void load(const QString &family = QString(), int script = -1)
+{
+ Q_UNUSED(family)
+ Q_UNUSED(script)
+ initializeDb();
+}
+
+static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
+{
+ Q_UNUSED(fnt);
+}
+
+bool QFontDatabase::removeApplicationFont(int handle)
+{
+ Q_UNUSED(handle);
+ return false;
+}
+
+bool QFontDatabase::supportsThreadedFontRendering()
+{
+ return false;
+}
+
+static
+QFontDef cleanedFontDef(const QFontDef &req)
+{
+ QFontDef result = req;
+ if (result.pixelSize <= 0) {
+ result.pixelSize = QFontEngineS60::pointsToPixels(qMax(qreal(1.0), result.pointSize));
+ result.pointSize = 0;
+ }
+ return result;
+}
+
+QFontEngine *QFontDatabase::findFont(int script, const QFontPrivate *, const QFontDef &req)
+{
+ const QFontCache::Key key(cleanedFontDef(req), script);
+
+ if (!privateDb()->count)
+ initializeDb();
+
+ QFontEngine *fe = QFontCache::instance()->findEngine(key);
+ if (!fe) {
+ // Making sure that fe->fontDef.family will be an existing font.
+ initializeDb();
+ QFontDatabasePrivate *db = privateDb();
+ QtFontDesc desc;
+ QList<int> blacklistedFamilies;
+ match(script, req, req.family, QString(), -1, &desc, blacklistedFamilies);
+ if (!desc.family) // falling back to application font
+ desc.family = db->family(QApplication::font().defaultFamily());
+ Q_ASSERT(desc.family);
+
+ // Making sure that desc.family supports the requested script
+ QtFontDesc mappedDesc;
+ bool supportsScript = false;
+ do {
+ match(script, req, QString(), QString(), -1, &mappedDesc, blacklistedFamilies);
+ if (mappedDesc.family == desc.family) {
+ supportsScript = true;
+ break;
+ }
+ blacklistedFamilies.append(mappedDesc.familyIndex);
+ } while (mappedDesc.family);
+ if (!supportsScript) {
+ blacklistedFamilies.clear();
+ match(script, req, QString(), QString(), -1, &mappedDesc, blacklistedFamilies);
+ if (mappedDesc.family)
+ desc = mappedDesc;
+ }
+
+ const QString fontFamily = desc.family->name;
+ QFontDef request = req;
+ request.family = fontFamily;
+#if defined(QT_NO_FREETYPE)
+ const QFontDatabaseS60StoreImplementation *store = dynamic_cast<const QFontDatabaseS60StoreImplementation*>(db->s60Store);
+ Q_ASSERT(store);
+ const QFontEngineS60Extensions *extension = store->extension(fontFamily);
+ fe = new QFontEngineS60(request, extension);
+#else
+ QFontEngine::FaceId faceId;
+ const QtFontFamily * const reqQtFontFamily = db->family(fontFamily);
+ faceId.filename = reqQtFontFamily->fontFilename;
+ faceId.index = reqQtFontFamily->fontFileIndex;
+
+ QFontEngineFTS60 *fte = new QFontEngineFTS60(cleanedFontDef(request));
+ if (fte->init(faceId, true, QFontEngineFT::Format_A8))
+ fe = fte;
+ else
+ delete fte;
+#endif
+
+ Q_ASSERT(fe);
+ if (script == QUnicodeTables::Common
+ && !(req.styleStrategy & QFont::NoFontMerging)
+ && !fe->symbol) {
+
+ QStringList commonFonts;
+ for (int ws = 1; ws < QFontDatabase::WritingSystemsCount; ++ws) {
+ if (scriptForWritingSystem[ws] != script)
+ continue;
+ for (int i = 0; i < db->count; ++i) {
+ if (db->families[i]->writingSystems[ws] & QtFontFamily::Supported)
+ commonFonts.append(db->families[i]->name);
+ }
+ }
+
+ // Hack: Prioritize .ccc fonts
+ const QString niceEastAsianFont(QLatin1String("Sans MT 936_S60"));
+ if (commonFonts.removeAll(niceEastAsianFont) > 0)
+ commonFonts.prepend(niceEastAsianFont);
+
+ fe = new QFontEngineMultiS60(fe, script, commonFonts);
+ }
+ }
+ fe->ref.ref();
+ QFontCache::instance()->insertEngine(key, fe);
+ return fe;
+}
+
+void QFontDatabase::load(const QFontPrivate *d, int script)
+{
+ QFontEngine *fe = 0;
+ QFontDef req = d->request;
+
+ if (!d->engineData) {
+ const QFontCache::Key key(cleanedFontDef(req), script);
+ getEngineData(d, key);
+ }
+
+ // the cached engineData could have already loaded the engine we want
+ if (d->engineData->engines[script])
+ fe = d->engineData->engines[script];
+
+ if (!fe) {
+ if (qt_enable_test_font && req.family == QLatin1String("__Qt__Box__Engine__")) {
+ fe = new QTestFontEngine(req.pixelSize);
+ fe->fontDef = req;
+ } else {
+ fe = findFont(script, d, req);
+ }
+ d->engineData->engines[script] = fe;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp
index a2a7cee38..6cde9edc9 100644
--- a/src/gui/text/qfontdatabase_win.cpp
+++ b/src/gui/text/qfontdatabase_win.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,26 +21,26 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qt_windows.h"
+#include <qmath.h>
#include <private/qapplication_p.h>
#include "qfont_p.h"
#include "qfontengine_p.h"
@@ -471,7 +472,7 @@ static void initializeDb()
// print the database
for (int f = 0; f < db->count; f++) {
QtFontFamily *family = db->families[f];
- qDebug(" %s: %p", family->name.latin1(), family);
+ qDebug(" %s: %p", qPrintable(family->name), family);
populate_database(family->name);
#if 0
@@ -670,7 +671,7 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, const QFontDef &requ
break;
}
- lf.lfHeight = -request.pixelSize;
+ lf.lfHeight = -qRound(request.pixelSize);
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
@@ -899,7 +900,6 @@ static QFontEngine *loadWin(const QFontPrivate *d, int script, const QFontDef &r
return fe;
}
-
void QFontDatabase::load(const QFontPrivate *d, int script)
{
// sanity checks
@@ -910,8 +910,9 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
// normalize the request to get better caching
QFontDef req = d->request;
if (req.pixelSize <= 0)
- req.pixelSize = qMax(1, qRound(req.pointSize * d->dpi / 72.));
- req.pointSize = 0;
+ req.pixelSize = qreal((req.pointSize * d->dpi) / 72.);
+ if (req.pixelSize < 1)
+ req.pixelSize = 1;
if (req.weight == 0)
req.weight = QFont::Normal;
if (req.stretch == 0)
@@ -928,7 +929,8 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
QFontEngine *fe = QFontCache::instance()->findEngine(key);
// set it to the actual pointsize, so QFontInfo will do the right thing
- req.pointSize = req.pixelSize*72./d->dpi;
+ if (req.pointSize < 0)
+ req.pointSize = req.pixelSize*72./d->dpi;
if (!fe) {
if (qt_enable_test_font && req.family == QLatin1String("__Qt__Box__Engine__")) {
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index cc4520bbf..dd575f97b 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -51,6 +51,7 @@
#include <qfile.h>
#include <qtemporaryfile.h>
#include <qabstractfileengine.h>
+#include <qmath.h>
#include <ctype.h>
#include <stdlib.h>
@@ -154,187 +155,187 @@ static const char writingSystems_for_xlfd_encoding[sizeof(xlfd_encoding)][QFontD
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-2
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-3
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-4
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-9
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-10
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-13
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-14
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-15
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// hp-roman8
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-5
{ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// *-cp1251
{ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// koi8-ru
{ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// koi8-u
{ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// koi8-r
{ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-7
{ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-8
{ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// gb18030-0
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// gb18030.2000-0
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// gbk-0
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// gb2312.*-0
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// jisx0201*-0
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
- 0 },
+ 0, 0 },
// jisx0208*-0
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
- 0 },
+ 0, 0 },
// ksc5601*-*
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
- 0 },
+ 0, 0 },
// big5hkscs-0
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
- 0 },
+ 0, 0 },
// hkscs-1
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
- 0 },
+ 0, 0 },
// big5*-*
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
- 0 },
+ 0, 0 },
// tscii-*
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// tis620*-*
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso8859-11
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// mulelao-1
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// ethiopic-unicode
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 },
+ 0, 0 },
// iso10646-1
{ 0, 1, 1, 1, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
- 0 },
+ 0, 0 },
// unicode-*
{ 0, 1, 1, 1, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
- 0 },
+ 0, 0 },
// *-symbol
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1 },
+ 1, 0 },
// *-fontspecific
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1 },
+ 1, 0 },
// fontspecific-*
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1 }
+ 1, 0 }
};
@@ -752,12 +753,12 @@ QFontDef qt_FcPatternToQFontDef(FcPattern *pattern, const QFontDef &request)
if (X11->display)
dpi = QX11Info::appDpiY();
else
- dpi = 96; // ####
+ dpi = qt_defaultDpiY();
}
double size;
if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
- fontDef.pixelSize = qRound(size);
+ fontDef.pixelSize = size;
else
fontDef.pixelSize = 12;
@@ -834,7 +835,8 @@ static const char *specialLanguages[] = {
"ko", // Hangul
"", // Ogham
"", // Runic
- "km" // Khmer
+ "km", // Khmer
+ "" // N'Ko
};
enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) };
@@ -865,7 +867,8 @@ static const ushort specialChars[] = {
0, // Hangul
0x1681, // Ogham
0x16a0, // Runic
- 0 // Khmer
+ 0, // Khmer
+ 0x7ca // N'Ko
};
enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) };
@@ -904,7 +907,8 @@ static const char *languageForWritingSystem[] = {
"vi", // Vietnamese
0, // Symbol
0, // Ogham
- 0 // Runic
+ 0, // Runic
+ 0 // N'Ko
};
enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
@@ -943,7 +947,8 @@ static const ushort sampleCharForWritingSystem[] = {
0, // Vietnamese
0, // Symbol
0x1681, // Ogham
- 0x16a0 // Runic
+ 0x16a0, // Runic
+ 0x7ca // N'Ko
};
enum { SampleCharCount = sizeof(sampleCharForWritingSystem) / sizeof(ushort) };
@@ -983,7 +988,8 @@ static const char *openType[] = {
0, // Vietnamese
0, // Symbol
0, // Ogham
- 0 // Runic
+ 0, // Runic
+ "nko " // N'Ko
};
enum { OpenTypeCount = sizeof(openType) / sizeof(const char *) };
@@ -1204,9 +1210,9 @@ static void loadFontConfig()
static void initializeDb();
-static void load(const QString &family = QString(), int script = -1)
+static void load(const QString &family = QString(), int script = -1, bool forceXLFD = false)
{
- if (X11->has_fontconfig) {
+ if (X11->has_fontconfig && !forceXLFD) {
initializeDb();
return;
}
@@ -1455,7 +1461,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD
slant_value = FC_SLANT_OBLIQUE;
FcPatternAddInteger(pattern, FC_SLANT, slant_value);
- double size_value = qMax(1, request.pixelSize);
+ double size_value = qMax(qreal(1.), request.pixelSize);
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value);
int stretch = request.stretch;
@@ -1471,7 +1477,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD
!(request.styleStrategy & QFont::NoAntialias));
}
- if (script != QUnicodeTables::Common) {
+ if (script != QUnicodeTables::Common && *specialLanguages[script] != '\0') {
Q_ASSERT(script < QUnicodeTables::ScriptCount);
FcLangSet *ls = FcLangSetCreate();
FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]);
@@ -1614,7 +1620,7 @@ static QFontEngine *tryPatternLoad(FcPattern *p, int screen,
goto done;
if (!FcCharSetHasChar(cs, specialChars[script]))
goto done;
- } else {
+ } else if (*specialLanguages[script] != '\0'){
FcLangSet *langSet = 0;
if (FcPatternGetLangSet(match, FC_LANG, 0, &langSet) != FcResultMatch)
goto done;
@@ -1784,7 +1790,7 @@ QFontEngine *QFontDatabase::loadXlfd(int screen, int script, const QFontDef &req
QString family, foundry;
QT_PREPEND_NAMESPACE(parseFontName)(families_and_foundries.at(i), foundry, family);
FM_DEBUG("loadXlfd: >>>>>>>>>>>>>>trying to match '%s' encoding=%d", family.toLatin1().data(), force_encoding_id);
- QT_PREPEND_NAMESPACE(match)(script, request, family, foundry, force_encoding_id, &desc);
+ QT_PREPEND_NAMESPACE(match)(script, request, family, foundry, force_encoding_id, &desc, QList<int>(), true);
if (desc.family)
break;
}
@@ -1847,23 +1853,26 @@ QFontEngine *QFontDatabase::loadXlfd(int screen, int script, const QFontDef &req
}
} else {
QList<int> encodings;
- if (desc.encoding)
- encodings.append(int(desc.encoding->encoding));
+ if (desc.encoding) {
+ if (desc.encoding->encoding >= 0)
+ encodings.append(int(desc.encoding->encoding));
+ }
if (desc.size) {
// append all other encodings for the matched font
for (int i = 0; i < desc.size->count; ++i) {
QtFontEncoding *e = desc.size->encodings + i;
- if (e == desc.encoding)
- continue;
+ if (e == desc.encoding || e->encoding < 0)
+ continue;
encodings.append(int(e->encoding));
}
}
// fill in the missing encodings
const XlfdEncoding *enc = xlfd_encoding;
for (; enc->name; ++enc) {
- if (!encodings.contains(enc->id))
+ if (!encodings.contains(enc->id) && enc->id >= 0) {
encodings.append(enc->id);
+ }
}
#if defined(FONT_MATCH_DEBUG)
@@ -1890,8 +1899,9 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
// normalize the request to get better caching
QFontDef req = d->request;
if (req.pixelSize <= 0)
- req.pixelSize = qRound(qt_pixelSize(req.pointSize, d->dpi));
- req.pointSize = 0;
+ req.pixelSize = floor(qt_pixelSize(req.pointSize, d->dpi) * 100 + 0.5) / 100;
+ if (req.pixelSize < 1)
+ req.pixelSize = 1;
if (req.weight == 0)
req.weight = QFont::Normal;
if (req.stretch == 0)
@@ -1906,7 +1916,9 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
return;
// set it to the actual pointsize, so QFontInfo will do the right thing
- req.pointSize = qt_pointSize(req.pixelSize, d->dpi);
+ if (req.pointSize < 0)
+ req.pointSize = qt_pointSize(req.pixelSize, d->dpi);
+
QFontEngine *fe = QFontCache::instance()->findEngine(key);
@@ -1925,6 +1937,13 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
#ifndef QT_NO_FONTCONFIG
} else if (X11->has_fontconfig) {
fe = loadFc(d, script, req);
+
+ if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize) {
+ delete fe;
+ fe = loadXlfd(d->screen, script, req);
+ }
+
+
#endif
} else if (mainThread) {
fe = loadXlfd(d->screen, script, req);
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index eaa06bdce..27fc3c18a 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -185,18 +185,20 @@ QFontEngine::QFontEngine()
QFontEngine::~QFontEngine()
{
- for (GlyphPointerHash::iterator it = m_glyphPointerHash.begin(), end = m_glyphPointerHash.end();
- it != end; ++it) {
- for (QList<QFontEngineGlyphCache*>::iterator it2 = it.value().begin(), end2 = it.value().end();
- it2 != end2; ++it2)
- delete *it2;
+ for (GlyphPointerHash::const_iterator it = m_glyphPointerHash.constBegin(),
+ end = m_glyphPointerHash.constEnd(); it != end; ++it) {
+ for (QList<QFontEngineGlyphCache*>::const_iterator it2 = it.value().constBegin(),
+ end2 = it.value().constEnd(); it2 != end2; ++it2) {
+ delete *it2;
+ }
}
m_glyphPointerHash.clear();
- for (GlyphIntHash::iterator it = m_glyphIntHash.begin(), end = m_glyphIntHash.end();
- it != end; ++it) {
- for (QList<QFontEngineGlyphCache*>::iterator it2 = it.value().begin(), end2 = it.value().end();
- it2 != end2; ++it2)
- delete *it2;
+ for (GlyphIntHash::const_iterator it = m_glyphIntHash.constBegin(),
+ end = m_glyphIntHash.constEnd(); it != end; ++it) {
+ for (QList<QFontEngineGlyphCache*>::const_iterator it2 = it.value().constBegin(),
+ end2 = it.value().constEnd(); it2 != end2; ++it2) {
+ delete *it2;
+ }
}
m_glyphIntHash.clear();
qHBFreeFace(hbFace);
@@ -234,8 +236,10 @@ HB_Font QFontEngine::harfbuzzFont() const
HB_Face QFontEngine::harfbuzzFace() const
{
- if (!hbFace)
+ if (!hbFace) {
hbFace = qHBNewFace(const_cast<QFontEngine *>(this), hb_getSFntTable);
+ Q_CHECK_PTR(hbFace);
+ }
return hbFace;
}
@@ -812,7 +816,7 @@ QFontEngineGlyphCache *QFontEngine::glyphCache(QFontEngineGlyphCache::Type key,
return 0;
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
static inline QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs)
{
uint left_right = (left << 16) + right;
@@ -942,48 +946,60 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy
if (maps + 8 * numTables > endPtr)
return 0;
+ enum {
+ Invalid,
+ Symbol,
+ AppleRoman,
+ Unicode11,
+ Unicode,
+ MicrosoftUnicode,
+ MicrosoftUnicodeExtended
+ };
+
+ int symbolTable = -1;
int tableToUse = -1;
- int score = 0;
+ int score = Invalid;
for (int n = 0; n < numTables; ++n) {
const quint16 platformId = qFromBigEndian<quint16>(maps + 8 * n);
const quint16 platformSpecificId = qFromBigEndian<quint16>(maps + 8 * n + 2);
switch (platformId) {
case 0: // Unicode
- if (score < 4 &&
+ if (score < Unicode &&
(platformSpecificId == 0 ||
platformSpecificId == 2 ||
platformSpecificId == 3)) {
tableToUse = n;
- score = 4;
- } else if (score < 3 && platformSpecificId == 1) {
+ score = Unicode;
+ } else if (score < Unicode11 && platformSpecificId == 1) {
tableToUse = n;
- score = 3;
+ score = Unicode11;
}
break;
case 1: // Apple
- if (score < 2 && platformSpecificId == 0) { // Apple Roman
+ if (score < AppleRoman && platformSpecificId == 0) { // Apple Roman
tableToUse = n;
- score = 2;
+ score = AppleRoman;
}
break;
case 3: // Microsoft
switch (platformSpecificId) {
case 0:
- if (score < 1) {
+ symbolTable = n;
+ if (score < Symbol) {
tableToUse = n;
- score = 1;
+ score = Symbol;
}
break;
case 1:
- if (score < 5) {
+ if (score < MicrosoftUnicode) {
tableToUse = n;
- score = 5;
+ score = MicrosoftUnicode;
}
break;
case 0xa:
- if (score < 6) {
+ if (score < MicrosoftUnicodeExtended) {
tableToUse = n;
- score = 6;
+ score = MicrosoftUnicodeExtended;
}
break;
default:
@@ -995,7 +1011,9 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy
}
if(tableToUse < 0)
return 0;
- *isSymbolFont = (score == 1);
+
+resolveTable:
+ *isSymbolFont = (score == Symbol);
unsigned int unicode_table = qFromBigEndian<quint32>(maps + 8*tableToUse + 4);
@@ -1015,6 +1033,41 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy
if (table + unicode_table + length > endPtr)
return 0;
*cmapSize = length;
+
+ // To support symbol fonts that contain a unicode table for the symbol area
+ // we check the cmap tables and fall back to symbol font unless that would
+ // involve losing information from the unicode table
+ if (symbolTable > -1 && ((score == Unicode) || (score == Unicode11))) {
+ const uchar *selectedTable = table + unicode_table;
+
+ // Check that none of the latin1 range are in the unicode table
+ bool unicodeTableHasLatin1 = false;
+ for (int uc=0x00; uc<0x100; ++uc) {
+ if (getTrueTypeGlyphIndex(selectedTable, uc) != 0) {
+ unicodeTableHasLatin1 = true;
+ break;
+ }
+ }
+
+ // Check that at least one symbol char is in the unicode table
+ bool unicodeTableHasSymbols = false;
+ if (!unicodeTableHasLatin1) {
+ for (int uc=0xf000; uc<0xf100; ++uc) {
+ if (getTrueTypeGlyphIndex(selectedTable, uc) != 0) {
+ unicodeTableHasSymbols = true;
+ break;
+ }
+ }
+ }
+
+ // Fall back to symbol table
+ if (!unicodeTableHasLatin1 && unicodeTableHasSymbols) {
+ tableToUse = symbolTable;
+ score = Symbol;
+ goto resolveTable;
+ }
+ }
+
return table + unicode_table;
}
@@ -1034,9 +1087,8 @@ quint32 QFontEngine::getTrueTypeGlyphIndex(const uchar *cmap, uint unicode)
return 0;
quint16 segCountX2 = qFromBigEndian<quint16>(cmap + 6);
const unsigned char *ends = cmap + 14;
- quint16 endIndex = 0;
int i = 0;
- for (; i < segCountX2/2 && (endIndex = qFromBigEndian<quint16>(ends + 2*i)) < unicode; i++) {}
+ for (; i < segCountX2/2 && qFromBigEndian<quint16>(ends + 2*i) < unicode; i++) {}
const unsigned char *idx = ends + segCountX2 + 2 + 2*i;
quint16 startIndex = qFromBigEndian<quint16>(idx);
@@ -1103,6 +1155,18 @@ quint32 QFontEngine::getTrueTypeGlyphIndex(const uchar *cmap, uint unicode)
return 0;
}
+Q_GLOBAL_STATIC_WITH_INITIALIZER(QVector<QRgb>, qt_grayPalette, {
+ x->resize(256);
+ QRgb *it = x->data();
+ for (int i = 0; i < x->size(); ++i, ++it)
+ *it = 0xff000000 | i | (i<<8) | (i<<16);
+})
+
+const QVector<QRgb> &QFontEngine::grayPalette()
+{
+ return *qt_grayPalette();
+}
+
// ------------------------------------------------------------------
// The box font engine
// ------------------------------------------------------------------
@@ -1306,8 +1370,8 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len,
for (int i = 0; i < len; ++i) {
bool surrogate = (str[i].unicode() >= 0xd800 && str[i].unicode() < 0xdc00 && i < len-1
&& str[i+1].unicode() >= 0xdc00 && str[i+1].unicode() < 0xe000);
- if (glyphs->glyphs[glyph_pos] == 0) {
+ if (glyphs->glyphs[glyph_pos] == 0 && str[i].category() != QChar::Separator_Line) {
QGlyphLayoutInstance tmp = glyphs->instance(glyph_pos);
for (int x = 1; x < engines.size(); ++x) {
QFontEngine *engine = engines.at(x);
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 221db0319..293eac76a 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -191,6 +191,9 @@ HB_Error QFreetypeFace::getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 p
/*
* One font file can contain more than one font (bold/italic for example)
* find the right one and return it.
+ *
+ * Returns the freetype face or 0 in case of an empty file or any other problems
+ * (like not being able to open the file)
*/
QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id)
{
@@ -202,8 +205,10 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id)
FT_Init_FreeType(&freetypeData->library);
QFreetypeFace *freetype = freetypeData->faces.value(face_id, 0);
- if (!freetype) {
- freetype = new QFreetypeFace;
+ if (freetype) {
+ freetype->ref.ref();
+ } else {
+ QScopedPointer<QFreetypeFace> newFreetype(new QFreetypeFace);
FT_Face face;
QFile file(QString::fromUtf8(face_id.filename));
if (face_id.filename.startsWith(":qmemoryfonts/")) {
@@ -212,86 +217,90 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id)
QByteArray idx = face_id.filename;
idx.remove(0, 14); // remove ':qmemoryfonts/'
bool ok = false;
- freetype->fontData = qt_fontdata_from_index(idx.toInt(&ok));
+ newFreetype->fontData = qt_fontdata_from_index(idx.toInt(&ok));
if (!ok)
- freetype->fontData = QByteArray();
+ newFreetype->fontData = QByteArray();
} else if (!(file.fileEngine()->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::LocalDiskFlag)) {
if (!file.open(QIODevice::ReadOnly)) {
- delete freetype;
return 0;
}
- freetype->fontData = file.readAll();
+ newFreetype->fontData = file.readAll();
}
- if (!freetype->fontData.isEmpty()) {
- if (FT_New_Memory_Face(freetypeData->library, (const FT_Byte *)freetype->fontData.constData(), freetype->fontData.size(), face_id.index, &face)) {
- delete freetype;
+ if (!newFreetype->fontData.isEmpty()) {
+ if (FT_New_Memory_Face(freetypeData->library, (const FT_Byte *)newFreetype->fontData.constData(), newFreetype->fontData.size(), face_id.index, &face)) {
return 0;
}
} else if (FT_New_Face(freetypeData->library, face_id.filename, face_id.index, &face)) {
- delete freetype;
return 0;
}
- freetype->face = face;
-
- freetype->hbFace = qHBNewFace(face, hb_getSFntTable);
- freetype->ref = 0;
- freetype->xsize = 0;
- freetype->ysize = 0;
- freetype->matrix.xx = 0x10000;
- freetype->matrix.yy = 0x10000;
- freetype->matrix.xy = 0;
- freetype->matrix.yx = 0;
- freetype->unicode_map = 0;
- freetype->symbol_map = 0;
+ newFreetype->face = face;
+
+ newFreetype->hbFace = qHBNewFace(face, hb_getSFntTable);
+ Q_CHECK_PTR(newFreetype->hbFace);
+ newFreetype->ref = 1;
+ newFreetype->xsize = 0;
+ newFreetype->ysize = 0;
+ newFreetype->matrix.xx = 0x10000;
+ newFreetype->matrix.yy = 0x10000;
+ newFreetype->matrix.xy = 0;
+ newFreetype->matrix.yx = 0;
+ newFreetype->unicode_map = 0;
+ newFreetype->symbol_map = 0;
#ifndef QT_NO_FONTCONFIG
- freetype->charset = 0;
+ newFreetype->charset = 0;
#endif
- memset(freetype->cmapCache, 0, sizeof(freetype->cmapCache));
+ memset(newFreetype->cmapCache, 0, sizeof(newFreetype->cmapCache));
- for (int i = 0; i < freetype->face->num_charmaps; ++i) {
- FT_CharMap cm = freetype->face->charmaps[i];
+ for (int i = 0; i < newFreetype->face->num_charmaps; ++i) {
+ FT_CharMap cm = newFreetype->face->charmaps[i];
switch(cm->encoding) {
case FT_ENCODING_UNICODE:
- freetype->unicode_map = cm;
+ newFreetype->unicode_map = cm;
break;
case FT_ENCODING_APPLE_ROMAN:
case FT_ENCODING_ADOBE_LATIN_1:
- if (!freetype->unicode_map || freetype->unicode_map->encoding != FT_ENCODING_UNICODE)
- freetype->unicode_map = cm;
+ if (!newFreetype->unicode_map || newFreetype->unicode_map->encoding != FT_ENCODING_UNICODE)
+ newFreetype->unicode_map = cm;
break;
case FT_ENCODING_ADOBE_CUSTOM:
case FT_ENCODING_MS_SYMBOL:
- if (!freetype->symbol_map)
- freetype->symbol_map = cm;
+ if (!newFreetype->symbol_map)
+ newFreetype->symbol_map = cm;
break;
default:
break;
}
}
- if (!FT_IS_SCALABLE(freetype->face) && freetype->face->num_fixed_sizes == 1)
- FT_Set_Char_Size (face, X_SIZE(freetype->face, 0), Y_SIZE(freetype->face, 0), 0, 0);
+ 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);
# if 0
FcChar8 *name;
FcPatternGetString(pattern, FC_FAMILY, 0, &name);
qDebug("%s: using maps: default: %x unicode: %x, symbol: %x", name,
- freetype->face->charmap ? freetype->face->charmap->encoding : 0,
- freetype->unicode_map ? freetype->unicode_map->encoding : 0,
- freetype->symbol_map ? freetype->symbol_map->encoding : 0);
+ newFreetype->face->charmap ? newFreetype->face->charmap->encoding : 0,
+ newFreetype->unicode_map ? newFreetype->unicode_map->encoding : 0,
+ newFreetype->symbol_map ? newFreetype->symbol_map->encoding : 0);
for (int i = 0; i < 256; i += 8)
qDebug(" %x: %d %d %d %d %d %d %d %d", i,
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i),
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i),
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i),
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i));
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i),
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i),
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i),
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i));
#endif
- FT_Set_Charmap(freetype->face, freetype->unicode_map);
- freetypeData->faces.insert(face_id, freetype);
+ FT_Set_Charmap(newFreetype->face, newFreetype->unicode_map);
+ QT_TRY {
+ freetypeData->faces.insert(face_id, newFreetype.data());
+ } QT_CATCH(...) {
+ newFreetype.take()->release(face_id);
+ // we could return null in principle instead of throwing
+ QT_RETHROW;
+ }
+ freetype = newFreetype.take();
}
- freetype->ref.ref();
return freetype;
}
@@ -305,7 +314,8 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id)
if (charset)
FcCharSetDestroy(charset);
#endif
- freetypeData->faces.take(face_id);
+ if(freetypeData->faces.contains(face_id))
+ freetypeData->faces.take(face_id);
delete this;
}
if (freetypeData->faces.isEmpty()) {
@@ -317,7 +327,7 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id)
void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing)
{
- *ysize = fontDef.pixelSize << 6;
+ *ysize = qRound(fontDef.pixelSize * 64);
*xsize = *ysize * fontDef.stretch / 100;
*outline_drawing = false;
@@ -377,7 +387,9 @@ QFontEngine::Properties QFreetypeFace::properties() const
p.descent = QFixed::fromFixed(-face->size->metrics.descender);
p.leading = QFixed::fromFixed(face->size->metrics.height - face->size->metrics.ascender + face->size->metrics.descender);
p.emSquare = face->size->metrics.y_ppem;
- p.boundingBox = QRectF(-p.ascent.toReal(), 0, (p.ascent + p.descent).toReal(), face->size->metrics.max_advance/64.);
+// p.boundingBox = QRectF(-p.ascent.toReal(), 0, (p.ascent + p.descent).toReal(), face->size->metrics.max_advance/64.);
+ p.boundingBox = QRectF(0, -p.ascent.toReal(),
+ face->size->metrics.max_advance/64, (p.ascent + p.descent).toReal() );
}
p.italicAngle = 0;
p.capHeight = p.ascent;
@@ -606,6 +618,7 @@ QFontEngineFT::QFontEngineFT(const QFontDef &fd)
kerning_pairs_loaded = false;
transform = false;
antialias = true;
+ freetype = 0;
default_load_flags = 0;
default_hint_style = HintNone;
subpixelType = Subpixel_None;
@@ -636,8 +649,14 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format)
{
defaultFormat = format;
this->antialias = antialias;
+
if (!antialias)
glyphFormat = QFontEngineGlyphCache::Raster_Mono;
+ else if (format == Format_A8)
+ glyphFormat = QFontEngineGlyphCache::Raster_A8;
+ else if (format == Format_A32)
+ glyphFormat = QFontEngineGlyphCache::Raster_RGBMask;
+
face_id = faceId;
freetype = QFreetypeFace::getFace(face_id);
if (!freetype) {
@@ -692,6 +711,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format)
hbFace = freetype->hbFace;
metrics = face->size->metrics;
+
#if defined(Q_WS_QWS)
/*
TrueType fonts with embedded bitmaps may have a bitmap font specific
@@ -735,9 +755,8 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph
load_flags = FT_LOAD_NO_BITMAP;
// apply our matrix to this, but note that the metrics will not be affected by this.
- FT_Matrix matrix = freetype->matrix;
FT_Face face = lockFace();
- matrix = this->matrix;
+ FT_Matrix matrix = this->matrix;
FT_Matrix_Multiply(&set->transformationMatrix, &matrix);
FT_Set_Transform(face, &matrix, 0);
freetype->matrix = matrix;
@@ -1202,7 +1221,8 @@ QFixed QFontEngineFT::ascent() const
QFixed QFontEngineFT::descent() const
{
- return QFixed::fromFixed(-metrics.descender);
+ // subtract a pixel to work around QFontMetrics's built-in + 1
+ return QFixed::fromFixed(-metrics.descender - 64);
}
QFixed QFontEngineFT::leading() const
@@ -1837,6 +1857,28 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g)
return img;
}
+QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, int margin, const QTransform &t)
+{
+ if (t.type() > QTransform::TxTranslate)
+ return QFontEngine::alphaRGBMapForGlyph(g, margin, t);
+
+ lockFace();
+
+ GlyphFormat glyph_format = Format_A32;
+
+ Glyph *glyph = defaultGlyphSet.outline_drawing ? 0 : loadGlyph(g, glyph_format);
+ if (!glyph) {
+ unlockFace();
+ return QFontEngine::alphaRGBMapForGlyph(g, margin, t);
+ }
+
+ QImage img(glyph->width, glyph->height, QImage::Format_RGB32);
+ memcpy(img.bits(), glyph->data, 4 * glyph->width * glyph->height);
+ unlockFace();
+
+ return img;
+}
+
void QFontEngineFT::removeGlyphFromCache(glyph_t glyph)
{
delete defaultGlyphSet.glyph_data.take(glyph);
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 07564ffac..99b40f8d1 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -119,6 +119,7 @@ struct QFreetypeFace
static void addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path, bool = false);
private:
+ friend class QScopedPointerDeleter<QFreetypeFace>;
QFreetypeFace() : _lock(QMutex::Recursive) {}
~QFreetypeFace() {}
QAtomicInt ref;
@@ -226,6 +227,7 @@ public:
virtual void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const;
virtual QImage alphaMapForGlyph(glyph_t);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t);
virtual void removeGlyphFromCache(glyph_t glyph);
virtual int glyphCount() const;
@@ -255,7 +257,7 @@ public:
QGlyphSet *loadTransformedGlyphSet(const QTransform &matrix);
bool loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, GlyphFormat format = Format_Render);
-#if defined(Q_WS_QWS)
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
virtual void draw(QPaintEngine * /*p*/, qreal /*x*/, qreal /*y*/, const QTextItemInt & /*si*/) {}
#endif
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 65f8cef7d..a4e7c0456 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -119,6 +119,28 @@ OSStatus QMacFontPath::closePath(void *data)
}
+
+void qmacfontengine_gamma_correct(QImage *image)
+{
+ extern uchar qt_pow_rgb_gamma[256];
+
+ // gamma correct the pixels back to linear color space...
+ int h = image->height();
+ int w = image->width();
+
+ for (int y=0; y<h; ++y) {
+ uint *pixels = (uint *) image->scanLine(y);
+ for (int x=0; x<w; ++x) {
+ uint p = pixels[x];
+ uint r = qt_pow_rgb_gamma[qRed(p)];
+ uint g = qt_pow_rgb_gamma[qGreen(p)];
+ uint b = qt_pow_rgb_gamma[qBlue(p)];
+ pixels[x] = (r << 16) | (g << 8) | b | 0xff000000;
+ }
+ }
+}
+
+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning)
: QFontEngineMulti(0)
@@ -138,9 +160,10 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con
QCFString name;
ATSFontGetName(atsFontRef, kATSOptionFlagsDefault, &name);
- QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pointSize);
- QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pointSize, 0);
- ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pointSize, 0, symbolicTraits, symbolicTraits);
+
+ QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize);
+ QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, 0);
+ ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, 0, symbolicTraits, symbolicTraits);
// CTFontCreateCopyWithSymbolicTraits returns NULL if we ask for a trait that does
// not exist for the given font. (for example italic)
@@ -523,7 +546,7 @@ void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *position
cgMatrix = CGAffineTransformScale(cgMatrix, 1, -1);
if (synthesisFlags & QFontEngine::SynthesizedItalic)
- cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, tanf(14 * acosf(0) / 90), 1, 0, 0));
+ cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0));
for (int i = 0; i < nGlyphs; ++i) {
@@ -533,7 +556,7 @@ void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *position
}
}
-QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph)
+QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, int margin, bool aa)
{
const glyph_metrics_t br = boundingBox(glyph);
QImage im(qRound(br.width)+2, qRound(br.height)+2, QImage::Format_RGB32);
@@ -548,9 +571,10 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph)
8, im.bytesPerLine(), colorspace,
cgflags);
CGContextSetFontSize(ctx, fontDef.pixelSize);
- CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold
- && !(fontDef.styleStrategy & QFont::NoAntialias));
- CGContextSetShouldSmoothFonts(ctx, false);
+ CGContextSetShouldAntialias(ctx, aa ||
+ (fontDef.pointSize > qt_antialiasing_threshold
+ && !(fontDef.styleStrategy & QFont::NoAntialias)));
+ CGContextSetShouldSmoothFonts(ctx, aa);
CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
@@ -585,6 +609,13 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph)
CGContextRelease(ctx);
+ return im;
+}
+
+QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph)
+{
+ QImage im = imageForGlyph(glyph, 0, false);
+
QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
QVector<QRgb> colors(256);
for (int i=0; i<256; ++i)
@@ -604,6 +635,16 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph)
return indexed;
}
+QImage QCoreTextFontEngine::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTransform &x)
+{
+ if (x.type() >= QTransform::TxScale)
+ return QFontEngine::alphaRGBMapForGlyph(glyph, margin, x);
+
+ QImage im = imageForGlyph(glyph, margin, true);
+ qmacfontengine_gamma_correct(&im);
+ return im;
+}
+
void QCoreTextFontEngine::recalcAdvances(int numGlyphs, QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
{
Q_ASSERT(false);
@@ -789,7 +830,6 @@ static OSStatus atsuPostLayoutCallback(ATSULayoutOperationSelector selector, ATS
surrogates += (str[i].unicode() >= 0xd800 && str[i].unicode() < 0xdc00
&& str[i+1].unicode() >= 0xdc00 && str[i+1].unicode() < 0xe000);
}
- Q_ASSERT(*nfo->numGlyphs == item->length - surrogates);
#endif
for (nextCharStop = item->from; nextCharStop < item->from + item->length; ++nextCharStop)
if (item->charAttributes[nextCharStop].charStop)
@@ -815,10 +855,13 @@ static OSStatus atsuPostLayoutCallback(ATSULayoutOperationSelector selector, ATS
QFixed xAdvance = FixedToQFixed(layoutData[glyphIdx + 1].realPos - layoutData[glyphIdx].realPos);
if (glyphId != 0xffff || i == 0) {
- nfo->glyphs->glyphs[i] = (glyphId & 0x00ffffff) | (fontIdx << 24);
+ if (i < nfo->glyphs->numGlyphs)
+ {
+ nfo->glyphs->glyphs[i] = (glyphId & 0x00ffffff) | (fontIdx << 24);
- nfo->glyphs->advances_y[i] = yAdvance;
- nfo->glyphs->advances_x[i] = xAdvance;
+ nfo->glyphs->advances_y[i] = yAdvance;
+ nfo->glyphs->advances_x[i] = xAdvance;
+ }
} else {
// ATSUI gives us 0xffff as glyph id at the index in the glyph array for
// a character position that maps to a ligtature. Such a glyph id does not
@@ -988,6 +1031,8 @@ bool QFontEngineMacMulti::stringToCMapInternal(const QChar *str, int len, QGlyph
nfo.flags = flags;
nfo.shaperItem = shaperItem;
+ int prevNumGlyphs = *nglyphs;
+
QVarLengthArray<int> mappedFonts(len);
for (int i = 0; i < len; ++i)
mappedFonts[i] = 0;
@@ -1014,6 +1059,8 @@ bool QFontEngineMacMulti::stringToCMapInternal(const QChar *str, int len, QGlyph
| kATSLineDisableAllJustification
;
+ layopts |= kATSLineUseDeviceMetrics;
+
if (fontDef.styleStrategy & QFont::NoAntialias)
layopts |= kATSLineNoAntiAliasing;
@@ -1097,6 +1144,8 @@ bool QFontEngineMacMulti::stringToCMapInternal(const QChar *str, int len, QGlyph
}
ATSUClearLayoutCache(textLayout, kATSUFromTextBeginning);
+ if (prevNumGlyphs < *nfo.numGlyphs)
+ return false;
return true;
}
@@ -1502,19 +1551,7 @@ QImage QFontEngineMac::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTra
im = im.transformed(t);
}
- extern uchar qt_pow_rgb_gamma[256];
-
- // gamma correct the pixels back to linear color space...
- for (int y=0; y<im.height(); ++y) {
- uint *pixels = (uint *) im.scanLine(y);
- for (int x=0; x<im.width(); ++x) {
- uint p = pixels[x];
- uint r = qt_pow_rgb_gamma[qRed(p)];
- uint g = qt_pow_rgb_gamma[qGreen(p)];
- uint b = qt_pow_rgb_gamma[qBlue(p)];
- pixels[x] = (r << 16) | (g << 8) | b | 0xff000000;
- }
- }
+ qmacfontengine_gamma_correct(&im);
return im;
}
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 8818e4f60..728c344b5 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -70,7 +70,7 @@
# include "private/qcore_mac_p.h"
#endif
-#include "qfontengineglyphcache_p.h"
+#include <private/qfontengineglyphcache_p.h>
struct glyph_metrics_t;
typedef unsigned int glyph_t;
@@ -112,6 +112,10 @@ public:
QPF1,
QPF2,
Proxy,
+
+ // S60 types
+ S60FontEngine, // Cannot be simply called "S60". Reason is qt_s60Data.h
+
TestFontEngine = 0x1000
};
@@ -163,7 +167,7 @@ public:
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const {}
virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
-#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
+#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN)
virtual void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si) = 0;
#endif
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
@@ -230,7 +234,7 @@ public:
bool symbol;
mutable HB_FontRec hbFont;
mutable HB_Face hbFace;
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
struct KernPair {
uint left_right;
QFixed adjust;
@@ -246,6 +250,9 @@ public:
int glyphFormat;
+protected:
+ static const QVector<QRgb> &grayPalette();
+
private:
/// remove old entries from the glyph cache. Helper method for the setGlyphCache ones.
void expireGlyphCache();
@@ -321,7 +328,7 @@ public:
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
-#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
+#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN)
void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si);
#endif
virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags);
@@ -441,12 +448,13 @@ public:
virtual bool getSfntTableData(uint /*tag*/, uchar * /*buffer*/, uint * /*length*/) const;
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
virtual QImage alphaMapForGlyph(glyph_t);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t);
virtual qreal minRightBearing() const;
virtual qreal minLeftBearing() const;
-
private:
+ QImage imageForGlyph(glyph_t glyph, int margin, bool colorful);
CTFontRef ctfont;
CGFontRef cgFont;
QCoreTextFontEngineMulti *parentEngine;
@@ -618,4 +626,8 @@ QT_END_NAMESPACE
# include "private/qfontengine_win_p.h"
#endif
+#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
+# include "private/qfontengine_ft_p.h"
+#endif
+
#endif // QFONTENGINE_P_H
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index b5cfb2ca7..f978bd897 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -66,9 +66,10 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_QWS_QPF2
-QT_BEGIN_INCLUDE_NAMESPACE
#include "qpfutil.cpp"
+QT_BEGIN_INCLUDE_NAMESPACE
+
#if defined(Q_WS_QWS)
# include "private/qwscommand_qws_p.h"
# include "qwsdisplay_qws.h"
@@ -326,17 +327,17 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng
fileName.replace(QLatin1Char(' '), QLatin1Char('_'));
fileName.prepend(qws_fontCacheDir());
- const QByteArray encodedName = QFile::encodeName(fileName);
- if (::access(encodedName, F_OK) == 0) {
+ encodedFileName = QFile::encodeName(fileName);
+ if (::access(encodedFileName, F_OK) == 0) {
#if defined(DEBUG_FONTENGINE)
qDebug() << "found existing qpf:" << fileName;
#endif
- if (::access(encodedName, W_OK | R_OK) == 0) {
- fd = QT_OPEN(encodedName, O_RDWR);
+ if (::access(encodedFileName, W_OK | R_OK) == 0) {
+ fd = QT_OPEN(encodedFileName, O_RDWR);
}
// read-write access failed - try read-only access
- if (fd == -1 && ::access(encodedName, R_OK) == 0) {
- fd = QT_OPEN(encodedName, O_RDONLY);
+ if (fd == -1 && ::access(encodedFileName, R_OK) == 0) {
+ fd = QT_OPEN(encodedFileName, O_RDONLY);
if (fd == -1) {
#if defined(DEBUG_FONTENGINE)
qErrnoWarning("QFontEngineQPF: unable to open %s", encodedName.constData());
@@ -355,7 +356,7 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng
qDebug() << "creating qpf on the fly:" << fileName;
#endif
if (::access(QFile::encodeName(qws_fontCacheDir()), W_OK) == 0) {
- fd = QT_OPEN(encodedName, O_RDWR | O_EXCL | O_CREAT, 0644);
+ fd = QT_OPEN(encodedFileName, O_RDWR | O_EXCL | O_CREAT, 0644);
if (fd == -1) {
#if defined(DEBUG_FONTENGINE)
qErrnoWarning(errno, "QFontEngineQPF: open() failed for %s", encodedName.constData());
@@ -506,15 +507,21 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng
#endif
#if defined(Q_WS_QWS)
if (isValid() && renderingFontEngine)
- qt_fbdpy->sendFontCommand(QWSFontCommand::StartedUsingFont, QFile::encodeName(fileName));
+ qt_fbdpy->sendFontCommand(QWSFontCommand::StartedUsingFont, encodedFileName);
#endif
}
QFontEngineQPF::~QFontEngineQPF()
{
#if defined(Q_WS_QWS)
- if (isValid() && renderingFontEngine)
- qt_fbdpy->sendFontCommand(QWSFontCommand::StoppedUsingFont, QFile::encodeName(fileName));
+ if (isValid() && renderingFontEngine) {
+ QT_TRY {
+ qt_fbdpy->sendFontCommand(QWSFontCommand::StoppedUsingFont, encodedFileName);
+ } QT_CATCH(...) {
+ qDebug("QFontEngineQPF::~QFontEngineQPF: Out of memory");
+ // ignore.
+ }
+ }
#endif
delete renderingFontEngine;
if (fontData) {
@@ -621,13 +628,13 @@ QImage QFontEngineQPF::alphaMapForGlyph(glyph_t g)
{
const Glyph *glyph = findGlyph(g);
if (!glyph)
- QImage();
+ return QImage();
const uchar *bits = ((const uchar *) glyph) + sizeof(Glyph);
QImage image(glyph->width, glyph->height, QImage::Format_Indexed8);
for (int j=0; j<256; ++j)
- image.setColor(j, 0xff000000 | j | (j<<8) | (j<<16));
+ image.setColor(j, qRgba(0, 0, 0, j));
for (int i=0; i<glyph->height; ++i) {
memcpy(image.scanLine(i), bits, glyph->bytesPerLine);
@@ -812,7 +819,7 @@ FT_Face QFontEngineQPF::lockFace() const
FT_Face face = freetype->face;
// ### not perfect
- const int ysize = fontDef.pixelSize << 6;
+ const int ysize = qRound(fontDef.pixelSize * qreal(64));
const int xsize = ysize;
if (freetype->xsize != xsize || freetype->ysize != ysize) {
@@ -931,7 +938,7 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph)
g.advance = qRound(metrics.xoff);
QT_WRITE(fd, &g, sizeof(g));
- QT_WRITE(fd, img.bits(), img.numBytes());
+ QT_WRITE(fd, img.bits(), img.byteCount());
glyphPos = oldSize - glyphDataOffset;
#if 0 && defined(DEBUG_FONTENGINE)
@@ -941,7 +948,7 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph)
quint32 *gmap = (quint32 *)(fontData + glyphMapOffset);
gmap[glyph] = qToBigEndian(glyphPos);
- glyphDataSize = glyphPos + sizeof(g) + img.numBytes();
+ glyphDataSize = glyphPos + sizeof(g) + img.byteCount();
quint32 *blockSizePtr = (quint32 *)(fontData + glyphDataOffset - 4);
*blockSizePtr = qToBigEndian(glyphDataSize);
}
@@ -1165,6 +1172,11 @@ void QPFGenerator::writeTaggedQFixed(QFontEngineQPF::HeaderTag tag, QFixed value
#endif // QT_NO_QWS_QPF2
+/*
+ Creates a new multi qws engine.
+
+ This function takes ownership of the QFontEngine, increasing it's refcount.
+*/
QFontEngineMultiQWS::QFontEngineMultiQWS(QFontEngine *fe, int _script, const QStringList &fallbacks)
: QFontEngineMulti(fallbacks.size() + 1),
fallbackFamilies(fallbacks), script(_script)
diff --git a/src/gui/text/qfontengine_qpf_p.h b/src/gui/text/qfontengine_qpf_p.h
index 7c8e3a446..e22c1846d 100644
--- a/src/gui/text/qfontengine_qpf_p.h
+++ b/src/gui/text/qfontengine_qpf_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -243,6 +243,7 @@ private:
quint32 glyphDataOffset;
quint32 glyphDataSize;
QString fileName;
+ QByteArray encodedFileName;
bool readOnly;
QFreetypeFace *freetype;
diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp
index dc926cb8d..de8028c25 100644
--- a/src/gui/text/qfontengine_qws.cpp
+++ b/src/gui/text/qfontengine_qws.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -381,6 +381,8 @@ class QFontEngineQPF1Data
public:
QPFFontMetrics fm;
QPFGlyphTree *tree;
+ void *mmapStart;
+ size_t mmapLength;
};
@@ -410,6 +412,8 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn)
QT_CLOSE(f);
d = new QFontEngineQPF1Data;
+ d->mmapStart = data;
+ d->mmapLength = st.st_size;
memcpy(reinterpret_cast<char*>(&d->fm),data,sizeof(d->fm));
data += sizeof(d->fm);
@@ -431,6 +435,8 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn)
QFontEngineQPF1::~QFontEngineQPF1()
{
+ if (d->mmapStart)
+ munmap(d->mmapStart, d->mmapLength);
delete d->tree;
delete d;
}
@@ -522,10 +528,12 @@ QImage QFontEngineQPF1::alphaMapForGlyph(glyph_t g)
QImage image;
if (mono) {
image = QImage((glyph->metrics->width+7)&~7, glyph->metrics->height, QImage::Format_Mono);
+ image.setColor(0, qRgba(0, 0, 0, 0));
+ image.setColor(1, qRgba(0, 0, 0, 255));
} else {
image = QImage(glyph->metrics->width, glyph->metrics->height, QImage::Format_Indexed8);
for (int j=0; j<256; ++j)
- image.setColor(j, 0xff000000 | j | (j<<8) | (j<<16));
+ image.setColor(j, qRgba(0, 0, 0, j));
}
for (int i=0; i<glyph->metrics->height; ++i) {
memcpy(image.scanLine(i), bits, glyph->metrics->linestep);
diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp
new file mode 100644
index 000000000..e279ad227
--- /dev/null
+++ b/src/gui/text/qfontengine_s60.cpp
@@ -0,0 +1,336 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qfontengine_s60_p.h"
+#include "qtextengine_p.h"
+#include "qglobal.h"
+#include <private/qapplication_p.h>
+#include "qimage.h"
+#include "qt_s60_p.h"
+#include "qpixmap_s60_p.h"
+
+#include <e32base.h>
+#include <e32std.h>
+#include <EIKENV.H>
+#include <GDI.H>
+
+QT_BEGIN_NAMESPACE
+
+QFontEngineS60Extensions::QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font)
+ : m_font(font)
+ , m_cmap(0)
+ , m_symbolCMap(false)
+ , m_fontOwner(fontOwner)
+{
+ TAny *shapingExtension = NULL;
+ m_font->ExtendedInterface(KUidOpenFontShapingExtension, shapingExtension);
+ m_shapingExtension = static_cast<MOpenFontShapingExtension*>(shapingExtension);
+ TAny *trueTypeExtension = NULL;
+ m_font->ExtendedInterface(KUidOpenFontTrueTypeExtension, trueTypeExtension);
+ m_trueTypeExtension = static_cast<MOpenFontTrueTypeExtension*>(trueTypeExtension);
+ Q_ASSERT(m_shapingExtension && m_trueTypeExtension);
+}
+
+QByteArray QFontEngineS60Extensions::getSfntTable(uint tag) const
+{
+ Q_ASSERT(m_trueTypeExtension->HasTrueTypeTable(tag));
+ TInt error = KErrNone;
+ TInt tableByteLength = 0;
+ TAny *table = q_check_ptr(m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength));
+ QByteArray result(static_cast<const char*>(table), tableByteLength);
+ m_trueTypeExtension->ReleaseTrueTypeTable(table);
+ return result;
+}
+
+const unsigned char *QFontEngineS60Extensions::cmap() const
+{
+ if (!m_cmap) {
+ m_cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p'));
+ int size = 0;
+ m_cmap = QFontEngineS60::getCMap(reinterpret_cast<const uchar *>(m_cmapTable.constData()), m_cmapTable.size(), &m_symbolCMap, &size);
+ }
+ return m_cmap;
+}
+
+QPainterPath QFontEngineS60Extensions::glyphOutline(glyph_t glyph) const
+{
+ QPainterPath result;
+ QPolygonF polygon;
+ TInt glyphIndex = glyph;
+ TInt pointNumber = 0;
+ TInt x, y;
+ while (m_shapingExtension->GlyphPointInFontUnits(glyphIndex, pointNumber++, x, y)) {
+ const QPointF point(qreal(x) / 0xffff, qreal(y) / 0xffff);
+ if (polygon.contains(point)) {
+ result.addPolygon(polygon);
+ result.closeSubpath();
+ polygon.clear();
+ } else {
+ polygon.append(point);
+ }
+ }
+ return result;
+}
+
+CFont *QFontEngineS60Extensions::fontOwner() const
+{
+ return m_fontOwner;
+}
+
+
+// duplicated from qfontengine_xyz.cpp
+static inline unsigned int getChar(const QChar *str, int &i, const int len)
+{
+ unsigned int uc = str[i].unicode();
+ if (uc >= 0xd800 && uc < 0xdc00 && i < len-1) {
+ uint low = str[i+1].unicode();
+ if (low >= 0xdc00 && low < 0xe000) {
+ uc = (uc - 0xd800)*0x400 + (low - 0xdc00) + 0x10000;
+ ++i;
+ }
+ }
+ return uc;
+}
+
+QFontEngineS60::QFontEngineS60(const QFontDef &request, const QFontEngineS60Extensions *extensions)
+ : m_extensions(extensions)
+{
+ QFontEngine::fontDef = request;
+ m_fontSizeInPixels = (request.pixelSize >= 0)?
+ request.pixelSize:pointsToPixels(request.pointSize);
+
+ QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
+
+ m_textRenderBitmap = q_check_ptr(new CFbsBitmap()); // CBase derived object needs check on new
+ const TSize bitmapSize(1, 1); // It is just a dummy bitmap that I need to keep the font alive (or maybe not)
+ qt_symbian_throwIfError(m_textRenderBitmap->Create(bitmapSize, EGray256));
+ QT_TRAP_THROWING(m_textRenderBitmapDevice = CFbsBitmapDevice::NewL(m_textRenderBitmap));
+ qt_symbian_throwIfError(m_textRenderBitmapDevice->CreateContext(m_textRenderBitmapGc));
+ cache_cost = sizeof(QFontEngineS60) + bitmapSize.iHeight * bitmapSize.iWidth * 4;
+
+ TFontSpec fontSpec(qt_QString2TPtrC(request.family), m_fontSizeInPixels);
+ fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
+ fontSpec.iFontStyle.SetPosture(request.style == QFont::StyleNormal?EPostureUpright:EPostureItalic);
+ fontSpec.iFontStyle.SetStrokeWeight(request.weight > QFont::Normal?EStrokeWeightBold:EStrokeWeightNormal);
+ const TInt errorCode = m_textRenderBitmapDevice->GetNearestFontInPixels(m_font, fontSpec);
+ Q_ASSERT(errorCode == 0);
+ m_textRenderBitmapGc->UseFont(m_font);
+
+ lock.relock();
+}
+
+QFontEngineS60::~QFontEngineS60()
+{
+ QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
+
+ m_textRenderBitmapGc->DiscardFont();
+ delete m_textRenderBitmapGc;
+ m_textRenderBitmapGc = NULL;
+ m_textRenderBitmapDevice->ReleaseFont(m_font);
+ delete m_textRenderBitmapDevice;
+ m_textRenderBitmapDevice = NULL;
+ delete m_textRenderBitmap;
+ m_textRenderBitmap = NULL;
+
+ lock.relock();
+}
+
+bool QFontEngineS60::stringToCMap(const QChar *characters, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
+{
+ if (*nglyphs < len) {
+ *nglyphs = len;
+ return false;
+ }
+
+ HB_Glyph *g = glyphs->glyphs;
+ const unsigned char* cmap = m_extensions->cmap();
+ for (int i = 0; i < len; ++i) {
+ const unsigned int uc = getChar(characters, i, len);
+ *g++ = QFontEngine::getTrueTypeGlyphIndex(cmap, uc);
+ }
+
+ glyphs->numGlyphs = g - glyphs->glyphs;
+ *nglyphs = glyphs->numGlyphs;
+
+ if (flags & QTextEngine::GlyphIndicesOnly)
+ return true;
+
+ recalcAdvances(glyphs, flags);
+ return true;
+}
+
+void QFontEngineS60::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
+{
+ Q_UNUSED(flags);
+ for (int i = 0; i < glyphs->numGlyphs; i++) {
+ const glyph_metrics_t bbox = boundingBox_const(glyphs->glyphs[i]);
+ glyphs->advances_x[i] = glyphs->offsets[i].x = bbox.xoff;
+ glyphs->advances_y[i] = glyphs->offsets[i].y = bbox.yoff;
+ }
+}
+
+QImage QFontEngineS60::alphaMapForGlyph(glyph_t glyph)
+{
+ TOpenFontCharMetrics metrics;
+ const TUint8 *glyphBitmapBytes;
+ TSize glyphBitmapSize;
+ getCharacterData(glyph, metrics, glyphBitmapBytes, glyphBitmapSize);
+ QImage result(glyphBitmapBytes, glyphBitmapSize.iWidth, glyphBitmapSize.iHeight, glyphBitmapSize.iWidth, QImage::Format_Indexed8);
+ result.setColorTable(grayPalette());
+
+ // The above setColorTable() call detached the image data anyway, so why not shape tha data a bit, while we can.
+ // CFont::GetCharacterData() returns 8-bit data that obviously was 4-bit data before, and converted to 8-bit incorrectly.
+ // The data values are 0x00, 0x10 ... 0xe0, 0xf0. So, a real opaque 0xff is never reached, which we get punished
+ // for every time we want to blit this glyph in the raster paint engine.
+ // "Fix" is to convert all 0xf0 to 0xff. Is fine, quality wise, and I assume faster than correcting all values.
+ // Blitting is however, evidentially faster now.
+ const int bpl = result.bytesPerLine();
+ for (int row = 0; row < result.height(); ++row) {
+ uchar *scanLine = result.scanLine(row);
+ for (int column = 0; column < bpl; ++column) {
+ if (*scanLine == 0xf0)
+ *scanLine = 0xff;
+ scanLine++;
+ }
+ }
+
+ return result;
+}
+
+glyph_metrics_t QFontEngineS60::boundingBox(const QGlyphLayout &glyphs)
+{
+ if (glyphs.numGlyphs == 0)
+ return glyph_metrics_t();
+
+ QFixed w = 0;
+ for (int i = 0; i < glyphs.numGlyphs; ++i)
+ w += glyphs.effectiveAdvance(i);
+
+ return glyph_metrics_t(0, -ascent(), w, ascent()+descent()+1, w, 0);
+}
+
+glyph_metrics_t QFontEngineS60::boundingBox_const(glyph_t glyph) const
+{
+ TOpenFontCharMetrics metrics;
+ const TUint8 *glyphBitmapBytes;
+ TSize glyphBitmapSize;
+ getCharacterData(glyph, metrics, glyphBitmapBytes, glyphBitmapSize);
+ TRect glyphBounds;
+ metrics.GetHorizBounds(glyphBounds);
+ const glyph_metrics_t result(
+ glyphBounds.iTl.iX,
+ glyphBounds.iTl.iY,
+ glyphBounds.Width(),
+ glyphBounds.Height(),
+ metrics.HorizAdvance(),
+ 0
+ );
+ return result;
+}
+
+glyph_metrics_t QFontEngineS60::boundingBox(glyph_t glyph)
+{
+ return boundingBox_const(glyph);
+}
+
+QFixed QFontEngineS60::ascent() const
+{
+ return m_font->FontMaxAscent();
+}
+
+QFixed QFontEngineS60::descent() const
+{
+ return m_font->FontMaxDescent();
+}
+
+QFixed QFontEngineS60::leading() const
+{
+ return 0;
+}
+
+qreal QFontEngineS60::maxCharWidth() const
+{
+ return m_font->MaxCharWidthInPixels();
+}
+
+const char *QFontEngineS60::name() const
+{
+ return "QFontEngineS60";
+}
+
+bool QFontEngineS60::canRender(const QChar *string, int len)
+{
+ const unsigned char *cmap = m_extensions->cmap();
+ for (int i = 0; i < len; ++i) {
+ const unsigned int uc = getChar(string, i, len);
+ if (QFontEngine::getTrueTypeGlyphIndex(cmap, uc) == 0)
+ return false;
+ }
+ return true;
+}
+
+QByteArray QFontEngineS60::getSfntTable(uint tag) const
+{
+ return m_extensions->getSfntTable(tag);
+}
+
+QFontEngine::Type QFontEngineS60::type() const
+{
+ return QFontEngine::S60FontEngine;
+}
+
+void QFontEngineS60::getCharacterData(glyph_t glyph, TOpenFontCharMetrics& metrics, const TUint8*& bitmap, TSize& bitmapSize) const
+{
+ // Setting the most significant bit tells GetCharacterData
+ // that 'code' is a Glyph ID, rather than a UTF-16 value
+ const TUint specialCode = (TUint)glyph | 0x80000000;
+
+ const CFont::TCharacterDataAvailability availability =
+ m_font->GetCharacterData(specialCode, metrics, bitmap, bitmapSize);
+ const glyph_t fallbackGlyph = '?';
+ if (availability != CFont::EAllCharacterData) {
+ const CFont::TCharacterDataAvailability fallbackAvailability =
+ m_font->GetCharacterData(fallbackGlyph, metrics, bitmap, bitmapSize);
+ Q_ASSERT(fallbackAvailability == CFont::EAllCharacterData);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h
new file mode 100644
index 000000000..9e2224557
--- /dev/null
+++ b/src/gui/text/qfontengine_s60_p.h
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFONTENGINE_S60_P_H
+#define QFONTENGINE_S60_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qconfig.h"
+#include "qfontengine_p.h"
+#include "qsize.h"
+#include <OPENFONT.H>
+
+class CFbsBitmap;
+class CFbsBitmapDevice;
+class CFbsBitGc;
+class CFont;
+
+QT_BEGIN_NAMESPACE
+
+// ..gives us access to truetype tables, UTF-16<->GlyphID mapping, and glyph outlines
+class QFontEngineS60Extensions
+{
+public:
+ QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font);
+
+ QByteArray getSfntTable(uint tag) const;
+ const unsigned char *cmap() const;
+ QPainterPath glyphOutline(glyph_t glyph) const;
+ CFont *fontOwner() const;
+
+private:
+ COpenFont *m_font;
+ const MOpenFontShapingExtension *m_shapingExtension;
+ mutable MOpenFontTrueTypeExtension *m_trueTypeExtension;
+ mutable const unsigned char *m_cmap;
+ mutable bool m_symbolCMap;
+ mutable QByteArray m_cmapTable;
+ CFont* m_fontOwner;
+};
+
+class QFontEngineS60 : public QFontEngine
+{
+public:
+ QFontEngineS60(const QFontDef &fontDef, const QFontEngineS60Extensions *extensions);
+ ~QFontEngineS60();
+
+ bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
+ void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const;
+
+ QImage alphaMapForGlyph(glyph_t glyph);
+
+ glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
+ glyph_metrics_t boundingBox_const(glyph_t glyph) const; // Const correctnes quirk.
+ glyph_metrics_t boundingBox(glyph_t glyph);
+
+ QFixed ascent() const;
+ QFixed descent() const;
+ QFixed leading() const;
+ qreal maxCharWidth() const;
+ qreal minLeftBearing() const { return 0; }
+ qreal minRightBearing() const { return 0; }
+
+ QByteArray getSfntTable(uint tag) const;
+
+ static qreal pixelsToPoints(qreal pixels, Qt::Orientation orientation = Qt::Horizontal);
+ static qreal pointsToPixels(qreal points, Qt::Orientation orientation = Qt::Horizontal);
+
+ const char *name() const;
+
+ bool canRender(const QChar *string, int len);
+
+ Type type() const;
+
+ void getCharacterData(glyph_t glyph, TOpenFontCharMetrics& metrics, const TUint8*& bitmap, TSize& bitmapSize) const;
+
+private:
+ friend class QFontPrivate;
+
+ QFixed glyphAdvance(HB_Glyph glyph) const;
+
+ CFbsBitmap *m_textRenderBitmap;
+ CFbsBitmapDevice *m_textRenderBitmapDevice;
+ CFbsBitGc *m_textRenderBitmapGc;
+ CFont* m_font;
+ const QFontEngineS60Extensions *m_extensions;
+ qreal m_fontSizeInPixels;
+};
+
+class QFontEngineMultiS60 : public QFontEngineMulti
+{
+public:
+ QFontEngineMultiS60(QFontEngine *first, int script, const QStringList &fallbackFamilies);
+ void loadEngine(int at);
+
+ int m_script;
+ QStringList m_fallbackFamilies;
+};
+
+QT_END_NAMESPACE
+
+#endif // QFONTENGINE_S60_P_H
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index ac2428eaa..7ec8e31b4 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -125,6 +125,7 @@ HDC shared_dc()
}
#endif
+#ifndef Q_WS_WINCE
typedef BOOL (WINAPI *PtrGetCharWidthI)(HDC, UINT, UINT, LPWORD, LPINT);
static PtrGetCharWidthI ptrGetCharWidthI = 0;
static bool resolvedGetCharWidthI = false;
@@ -136,6 +137,7 @@ static void resolveGetCharWidthI()
resolvedGetCharWidthI = true;
ptrGetCharWidthI = (PtrGetCharWidthI)QLibrary::resolve(QLatin1String("gdi32"), "GetCharWidthI");
}
+#endif // !defined(Q_WS_WINCE)
// defined in qtextengine_win.cpp
typedef void *SCRIPT_CACHE;
@@ -206,7 +208,7 @@ void QFontEngineWin::getCMap()
unitsPerEm = otm->otmEMSquare;
x_height = (int)otm->otmsXHeight;
loadKerningPairs(designToDevice);
- _faceId.filename = (char *)otm + (int)otm->otmpFullName;
+ _faceId.filename = QString::fromWCharArray((wchar_t *)((char *)otm + (int)otm->otmpFullName)).toLatin1();
lineWidth = otm->otmsUnderscoreSize;
fsType = otm->otmfsType;
free(otm);
@@ -327,8 +329,10 @@ QFontEngineWin::QFontEngineWin(const QString &name, HFONT _hfont, bool stockFont
BOOL res = GetTextMetrics(hdc, &tm);
fontDef.fixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
- if (!res)
+ if (!res) {
qErrnoWarning("QFontEngineWin: GetTextMetrics failed");
+ ZeroMemory(&tm, sizeof(TEXTMETRIC));
+ }
cache_cost = tm.tmHeight * tm.tmAveCharWidth * 2000;
getCMap();
@@ -338,8 +342,10 @@ QFontEngineWin::QFontEngineWin(const QString &name, HFONT _hfont, bool stockFont
designAdvances = 0;
designAdvancesSize = 0;
+#ifndef Q_WS_WINCE
if (!resolvedGetCharWidthI)
resolveGetCharWidthI();
+#endif
}
QFontEngineWin::~QFontEngineWin()
@@ -379,79 +385,18 @@ bool QFontEngineWin::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph
if (flags & QTextEngine::GlyphIndicesOnly)
return true;
-#if defined(Q_WS_WINCE)
- HDC hdc = shared_dc();
- if (flags & QTextEngine::DesignMetrics) {
- HGDIOBJ oldFont = 0;
- int glyph_pos = 0;
- for(register int i = 0; i < len; i++) {
- bool surrogate = (str[i].unicode() >= 0xd800 && str[i].unicode() < 0xdc00 && i < len-1
- && str[i+1].unicode() >= 0xdc00 && str[i+1].unicode() < 0xe000);
- unsigned int glyph = glyphs->glyphs[glyph_pos];
- if(int(glyph) >= designAdvancesSize) {
- int newSize = (glyph + 256) >> 8 << 8;
- designAdvances = (QFixed *)realloc(designAdvances, newSize*sizeof(QFixed));
- for(int i = designAdvancesSize; i < newSize; ++i)
- designAdvances[i] = -1000000;
- designAdvancesSize = newSize;
- }
- if(designAdvances[glyph] < -999999) {
- if(!oldFont)
- oldFont = selectDesignFont();
- SIZE size = {0, 0};
- GetTextExtentPoint32(hdc, (wchar_t *)(str+i), surrogate ? 2 : 1, &size);
- designAdvances[glyph] = QFixed((int)size.cx)/designToDevice;
- }
- glyphs->advances_x[glyph_pos] = designAdvances[glyph];
- glyphs->advances_y[glyph_pos] = 0;
- if (surrogate)
- ++i;
- ++glyph_pos;
- }
- if(oldFont)
- DeleteObject(SelectObject(hdc, oldFont));
- } else {
- int glyph_pos = 0;
- HGDIOBJ oldFont = 0;
-
- for(register int i = 0; i < len; i++) {
- bool surrogate = (str[i].unicode() >= 0xd800 && str[i].unicode() < 0xdc00 && i < len-1
- && str[i+1].unicode() >= 0xdc00 && str[i+1].unicode() < 0xe000);
- unsigned int glyph = glyphs->glyphs[glyph_pos];
-
- glyphs->advances_y[glyph_pos] = 0;
-
- if (glyph >= widthCacheSize) {
- int newSize = (glyph + 256) >> 8 << 8;
- widthCache = (unsigned char *)realloc(widthCache, newSize*sizeof(QFixed));
- memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize);
- widthCacheSize = newSize;
- }
- glyphs->advances_x[glyph_pos] = widthCache[glyph];
- // font-width cache failed
- if (glyphs->advances_x[glyph_pos] == 0) {
- SIZE size = {0, 0};
- if (!oldFont)
- oldFont = SelectObject(hdc, hfont);
- GetTextExtentPoint32(hdc, (wchar_t *)str + i, surrogate ? 2 : 1, &size);
- glyphs->advances_x[glyph_pos] = size.cx;
- // if glyph's within cache range, store it for later
- if (size.cx > 0 && size.cx < 0x100)
- widthCache[glyph] = size.cx;
- }
-
- if (surrogate)
- ++i;
- ++glyph_pos;
- }
+ recalcAdvances(glyphs, flags);
+ return true;
+}
- if (oldFont)
- SelectObject(hdc, oldFont);
- }
+inline void calculateTTFGlyphWidth(HDC hdc, UINT glyph, int &width)
+{
+#if defined(Q_WS_WINCE)
+ GetCharWidth32(hdc, glyph, glyph, &width);
#else
- recalcAdvances(glyphs, flags);
+ if (ptrGetCharWidthI)
+ ptrGetCharWidthI(hdc, glyph, 1, 0, &width);
#endif
- return true;
}
void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
@@ -463,7 +408,8 @@ void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla
unsigned int glyph = glyphs->glyphs[i];
if(int(glyph) >= designAdvancesSize) {
int newSize = (glyph + 256) >> 8 << 8;
- designAdvances = (QFixed *)realloc(designAdvances, newSize*sizeof(QFixed));
+ designAdvances = q_check_ptr((QFixed *)realloc(designAdvances,
+ newSize*sizeof(QFixed)));
for(int i = designAdvancesSize; i < newSize; ++i)
designAdvances[i] = -1000000;
designAdvancesSize = newSize;
@@ -473,8 +419,7 @@ void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla
oldFont = selectDesignFont();
int width = 0;
- if (ptrGetCharWidthI)
- ptrGetCharWidthI(hdc, glyph, 1, 0, &width);
+ calculateTTFGlyphWidth(hdc, glyph, width);
designAdvances[glyph] = QFixed(width) / designToDevice;
}
glyphs->advances_x[i] = designAdvances[glyph];
@@ -490,7 +435,8 @@ void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla
if (glyph >= widthCacheSize) {
int newSize = (glyph + 256) >> 8 << 8;
- widthCache = (unsigned char *)realloc(widthCache, newSize*sizeof(QFixed));
+ widthCache = q_check_ptr((unsigned char *)realloc(widthCache,
+ newSize*sizeof(QFixed)));
memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize);
widthCacheSize = newSize;
}
@@ -512,8 +458,8 @@ void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla
SIZE size = {0, 0};
GetTextExtentPoint32(hdc, (wchar_t *)ch, chrLen, &size);
width = size.cx;
- } else if (ptrGetCharWidthI) {
- ptrGetCharWidthI(hdc, glyph, 1, 0, &width);
+ } else {
+ calculateTTFGlyphWidth(hdc, glyph, width);
}
glyphs->advances_x[i] = width;
// if glyph's within cache range, store it for later
@@ -539,61 +485,80 @@ glyph_metrics_t QFontEngineWin::boundingBox(const QGlyphLayout &glyphs)
return glyph_metrics_t(0, -tm.tmAscent, w, tm.tmHeight, w, 0);
}
+#ifndef Q_WS_WINCE
+bool QFontEngineWin::getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const
+{
+ Q_ASSERT(metrics != 0);
+
+ HDC hdc = shared_dc();
+
+ GLYPHMETRICS gm;
+ DWORD res = 0;
+ MAT2 mat;
+ mat.eM11.value = mat.eM22.value = 1;
+ mat.eM11.fract = mat.eM22.fract = 0;
+ mat.eM21.value = mat.eM12.value = 0;
+ mat.eM21.fract = mat.eM12.fract = 0;
+
+ if (t.type() > QTransform::TxTranslate) {
+ // We need to set the transform using the HDC's world
+ // matrix rather than using the MAT2 above, because the
+ // results provided when transforming via MAT2 does not
+ // match the glyphs that are drawn using a WorldTransform
+ XFORM xform;
+ xform.eM11 = t.m11();
+ xform.eM12 = t.m12();
+ xform.eM21 = t.m21();
+ xform.eM22 = t.m22();
+ xform.eDx = 0;
+ xform.eDy = 0;
+ SetGraphicsMode(hdc, GM_ADVANCED);
+ SetWorldTransform(hdc, &xform);
+ }
+
+ uint format = GGO_METRICS;
+ if (ttf)
+ format |= GGO_GLYPH_INDEX;
+ res = GetGlyphOutline(hdc, glyph, format, &gm, 0, 0, &mat);
+
+ if (t.type() > QTransform::TxTranslate) {
+ XFORM xform;
+ xform.eM11 = xform.eM22 = 1;
+ xform.eM12 = xform.eM21 = xform.eDx = xform.eDy = 0;
+ SetWorldTransform(hdc, &xform);
+ SetGraphicsMode(hdc, GM_COMPATIBLE);
+ }
+
+ if (res != GDI_ERROR) {
+ *metrics = glyph_metrics_t(gm.gmptGlyphOrigin.x, -gm.gmptGlyphOrigin.y,
+ (int)gm.gmBlackBoxX, (int)gm.gmBlackBoxY, gm.gmCellIncX, gm.gmCellIncY);
+ return true;
+ } else {
+ return false;
+ }
+}
+#endif
glyph_metrics_t QFontEngineWin::boundingBox(glyph_t glyph, const QTransform &t)
{
#ifndef Q_WS_WINCE
- GLYPHMETRICS gm;
-
HDC hdc = shared_dc();
SelectObject(hdc, hfont);
- if (!ttf) {
+
+ glyph_metrics_t glyphMetrics;
+ bool success = getOutlineMetrics(glyph, t, &glyphMetrics);
+
+ if (!ttf && !success) {
+ // Bitmap fonts
wchar_t ch = glyph;
ABCFLOAT abc;
GetCharABCWidthsFloat(hdc, ch, ch, &abc);
int width = qRound(abc.abcfB);
- return glyph_metrics_t(0, -tm.tmAscent, width, tm.tmHeight, width, 0).transformed(t);
- } else {
- DWORD res = 0;
- MAT2 mat;
- mat.eM11.value = mat.eM22.value = 1;
- mat.eM11.fract = mat.eM22.fract = 0;
- mat.eM21.value = mat.eM12.value = 0;
- mat.eM21.fract = mat.eM12.fract = 0;
-
- if (t.type() > QTransform::TxTranslate) {
- // We need to set the transform using the HDC's world
- // matrix rather than using the MAT2 above, because the
- // results provided when transforming via MAT2 does not
- // match the glyphs that are drawn using a WorldTransform
- XFORM xform;
- xform.eM11 = t.m11();
- xform.eM12 = t.m12();
- xform.eM21 = t.m21();
- xform.eM22 = t.m22();
- xform.eDx = 0;
- xform.eDy = 0;
- SetGraphicsMode(hdc, GM_ADVANCED);
- SetWorldTransform(hdc, &xform);
- }
-
- res = GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, 0, &mat);
-
- if (t.type() > QTransform::TxTranslate) {
- XFORM xform;
- xform.eM11 = xform.eM22 = 1;
- xform.eM12 = xform.eM21 = xform.eDx = xform.eDy = 0;
- SetWorldTransform(hdc, &xform);
- SetGraphicsMode(hdc, GM_COMPATIBLE);
- }
-
- if (res != GDI_ERROR) {
- return glyph_metrics_t(gm.gmptGlyphOrigin.x, -gm.gmptGlyphOrigin.y,
- (int)gm.gmBlackBoxX, (int)gm.gmBlackBoxY, gm.gmCellIncX, gm.gmCellIncY);
- }
+ return glyph_metrics_t(QFixed::fromReal(abc.abcfA), -tm.tmAscent, width, tm.tmHeight, width, 0).transformed(t);
}
- return glyph_metrics_t();
+
+ return glyphMetrics;
#else
HDC hdc = shared_dc();
HGDIOBJ oldFont = SelectObject(hdc, hfont);
@@ -631,7 +596,9 @@ QFixed QFontEngineWin::ascent() const
QFixed QFontEngineWin::descent() const
{
- return tm.tmDescent;
+ // ### we substract 1 to even out the historical +1 in QFontMetrics's
+ // ### height=asc+desc+1 equation. Fix in Qt5.
+ return tm.tmDescent - 1;
}
QFixed QFontEngineWin::leading() const
@@ -1039,8 +1006,8 @@ QFontEngine::Properties QFontEngineWin::properties() const
Properties p;
p.emSquare = unitsPerEm;
p.italicAngle = otm->otmItalicAngle;
- p.postscriptName = (char *)otm + (int)otm->otmpFamilyName;
- p.postscriptName += (char *)otm + (int)otm->otmpStyleName;
+ p.postscriptName = QString::fromWCharArray((wchar_t *)((char *)otm + (int)otm->otmpFamilyName)).toLatin1();
+ p.postscriptName += QString::fromWCharArray((wchar_t *)((char *)otm + (int)otm->otmpStyleName)).toLatin1();
#ifndef QT_NO_PRINTER
p.postscriptName = QPdf::stripSpecialCharacters(p.postscriptName);
#endif
@@ -1095,6 +1062,7 @@ extern bool qt_cleartype_enabled;
QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin,
const QTransform &t, QImage::Format mask_format)
{
+ Q_UNUSED(mask_format)
glyph_metrics_t gm = boundingBox(glyph);
// printf(" -> for glyph %4x\n", glyph);
@@ -1161,7 +1129,7 @@ QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin
ih + 2 * margin + 4,
QNativeImage::systemFormat(), !qt_cleartype_enabled);
- /*If cleartype is enabled we use the standard system format even on Windows CE
+ /*If cleartype is enabled we use the standard system format even on Windows CE
and not the special textbuffer format we have to use if cleartype is disabled*/
ni->image.fill(0xffffffff);
@@ -1186,7 +1154,7 @@ QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin
{
ExtTextOut(hdc, -gx + margin, -gy + margin, options, 0, (LPCWSTR) &glyph, 1, 0);
}
-
+
SelectObject(hdc, old_font);
return ni;
}
diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h
index ad2dec2a0..bab71c9e6 100644
--- a/src/gui/text/qfontengine_win_p.h
+++ b/src/gui/text/qfontengine_win_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -109,6 +109,10 @@ public:
int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, bool mirrored) const;
void getCMap();
+#ifndef Q_WS_WINCE
+ bool getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const;
+#endif
+
QString _name;
HFONT hfont;
LOGFONT logfont;
diff --git a/src/gui/text/qfontengine_x11.cpp b/src/gui/text/qfontengine_x11.cpp
index 8552b0483..ff3f62846 100644
--- a/src/gui/text/qfontengine_x11.cpp
+++ b/src/gui/text/qfontengine_x11.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -488,9 +488,10 @@ glyph_metrics_t QFontEngineXLFD::boundingBox(const QGlyphLayout &glyphs)
QFixed y = overall.yoff + glyphs.offsets[i].y - xcs->ascent;
overall.x = qMin(overall.x, x);
overall.y = qMin(overall.y, y);
+ // XCharStruct::rbearing is defined as distance from left edge to rightmost pixel
xmax = qMax(xmax, overall.xoff + glyphs.offsets[i].x + xcs->rbearing);
ymax = qMax(ymax, y + xcs->ascent + xcs->descent);
- overall.xoff += glyphs.advances_x[i];
+ overall.xoff += glyphs.advances_x[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6);
} else {
QFixed size = _fs->ascent;
overall.x = qMin(overall.x, overall.xoff);
@@ -511,6 +512,8 @@ glyph_metrics_t QFontEngineXLFD::boundingBox(glyph_t glyph)
glyph_metrics_t gm;
XCharStruct *xcs = charStruct(_fs, glyph);
if (xcs) {
+ // XCharStruct::rbearing is defined as distance from left edge to rightmost pixel
+ // XCharStruct::width is defined as the advance
gm = glyph_metrics_t(xcs->lbearing, -xcs->ascent, xcs->rbearing- xcs->lbearing, xcs->ascent + xcs->descent,
xcs->width, 0);
} else {
diff --git a/src/gui/text/qfontengine_x11_p.h b/src/gui/text/qfontengine_x11_p.h
index 25e2dcf71..3f29c05c9 100644
--- a/src/gui/text/qfontengine_x11_p.h
+++ b/src/gui/text/qfontengine_x11_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h
index d7bff73b6..e04f4ac75 100644
--- a/src/gui/text/qfontengineglyphcache_p.h
+++ b/src/gui/text/qfontengineglyphcache_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfontinfo.h b/src/gui/text/qfontinfo.h
index f16928077..099894917 100644
--- a/src/gui/text/qfontinfo.h
+++ b/src/gui/text/qfontinfo.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -43,6 +43,7 @@
#define QFONTINFO_H
#include <QtGui/qfont.h>
+#include <QtCore/qsharedpointer.h>
QT_BEGIN_HEADER
@@ -77,7 +78,7 @@ public:
bool exactMatch() const;
private:
- QFontPrivate *d;
+ QExplicitlySharedDataPointer<QFontPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index b3d1a5f63..3d3f1e14b 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -75,9 +75,8 @@ extern int qt_defaultDpi();
\brief The QFontMetrics class provides font metrics information.
- \ingroup multimedia
+ \ingroup painting
\ingroup shared
- \ingroup text
QFontMetrics functions calculate the size of characters and
strings for a given font. There are three ways you can create a
@@ -164,9 +163,8 @@ extern int qt_defaultDpi();
metrics that are compatible with a certain paint device.
*/
QFontMetrics::QFontMetrics(const QFont &font)
- : d(font.d)
+ : d(font.d.data())
{
- d->ref.ref();
}
/*!
@@ -196,8 +194,7 @@ QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice)
d->dpi = dpi;
d->screen = screen;
} else {
- d = font.d;
- d->ref.ref();
+ d = font.d.data();
}
}
@@ -206,8 +203,9 @@ QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice)
Constructs a copy of \a fm.
*/
QFontMetrics::QFontMetrics(const QFontMetrics &fm)
- : d(fm.d)
-{ d->ref.ref(); }
+ : d(fm.d.data())
+{
+}
/*!
Destroys the font metrics object and frees all allocated
@@ -215,8 +213,6 @@ QFontMetrics::QFontMetrics(const QFontMetrics &fm)
*/
QFontMetrics::~QFontMetrics()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -224,7 +220,7 @@ QFontMetrics::~QFontMetrics()
*/
QFontMetrics &QFontMetrics::operator=(const QFontMetrics &fm)
{
- qAtomicAssign(d, fm.d);
+ d = fm.d.data();
return *this;
}
@@ -529,13 +525,15 @@ int QFontMetrics::rightBearing(QChar ch) const
int QFontMetrics::width(const QString &text, int len) const
{
int pos = text.indexOf(QLatin1Char('\x9c'));
- QString txt = (pos == -1) ? text : text.left(pos);
- if (len < 0)
- len = txt.length();
+ if (pos != -1) {
+ len = (len < 0) ? pos : qMin(pos, len);
+ } else if (len < 0) {
+ len = text.length();
+ }
if (len == 0)
return 0;
- QTextEngine layout(txt, d);
+ QTextEngine layout(text, d.data());
layout.ignoreBidi = true;
return qRound(layout.width(0, len));
}
@@ -611,7 +609,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const
int from = qMax(0, pos - 8);
int to = qMin(text.length(), pos + 8);
QString cstr = QString::fromRawData(text.unicode() + from, to - from);
- QTextEngine layout(cstr, d);
+ QTextEngine layout(cstr, d.data());
layout.ignoreBidi = true;
layout.itemize();
width = qRound(layout.width(pos-from, 1));
@@ -660,7 +658,7 @@ QRect QFontMetrics::boundingRect(const QString &text) const
if (text.length() == 0)
return QRect();
- QTextEngine layout(text, d);
+ QTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.boundingBox(0, text.length());
@@ -769,7 +767,7 @@ QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &te
QRectF rb;
QRectF rr(rect);
- qt_format_text(QFont(d), rr, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray,
+ qt_format_text(QFont(d.data()), rr, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray,
tabArrayLen, 0);
return rb.toAlignedRect();
@@ -830,7 +828,7 @@ QRect QFontMetrics::tightBoundingRect(const QString &text) const
if (text.length() == 0)
return QRect();
- QTextEngine layout(text, d);
+ QTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.tightBoundingBox(0, text.length());
@@ -875,7 +873,7 @@ QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, in
}
_text = _text.mid(posA);
}
- QStackTextEngine engine(_text, QFont(d));
+ QStackTextEngine engine(_text, QFont(d.data()));
return engine.elidedText(mode, width, flags);
}
@@ -941,9 +939,8 @@ int QFontMetrics::lineWidth() const
\brief The QFontMetricsF class provides font metrics information.
- \ingroup multimedia
+ \ingroup painting
\ingroup shared
- \ingroup text
QFontMetricsF functions calculate the size of characters and
strings for a given font. You can construct a QFontMetricsF object
@@ -989,9 +986,8 @@ int QFontMetrics::lineWidth() const
from the given \a fontMetrics object.
*/
QFontMetricsF::QFontMetricsF(const QFontMetrics &fontMetrics)
- : d(fontMetrics.d)
+ : d(fontMetrics.d.data())
{
- d->ref.ref();
}
/*!
@@ -1001,7 +997,7 @@ QFontMetricsF::QFontMetricsF(const QFontMetrics &fontMetrics)
*/
QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other)
{
- qAtomicAssign(d, other.d);
+ d = other.d.data();
return *this;
}
@@ -1019,9 +1015,8 @@ QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other)
metrics that are compatible with a certain paint device.
*/
QFontMetricsF::QFontMetricsF(const QFont &font)
- : d(font.d)
+ : d(font.d.data())
{
- d->ref.ref();
}
/*!
@@ -1051,8 +1046,7 @@ QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice)
d->dpi = dpi;
d->screen = screen;
} else {
- d = font.d;
- d->ref.ref();
+ d = font.d.data();
}
}
@@ -1061,8 +1055,9 @@ QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice)
Constructs a copy of \a fm.
*/
QFontMetricsF::QFontMetricsF(const QFontMetricsF &fm)
- : d(fm.d)
-{ d->ref.ref(); }
+ : d(fm.d.data())
+{
+}
/*!
Destroys the font metrics object and frees all allocated
@@ -1070,8 +1065,6 @@ QFontMetricsF::QFontMetricsF(const QFontMetricsF &fm)
*/
QFontMetricsF::~QFontMetricsF()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -1079,7 +1072,7 @@ QFontMetricsF::~QFontMetricsF()
*/
QFontMetricsF &QFontMetricsF::operator=(const QFontMetricsF &fm)
{
- qAtomicAssign(d, fm.d);
+ d = fm.d.data();
return *this;
}
@@ -1374,10 +1367,13 @@ qreal QFontMetricsF::rightBearing(QChar ch) const
*/
qreal QFontMetricsF::width(const QString &text) const
{
- QTextEngine layout(text, d);
+ int pos = text.indexOf(QLatin1Char('\x9c'));
+ int len = (pos != -1) ? pos : text.length();
+
+ QTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
- return layout.width(0, text.length()).toReal();
+ return layout.width(0, len).toReal();
}
/*!
@@ -1451,7 +1447,7 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const
if (len == 0)
return QRectF();
- QTextEngine layout(text, d);
+ QTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.boundingBox(0, len);
@@ -1559,7 +1555,7 @@ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString&
tabArrayLen++;
QRectF rb;
- qt_format_text(QFont(d), rect, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray,
+ qt_format_text(QFont(d.data()), rect, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray,
tabArrayLen, 0);
return rb;
}
@@ -1594,7 +1590,7 @@ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString&
*/
QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *tabArray) const
{
- return boundingRect(QRectF(), flags, text, tabStops, tabArray).size();
+ return boundingRect(QRectF(), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size();
}
/*!
@@ -1624,7 +1620,7 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const
if (text.length() == 0)
return QRect();
- QTextEngine layout(text, d);
+ QTextEngine layout(text, d.data());
layout.ignoreBidi = true;
layout.itemize();
glyph_metrics_t gm = layout.tightBoundingBox(0, text.length());
@@ -1649,7 +1645,20 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const
*/
QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags) const
{
- QStackTextEngine engine(text, QFont(d));
+ QString _text = text;
+ if (!(flags & Qt::TextLongestVariant)) {
+ int posA = 0;
+ int posB = _text.indexOf(QLatin1Char('\x9c'));
+ while (posB >= 0) {
+ QString portion = _text.mid(posA, posB - posA);
+ if (size(flags, portion).width() <= width)
+ return portion;
+ posA = posB + 1;
+ posB = _text.indexOf(QLatin1Char('\x9c'), posA);
+ }
+ _text = _text.mid(posA);
+ }
+ QStackTextEngine engine(_text, QFont(d.data()));
return engine.elidedText(mode, QFixed::fromReal(width), flags);
}
diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h
index dba2f4ed2..23200c51f 100644
--- a/src/gui/text/qfontmetrics.h
+++ b/src/gui/text/qfontmetrics.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -43,6 +43,7 @@
#define QFONTMETRICS_H
#include <QtGui/qfont.h>
+#include <QtCore/qsharedpointer.h>
#ifndef QT_INCLUDE_COMPAT
#include <QtCore/qrect.h>
#endif
@@ -131,7 +132,7 @@ private:
friend class QFontMetricsF;
friend class QStackTextEngine;
- QFontPrivate *d;
+ QExplicitlySharedDataPointer<QFontPrivate> d;
};
@@ -187,7 +188,7 @@ public:
inline bool operator !=(const QFontMetricsF &other) const { return !operator==(other); }
private:
- QFontPrivate *d;
+ QExplicitlySharedDataPointer<QFontPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp
index 8e945d4c0..ce7744aa9 100644
--- a/src/gui/text/qfontsubset.cpp
+++ b/src/gui/text/qfontsubset.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfontsubset_p.h b/src/gui/text/qfontsubset_p.h
index 891608e3c..cd9fe51d5 100644
--- a/src/gui/text/qfontsubset_p.h
+++ b/src/gui/text/qfontsubset_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfragmentmap.cpp b/src/gui/text/qfragmentmap.cpp
index 53f554022..0d2493ce6 100644
--- a/src/gui/text/qfragmentmap.cpp
+++ b/src/gui/text/qfragmentmap.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h
index 6ca5e8043..88288e45c 100644
--- a/src/gui/text/qfragmentmap_p.h
+++ b/src/gui/text/qfragmentmap_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -214,6 +214,7 @@ private:
template <class Fragment>
QFragmentMapData<Fragment>::QFragmentMapData()
+ : fragments(0)
{
init();
}
@@ -221,12 +222,19 @@ QFragmentMapData<Fragment>::QFragmentMapData()
template <class Fragment>
void QFragmentMapData<Fragment>::init()
{
- fragments = (Fragment *)malloc(64*fragmentSize);
+ // the following code will realloc an existing fragment or create a new one.
+ // it will also ignore errors when shrinking an existing fragment.
+ Fragment *newFragments = (Fragment *)realloc(fragments, 64*fragmentSize);
+ if (newFragments) {
+ fragments = newFragments;
+ head->allocated = 64;
+ }
+ Q_CHECK_PTR(fragments);
+
head->tag = (((quint32)'p') << 24) | (((quint32)'m') << 16) | (((quint32)'a') << 8) | 'p'; //TAG('p', 'm', 'a', 'p');
head->root = 0;
head->freelist = 1;
head->node_count = 0;
- head->allocated = 64;
// mark all items to the right as unused
F(head->freelist).right = 0;
}
@@ -234,7 +242,7 @@ void QFragmentMapData<Fragment>::init()
template <class Fragment>
QFragmentMapData<Fragment>::~QFragmentMapData()
{
- free(head);
+ free(fragments);
}
template <class Fragment>
@@ -247,7 +255,9 @@ uint QFragmentMapData<Fragment>::createFragment()
// need to create some free space
uint needed = qAllocMore((freePos+1)*fragmentSize, 0);
Q_ASSERT(needed/fragmentSize > head->allocated);
- fragments = (Fragment *)realloc(fragments, needed);
+ Fragment *newFragments = (Fragment *)realloc(fragments, needed);
+ Q_CHECK_PTR(newFragments);
+ fragments = newFragments;
head->allocated = needed/fragmentSize;
F(freePos).right = 0;
}
@@ -787,6 +797,8 @@ public:
QFragmentMap() {}
~QFragmentMap()
{
+ if (!data.fragments)
+ return; // in case of out-of-memory, we won't have fragments
for (Iterator it = begin(); !it.atEnd(); ++it)
it.value()->free();
}
@@ -794,7 +806,6 @@ public:
inline void clear() {
for (Iterator it = begin(); !it.atEnd(); ++it)
it.value()->free();
- ::free(data.head);
data.init();
}
diff --git a/src/gui/text/qpfutil.cpp b/src/gui/text/qpfutil.cpp
index a779a529b..462281942 100644
--- a/src/gui/text/qpfutil.cpp
+++ b/src/gui/text/qpfutil.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index 5c54500cc..470c8e17f 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -170,7 +170,7 @@ void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, in
return;
int endPosition;
- QTextBlock lastBlock = doc->findBlock(from + charsAdded);
+ QTextBlock lastBlock = doc->findBlock(from + charsAdded + (charsRemoved > 0 ? 1 : 0));
if (lastBlock.isValid())
endPosition = lastBlock.position() + lastBlock.length();
else
@@ -219,7 +219,7 @@ void QSyntaxHighlighterPrivate::reformatBlock(QTextBlock block)
\since 4.1
- \ingroup text
+ \ingroup richtext-processing
The QSyntaxHighlighter class is a base class for implementing
QTextEdit syntax highlighters. A syntax highligher automatically
diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h
index c38ad47cf..ca778d821 100644
--- a/src/gui/text/qsyntaxhighlighter.h
+++ b/src/gui/text/qsyntaxhighlighter.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index 1c14d202f..f96f66b53 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -55,6 +55,7 @@
#include <qstyle.h>
#include <qtimer.h>
#include "private/qtextdocumentlayout_p.h"
+#include "private/qabstracttextdocumentlayout_p.h"
#include "private/qtextedit_p.h"
#include "qtextdocument.h"
#include "private/qtextdocument_p.h"
@@ -126,6 +127,7 @@ QTextControlPrivate::QTextControlPrivate()
#endif
isEnabled(true),
hadSelectionOnMousePress(false),
+ ignoreUnusedNavigationEvents(false),
openExternalLinks(false)
{}
@@ -264,17 +266,25 @@ bool QTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
cursor.setVisualNavigation(visualNavigation);
q->ensureCursorVisible();
+ bool ignoreNavigationEvents = ignoreUnusedNavigationEvents;
+ bool isNavigationEvent = e->key() == Qt::Key_Up || e->key() == Qt::Key_Down;
+
+#ifdef QT_KEYPAD_NAVIGATION
+ ignoreNavigationEvents = ignoreNavigationEvents || QApplication::keypadNavigationEnabled();
+ isNavigationEvent = isNavigationEvent ||
+ (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
+ && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right));
+#else
+ isNavigationEvent = isNavigationEvent || e->key() == Qt::Key_Left || e->key() == Qt::Key_Right;
+#endif
+
if (moved) {
if (cursor.position() != oldCursorPos)
emit q->cursorPositionChanged();
emit q->microFocusChanged();
- }
-#ifdef QT_KEYPAD_NAVIGATION
- else if (QApplication::keypadNavigationEnabled()
- && (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)) {
+ } else if (ignoreNavigationEvents && isNavigationEvent) {
return false;
}
-#endif
selectionChanged(/*forceEmitSelectionChanged =*/(mode == QTextCursor::KeepAnchor));
@@ -503,9 +513,13 @@ void QTextControlPrivate::startDrag()
drag->setMimeData(data);
Qt::DropActions actions = Qt::CopyAction;
- if (interactionFlags & Qt::TextEditable)
+ Qt::DropAction action;
+ if (interactionFlags & Qt::TextEditable) {
actions |= Qt::MoveAction;
- Qt::DropAction action = drag->exec(actions, Qt::MoveAction);
+ action = drag->exec(actions, Qt::MoveAction);
+ } else {
+ action = drag->exec(actions, Qt::CopyAction);
+ }
if (action == Qt::MoveAction && drag->target() != contextWidget)
cursor.removeSelectedText();
@@ -905,7 +919,7 @@ void QTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *conte
break;
case QEvent::MouseButtonPress: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mousePressEvent(ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
ev->buttons(), ev->globalPos());
break; }
case QEvent::MouseMove: {
@@ -973,7 +987,7 @@ void QTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *conte
#ifndef QT_NO_GRAPHICSVIEW
case QEvent::GraphicsSceneMousePress: {
QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mousePressEvent(ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
ev->screenPos());
break; }
case QEvent::GraphicsSceneMouseMove: {
@@ -1221,11 +1235,13 @@ void QTextControlPrivate::keyPressEvent(QKeyEvent *e)
cursor.deleteChar();
}
else if (e == QKeySequence::DeleteEndOfWord) {
- cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);
+ if (!cursor.hasSelection())
+ cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
}
else if (e == QKeySequence::DeleteStartOfWord) {
- cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
+ if (!cursor.hasSelection())
+ cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
}
else if (e == QKeySequence::DeleteEndOfLine) {
@@ -1288,7 +1304,9 @@ QVariant QTextControl::loadResource(int type, const QUrl &name)
void QTextControlPrivate::_q_updateBlock(const QTextBlock &block)
{
Q_Q(QTextControl);
- emit q->updateRequest(q->blockBoundingRect(block));
+ QRectF br = q->blockBoundingRect(block);
+ br.setRight(qreal(INT_MAX)); // the block might have shrunk
+ emit q->updateRequest(br);
}
QRectF QTextControlPrivate::rectForPosition(int position) const
@@ -1457,7 +1475,7 @@ QRectF QTextControl::selectionRect() const
return selectionRect(d->cursor);
}
-void QTextControlPrivate::mousePressEvent(Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
+void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
Qt::MouseButtons buttons, const QPoint &globalPos)
{
Q_Q(QTextControl);
@@ -1471,11 +1489,11 @@ void QTextControlPrivate::mousePressEvent(Qt::MouseButton button, const QPointF
cursor.clearSelection();
}
}
- if (!(button & Qt::LeftButton))
- return;
-
- if (!((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable)))
- return;
+ if (!(button & Qt::LeftButton) ||
+ !((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))) {
+ e->ignore();
+ return;
+ }
cursorIsFocusIndicator = false;
const QTextCursor oldSelection = cursor;
@@ -1499,8 +1517,10 @@ void QTextControlPrivate::mousePressEvent(Qt::MouseButton button, const QPointF
trippleClickTimer.stop();
} else {
int cursorPos = q->hitTest(pos, Qt::FuzzyHit);
- if (cursorPos == -1)
+ if (cursorPos == -1) {
+ e->ignore();
return;
+ }
#if !defined(QT_NO_IM)
QTextLayout *layout = cursor.block().layout();
@@ -1511,8 +1531,10 @@ void QTextControlPrivate::mousePressEvent(Qt::MouseButton button, const QPointF
button, buttons, modifiers);
ctx->mouseHandler(cursorPos - cursor.position(), &ev);
}
- if (!layout->preeditAreaText().isEmpty())
+ if (!layout->preeditAreaText().isEmpty()) {
+ e->ignore();
return;
+ }
}
#endif
if (modifiers == Qt::ShiftModifier) {
@@ -1611,6 +1633,11 @@ void QTextControlPrivate::mouseMoveEvent(Qt::MouseButtons buttons, const QPointF
if (cursor.position() != oldCursorPos)
emit q->cursorPositionChanged();
_q_updateCurrentCharFormatAndSelection();
+#ifndef QT_NO_IM
+ if (QInputContext *ic = inputContext()) {
+ ic->update();
+ }
+#endif //QT_NO_IM
} else {
//emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1)));
if (cursor.position() != oldCursorPos)
@@ -1813,13 +1840,19 @@ bool QTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPointF &po
void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
{
+ Q_Q(QTextControl);
if (!(interactionFlags & Qt::TextEditable) || cursor.isNull()) {
e->ignore();
return;
}
- cursor.beginEditBlock();
+ bool isGettingInput = !e->commitString().isEmpty()
+ || e->preeditString() != cursor.block().layout()->preeditAreaText()
+ || e->replacementLength() > 0;
- cursor.removeSelectedText();
+ cursor.beginEditBlock();
+ if (isGettingInput) {
+ cursor.removeSelectedText();
+ }
// insert commit string
if (!e->commitString().isEmpty() || e->replacementLength()) {
@@ -1829,9 +1862,22 @@ void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
c.insertText(e->commitString());
}
+ for (int i = 0; i < e->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute &a = e->attributes().at(i);
+ if (a.type == QInputMethodEvent::Selection) {
+ QTextCursor oldCursor = cursor;
+ int blockStart = a.start + cursor.block().position();
+ cursor.setPosition(blockStart, QTextCursor::MoveAnchor);
+ cursor.setPosition(blockStart + a.length, QTextCursor::KeepAnchor);
+ q->ensureCursorVisible();
+ repaintOldAndNewSelection(oldCursor);
+ }
+ }
+
QTextBlock block = cursor.block();
QTextLayout *layout = block.layout();
- layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
+ if (isGettingInput)
+ layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
QList<QTextLayout::FormatRange> overrides;
preeditCursor = e->preeditString().length();
hideCursor = false;
@@ -1865,11 +1911,15 @@ QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const
case Qt::ImFont:
return QVariant(d->cursor.charFormat().font());
case Qt::ImCursorPosition:
- return QVariant(d->cursor.selectionEnd() - block.position());
+ return QVariant(d->cursor.position() - block.position());
case Qt::ImSurroundingText:
return QVariant(block.text());
case Qt::ImCurrentSelection:
return QVariant(d->cursor.selectedText());
+ case Qt::ImMaximumTextLength:
+ return QVariant(); // No limit.
+ case Qt::ImAnchorPosition:
+ return QVariant(qBound(0, d->cursor.anchor() - block.position(), block.length()));
default:
return QVariant();
}
@@ -2220,6 +2270,18 @@ bool QTextControl::openExternalLinks() const
return d->openExternalLinks;
}
+bool QTextControl::ignoreUnusedNavigationEvents() const
+{
+ Q_D(const QTextControl);
+ return d->ignoreUnusedNavigationEvents;
+}
+
+void QTextControl::setIgnoreUnusedNavigationEvents(bool ignore)
+{
+ Q_D(QTextControl);
+ d->ignoreUnusedNavigationEvents = ignore;
+}
+
void QTextControl::moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode)
{
Q_D(QTextControl);
@@ -2276,6 +2338,9 @@ void QTextControl::print(QPrinter *printer) const
tempDoc->setUseDesignMetrics(doc->useDesignMetrics());
QTextCursor(tempDoc).insertFragment(d->cursor.selection());
doc = tempDoc;
+
+ // copy the custom object handlers
+ doc->documentLayout()->d_func()->handlers = d->doc->documentLayout()->d_func()->handlers;
}
doc->print(printer);
delete tempDoc;
diff --git a/src/gui/text/qtextcontrol_p.h b/src/gui/text/qtextcontrol_p.h
index 77dd3865f..bc8e063f7 100644
--- a/src/gui/text/qtextcontrol_p.h
+++ b/src/gui/text/qtextcontrol_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -95,6 +95,7 @@ class Q_GUI_EXPORT QTextControl : public QObject
Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
+ Q_PROPERTY(bool ignoreUnusedNavigationEvents READ ignoreUnusedNavigationEvents WRITE setIgnoreUnusedNavigationEvents)
public:
explicit QTextControl(QObject *parent = 0);
explicit QTextControl(const QString &text, QObject *parent = 0);
@@ -163,6 +164,9 @@ public:
void setOpenExternalLinks(bool open);
bool openExternalLinks() const;
+ void setIgnoreUnusedNavigationEvents(bool ignore);
+ bool ignoreUnusedNavigationEvents() const;
+
void moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
bool canPaste() const;
diff --git a/src/gui/text/qtextcontrol_p_p.h b/src/gui/text/qtextcontrol_p_p.h
index 91ab352c1..c2305122b 100644
--- a/src/gui/text/qtextcontrol_p_p.h
+++ b/src/gui/text/qtextcontrol_p_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -131,10 +131,10 @@ public:
QString anchorForCursor(const QTextCursor &anchor) const;
void keyPressEvent(QKeyEvent *e);
- void mousePressEvent(Qt::MouseButton button, const QPointF &pos,
+ void mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
Qt::KeyboardModifiers modifiers,
Qt::MouseButtons buttons,
- const QPoint &globalPos = QPoint());
+ const QPoint &globalPos);
void mouseMoveEvent(Qt::MouseButtons buttons, const QPointF &pos);
void mouseReleaseEvent(Qt::MouseButton button, const QPointF &pos);
void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos);
@@ -206,6 +206,7 @@ public:
QString anchorOnMousePress;
bool hadSelectionOnMousePress;
+ bool ignoreUnusedNavigationEvents;
bool openExternalLinks;
QString linkToCopy;
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index f97146dbf..ce6283443 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -84,15 +84,20 @@ QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs)
QTextCursorPrivate::~QTextCursorPrivate()
{
- priv->removeCursor(this);
+ if (priv)
+ priv->removeCursor(this);
}
QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op)
{
QTextCursorPrivate::AdjustResult result = QTextCursorPrivate::CursorMoved;
// not(!) <= , so that inserting text adjusts the cursor correctly
- if (position < positionOfChange ||
- (position == positionOfChange && op == QTextUndoCommand::KeepCursor)) {
+ if (position < positionOfChange
+ || (position == positionOfChange
+ && (op == QTextUndoCommand::KeepCursor
+ || anchor < position)
+ )
+ ) {
result = CursorUnchanged;
} else {
if (charsAddedOrRemoved < 0 && position < positionOfChange - charsAddedOrRemoved)
@@ -854,9 +859,9 @@ QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{
\brief The QTextCursor class offers an API to access and modify QTextDocuments.
- \ingroup text
+ \ingroup richtext-processing
\ingroup shared
- \mainclass
+
Text cursors are objects that are used to access and modify the contents
and underlying structure of text documents via a programming interface
@@ -1327,6 +1332,8 @@ void QTextCursor::insertText(const QString &text, const QTextCharFormat &_format
if (ch == QLatin1Char('\n')
|| ch == QChar::ParagraphSeparator
+ || ch == QTextBeginningOfFrame
+ || ch == QTextEndOfFrame
|| ch == QLatin1Char('\r')) {
if (!hasEditBlock) {
diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h
index 95073e349..c75e02828 100644
--- a/src/gui/text/qtextcursor.h
+++ b/src/gui/text/qtextcursor.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextcursor_p.h b/src/gui/text/qtextcursor_p.h
index e94b1f088..264947854 100644
--- a/src/gui/text/qtextcursor_p.h
+++ b/src/gui/text/qtextcursor_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 6fa3e9000..3b0a97949 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -61,9 +61,11 @@
#include <qapplication.h>
#include "qtextcontrol_p.h"
#include "private/qtextedit_p.h"
+#include "private/qdataurl_p.h"
#include "qtextdocument_p.h"
#include <private/qprinter_p.h>
+#include <private/qabstracttextdocumentlayout_p.h>
#include <limits.h>
@@ -140,7 +142,7 @@ bool Qt::mightBeRichText(const QString& text)
/*!
Converts the plain text string \a plain to a HTML string with
- HTML metacharacters \c{<}, \c{>}, and \c{&} replaced by HTML
+ HTML metacharacters \c{<}, \c{>}, \c{&}, and \c{"} replaced by HTML
entities.
Example:
@@ -162,6 +164,8 @@ QString Qt::escape(const QString& plain)
rich += QLatin1String("&gt;");
else if (plain.at(i) == QLatin1Char('&'))
rich += QLatin1String("&amp;");
+ else if (plain.at(i) == QLatin1Char('"'))
+ rich += QLatin1String("&quot;");
else
rich += plain.at(i);
}
@@ -247,8 +251,8 @@ QTextCodec *Qt::codecForHtml(const QByteArray &ba)
\brief The QTextDocument class holds formatted text that can be
viewed and edited using a QTextEdit.
- \ingroup text
- \mainclass
+ \ingroup richtext-processing
+
QTextDocument is a container for structured rich text documents, providing
support for styled text and various types of document elements, such as
@@ -956,6 +960,8 @@ QString QTextDocument::defaultStyleSheet() const
/*!
Returns true if undo is available; otherwise returns false.
+
+ \sa isRedoAvailable(), availableUndoSteps()
*/
bool QTextDocument::isUndoAvailable() const
{
@@ -965,6 +971,8 @@ bool QTextDocument::isUndoAvailable() const
/*!
Returns true if redo is available; otherwise returns false.
+
+ \sa isUndoAvailable(), availableRedoSteps()
*/
bool QTextDocument::isRedoAvailable() const
{
@@ -972,6 +980,29 @@ bool QTextDocument::isRedoAvailable() const
return d->isRedoAvailable();
}
+/*! \since 4.6
+
+ Returns the number of available undo steps.
+
+ \sa isUndoAvailable()
+*/
+int QTextDocument::availableUndoSteps() const
+{
+ Q_D(const QTextDocument);
+ return d->availableUndoSteps();
+}
+
+/*! \since 4.6
+
+ Returns the number of available redo steps.
+
+ \sa isRedoAvailable()
+*/
+int QTextDocument::availableRedoSteps() const
+{
+ Q_D(const QTextDocument);
+ return d->availableRedoSteps();
+}
/*! \since 4.4
@@ -985,7 +1016,7 @@ bool QTextDocument::isRedoAvailable() const
int QTextDocument::revision() const
{
Q_D(const QTextDocument);
- return d->undoState;
+ return d->revision;
}
@@ -1096,8 +1127,10 @@ void QTextDocument::setPlainText(const QString &text)
Q_D(QTextDocument);
bool previousState = d->isUndoRedoEnabled();
d->enableUndoRedo(false);
+ d->beginEditBlock();
d->clear();
QTextCursor(this).insertText(text);
+ d->endEditBlock();
d->enableUndoRedo(previousState);
}
@@ -1123,8 +1156,10 @@ void QTextDocument::setHtml(const QString &html)
Q_D(QTextDocument);
bool previousState = d->isUndoRedoEnabled();
d->enableUndoRedo(false);
+ d->beginEditBlock();
d->clear();
QTextHtmlImporter(this, html, QTextHtmlImporter::ImportToDocument).import();
+ d->endEditBlock();
d->enableUndoRedo(previousState);
}
@@ -1689,6 +1724,9 @@ void QTextDocument::print(QPrinter *printer) const
QAbstractTextDocumentLayout *layout = doc->documentLayout();
layout->setPaintDevice(p.device());
+ // copy the custom object handlers
+ layout->d_func()->handlers = documentLayout()->d_func()->handlers;
+
int dpiy = p.device()->logicalDpiY();
int margin = 0;
if (printer->fullPage() && !printer->d_func()->hasCustomPageMargins) {
@@ -1730,6 +1768,12 @@ void QTextDocument::print(QPrinter *printer) const
fromPage = qMax(1, fromPage);
toPage = qMin(doc->pageCount(), toPage);
+ if (toPage < fromPage) {
+ // if the user entered a page range outside the actual number
+ // of printable pages, just return
+ return;
+ }
+
if (printer->pageOrder() == QPrinter::LastPageFirst) {
int tmp = fromPage;
fromPage = toPage;
@@ -1881,6 +1925,10 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name)
}
#endif
+ // handle data: URLs
+ if (r.isNull() && name.scheme() == QLatin1String("data"))
+ r = qDecodeDataUrl(name).second;
+
// if resource was not loaded try to load it here
if (!doc && r.isNull() && name.isRelative()) {
QUrl currentURL = d->url;
@@ -2034,7 +2082,7 @@ void QTextHtmlExporter::emitAttribute(const char *attribute, const QString &valu
html += QLatin1Char(' ');
html += QLatin1String(attribute);
html += QLatin1String("=\"");
- html += value;
+ html += Qt::escape(value);
html += QLatin1Char('"');
}
@@ -2298,12 +2346,12 @@ void QTextHtmlExporter::emitFontFamily(const QString &family)
{
html += QLatin1String(" font-family:");
- QLatin1Char quote('\'');
- if (family.contains(quote))
- quote = QLatin1Char('\"');
+ QLatin1String quote("\'");
+ if (family.contains(QLatin1Char('\'')))
+ quote = QLatin1String("&quot;");
html += quote;
- html += family;
+ html += Qt::escape(family);
html += quote;
html += QLatin1Char(';');
}
@@ -2337,13 +2385,13 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment)
const QString name = format.anchorName();
if (!name.isEmpty()) {
html += QLatin1String("<a name=\"");
- html += name;
+ html += Qt::escape(name);
html += QLatin1String("\"></a>");
}
const QString href = format.anchorHref();
if (!href.isEmpty()) {
html += QLatin1String("<a href=\"");
- html += href;
+ html += Qt::escape(href);
html += QLatin1String("\">");
closeAnchor = true;
}
@@ -2521,13 +2569,15 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block)
default: html += QLatin1String("<ul"); // ### should not happen
}
+ html += QLatin1String(" style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;");
+
if (format.hasProperty(QTextFormat::ListIndent)) {
- html += QLatin1String(" style=\"-qt-list-indent: ");
+ html += QLatin1String(" -qt-list-indent: ");
html += QString::number(format.indent());
- html += QLatin1String(";\"");
+ html += QLatin1Char(';');
}
- html += QLatin1Char('>');
+ html += QLatin1String("\">");
}
html += QLatin1String("<li");
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index 992e43afc..d217a4dfb 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -142,6 +142,9 @@ public:
bool isUndoAvailable() const;
bool isRedoAvailable() const;
+ int availableUndoSteps() const;
+ int availableRedoSteps() const;
+
int revision() const;
void setDocumentLayout(QAbstractTextDocumentLayout *layout);
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 533ef4623..18e1ffc98 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -63,10 +63,10 @@ QT_BEGIN_NAMESPACE
// The VxWorks DIAB compiler crashes when initializing the anonymouse union with { a7 }
#if !defined(Q_CC_DIAB)
# define QT_INIT_TEXTUNDOCOMMAND(c, a1, a2, a3, a4, a5, a6, a7, a8) \
- QTextUndoCommand c = { a1, a2, a3, a4, a5, a6, { a7 }, a8 }
+ QTextUndoCommand c = { a1, a2, 0, 0, a3, a4, a5, a6, { a7 }, a8 }
#else
# define QT_INIT_TEXTUNDOCOMMAND(c, a1, a2, a3, a4, a5, a6, a7, a8) \
- QTextUndoCommand c = { a1, a2, a3, a4, a5, a6 }; c.blockFormat = a7; c.revision = a8
+ QTextUndoCommand c = { a1, a2, 0, 0, a3, a4, a5, a6 }; c.blockFormat = a7; c.revision = a8
#endif
/*
@@ -188,12 +188,14 @@ QTextDocumentPrivate::QTextDocumentPrivate()
docChangeOldLength(0),
docChangeLength(0),
framesDirty(true),
+ rtFrame(0),
initialBlockCharFormatIndex(-1) // set correctly later in init()
{
editBlock = 0;
docChangeFrom = -1;
undoState = 0;
+ revision = -1; // init() inserts a block, bringing it to 0
lout = 0;
@@ -202,7 +204,6 @@ QTextDocumentPrivate::QTextDocumentPrivate()
undoEnabled = true;
inContentsChange = false;
- inEdit = false;
defaultTextOption.setTabStop(80); // same as in qtextengine.cpp
defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
@@ -218,7 +219,6 @@ QTextDocumentPrivate::QTextDocumentPrivate()
void QTextDocumentPrivate::init()
{
- rtFrame = 0;
framesDirty = false;
bool undoState = undoEnabled;
@@ -241,42 +241,48 @@ void QTextDocumentPrivate::clear()
}
QList<QTextCursorPrivate *>oldCursors = cursors;
- cursors.clear();
- changedCursors.clear();
-
- QMap<int, QTextObject *>::Iterator objectIt = objects.begin();
- while (objectIt != objects.end()) {
- if (*objectIt != rtFrame) {
- delete *objectIt;
- objectIt = objects.erase(objectIt);
- } else {
- ++objectIt;
+ QT_TRY{
+ cursors.clear();
+ changedCursors.clear();
+
+ QMap<int, QTextObject *>::Iterator objectIt = objects.begin();
+ while (objectIt != objects.end()) {
+ if (*objectIt != rtFrame) {
+ delete *objectIt;
+ objectIt = objects.erase(objectIt);
+ } else {
+ ++objectIt;
+ }
}
- }
- // also clear out the remaining root frame pointer
- // (we're going to delete the object further down)
- objects.clear();
+ // also clear out the remaining root frame pointer
+ // (we're going to delete the object further down)
+ objects.clear();
- title.clear();
- undoState = 0;
- truncateUndoStack();
- text = QString();
- unreachableCharacterCount = 0;
- modifiedState = 0;
- modified = false;
- formats = QTextFormatCollection();
- int len = fragments.length();
- fragments.clear();
- blocks.clear();
- cachedResources.clear();
- delete rtFrame;
- init();
- cursors = oldCursors;
- inContentsChange = true;
- q->contentsChange(0, len, 0);
- inContentsChange = false;
- if (lout)
- lout->documentChanged(0, len, 0);
+ title.clear();
+ undoState = 0;
+ truncateUndoStack();
+ text = QString();
+ unreachableCharacterCount = 0;
+ modifiedState = 0;
+ modified = false;
+ formats = QTextFormatCollection();
+ int len = fragments.length();
+ fragments.clear();
+ blocks.clear();
+ cachedResources.clear();
+ delete rtFrame;
+ rtFrame = 0;
+ init();
+ cursors = oldCursors;
+ inContentsChange = true;
+ q->contentsChange(0, len, 0);
+ inContentsChange = false;
+ if (lout)
+ lout->documentChanged(0, len, 0);
+ } QT_CATCH(...) {
+ cursors = oldCursors; // at least recover the cursors
+ QT_RETHROW;
+ }
}
QTextDocumentPrivate::~QTextDocumentPrivate()
@@ -415,7 +421,7 @@ int QTextDocumentPrivate::insertBlock(const QChar &blockSeparator,
int b = blocks.findNode(pos);
QTextBlockData *B = blocks.fragment(b);
- QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::BlockInserted, editBlock != 0,
+ QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::BlockInserted, (editBlock != 0),
op, charFormat, strPos, pos, blockFormat,
B->revision);
@@ -423,11 +429,11 @@ int QTextDocumentPrivate::insertBlock(const QChar &blockSeparator,
Q_ASSERT(undoState == undoStack.size());
// update revision numbers of the modified blocks.
- B->revision = (atBlockEnd && !atBlockStart)? oldRevision : undoState;
+ B->revision = (atBlockEnd && !atBlockStart)? oldRevision : revision;
b = blocks.next(b);
if (b) {
B = blocks.fragment(b);
- B->revision = atBlockStart ? oldRevision : undoState;
+ B->revision = atBlockStart ? oldRevision : revision;
}
if (formats.charFormat(charFormat).objectIndex() == -1)
@@ -450,17 +456,16 @@ void QTextDocumentPrivate::insert(int pos, int strPos, int strLength, int format
Q_ASSERT(pos >= 0 && pos < fragments.length());
Q_ASSERT(formats.format(format).isCharFormat());
- beginEdit();
insert_string(pos, strPos, strLength, format, QTextUndoCommand::MoveCursor);
if (undoEnabled) {
int b = blocks.findNode(pos);
QTextBlockData *B = blocks.fragment(b);
- QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::Inserted, editBlock != 0,
+ QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::Inserted, (editBlock != 0),
QTextUndoCommand::MoveCursor, format, strPos, pos, strLength,
B->revision);
appendUndoItem(c);
- B->revision = undoState;
+ B->revision = revision;
Q_ASSERT(undoState == undoStack.size());
}
finishEdit();
@@ -576,7 +581,6 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O
if (pos == to)
return;
- beginEdit();
const bool needsInsert = to != -1;
#if !defined(QT_NO_DEBUG)
@@ -615,10 +619,10 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O
int blockRevision = B->revision;
QTextFragmentData *X = fragments.fragment(x);
- QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::Removed, editBlock != 0,
+ QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::Removed, (editBlock != 0),
op, X->format, X->stringPosition, key, X->size_array[0],
blockRevision);
- QT_INIT_TEXTUNDOCOMMAND(cInsert, QTextUndoCommand::Inserted, editBlock != 0,
+ QT_INIT_TEXTUNDOCOMMAND(cInsert, QTextUndoCommand::Inserted, (editBlock != 0),
op, X->format, X->stringPosition, dstKey, X->size_array[0],
blockRevision);
@@ -647,7 +651,7 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O
}
appendUndoItem(c);
if (B)
- B->revision = undoState;
+ B->revision = revision;
x = n;
if (needsInsert)
@@ -961,14 +965,18 @@ int QTextDocumentPrivate::undoRedo(bool undo)
B->revision = c.revision;
}
- if (undo) {
- if (undoState == 0 || !undoStack[undoState-1].block)
- break;
- } else {
+ if (!undo)
++undoState;
- if (undoState == undoStack.size() || !undoStack[undoState-1].block)
- break;
- }
+
+ bool inBlock = (
+ undoState > 0
+ && undoState < undoStack.size()
+ && undoStack[undoState].block_part
+ && undoStack[undoState-1].block_part
+ && !undoStack[undoState-1].block_end
+ );
+ if (!inBlock)
+ break;
}
undoEnabled = true;
int editPos = -1;
@@ -993,7 +1001,8 @@ void QTextDocumentPrivate::appendUndoItem(QAbstractUndoItem *item)
QTextUndoCommand c;
c.command = QTextUndoCommand::Custom;
- c.block = editBlock != 0;
+ c.block_part = editBlock != 0;
+ c.block_end = 0;
c.operation = QTextUndoCommand::MoveCursor;
c.format = 0;
c.strPos = 0;
@@ -1014,9 +1023,10 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c)
if (!undoStack.isEmpty() && modified) {
QTextUndoCommand &last = undoStack[undoState - 1];
- if ( (last.block && c.block) // part of the same block => can merge
- || (!c.block && !last.block // two single undo items => can merge
- && (undoState < 2 || !undoStack[undoState-2].block))) {
+
+ if ( (last.block_part && c.block_part && !last.block_end) // part of the same block => can merge
+ || (!c.block_part && !last.block_part)) { // two single undo items => can merge
+
if (last.tryMerge(c))
return;
}
@@ -1028,7 +1038,7 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c)
emitUndoAvailable(true);
emitRedoAvailable(false);
- if (!c.block)
+ if (!c.block_part)
emit document()->undoCommandAdded();
}
@@ -1094,19 +1104,22 @@ void QTextDocumentPrivate::joinPreviousEditBlock()
beginEditBlock();
if (undoEnabled && undoState)
- undoStack[undoState - 1].block = true;
+ undoStack[undoState - 1].block_end = false;
}
void QTextDocumentPrivate::endEditBlock()
{
+ Q_ASSERT(editBlock > 0);
if (--editBlock)
return;
if (undoEnabled && undoState > 0) {
- const bool wasBlocking = undoStack[undoState - 1].block;
- undoStack[undoState - 1].block = false;
- if (wasBlocking)
- emit document()->undoCommandAdded();
+ const bool wasBlocking = !undoStack[undoState - 1].block_end;
+ if (undoStack[undoState - 1].block_part) {
+ undoStack[undoState - 1].block_end = true;
+ if (wasBlocking)
+ emit document()->undoCommandAdded();
+ }
}
finishEdit();
@@ -1119,8 +1132,6 @@ void QTextDocumentPrivate::finishEdit()
if (editBlock)
return;
- inEdit = false;
-
if (framesDirty)
scan_frames(docChangeFrom, docChangeOldLength, docChangeLength);
@@ -1183,19 +1194,19 @@ void QTextDocumentPrivate::documentChange(int from, int length)
adjustDocumentChangesAndCursors is called whenever there is an insert or remove of characters.
param from is the cursor position in the document
param addedOrRemoved is the amount of characters added or removed. A negative number means characters are removed.
+
+ The function stores information to be emitted when finishEdit() is called.
*/
void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOrRemoved, QTextUndoCommand::Operation op)
{
- Q_Q(QTextDocument);
+ if (!editBlock)
+ ++revision;
+
for (int i = 0; i < cursors.size(); ++i) {
QTextCursorPrivate *curs = cursors.at(i);
if (curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved) {
- if (editBlock || inEdit) {
- if (!changedCursors.contains(curs))
- changedCursors.append(curs);
- } else {
- emit q->cursorPositionChanged(QTextCursor(curs));
- }
+ if (!changedCursors.contains(curs))
+ changedCursors.append(curs);
}
}
@@ -1211,7 +1222,6 @@ void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOr
}
// qDebug("adjustDocumentChanges:");
// qDebug(" -> %d %d %d", docChangeFrom, docChangeOldLength, docChangeLength);
- contentsChanged();
return;
}
@@ -1236,7 +1246,6 @@ void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOr
docChangeLength += added - removedInside + diff;
// qDebug(" -> %d %d %d", docChangeFrom, docChangeOldLength, docChangeLength);
- contentsChanged();
}
@@ -1307,7 +1316,7 @@ void QTextDocumentPrivate::changeObjectFormat(QTextObject *obj, int format)
if (f)
documentChange(f->firstPosition(), f->lastPosition() - f->firstPosition());
- QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::GroupFormatChange, editBlock != 0, QTextUndoCommand::MoveCursor, oldFormatIndex,
+ QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::GroupFormatChange, (editBlock != 0), QTextUndoCommand::MoveCursor, oldFormatIndex,
0, 0, obj->d_func()->objectIndex, 0);
appendUndoItem(c);
diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h
index 55aa17eec..c10855bcf 100644
--- a/src/gui/text/qtextdocument_p.h
+++ b/src/gui/text/qtextdocument_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -139,7 +139,9 @@ public:
MoveCursor = 1
};
quint16 command;
- quint8 block; ///< All undo commands that have this set to true are combined with the preceding command on undo/redo.
+ uint block_part : 1; // all commands that are part of an undo block (including the first and the last one) have this set to 1
+ uint block_end : 1; // the last command in an undo block has this set to 1.
+ uint block_padding : 6; // padding since block used to be a quint8
quint8 operation;
int format;
quint32 strPos;
@@ -199,10 +201,9 @@ public:
inline void undo() { undoRedo(true); }
inline void redo() { undoRedo(false); }
void appendUndoItem(QAbstractUndoItem *);
- inline void beginEditBlock() { editBlock++; }
+ inline void beginEditBlock() { if (0 == editBlock++) ++revision; }
void joinPreviousEditBlock();
void endEditBlock();
- inline void beginEdit() { inEdit = true; }
void finishEdit();
inline bool isInEditBlock() const { return editBlock; }
void enableUndoRedo(bool enable);
@@ -211,6 +212,9 @@ public:
inline bool isUndoAvailable() const { return undoEnabled && undoState > 0; }
inline bool isRedoAvailable() const { return undoEnabled && undoState < undoStack.size(); }
+ inline int availableUndoSteps() const { return undoEnabled ? undoState : 0; }
+ inline int availableRedoSteps() const { return undoEnabled ? qMax(undoStack.size() - undoState - 1, 0) : 0; }
+
inline QString buffer() const { return text; }
QString plainText() const;
inline int length() const { return fragments.length(); }
@@ -304,6 +308,7 @@ private:
QVector<QTextUndoCommand> undoStack;
bool undoEnabled;
int undoState;
+ int revision;
// position in undo stack of the last setModified(false) call
int modifiedState;
bool modified;
@@ -338,7 +343,6 @@ public:
int maximumBlockCount;
uint needsEnsureMaximumBlockCount : 1;
uint inContentsChange : 1;
- uint inEdit : 1; // between beginEdit() and finishEdit()
QSizeF pageSize;
QString title;
QString url;
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index da7025c61..a8be557c5 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -259,7 +259,7 @@ void QTextDocumentFragmentPrivate::insert(QTextCursor &_cursor) const
\brief The QTextDocumentFragment class represents a piece of formatted text
from a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
\ingroup shared
A QTextDocumentFragment is a fragment of rich text, that can be inserted into
diff --git a/src/gui/text/qtextdocumentfragment.h b/src/gui/text/qtextdocumentfragment.h
index 32986f79a..51ed1d2ed 100644
--- a/src/gui/text/qtextdocumentfragment.h
+++ b/src/gui/text/qtextdocumentfragment.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextdocumentfragment_p.h b/src/gui/text/qtextdocumentfragment_p.h
index 037316cfe..a86657889 100644
--- a/src/gui/text/qtextdocumentfragment_p.h
+++ b/src/gui/text/qtextdocumentfragment_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index a795c1fe3..2604879e5 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -1437,7 +1437,9 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
option.setTextDirection(dir);
layout.setTextOption(option);
layout.beginLayout();
- layout.createLine();
+ QTextLine line = layout.createLine();
+ if (line.isValid())
+ line.setLeadingIncluded(true);
layout.endLayout();
layout.draw(painter, QPointF(r.left(), pos.y()));
break;
@@ -1446,13 +1448,13 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
painter->fillRect(r, brush);
break;
case QTextListFormat::ListCircle:
- painter->drawEllipse(r);
+ painter->setPen(QPen(brush, 0));
+ painter->drawEllipse(r.translated(0.5, 0.5)); // pixel align for sharper rendering
break;
case QTextListFormat::ListDisc:
painter->setBrush(brush);
painter->setPen(Qt::NoPen);
painter->drawEllipse(r);
- painter->setBrush(Qt::NoBrush);
break;
case QTextListFormat::ListStyleUndefined:
break;
@@ -1994,9 +1996,12 @@ void QTextDocumentLayoutPrivate::positionFloat(QTextFrame *frame, QTextLine *cur
}
}
- if (y + layoutStruct->frameY + fd->size.height > layoutStruct->pageBottom) {
+ bool frameSpansIntoNextPage = (y + layoutStruct->frameY + fd->size.height > layoutStruct->pageBottom);
+ if (frameSpansIntoNextPage && fd->size.height <= layoutStruct->pageHeight) {
layoutStruct->newPage();
y = layoutStruct->y;
+
+ frameSpansIntoNextPage = false;
}
y = findY(y, layoutStruct, fd->size.width);
@@ -2017,6 +2022,11 @@ void QTextDocumentLayoutPrivate::positionFloat(QTextFrame *frame, QTextLine *cur
// qDebug()<< "float positioned at " << fd->position.x << fd->position.y;
fd->layoutDirty = false;
+
+ // If the frame is a table, then positioning it will affect the size if it covers more than
+ // one page, because of page breaks and repeating the header.
+ if (qobject_cast<QTextTable *>(frame) != 0)
+ fd->sizeDirty = frameSpansIntoNextPage;
}
QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, int layoutTo, QFixed parentY)
@@ -2349,6 +2359,10 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QLayoutStru
positionFloat(c);
+ // If the size was made dirty when the position was set, layout again
+ if (cd->sizeDirty)
+ updateRect = layoutFrame(c, layoutFrom, layoutTo);
+
QRectF frameRect(cd->position.toPointF(), cd->size.toSizeF());
if (frameRect == oldFrameRect && updateRect.isValid())
@@ -2567,6 +2581,7 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
QTextLine line = tl->createLine();
if (!line.isValid())
break;
+ line.setLeadingIncluded(true);
QFixed left, right;
floatMargins(layoutStruct->y, layoutStruct, &left, &right);
diff --git a/src/gui/text/qtextdocumentlayout_p.h b/src/gui/text/qtextdocumentlayout_p.h
index a3d014fc4..eaa91aeda 100644
--- a/src/gui/text/qtextdocumentlayout_p.h
+++ b/src/gui/text/qtextdocumentlayout_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp
index 33a5018d6..1e7e47bcb 100644
--- a/src/gui/text/qtextdocumentwriter.cpp
+++ b/src/gui/text/qtextdocumentwriter.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -76,7 +76,7 @@ public:
\brief The QTextDocumentWriter class provides a format-independent interface for writing a QTextDocument to files or other devices.
- \ingroup text
+ \ingroup richtext-processing
\ingroup io
To write a document, construct a QTextDocumentWriter object with either a
diff --git a/src/gui/text/qtextdocumentwriter.h b/src/gui/text/qtextdocumentwriter.h
index 9b7e9d48c..7c502a74c 100644
--- a/src/gui/text/qtextdocumentwriter.h
+++ b/src/gui/text/qtextdocumentwriter.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 953ca2fc5..a91408f01 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -1042,7 +1042,7 @@ void QTextEngine::shapeTextWithCE(int item) const
QScriptItem &si = layoutData->items[item];
si.glyph_data_offset = layoutData->used;
- QFontEngine *fe = fontEngine(si, &si.ascent, &si.descent);
+ QFontEngine *fe = fontEngine(si, &si.ascent, &si.descent, &si.leading);
QTextEngine::ShaperFlags flags;
if (si.analysis.bidiLevel % 2)
@@ -1119,7 +1119,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
si.glyph_data_offset = layoutData->used;
- QFontEngine *font = fontEngine(si, &si.ascent, &si.descent);
+ QFontEngine *font = fontEngine(si, &si.ascent, &si.descent, &si.leading);
bool kerningEnabled = this->font(si).d->kerning;
@@ -1350,8 +1350,11 @@ void QTextEngine::shape(int item) const
layoutData->items[item].position + block.position(), format);
}
} else if (layoutData->items[item].analysis.flags == QScriptAnalysis::Tab) {
- // set up at least the ascent/descent of the script item for the tab
- fontEngine(layoutData->items[item], &layoutData->items[item].ascent, &layoutData->items[item].descent);
+ // set up at least the ascent/descent/leading of the script item for the tab
+ fontEngine(layoutData->items[item],
+ &layoutData->items[item].ascent,
+ &layoutData->items[item].descent,
+ &layoutData->items[item].leading);
} else {
shapeText(item);
}
@@ -1396,8 +1399,12 @@ void QTextEngine::itemize() const
int length = layoutData->string.length();
if (!length)
return;
-
+#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
+ // ATSUI requires RTL flags to correctly identify the character stops.
+ bool ignore = false;
+#else
bool ignore = ignoreBidi;
+#endif
if (!ignore && option.textDirection() == Qt::LeftToRight) {
ignore = true;
const QChar *start = layoutData->string.unicode();
@@ -1594,11 +1601,13 @@ glyph_metrics_t QTextEngine::boundingBox(int from, int len) const
for (int i = 0; i < layoutData->items.size(); i++) {
const QScriptItem *si = layoutData->items.constData() + i;
+ QFontEngine *fe = fontEngine(*si);
+
int pos = si->position;
int ilen = length(i);
if (pos > from + len)
break;
- if (pos + len > from) {
+ if (pos + ilen > from) {
if (!si->num_glyphs)
shape(i);
@@ -1631,7 +1640,6 @@ glyph_metrics_t QTextEngine::boundingBox(int from, int len) const
charEnd++;
glyphEnd = (charEnd == ilen) ? si->num_glyphs : logClusters[charEnd];
if (glyphStart <= glyphEnd ) {
- QFontEngine *fe = fontEngine(*si);
glyph_metrics_t m = fe->boundingBox(glyphs.mid(glyphStart, glyphEnd - glyphStart));
gm.x = qMin(gm.x, m.x + gm.xoff);
gm.y = qMin(gm.y, m.y + gm.yoff);
@@ -1641,6 +1649,11 @@ glyph_metrics_t QTextEngine::boundingBox(int from, int len) const
gm.yoff += m.yoff;
}
}
+
+ glyph_t glyph = glyphs.glyphs[logClusters[pos + ilen - 1]];
+ glyph_metrics_t gi = fe->boundingBox(glyph);
+ if (gi.isValid())
+ gm.width -= qRound(gi.xoff - gi.x - gi.width);
}
}
return gm;
@@ -1727,7 +1740,7 @@ QFont QTextEngine::font(const QScriptItem &si) const
return font;
}
-QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFixed *descent) const
+QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFixed *descent, QFixed *leading) const
{
QFontEngine *engine = 0;
QFontEngine *scaledEngine = 0;
@@ -1767,6 +1780,7 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
if (ascent) {
*ascent = engine->ascent();
*descent = engine->descent();
+ *leading = engine->leading();
}
if (scaledEngine)
@@ -1999,8 +2013,12 @@ void QScriptLine::setDefaultHeight(QTextEngine *eng)
e = eng->fnt.d->engineForScript(QUnicodeTables::Common);
}
- ascent = qMax(ascent, e->ascent());
- descent = qMax(descent, e->descent());
+ QFixed other_ascent = e->ascent();
+ QFixed other_descent = e->descent();
+ QFixed other_leading = e->leading();
+ leading = qMax(leading + ascent, other_leading + other_ascent) - qMax(ascent, other_ascent);
+ ascent = qMax(ascent, other_ascent);
+ descent = qMax(descent, other_descent);
}
QTextEngine::LayoutData::LayoutData()
@@ -2069,10 +2087,12 @@ void QTextEngine::LayoutData::reallocate(int totalGlyphs)
int newAllocated = space_charAttributes + space_glyphs + space_logClusters;
Q_ASSERT(newAllocated >= allocated);
- void **old_mem = memory;
- memory = (void **)::realloc(memory_on_stack ? 0 : old_mem, newAllocated*sizeof(void *));
- if (memory_on_stack && memory)
- memcpy(memory, old_mem, allocated*sizeof(void *));
+ void **newMem = memory;
+ newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated*sizeof(void *));
+ Q_CHECK_PTR(newMem);
+ if (memory_on_stack && newMem)
+ memcpy(newMem, memory, allocated*sizeof(void *));
+ memory = newMem;
memory_on_stack = false;
void **m = memory;
@@ -2243,6 +2263,28 @@ void QTextEngine::indexAdditionalFormats()
}
}
+/* These two helper functions are used to determine whether we need to insert a ZWJ character
+ between the text that gets truncated and the ellipsis. This is important to get
+ correctly shaped results for arabic text.
+*/
+static bool nextCharJoins(const QString &string, int pos)
+{
+ while (pos < string.length() && string.at(pos).category() == QChar::Mark_NonSpacing)
+ ++pos;
+ if (pos == string.length())
+ return false;
+ return string.at(pos).joining() != QChar::OtherJoining;
+}
+
+static bool prevCharJoins(const QString &string, int pos)
+{
+ while (pos > 0 && string.at(pos - 1).category() == QChar::Mark_NonSpacing)
+ --pos;
+ if (pos == 0)
+ return false;
+ return (string.at(pos - 1).joining() == QChar::Dual || string.at(pos - 1).joining() == QChar::Center);
+}
+
QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags) const
{
// qDebug() << "elidedText; available width" << width.toReal() << "text width:" << this->width(0, layoutData->string.length()).toReal();
@@ -2343,6 +2385,9 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
} while (nextBreak < layoutData->string.length()
&& currentWidth < availableWidth);
+ if (nextCharJoins(layoutData->string, pos))
+ ellipsisText.prepend(QChar(0x200d) /* ZWJ */);
+
return layoutData->string.left(pos) + ellipsisText;
} else if (mode == Qt::ElideLeft) {
QFixed currentWidth;
@@ -2360,6 +2405,9 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
} while (nextBreak > 0
&& currentWidth < availableWidth);
+ if (prevCharJoins(layoutData->string, pos))
+ ellipsisText.append(QChar(0x200d) /* ZWJ */);
+
return ellipsisText + layoutData->string.mid(pos);
} else if (mode == Qt::ElideMiddle) {
QFixed leftWidth;
@@ -2389,6 +2437,11 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
&& nextRightBreak > 0
&& leftWidth + rightWidth < availableWidth);
+ if (nextCharJoins(layoutData->string, leftPos))
+ ellipsisText.prepend(QChar(0x200d) /* ZWJ */);
+ if (prevCharJoins(layoutData->string, rightPos))
+ ellipsisText.append(QChar(0x200d) /* ZWJ */);
+
return layoutData->string.left(leftPos) + ellipsisText + layoutData->string.mid(rightPos);
}
diff --git a/src/gui/text/qtextengine_mac.cpp b/src/gui/text/qtextengine_mac.cpp
index ce8011b98..54be53b05 100644
--- a/src/gui/text/qtextengine_mac.cpp
+++ b/src/gui/text/qtextengine_mac.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +50,6 @@ static void heuristicSetGlyphAttributes(const QChar *uc, int length, QGlyphLayou
{
// ### zeroWidth and justification are missing here!!!!!
- Q_ASSERT(num_glyphs <= length);
Q_UNUSED(num_glyphs);
// qDebug("QScriptEngine::heuristicSetGlyphAttributes, num_glyphs=%d", item->num_glyphs);
@@ -558,7 +557,7 @@ void QTextEngine::shapeTextMac(int item) const
si.glyph_data_offset = layoutData->used;
- QFontEngine *font = fontEngine(si, &si.ascent, &si.descent);
+ QFontEngine *font = fontEngine(si, &si.ascent, &si.descent, &si.leading);
if (font->type() != QFontEngine::Multi) {
shapeTextWithHarfbuzz(item);
return;
@@ -595,53 +594,50 @@ void QTextEngine::shapeTextMac(int item) const
str = reinterpret_cast<const QChar *>(uc);
}
- while (true) {
- ensureSpace(num_glyphs);
- num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used;
-
- QGlyphLayout g = availableGlyphs(&si);
- g.numGlyphs = num_glyphs;
- unsigned short *log_clusters = logClusters(&si);
-
- if (fe->stringToCMap(str,
- len,
- &g,
- &num_glyphs,
- flags,
- log_clusters,
- attributes())) {
-
- heuristicSetGlyphAttributes(str, len, &g, log_clusters, num_glyphs);
- break;
- }
+ ensureSpace(num_glyphs);
+ num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used;
+
+ QGlyphLayout g = availableGlyphs(&si);
+ g.numGlyphs = num_glyphs;
+ unsigned short *log_clusters = logClusters(&si);
+
+ bool stringToCMapFailed = false;
+ if (!fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters, attributes())) {
+ ensureSpace(num_glyphs);
+ stringToCMapFailed = fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters,
+ attributes());
}
- si.num_glyphs = num_glyphs;
+ if (!stringToCMapFailed) {
+ heuristicSetGlyphAttributes(str, len, &g, log_clusters, num_glyphs);
- layoutData->used += si.num_glyphs;
+ si.num_glyphs = num_glyphs;
- QGlyphLayout g = shapedGlyphs(&si);
+ layoutData->used += si.num_glyphs;
- if (si.analysis.script == QUnicodeTables::Arabic) {
- QVarLengthArray<QArabicProperties> props(len + 2);
- QArabicProperties *properties = props.data();
- int f = si.position;
- int l = len;
- if (f > 0) {
- --f;
- ++l;
- ++properties;
- }
- if (f + l < layoutData->string.length()) {
- ++l;
- }
- qt_getArabicProperties((const unsigned short *)(layoutData->string.unicode()+f), l, props.data());
+ QGlyphLayout g = shapedGlyphs(&si);
- unsigned short *log_clusters = logClusters(&si);
+ if (si.analysis.script == QUnicodeTables::Arabic) {
+ QVarLengthArray<QArabicProperties> props(len + 2);
+ QArabicProperties *properties = props.data();
+ int f = si.position;
+ int l = len;
+ if (f > 0) {
+ --f;
+ ++l;
+ ++properties;
+ }
+ if (f + l < layoutData->string.length()) {
+ ++l;
+ }
+ qt_getArabicProperties((const unsigned short *)(layoutData->string.unicode()+f), l, props.data());
- for (int i = 0; i < len; ++i) {
- int gpos = log_clusters[i];
- g.attributes[gpos].justification = properties[i].justification;
+ unsigned short *log_clusters = logClusters(&si);
+
+ for (int i = 0; i < len; ++i) {
+ int gpos = log_clusters[i];
+ g.attributes[gpos].justification = properties[i].justification;
+ }
}
}
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 0c33df9e7..a1d363be7 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -110,6 +110,7 @@ struct glyph_metrics_t
QFixed yoff;
glyph_metrics_t transformed(const QTransform &xform) const;
+ inline bool isValid() const {return x != 100000 && y != 100000;}
};
Q_DECLARE_TYPEINFO(glyph_metrics_t, Q_PRIMITIVE_TYPE);
@@ -344,11 +345,11 @@ struct Q_AUTOTEST_EXPORT QScriptItem
{
inline QScriptItem()
: position(0),
- num_glyphs(0), descent(-1), ascent(-1), width(-1),
+ num_glyphs(0), descent(-1), ascent(-1), leading(-1), width(-1),
glyph_data_offset(0) {}
inline QScriptItem(int p, const QScriptAnalysis &a)
: position(p), analysis(a),
- num_glyphs(0), descent(-1), ascent(-1), width(-1),
+ num_glyphs(0), descent(-1), ascent(-1), leading(-1), width(-1),
glyph_data_offset(0) {}
int position;
@@ -356,6 +357,7 @@ struct Q_AUTOTEST_EXPORT QScriptItem
unsigned short num_glyphs;
QFixed descent;
QFixed ascent;
+ QFixed leading;
QFixed width;
int glyph_data_offset;
QFixed height() const { return ascent + descent + 1; }
@@ -372,9 +374,10 @@ struct Q_AUTOTEST_EXPORT QScriptLine
QScriptLine()
: from(0), length(0),
justified(0), gridfitted(0),
- hasTrailingSpaces(0) {}
+ hasTrailingSpaces(0), leadingIncluded(0) {}
QFixed descent;
QFixed ascent;
+ QFixed leading;
QFixed x;
QFixed y;
QFixed width;
@@ -384,7 +387,11 @@ struct Q_AUTOTEST_EXPORT QScriptLine
mutable uint justified : 1;
mutable uint gridfitted : 1;
uint hasTrailingSpaces : 1;
- QFixed height() const { return ascent + descent + 1; }
+ uint leadingIncluded : 1;
+ QFixed height() const { return ascent + descent + 1
+ + (leadingIncluded? qMax(QFixed(),leading) : QFixed()); }
+ QFixed base() const { return ascent
+ + (leadingIncluded ? qMax(QFixed(),leading) : QFixed()); }
void setDefaultHeight(QTextEngine *eng);
void operator+=(const QScriptLine &other);
};
@@ -393,6 +400,7 @@ Q_DECLARE_TYPEINFO(QScriptLine, Q_PRIMITIVE_TYPE);
inline void QScriptLine::operator+=(const QScriptLine &other)
{
+ leading= qMax(leading + ascent, other.leading + other.ascent) - qMax(ascent, other.ascent);
descent = qMax(descent, other.descent);
ascent = qMax(ascent, other.ascent);
textWidth += other.textWidth;
@@ -475,7 +483,7 @@ public:
return end - si->position;
}
- QFontEngine *fontEngine(const QScriptItem &si, QFixed *ascent = 0, QFixed *descent = 0) const;
+ QFontEngine *fontEngine(const QScriptItem &si, QFixed *ascent = 0, QFixed *descent = 0, QFixed *leading = 0) const;
QFont font(const QScriptItem &si) const;
inline QFont font() const { return fnt; }
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 075f2ff2b..deda39fe9 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
\brief The QTextLength class encapsulates the different types of length
used in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
When we specify a value for the length of an element in a text document,
we often need to provide some other information so that the length is
@@ -265,21 +265,55 @@ private:
friend QDataStream &operator>>(QDataStream &, QTextFormat &);
};
-static uint variantHash(const QVariant &variant)
+// this is only safe if sizeof(int) == sizeof(float)
+static inline uint hash(float d)
{
- switch (variant.userType()) {
- case QVariant::Invalid: return 0;
- case QVariant::Bool: return variant.toBool();
- case QVariant::Int: return variant.toInt();
- case QMetaType::Float: return static_cast<int>(variant.toFloat());
- case QVariant::Double: return static_cast<int>(variant.toDouble());
+ return reinterpret_cast<uint&>(d);
+}
+
+static inline uint hash(const QColor &color)
+{
+ return (color.isValid()) ? color.rgba() : 0x234109;
+}
+
+static inline uint hash(const QPen &pen)
+{
+ return hash(pen.color()) + hash(pen.widthF());
+}
+
+static inline uint hash(const QBrush &brush)
+{
+ return hash(brush.color()) + (brush.style() << 3);
+}
+
+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::Color: return qHash(qvariant_cast<QColor>(variant).rgb());
+ case QVariant::Double: return hash(variant.toDouble());
+ case QVariant::Int: return 0x811890 + variant.toInt();
+ case QVariant::Brush:
+ return 0x01010101 + hash(qvariant_cast<QBrush>(variant));
+ case QVariant::Bool: return 0x371818 + variant.toBool();
+ case QVariant::Pen: return 0x02020202 + hash(qvariant_cast<QPen>(variant));
+ case QVariant::List:
+ return 0x8377 + qvariant_cast<QVariantList>(variant).count();
+ 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 QVariant::Invalid: return 0;
default: break;
}
return qHash(variant.typeName());
}
+static inline int getHash(const QTextFormatPrivate *d, int format)
+{
+ return (d ? d->hash() : 0) + format;
+}
+
uint QTextFormatPrivate::recalcHash() const
{
hashValue = 0;
@@ -415,7 +449,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
\brief The QTextFormat class provides formatting information for a
QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
\ingroup shared
A QTextFormat is a generic class used for describing the format of
@@ -448,7 +482,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
associate the format with a QTextObject. It is used to represent
lists, frames, and tables inside the document.
- \sa {Text Processing Classes}
+ \sa {Rich Text Processing}
*/
/*!
@@ -1184,7 +1218,7 @@ bool QTextFormat::operator==(const QTextFormat &rhs) const
\brief The QTextCharFormat class provides formatting information for
characters in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
The character format of text in a document specifies the visual properties
of the text, as well as information about its role in a hypertext document.
@@ -1797,7 +1831,7 @@ QFont QTextCharFormat::font() const
\brief The QTextBlockFormat class provides formatting information for
blocks of text in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
A document is composed of a list of blocks, represented by QTextBlock
objects. Each block can contain an item of some kind, such as a
@@ -2088,7 +2122,7 @@ QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const
\brief The QTextListFormat class provides formatting information for
lists in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
A list is composed of one or more items, represented as text blocks.
The list's format specifies the appearance of items in the list.
@@ -2198,7 +2232,7 @@ QTextListFormat::QTextListFormat(const QTextFormat &fmt)
\brief The QTextFrameFormat class provides formatting information for
frames in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
A text frame groups together one or more blocks of text, providing a layer
of structure larger than the paragraph. The format of a frame specifies
@@ -2524,7 +2558,7 @@ qreal QTextFrameFormat::rightMargin() const
\brief The QTextTableFormat class provides formatting information for
tables in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
A table is a group of cells ordered into rows and columns. Each table
contains at least one row and one column. Each cell contains a block.
@@ -2730,7 +2764,7 @@ QTextTableFormat::QTextTableFormat(const QTextFormat &fmt)
\brief The QTextImageFormat class provides formatting information for
images in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
Inline images are represented by an object replacement character
(0xFFFC in Unicode) which has an associated QTextImageFormat. The
@@ -2999,7 +3033,7 @@ QTextTableCellFormat::QTextTableCellFormat(const QTextFormat &fmt)
\brief The QTextTableCellFormat class provides formatting information for
table cells in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
The table cell format of a table cell in a document specifies the visual
properties of the table cell.
@@ -3033,32 +3067,42 @@ QTextFormatCollection::~QTextFormatCollection()
int QTextFormatCollection::indexForFormat(const QTextFormat &format)
{
- uint hash = format.d ? format.d->hash() : 0;
- if (hashes.contains(hash)) {
- for (int i = 0; i < formats.size(); ++i) {
- if (formats.at(i) == format)
- return i;
+ uint hash = getHash(format.d, format.format_type);
+ QMultiHash<uint, int>::const_iterator i = hashes.find(hash);
+ while (i != hashes.end() && i.key() == hash) {
+ if (formats.value(i.value()) == format) {
+ return i.value();
}
+ ++i;
}
+
int idx = formats.size();
formats.append(format);
- QTextFormat &f = formats.last();
- if (!f.d)
- f.d = new QTextFormatPrivate;
- f.d->resolveFont(defaultFnt);
+ QT_TRY{
+ QTextFormat &f = formats.last();
+ if (!f.d)
+ f.d = new QTextFormatPrivate;
+ f.d->resolveFont(defaultFnt);
- hashes.insert(hash);
+ hashes.insert(hash, idx);
+
+ } QT_CATCH(...) {
+ formats.pop_back();
+ QT_RETHROW;
+ }
return idx;
}
bool QTextFormatCollection::hasFormatCached(const QTextFormat &format) const
{
- uint hash = format.d ? format.d->hash() : 0;
- if (hashes.contains(hash)) {
- for (int i = 0; i < formats.size(); ++i)
- if (formats.at(i) == format)
- return true;
+ uint hash = getHash(format.d, format.format_type);
+ QMultiHash<uint, int>::const_iterator i = hashes.find(hash);
+ while (i != hashes.end() && i.key() == hash) {
+ if (formats.value(i.value()) == format) {
+ return true;
+ }
+ ++i;
}
return false;
}
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index c58337176..7accf8115 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h
index 205e32265..73ca0ce73 100644
--- a/src/gui/text/qtextformat_p.h
+++ b/src/gui/text/qtextformat_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -55,7 +55,7 @@
#include "QtGui/qtextformat.h"
#include "QtCore/qvector.h"
-#include "QtCore/qset.h"
+#include "QtCore/qhash.h"
QT_BEGIN_NAMESPACE
@@ -97,7 +97,7 @@ public:
FormatVector formats;
QVector<qint32> objFormats;
- QSet<uint> hashes;
+ QMultiHash<uint,int> hashes;
inline QFont defaultFont() const { return defaultFnt; }
void setDefaultFont(const QFont &f);
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 92b2d4ee9..c4714057c 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h
index 27d210c75..63dfcf520 100644
--- a/src/gui/text/qtexthtmlparser_p.h
+++ b/src/gui/text/qtexthtmlparser_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index 26b8ad7ef..415cb910b 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextimagehandler_p.h b/src/gui/text/qtextimagehandler_p.h
index 1bbce5d11..1665c672e 100644
--- a/src/gui/text/qtextimagehandler_p.h
+++ b/src/gui/text/qtextimagehandler_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 242dbbf2c..4600a291d 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -128,7 +128,7 @@ static QFixed alignLine(QTextEngine *eng, const QScriptLine &line)
\brief The QTextInlineObject class represents an inline object in
a QTextLayout.
- \ingroup text
+ \ingroup richtext-processing
This class is only used if the text layout is used to lay out
parts of a QTextDocument.
@@ -285,7 +285,7 @@ Qt::LayoutDirection QTextInlineObject::textDirection() const
\brief The QTextLayout class is used to lay out and paint a single
paragraph of text.
- \ingroup text
+ \ingroup richtext-processing
It offers most features expected from a modern text layout
engine, including Unicode compliant rendering, line breaking and
@@ -367,7 +367,7 @@ QTextLayout::QTextLayout(const QString& text, const QFont &font, QPaintDevice *p
QFont f(font);
if (paintdevice)
f = QFont(font, paintdevice);
- d = new QTextEngine((text.isNull() ? (const QString&)QString::fromLatin1("") : text), f.d);
+ d = new QTextEngine((text.isNull() ? (const QString&)QString::fromLatin1("") : text), f.d.data());
}
/*!
@@ -860,7 +860,7 @@ QRectF QTextLayout::boundingRect() const
ymin = qMin(ymin, si.y);
xmax = qMax(xmax, si.x+qMax(si.width, si.textWidth));
// ### shouldn't the ascent be used in ymin???
- ymax = qMax(ymax, si.y+si.ascent+si.descent+1);
+ ymax = qMax(ymax, si.y+si.height());
}
return QRectF(xmin.toReal(), ymin.toReal(), (xmax-xmin).toReal(), (ymax-ymin).toReal());
}
@@ -1071,10 +1071,10 @@ static void addSelectedRegionsToPath(QTextEngine *eng, int lineNumber, const QPo
QTextLineItemIterator iterator(eng, lineNumber, pos, selection);
- const QFixed y = QFixed::fromReal(pos.y()) + line.y + line.ascent;
+
+ const qreal selectionY = pos.y() + line.y.toReal();
const qreal lineHeight = line.height().toReal();
- const qreal selectionY = (y - line.ascent).toReal();
QFixed lastSelectionX = iterator.x;
QFixed lastSelectionWidth;
@@ -1334,23 +1334,23 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
const qreal x = position.x() + l.cursorToX(cursorPosition);
int itm = d->findItem(cursorPosition - 1);
- QFixed ascent = sl.ascent;
+ QFixed base = sl.base();
QFixed descent = sl.descent;
bool rightToLeft = (d->option.textDirection() == Qt::RightToLeft);
if (itm >= 0) {
const QScriptItem &si = d->layoutData->items.at(itm);
if (si.ascent > 0)
- ascent = si.ascent;
+ base = si.ascent;
if (si.descent > 0)
descent = si.descent;
rightToLeft = si.analysis.bidiLevel % 2;
}
- qreal y = position.y() + (sl.y + sl.ascent - ascent).toReal();
+ qreal y = position.y() + (sl.y + sl.base() - base).toReal();
bool toggleAntialiasing = !(p->renderHints() & QPainter::Antialiasing)
&& (p->transform().type() > QTransform::TxTranslate);
if (toggleAntialiasing)
p->setRenderHint(QPainter::Antialiasing);
- p->fillRect(QRectF(x, y, qreal(width), (ascent + descent).toReal()), p->pen().brush());
+ p->fillRect(QRectF(x, y, qreal(width), (base + descent + 1).toReal()), p->pen().brush());
if (toggleAntialiasing)
p->setRenderHint(QPainter::Antialiasing, false);
if (d->layoutData->hasBidi) {
@@ -1368,7 +1368,7 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
\brief The QTextLine class represents a line of text inside a QTextLayout.
- \ingroup text
+ \ingroup richtext-processing
A text line is usually created by QTextLayout::createLine().
@@ -1500,9 +1500,11 @@ qreal QTextLine::descent() const
}
/*!
- Returns the line's height. This is equal to ascent() + descent() + 1.
+ Returns the line's height. This is equal to ascent() + descent() + 1
+ if leading is not included. If leading is included, this equals to
+ ascent() + descent() + leading() + 1.
- \sa ascent() descent()
+ \sa ascent() descent() leading() setLeadingIncluded()
*/
qreal QTextLine::height() const
{
@@ -1510,6 +1512,51 @@ qreal QTextLine::height() const
}
/*!
+ \since 4.6
+
+ Returns the line's leading.
+
+ \sa ascent() descent() height()
+*/
+qreal QTextLine::leading() const
+{
+ return eng->lines[i].leading.toReal();
+}
+
+/*! \since 4.6
+
+ Includes positive leading into the line's height if \a included is true;
+ otherwise does not include leading.
+
+ By default, leading is not included.
+
+ Note that negative leading is ignored, it must be handled
+ in the code using the text lines by letting the lines overlap.
+
+ \sa leadingIncluded()
+
+*/
+void QTextLine::setLeadingIncluded(bool included)
+{
+ eng->lines[i].leadingIncluded= included;
+
+}
+
+/*! \since 4.6
+
+ Returns true if positive leading is included into the line's height; otherwise returns false.
+
+ By default, leading is not included.
+
+ \sa setLeadingIncluded()
+*/
+bool QTextLine::leadingIncluded() const
+{
+ return eng->lines[i].leadingIncluded;
+}
+
+
+/*!
Returns the width of the line that is occupied by text. This is
always \<= to width(), and is the minimum width that could be used
by layout() without changing the line break position.
@@ -1589,27 +1636,54 @@ void QTextLine::setNumColumns(int numColumns, qreal alignmentWidth)
#define LB_DEBUG if (0) qDebug
#endif
-static inline bool checkFullOtherwiseExtend(QScriptLine &line, QScriptLine &tmpData, QScriptLine &spaceData,
- int glyphCount, int maxGlyphs, QFixed &minw, bool manualWrap,
- QFixed softHyphenWidth = QFixed())
-{
+namespace {
+
+ struct LineBreakHelper
+ {
+ LineBreakHelper() : glyphCount(0), maxGlyphs(0), manualWrap(false) {}
+
+ QScriptLine tmpData;
+ QScriptLine spaceData;
+
+ int glyphCount;
+ int maxGlyphs;
+
+ QFixed minw;
+ QFixed softHyphenWidth;
+ QFixed rightBearing;
+
+ bool manualWrap;
+
+ bool checkFullOtherwiseExtend(QScriptLine &line);
+ };
+
+inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line)
+{
LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal());
- if (line.length && !manualWrap &&
- (line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth > line.width || glyphCount > maxGlyphs))
+
+ QFixed newWidth = line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth + rightBearing;
+ if (line.length && !manualWrap && (newWidth > line.width || glyphCount > maxGlyphs))
return true;
+
minw = qMax(minw, tmpData.textWidth);
line += tmpData;
line.textWidth += spaceData.textWidth;
+
line.length += spaceData.length;
tmpData.textWidth = 0;
tmpData.length = 0;
spaceData.textWidth = 0;
spaceData.length = 0;
+
return false;
}
+} // anonymous namespace
+
+
static inline void addNextCluster(int &pos, int end, QScriptLine &line, int &glyphCount,
- const QScriptItem &current, const unsigned short *logClusters, const QGlyphLayout &glyphs)
+ const QScriptItem &current, const unsigned short *logClusters,
+ const QGlyphLayout &glyphs)
{
int glyphPosition = logClusters[pos];
do { // got to the first next cluster
@@ -1642,9 +1716,13 @@ void QTextLine::layout_helper(int maxGlyphs)
Q_ASSERT(line.from < eng->layoutData->string.length());
+ LineBreakHelper lbh;
+
+ lbh.maxGlyphs = maxGlyphs;
+
QTextOption::WrapMode wrapMode = eng->option.wrapMode();
bool breakany = (wrapMode == QTextOption::WrapAnywhere);
- bool manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap);
+ lbh.manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap);
// #### binary search!
int item = -1;
@@ -1654,12 +1732,7 @@ void QTextLine::layout_helper(int maxGlyphs)
break;
}
- QFixed minw = 0;
- int glyphCount = 0;
-
LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal());
- QScriptLine tmpData;
- QScriptLine spaceData;
Qt::Alignment alignment = eng->option.alignment();
@@ -1668,7 +1741,10 @@ void QTextLine::layout_helper(int maxGlyphs)
int end = 0;
QGlyphLayout glyphs;
const unsigned short *logClusters = eng->layoutData->logClustersPtr;
+
while (newItem < eng->layoutData->items.size()) {
+ lbh.rightBearing = 0;
+ lbh.softHyphenWidth = 0;
if (newItem != item) {
item = newItem;
const QScriptItem &current = eng->layoutData->items[item];
@@ -1683,57 +1759,68 @@ void QTextLine::layout_helper(int maxGlyphs)
}
const QScriptItem &current = eng->layoutData->items[item];
- tmpData.ascent = qMax(tmpData.ascent, current.ascent);
- tmpData.descent = qMax(tmpData.descent, current.descent);
+ lbh.tmpData.leading = qMax(lbh.tmpData.leading + lbh.tmpData.ascent,
+ current.leading + current.ascent) - qMax(lbh.tmpData.ascent,
+ current.ascent);
+ lbh.tmpData.ascent = qMax(lbh.tmpData.ascent, current.ascent);
+ lbh.tmpData.descent = qMax(lbh.tmpData.descent, current.descent);
if (current.analysis.flags == QScriptAnalysis::Tab && (alignment & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignCenter | Qt::AlignJustify))) {
- if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap))
+ if (lbh.checkFullOtherwiseExtend(line))
goto found;
- QFixed x = line.x + line.textWidth + tmpData.textWidth + spaceData.textWidth;
- spaceData.textWidth += eng->calculateTabWidth(item, x);
- spaceData.length++;
+ QFixed x = line.x + line.textWidth + lbh.tmpData.textWidth + lbh.spaceData.textWidth;
+ QFixed tabWidth = eng->calculateTabWidth(item, x);
+
+ lbh.spaceData.textWidth += tabWidth;
+ lbh.spaceData.length++;
newItem = item + 1;
- ++glyphCount;
- if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap))
+
+ QFixed averageCharWidth = eng->fontEngine(current)->averageCharWidth();
+ lbh.glyphCount += qRound(tabWidth / averageCharWidth);
+
+ if (lbh.checkFullOtherwiseExtend(line))
goto found;
} else if (current.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator) {
// if the line consists only of the line separator make sure
// we have a sane height
- if (!line.length && !tmpData.length)
+ if (!line.length && !lbh.tmpData.length)
line.setDefaultHeight(eng);
if (eng->option.flags() & QTextOption::ShowLineAndParagraphSeparators) {
- addNextCluster(pos, end, tmpData, glyphCount, current, logClusters, glyphs);
+ addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount,
+ current, logClusters, glyphs);
} else {
- tmpData.length++;
+ lbh.tmpData.length++;
}
- line += tmpData;
+ line += lbh.tmpData;
goto found;
} else if (current.analysis.flags == QScriptAnalysis::Object) {
- tmpData.length++;
+ lbh.tmpData.length++;
QTextFormat format = eng->formats()->format(eng->formatIndex(&eng->layoutData->items[item]));
if (eng->block.docHandle())
eng->docLayout()->positionInlineObject(QTextInlineObject(item, eng), eng->block.position() + current.position, format);
- tmpData.textWidth += current.width;
+ lbh.tmpData.textWidth += current.width;
newItem = item + 1;
- ++glyphCount;
- if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap))
+ ++lbh.glyphCount;
+ if (lbh.checkFullOtherwiseExtend(line))
goto found;
} else if (attributes[pos].whiteSpace) {
while (pos < end && attributes[pos].whiteSpace)
- addNextCluster(pos, end, spaceData, glyphCount, current, logClusters, glyphs);
+ addNextCluster(pos, end, lbh.spaceData, lbh.glyphCount,
+ current, logClusters, glyphs);
- if (!manualWrap && spaceData.textWidth > line.width) {
- spaceData.textWidth = line.width; // ignore spaces that fall out of the line.
+ if (!lbh.manualWrap && lbh.spaceData.textWidth > line.width) {
+ lbh.spaceData.textWidth = line.width; // ignore spaces that fall out of the line.
goto found;
}
} else {
bool sb_or_ws = false;
do {
- addNextCluster(pos, end, tmpData, glyphCount, current, logClusters, glyphs);
+ addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount,
+ current, logClusters, glyphs);
if (attributes[pos].whiteSpace || attributes[pos-1].lineBreakType != HB_NoBreak) {
sb_or_ws = true;
@@ -1742,9 +1829,8 @@ void QTextLine::layout_helper(int maxGlyphs)
break;
}
} while (pos < end);
- minw = qMax(tmpData.textWidth, minw);
+ lbh.minw = qMax(lbh.tmpData.textWidth, lbh.minw);
- QFixed softHyphenWidth;
if (pos && attributes[pos - 1].lineBreakType == HB_SoftHyphen) {
// if we are splitting up a word because of
// a soft hyphen then we ...
@@ -1763,16 +1849,30 @@ void QTextLine::layout_helper(int maxGlyphs)
// and thus become invisible again.
//
if (line.length)
- softHyphenWidth = glyphs.advances_x[logClusters[pos - 1]];
+ lbh.softHyphenWidth = glyphs.advances_x[logClusters[pos - 1]];
else if (breakany)
- tmpData.textWidth += glyphs.advances_x[logClusters[pos - 1]];
+ lbh.tmpData.textWidth += glyphs.advances_x[logClusters[pos - 1]];
}
- if ((sb_or_ws|breakany)
- && checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap, softHyphenWidth)) {
+ // The actual width of the text needs to take the right bearing into account. The
+ // right bearing is left-ward, which means that if the rightmost pixel is to the right
+ // of the advance of the glyph, the bearing will be negative. We flip the sign
+ // for the code to be more readable. Logic borrowed from qfontmetrics.cpp.
+ if (pos) {
+ QFontEngine *fontEngine = eng->fontEngine(current);
+ glyph_t glyph = glyphs.glyphs[logClusters[pos - 1]];
+ glyph_metrics_t gi = fontEngine->boundingBox(glyph);
+ if (gi.isValid())
+ lbh.rightBearing = qMax(QFixed(), -(gi.xoff - gi.x - gi.width));
+ }
+
+ if ((sb_or_ws|breakany) && lbh.checkFullOtherwiseExtend(line)) {
if (!breakany) {
- line.textWidth += softHyphenWidth;
+ line.textWidth += lbh.softHyphenWidth;
}
+
+ line.textWidth += lbh.rightBearing;
+
goto found;
}
}
@@ -1780,45 +1880,48 @@ void QTextLine::layout_helper(int maxGlyphs)
newItem = item + 1;
}
LB_DEBUG("reached end of line");
- checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap);
-found:
+ lbh.checkFullOtherwiseExtend(line);
+ line.textWidth += lbh.rightBearing;
+
+found:
if (line.length == 0) {
LB_DEBUG("no break available in line, adding temp: length %d, width %f, space: length %d, width %f",
- tmpData.length, tmpData.textWidth.toReal(), spaceData.length, spaceData.textWidth.toReal());
- line += tmpData;
+ lbh.tmpData.length, lbh.tmpData.textWidth.toReal(),
+ lbh.spaceData.length, lbh.spaceData.textWidth.toReal());
+ line += lbh.tmpData;
}
LB_DEBUG("line length = %d, ascent=%f, descent=%f, textWidth=%f (spacew=%f)", line.length, line.ascent.toReal(),
- line.descent.toReal(), line.textWidth.toReal(), spaceData.width.toReal());
+ line.descent.toReal(), line.textWidth.toReal(), lbh.spaceData.width.toReal());
LB_DEBUG(" : '%s'", eng->layoutData->string.mid(line.from, line.length).toUtf8().data());
- if (manualWrap) {
+ if (lbh.manualWrap) {
eng->minWidth = qMax(eng->minWidth, line.textWidth);
eng->maxWidth = qMax(eng->maxWidth, line.textWidth);
} else {
- eng->minWidth = qMax(eng->minWidth, minw);
+ eng->minWidth = qMax(eng->minWidth, lbh.minw);
eng->maxWidth += line.textWidth;
}
if (line.textWidth > 0 && item < eng->layoutData->items.size())
- eng->maxWidth += spaceData.textWidth;
+ eng->maxWidth += lbh.spaceData.textWidth;
if (eng->option.flags() & QTextOption::IncludeTrailingSpaces)
- line.textWidth += spaceData.textWidth;
- line.length += spaceData.length;
- if (spaceData.length)
+ line.textWidth += lbh.spaceData.textWidth;
+ line.length += lbh.spaceData.length;
+ if (lbh.spaceData.length)
line.hasTrailingSpaces = true;
line.justified = false;
line.gridfitted = false;
if (eng->option.wrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere) {
- if ((maxGlyphs != INT_MAX && glyphCount > maxGlyphs)
- || (maxGlyphs == INT_MAX && line.textWidth > line.width)) {
+ if ((lbh.maxGlyphs != INT_MAX && lbh.glyphCount > lbh.maxGlyphs)
+ || (lbh.maxGlyphs == INT_MAX && line.textWidth > line.width)) {
eng->option.setWrapMode(QTextOption::WrapAnywhere);
line.length = 0;
line.textWidth = 0;
- layout_helper(maxGlyphs);
+ layout_helper(lbh.maxGlyphs);
eng->option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
}
}
@@ -1989,7 +2092,9 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
QTextLineItemIterator iterator(eng, i, pos, selection);
- const QFixed y = QFixed::fromReal(pos.y()) + line.y + line.ascent;
+ QFixed lineBase = line.base();
+
+ const QFixed y = QFixed::fromReal(pos.y()) + line.y + lineBase;
bool suppressColors = (eng->option.flags() & QTextOption::SuppressColors);
while (!iterator.atEnd()) {
@@ -2012,7 +2117,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
if (selection)
format.merge(selection->format);
- setPenAndDrawBackground(p, pen, format, QRectF(iterator.x.toReal(), (y - line.ascent).toReal(),
+ setPenAndDrawBackground(p, pen, format, QRectF(iterator.x.toReal(), (y - lineBase).toReal(),
iterator.itemWidth.toReal(), line.height().toReal()));
QTextCharFormat::VerticalAlignment valign = format.verticalAlignment();
@@ -2033,7 +2138,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
if (si.analysis.flags == QScriptAnalysis::Object && eng->block.docHandle()) {
QFixed itemY = y - si.ascent;
if (format.verticalAlignment() == QTextCharFormat::AlignTop) {
- itemY = y - line.ascent;
+ itemY = y - lineBase;
}
QRectF itemRect(iterator.x.toReal(), itemY.toReal(), iterator.itemWidth.toReal(), si.height().toReal());
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index b2d4a572d..9f170f50c 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -196,6 +196,10 @@ public:
qreal ascent() const;
qreal descent() const;
qreal height() const;
+ qreal leading() const;
+
+ void setLeadingIncluded(bool included);
+ bool leadingIncluded() const;
qreal naturalTextWidth() const;
QRectF naturalTextRect() const;
diff --git a/src/gui/text/qtextlist.cpp b/src/gui/text/qtextlist.cpp
index 8348c924f..2b6788eba 100644
--- a/src/gui/text/qtextlist.cpp
+++ b/src/gui/text/qtextlist.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -63,7 +63,7 @@ public:
\brief The QTextList class provides a decorated list of items in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
A list contains a sequence of text blocks, each of which is marked with a
bullet point or other symbol. Multiple levels of lists can be used, and
diff --git a/src/gui/text/qtextlist.h b/src/gui/text/qtextlist.h
index bc4885a14..49a7110e3 100644
--- a/src/gui/text/qtextlist.h
+++ b/src/gui/text/qtextlist.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index 5dc0c48ee..d9438fdc5 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
\brief The QTextObject class is a base class for different kinds
of objects that can group parts of a QTextDocument together.
- \ingroup text
+ \ingroup richtext-processing
The common grouping text objects are lists (QTextList), frames
(QTextFrame), and tables (QTextTable). A text object has an
@@ -183,7 +183,7 @@ QTextDocumentPrivate *QTextObject::docHandle() const
\brief The QTextBlockGroup class provides a container for text blocks within
a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
Block groups can be used to organize blocks of text within a document.
They maintain an up-to-date list of the text blocks that belong to
@@ -305,7 +305,7 @@ QTextFrameLayoutData::~QTextFrameLayoutData()
\brief The QTextFrame class represents a frame in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
Text frames provide structure for the text in a document. They are used
as generic containers for other document elements.
@@ -599,7 +599,7 @@ void QTextFramePrivate::remove_me()
\brief The iterator class provides an iterator for reading
the contents of a QTextFrame.
- \ingroup text
+ \ingroup richtext-processing
A frame consists of an arbitrary sequence of \l{QTextBlock}s and
child \l{QTextFrame}s. This class provides a way to iterate over the
@@ -799,7 +799,7 @@ QTextFrame::iterator &QTextFrame::iterator::operator--()
\brief The QTextBlockUserData class is used to associate custom data with blocks of text.
\since 4.1
- \ingroup text
+ \ingroup richtext-processing
QTextBlockUserData provides an abstract interface for container classes that are used
to associate application-specific user data with text blocks in a QTextDocument.
@@ -829,7 +829,7 @@ QTextBlockUserData::~QTextBlockUserData()
\brief The QTextBlock class provides a container for text fragments in a
QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
A text block encapsulates a block or paragraph of text in a QTextDocument.
QTextBlock provides read-only access to the block/paragraph structure of
@@ -924,7 +924,7 @@ QTextBlockUserData::~QTextBlockUserData()
\brief The QTextBlock::iterator class provides an iterator for reading
the contents of a QTextBlock.
- \ingroup text
+ \ingroup richtext-processing
A block consists of a sequence of text fragments. This class provides
a way to iterate over these, and read their contents. It does not provide
@@ -1370,7 +1370,7 @@ int QTextBlock::firstLineNumber() const
Sets the line count to \a count.
-/sa lineCount()
+\sa lineCount()
*/
void QTextBlock::setLineCount(int count)
{
@@ -1525,7 +1525,7 @@ QTextBlock::iterator &QTextBlock::iterator::operator--()
\brief The QTextFragment class holds a piece of text in a
QTextDocument with a single QTextCharFormat.
- \ingroup text
+ \ingroup richtext-processing
A text fragment describes a piece of text that is stored with a single
character format. Text in which the character format changes can be
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index d62fab2a7..9bdc6a6c3 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h
index 22034c8e5..d2153d31f 100644
--- a/src/gui/text/qtextobject_p.h
+++ b/src/gui/text/qtextobject_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index 7dc384ef8..1bd4dd674 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -447,18 +447,19 @@ void QTextOdfWriter::writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat
writer.writeStartElement(styleNS, QString::fromLatin1("paragraph-properties"));
if (format.hasProperty(QTextFormat::BlockAlignment)) {
+ const Qt::Alignment alignment = format.alignment() & Qt::AlignHorizontal_Mask;
QString value;
- if (format.alignment() == Qt::AlignLeading)
+ if (alignment == Qt::AlignLeading)
value = QString::fromLatin1("start");
- else if (format.alignment() == Qt::AlignTrailing)
+ else if (alignment == Qt::AlignTrailing)
value = QString::fromLatin1("end");
- else if (format.alignment() == (Qt::AlignLeft | Qt::AlignAbsolute))
+ else if (alignment == (Qt::AlignLeft | Qt::AlignAbsolute))
value = QString::fromLatin1("left");
- else if (format.alignment() == (Qt::AlignRight | Qt::AlignAbsolute))
+ else if (alignment == (Qt::AlignRight | Qt::AlignAbsolute))
value = QString::fromLatin1("right");
- else if (format.alignment() == Qt::AlignHCenter)
+ else if (alignment == Qt::AlignHCenter)
value = QString::fromLatin1("center");
- else if (format.alignment() == Qt::AlignJustify)
+ else if (alignment == Qt::AlignJustify)
value = QString::fromLatin1("justify");
else
qWarning() << "QTextOdfWriter: unsupported paragraph alignment; " << format.alignment();
@@ -550,9 +551,9 @@ void QTextOdfWriter::writeCharacterFormat(QXmlStreamWriter &writer, QTextCharFor
}
}
if (format.hasProperty(QTextFormat::FontLetterSpacing))
- writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontLetterSpacing()) );
+ writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontLetterSpacing()));
if (format.hasProperty(QTextFormat::FontWordSpacing))
- writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontWordSpacing()) );
+ writer.writeAttribute(foNS, QString::fromLatin1("word-spacing"), pixelToPoint(format.fontWordSpacing()));
if (format.hasProperty(QTextFormat::FontUnderline))
writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-type"),
format.fontUnderline() ? QString::fromLatin1("single") : QString::fromLatin1("none"));
diff --git a/src/gui/text/qtextodfwriter_p.h b/src/gui/text/qtextodfwriter_p.h
index b857939ec..de59721c8 100644
--- a/src/gui/text/qtextodfwriter_p.h
+++ b/src/gui/text/qtextodfwriter_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp
index ca30ed4c8..bdab3f283 100644
--- a/src/gui/text/qtextoption.cpp
+++ b/src/gui/text/qtextoption.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -117,7 +117,13 @@ QTextOption &QTextOption::operator=(const QTextOption &o)
{
if (this == &o)
return *this;
- delete d; d = 0;
+
+ QTextOptionPrivate* dNew = 0;
+ if (o.d)
+ dNew = new QTextOptionPrivate(*o.d);
+ delete d;
+ d = dNew;
+
align = o.align;
wordWrap = o.wordWrap;
design = o.design;
@@ -125,8 +131,6 @@ QTextOption &QTextOption::operator=(const QTextOption &o)
unused = o.unused;
f = o.f;
tab = o.tab;
- if (o.d)
- d = new QTextOptionPrivate(*o.d);
return *this;
}
@@ -197,7 +201,7 @@ QList<QTextOption::Tab> QTextOption::tabs() const
\brief The QTextOption class provides a description of general rich text
properties.
- \ingroup text
+ \ingroup richtext-processing
QTextOption is used to encapsulate common rich text properties in a single
object. It contains information about text alignment, layout direction,
@@ -341,9 +345,9 @@ QList<QTextOption::Tab> QTextOption::tabs() const
This enum holds the different types of tabulator
- \value LeftTab, A left-tab
- \value RightTab, A right-tab
- \value CenterTab, A centered-tab
+ \value LeftTab A left-tab
+ \value RightTab A right-tab
+ \value CenterTab A centered-tab
\value DelimiterTab A tab stopping at a certain delimiter-character
*/
diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h
index 29cd30c6f..62800e6fe 100644
--- a/src/gui/text/qtextoption.h
+++ b/src/gui/text/qtextoption.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index 9097b4ea3..c93287f3d 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
\brief The QTextTableCell class represents the properties of a
cell in a QTextTable.
- \ingroup text
+ \ingroup richtext-processing
Table cells are pieces of document structure that belong to a table.
The table orders cells into particular rows and columns; cells can
@@ -432,6 +432,13 @@ void QTextTablePrivate::fragmentRemoved(const QChar &type, uint fragment)
QTextFramePrivate::fragmentRemoved(type, fragment);
}
+/*!
+ /fn void QTextTablePrivate::update() const
+
+ This function is usually called when the table is "dirty".
+ It seems to update all kind of table information.
+
+*/
void QTextTablePrivate::update() const
{
Q_Q(const QTextTable);
@@ -439,7 +446,7 @@ void QTextTablePrivate::update() const
nRows = (cells.size() + nCols-1)/nCols;
// qDebug(">>>> QTextTablePrivate::update, nRows=%d, nCols=%d", nRows, nCols);
- grid = (int *)realloc(grid, nRows*nCols*sizeof(int));
+ grid = q_check_ptr((int *)realloc(grid, nRows*nCols*sizeof(int)));
memset(grid, 0, nRows*nCols*sizeof(int));
QTextDocumentPrivate *p = pieceTable;
@@ -463,7 +470,7 @@ void QTextTablePrivate::update() const
cellIndices[i] = cell;
if (r + rowspan > nRows) {
- grid = (int *)realloc(grid, sizeof(int)*(r + rowspan)*nCols);
+ grid = q_check_ptr((int *)realloc(grid, sizeof(int)*(r + rowspan)*nCols));
memset(grid + (nRows*nCols), 0, sizeof(int)*(r+rowspan-nRows)*nCols);
nRows = r + rowspan;
}
@@ -492,7 +499,7 @@ void QTextTablePrivate::update() const
\brief The QTextTable class represents a table in a QTextDocument.
- \ingroup text
+ \ingroup richtext-processing
A table is a group of cells ordered into rows and columns. Each table
contains at least one row and one column. Each cell contains a block, and
diff --git a/src/gui/text/qtexttable.h b/src/gui/text/qtexttable.h
index 800c2c57b..d887f41fc 100644
--- a/src/gui/text/qtexttable.h
+++ b/src/gui/text/qtexttable.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h
index 7783b5d36..b2e0f7465 100644
--- a/src/gui/text/qtexttable_p.h
+++ b/src/gui/text/qtexttable_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index 9fd13cd61..956704620 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -705,7 +705,7 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const
*/
QZipReader::QZipReader(const QString &archive, QIODevice::OpenMode mode)
{
- QFile *f = new QFile(archive);
+ QScopedPointer<QFile> f(new QFile(archive));
f->open(mode);
QZipReader::Status status;
if (f->error() == QFile::NoError)
@@ -721,7 +721,8 @@ QZipReader::QZipReader(const QString &archive, QIODevice::OpenMode mode)
status = FileError;
}
- d = new QZipReaderPrivate(f, /*ownDevice=*/true);
+ d = new QZipReaderPrivate(f.data(), /*ownDevice=*/true);
+ f.take();
d->status = status;
}
@@ -979,7 +980,7 @@ void QZipReader::close()
*/
QZipWriter::QZipWriter(const QString &fileName, QIODevice::OpenMode mode)
{
- QFile *f = new QFile(fileName);
+ QScopedPointer<QFile> f(new QFile(fileName));
f->open(mode);
QZipWriter::Status status;
if (f->error() == QFile::NoError)
@@ -995,7 +996,8 @@ QZipWriter::QZipWriter(const QString &fileName, QIODevice::OpenMode mode)
status = QZipWriter::FileError;
}
- d = new QZipWriterPrivate(f, /*ownDevice=*/true);
+ d = new QZipWriterPrivate(f.data(), /*ownDevice=*/true);
+ f.take();
d->status = status;
}
diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h
index 6e1730423..51546e8c1 100644
--- a/src/gui/text/qzipreader_p.h
+++ b/src/gui/text/qzipreader_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qzipwriter_p.h b/src/gui/text/qzipwriter_p.h
index f5190ad39..55b14675f 100644
--- a/src/gui/text/qzipwriter_p.h
+++ b/src/gui/text/qzipwriter_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index 94ed75631..b7615a43e 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -78,6 +78,7 @@ win32 {
unix:x11 {
HEADERS += \
text/qfontengine_x11_p.h \
+ text/qfontdatabase_x11.cpp \
text/qfontengine_ft_p.h
SOURCES += \
text/qfont_x11.cpp \
@@ -106,9 +107,27 @@ embedded {
DEFINES += QT_NO_FONTCONFIG
}
+symbian {
+ SOURCES += \
+ text/qfont_s60.cpp
+ contains(QT_CONFIG, freetype) {
+ SOURCES += \
+ text/qfontengine_ft.cpp
+ HEADERS += \
+ text/qfontengine_ft_p.h
+ DEFINES += \
+ QT_NO_FONTCONFIG
+ } else {
+ SOURCES += \
+ text/qfontengine_s60.cpp
+ HEADERS += \
+ text/qfontengine_s60_p.h
+ LIBS += -lfntstr -lecom
+ }
+}
+
contains(QT_CONFIG, freetype) {
SOURCES += \
- ../3rdparty/freetype/builds/unix/ftsystem.c \
../3rdparty/freetype/src/base/ftbase.c \
../3rdparty/freetype/src/base/ftbbox.c \
../3rdparty/freetype/src/base/ftdebug.c \
@@ -152,10 +171,19 @@ contains(QT_CONFIG, freetype) {
../3rdparty/freetype/src/autofit/afloader.c\
../3rdparty/freetype/src/autofit/autofit.c
+ symbian {
+ SOURCES += \
+ ../3rdparty/freetype/src/base/ftsystem.c
+ } else {
+ SOURCES += \
+ ../3rdparty/freetype/builds/unix/ftsystem.c
+ INCLUDEPATH += \
+ ../3rdparty/freetype/builds/unix
+ }
+
INCLUDEPATH += \
../3rdparty/freetype/src \
- ../3rdparty/freetype/include \
- ../3rdparty/freetype/builds/unix
+ ../3rdparty/freetype/include
DEFINES += FT2_BUILD_LIBRARY FT_CONFIG_OPTION_SYSTEM_ZLIB