summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-12-13 09:36:26 +0100
committerLiang Qi <liang.qi@qt.io>2016-12-13 09:39:20 +0100
commit6755ec891a1740110c48895afd53d39e8370704a (patch)
tree982606f3bc582262e4b315a63f55ccb141fff97b /src/gui/text
parent449204f8c0d6679ae0e58dbb8a30b8a86fbdb4ec (diff)
parent00c9ec63a552d040e851b561c11428fabf1a2b08 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: configure qmake/Makefile.unix.macos qmake/Makefile.unix.win32 qmake/generators/win32/msvc_vcproj.cpp src/3rdparty/pcre/qt_attribution.json src/corelib/io/qsettings.cpp src/corelib/kernel/qdeadlinetimer.cpp src/platformsupport/kmsconvenience/qkmsdevice.cpp src/platformsupport/kmsconvenience/qkmsdevice_p.h src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h tests/manual/qstorageinfo/printvolumes.cpp tools/configure/configureapp.cpp Change-Id: Ibaabcc8e965c44926f9fb018466e8b132b8df49e
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qcssparser.cpp1
-rw-r--r--src/gui/text/qfontdatabase.cpp10
-rw-r--r--src/gui/text/qfontengine.cpp11
-rw-r--r--src/gui/text/qfontengine_p.h1
-rw-r--r--src/gui/text/qharfbuzzng_p.h3
-rw-r--r--src/gui/text/qinputcontrol.cpp82
-rw-r--r--src/gui/text/qinputcontrol_p.h76
-rw-r--r--src/gui/text/qtextengine.cpp19
-rw-r--r--src/gui/text/qtextengine_p.h2
-rw-r--r--src/gui/text/text.pri10
10 files changed, 193 insertions, 22 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 31d832a9ce..a0438bd458 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -2211,6 +2211,7 @@ void Parser::init(const QString &css, bool isFile)
bool Parser::parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity)
{
if (testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("charset"))) {
+ while (test(S) || test(CDO) || test(CDC)) {}
if (!next(STRING)) return false;
if (!next(SEMICOLON)) return false;
}
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index d2da24ca94..43648d0f7f 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -406,9 +406,14 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create)
return foundries[count++];
}
+static inline bool equalsCaseInsensitive(const QString &a, const QString &b)
+{
+ return a.size() == b.size() && a.compare(b, Qt::CaseInsensitive) == 0;
+}
+
bool QtFontFamily::matchesFamilyName(const QString &familyName) const
{
- return name.compare(familyName, Qt::CaseInsensitive) == 0 || aliases.contains(familyName, Qt::CaseInsensitive);
+ return equalsCaseInsensitive(name, familyName) || aliases.contains(familyName, Qt::CaseInsensitive);
}
void QtFontFamily::ensurePopulated()
@@ -947,8 +952,8 @@ QFontEngine *loadSingleEngine(int script,
return 0;
}
+ engine->isSmoothlyScalable = style->smoothScalable;
fontCache->insertEngine(key, engine);
-
return engine;
}
}
@@ -973,6 +978,7 @@ QFontEngine *loadSingleEngine(int script,
return 0;
}
+ engine->isSmoothlyScalable = style->smoothScalable;
fontCache->insertEngine(key, engine);
if (Q_LIKELY(cacheForCommonScript && !engine->symbol)) {
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 74ea8d15b7..0b2972f189 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -53,7 +53,7 @@
#include <qendian.h>
#include <private/qstringiterator_p.h>
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
# include "qharfbuzzng_p.h"
# include <harfbuzz/hb-ot.h>
#endif
@@ -93,7 +93,7 @@ static inline bool qSafeFromBigEndian(const uchar *source, const uchar *end, T *
// Harfbuzz helper functions
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
Q_GLOBAL_STATIC_WITH_ARGS(bool, useHarfbuzzNG,(qgetenv("QT_HARFBUZZ") != "old"))
bool qt_useHarfbuzzNG()
@@ -257,6 +257,7 @@ QFontEngine::QFontEngine(Type type)
cache_cost = 0;
fsType = 0;
symbol = false;
+ isSmoothlyScalable = false;
glyphFormat = Format_None;
m_subPixelPositionCount = 0;
@@ -296,7 +297,7 @@ QFixed QFontEngine::underlinePosition() const
void *QFontEngine::harfbuzzFont() const
{
Q_ASSERT(type() != QFontEngine::Multi);
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
if (qt_useHarfbuzzNG())
return hb_qt_font_get_for_engine(const_cast<QFontEngine *>(this));
#endif
@@ -331,7 +332,7 @@ void *QFontEngine::harfbuzzFont() const
void *QFontEngine::harfbuzzFace() const
{
Q_ASSERT(type() != QFontEngine::Multi);
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
if (qt_useHarfbuzzNG())
return hb_qt_face_get_for_engine(const_cast<QFontEngine *>(this));
#endif
@@ -363,7 +364,7 @@ bool QFontEngine::supportsScript(QChar::Script script) const
return true;
}
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
if (qt_useHarfbuzzNG()) {
#if defined(Q_OS_DARWIN)
// in AAT fonts, 'gsub' table is effectively replaced by 'mort'/'morx' table
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 42610e9b70..c0e350f755 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -325,6 +325,7 @@ public:
uint cache_cost; // amount of mem used in bytes by the font
uint fsType : 16;
bool symbol;
+ bool isSmoothlyScalable;
struct KernPair {
uint left_right;
QFixed adjust;
diff --git a/src/gui/text/qharfbuzzng_p.h b/src/gui/text/qharfbuzzng_p.h
index 95a21eedb6..fabf222bae 100644
--- a/src/gui/text/qharfbuzzng_p.h
+++ b/src/gui/text/qharfbuzzng_p.h
@@ -53,6 +53,9 @@
//
#include <QtGui/private/qtguiglobal_p.h>
+
+QT_REQUIRE_CONFIG(harfbuzz);
+
#include <QtCore/qchar.h>
#include <harfbuzz/hb.h>
diff --git a/src/gui/text/qinputcontrol.cpp b/src/gui/text/qinputcontrol.cpp
new file mode 100644
index 0000000000..c2c198866a
--- /dev/null
+++ b/src/gui/text/qinputcontrol.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qinputcontrol_p.h"
+#include <QtGui/qevent.h>
+
+QT_BEGIN_NAMESPACE
+
+QInputControl::QInputControl(Type type, QObject *parent)
+ : QObject(parent)
+ , m_type(type)
+{
+}
+
+QInputControl::QInputControl(Type type, QObjectPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+ , m_type(type)
+{
+}
+
+bool QInputControl::isAcceptableInput(const QKeyEvent *event) const
+{
+ const QString text = event->text();
+ if (text.isEmpty())
+ return false;
+
+ const QChar c = text.at(0);
+
+ // ZWNJ and ZWJ. This needs to go before the next test, since CTRL+SHIFT is
+ // used to input it on Windows.
+ if (c == QChar(0x200C) || c == QChar(0x200D))
+ return true;
+
+ // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards
+ if (event->modifiers() == Qt::ControlModifier
+ || event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) {
+ return false;
+ }
+
+ if (c.isPrint())
+ return true;
+
+ if (c.category() == QChar::Other_PrivateUse)
+ return true;
+
+ if (m_type == TextEdit && c == QLatin1Char('\t'))
+ return true;
+
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/text/qinputcontrol_p.h b/src/gui/text/qinputcontrol_p.h
new file mode 100644
index 0000000000..3b46067ba9
--- /dev/null
+++ b/src/gui/text/qinputcontrol_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QINPUTCONTROL_P_H
+#define QINPUTCONTROL_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 <QtCore/qobject.h>
+#include <qtguiglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QKeyEvent;
+class Q_GUI_EXPORT QInputControl : public QObject
+{
+ Q_OBJECT
+public:
+ enum Type {
+ LineEdit,
+ TextEdit
+ };
+
+ explicit QInputControl(Type type, QObject *parent = nullptr);
+
+ bool isAcceptableInput(const QKeyEvent *event) const;
+
+protected:
+ explicit QInputControl(Type type, QObjectPrivate &dd, QObject *parent = nullptr);
+
+private:
+ const Type m_type;
+};
+
+QT_END_NAMESPACE
+
+#endif // QINPUTCONTROL_P_H
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 742b01dd1f..67cafa53fe 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -37,6 +37,7 @@
**
****************************************************************************/
+#include <QtGui/private/qtguiglobal_p.h>
#include "qdebug.h"
#include "qtextformat.h"
#include "qtextformat_p.h"
@@ -837,7 +838,7 @@ enum JustificationClass {
Justification_Arabic_Kashida = 13 // User-inserted Kashida(U+0640)
};
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
/*
Adds an inter character justification opportunity after the number or letter
@@ -916,7 +917,7 @@ static inline void qt_getJustificationOpportunities(const ushort *string, int le
qt_getDefaultJustificationOpportunities(string, length, g, log_clusters, spaceAs);
}
-#endif // QT_ENABLE_HARFBUZZ_NG
+#endif // harfbuzz
// shape all the items that intersect with the line, taking tab widths into account to find out what text actually fits in the line.
@@ -950,7 +951,7 @@ void QTextEngine::shapeLine(const QScriptLine &line)
}
}
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
extern bool qt_useHarfbuzzNG(); // defined in qfontengine.cpp
#endif
@@ -1063,7 +1064,7 @@ void QTextEngine::shapeText(int item) const
letterSpacing *= font.d->dpi / qt_defaultDpiY();
}
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
if (Q_LIKELY(qt_useHarfbuzzNG()))
si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled, letterSpacing != 0);
else
@@ -1079,7 +1080,7 @@ void QTextEngine::shapeText(int item) const
QGlyphLayout glyphs = shapedGlyphs(&si);
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
if (Q_LIKELY(qt_useHarfbuzzNG()))
qt_getJustificationOpportunities(string, itemLength, si, glyphs, logClusters(&si));
#endif
@@ -1119,7 +1120,7 @@ void QTextEngine::shapeText(int item) const
si.width += glyphs.advances[i] * !glyphs.attributes[i].dontPrint;
}
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
QT_BEGIN_INCLUDE_NAMESPACE
@@ -1313,7 +1314,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si,
return glyphs_shaped;
}
-#endif // QT_ENABLE_HARFBUZZ_NG
+#endif // harfbuzz
QT_BEGIN_INCLUDE_NAMESPACE
@@ -1669,7 +1670,7 @@ void QTextEngine::itemize() const
analysis->flags = QScriptAnalysis::None;
break;
}
-#ifndef QT_ENABLE_HARFBUZZ_NG
+#if !QT_CONFIG(harfbuzz)
analysis->script = hbscript_to_script(script_to_hbscript(analysis->script));
#endif
++uc;
@@ -1678,7 +1679,7 @@ void QTextEngine::itemize() const
if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) {
(analysis-1)->flags = QScriptAnalysis::LineOrParagraphSeparator; // to exclude it from width
}
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
analysis = scriptAnalysis.data();
if (qt_useHarfbuzzNG()) {
// ### pretend HB-old behavior for now
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 160e9ce490..f49e2638f5 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -649,7 +649,7 @@ private:
void setBoundary(int strPos) const;
void addRequiredBoundaries() const;
void shapeText(int item) const;
-#ifdef QT_ENABLE_HARFBUZZ_NG
+#if QT_CONFIG(harfbuzz)
int shapeTextWithHarfbuzzNG(const QScriptItem &si,
const ushort *string,
int itemLength,
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index a15793ec2f..abe20abe02 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -39,7 +39,8 @@ HEADERS += \
text/qrawfont_p.h \
text/qglyphrun.h \
text/qglyphrun_p.h \
- text/qdistancefield_p.h
+ text/qdistancefield_p.h \
+ text/qinputcontrol_p.h
SOURCES += \
text/qfont.cpp \
@@ -69,7 +70,8 @@ SOURCES += \
text/qstatictext.cpp \
text/qrawfont.cpp \
text/qglyphrun.cpp \
- text/qdistancefield.cpp
+ text/qdistancefield.cpp \
+ text/qinputcontrol.cpp
SOURCES += \
text/qfontengine_qpf2.cpp \
@@ -78,9 +80,7 @@ SOURCES += \
HEADERS += \
text/qplatformfontdatabase.h
-qtConfig(harfbuzz)|qtConfig(system-harfbuzz) {
- DEFINES += QT_ENABLE_HARFBUZZ_NG
-
+qtConfig(harfbuzz) {
QMAKE_USE_PRIVATE += harfbuzz
SOURCES += text/qharfbuzzng.cpp