summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-07-01 11:05:26 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-07-01 11:05:26 +0200
commit0aa2d318b1524cdab42ab9988270779ddcc1922a (patch)
tree695c70702763ba2c66eb398ae9d545fc712a9e2d /src/gui/text
parent6251d4dafc86bcbec09d1962050af9924249d419 (diff)
parent49049d90470eb3e94bda77d19ab7f7c57a0bd57f (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/corelib/global/qglobal.cpp src/corelib/global/qglobal.h src/corelib/global/qsysinfo.h src/corelib/global/qsystemdetection.h src/corelib/kernel/qobjectdefs.h src/plugins/plugins.pro tests/auto/widgets/itemviews/qlistview/qlistview.pro Change-Id: Ib55aa79d707c4c1453fb9d697f6cf92211ed665c
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfont.cpp4
-rw-r--r--src/gui/text/qfont_p.h4
-rw-r--r--src/gui/text/qfontdatabase.cpp29
-rw-r--r--src/gui/text/qfontengine.cpp10
-rw-r--r--src/gui/text/qfontmetrics.cpp2
-rw-r--r--src/gui/text/qfontmetrics.h4
-rw-r--r--src/gui/text/qrawfont.cpp2
-rw-r--r--src/gui/text/qtextformat.cpp2
-rw-r--r--src/gui/text/qzip.cpp201
9 files changed, 137 insertions, 121 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 3b55ace68d..796f223797 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -725,7 +725,7 @@ void QFont::setFamily(const QString &family)
Returns the requested font style name, it will be used to match the
font with irregular styles (that can't be normalized in other style
properties). It depends on system font support, thus only works for
- Mac OS X and X11 so far. On Windows irregular styles will be added
+ OS X and X11 so far. On Windows irregular styles will be added
as separate font families so there is no need for this.
\sa setFamily(), setStyle()
@@ -820,7 +820,7 @@ int QFont::pointSize() const
\li Vertical hinting (light)
\li Full hinting
\row
- \li Cocoa on Mac OS X
+ \li Cocoa on OS X
\li No hinting
\li No hinting
\li No hinting
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index 3f8241a80e..25b5ef0b0e 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -102,7 +102,7 @@ struct QFontDef
&& styleStrategy == other.styleStrategy
&& ignorePitch == other.ignorePitch && fixedPitch == other.fixedPitch
&& family == other.family
- && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName)
+ && styleName == other.styleName
&& hintingPreference == other.hintingPreference
;
}
@@ -115,7 +115,7 @@ struct QFontDef
if (styleHint != other.styleHint) return styleHint < other.styleHint;
if (styleStrategy != other.styleStrategy) return styleStrategy < other.styleStrategy;
if (family != other.family) return family < other.family;
- if (!styleName.isEmpty() && !other.styleName.isEmpty() && styleName != other.styleName)
+ if (styleName != other.styleName)
return styleName < other.styleName;
if (hintingPreference != other.hintingPreference) return hintingPreference < other.hintingPreference;
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 0a3ce5c5d1..0b0940855d 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -1184,14 +1184,25 @@ static int match(int script, const QFontDef &request,
static QString styleStringHelper(int weight, QFont::Style style)
{
QString result;
- if (weight >= QFont::Black)
- result = QCoreApplication::translate("QFontDatabase", "Black");
- else if (weight >= QFont::Bold)
- result = QCoreApplication::translate("QFontDatabase", "Bold");
- else if (weight >= QFont::DemiBold)
- result = QCoreApplication::translate("QFontDatabase", "Demi Bold");
- else if (weight < QFont::Normal)
- result = QCoreApplication::translate("QFontDatabase", "Light");
+ if (weight > QFont::Normal) {
+ if (weight >= QFont::Black)
+ result = QCoreApplication::translate("QFontDatabase", "Black");
+ else if (weight >= QFont::ExtraBold)
+ result = QCoreApplication::translate("QFontDatabase", "Extra Bold");
+ else if (weight >= QFont::Bold)
+ result = QCoreApplication::translate("QFontDatabase", "Bold");
+ else if (weight >= QFont::DemiBold)
+ result = QCoreApplication::translate("QFontDatabase", "Demi Bold");
+ else if (weight >= QFont::Medium)
+ result = QCoreApplication::translate("QFontDatabase", "Medium", "The Medium font weight");
+ } else {
+ if (weight <= QFont::Thin)
+ result = QCoreApplication::translate("QFontDatabase", "Thin");
+ else if (weight <= QFont::ExtraLight)
+ result = QCoreApplication::translate("QFontDatabase", "Extra Light");
+ else if (weight <= QFont::Light)
+ result = QCoreApplication::translate("QFontDatabase", "Light");
+ }
if (style == QFont::StyleItalic)
result += QLatin1Char(' ') + QCoreApplication::translate("QFontDatabase", "Italic");
@@ -1199,7 +1210,7 @@ static QString styleStringHelper(int weight, QFont::Style style)
result += QLatin1Char(' ') + QCoreApplication::translate("QFontDatabase", "Oblique");
if (result.isEmpty())
- result = QCoreApplication::translate("QFontDatabase", "Normal");
+ result = QCoreApplication::translate("QFontDatabase", "Normal", "The Normal or Regular font weight");
return result.simplified();
}
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 87e6c30afe..6f5d178655 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1344,13 +1344,13 @@ QByteArray QFontEngine::convertToPostscriptFontFamilyName(const QByteArray &fami
return f;
}
-/**
- * Some font engines like the windows font engine
- * can not reliable create outline paths
- */
+// Allow font engines (e.g. Windows) that can not reliably create
+// outline paths for distance-field rendering to switch the scene
+// graph over to native text rendering.
bool QFontEngine::hasUnreliableGlyphOutline() const
{
- return false;
+ // Color glyphs (Emoji) are generally not suited for outlining
+ return glyphFormat == QFontEngine::Format_ARGB;
}
QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round)
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index c2d4b64152..e351d4d2c5 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -582,6 +582,7 @@ int QFontMetrics::width(QChar ch) const
return qRound(advance);
}
+#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
/*! \obsolete
Returns the width of the character at position \a pos in the
@@ -634,6 +635,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const
}
return width;
}
+#endif
/*!
Returns the bounding rectangle of the characters in the string
diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h
index 65ec219a99..2031f022d4 100644
--- a/src/gui/text/qfontmetrics.h
+++ b/src/gui/text/qfontmetrics.h
@@ -86,7 +86,9 @@ public:
int width(const QString &, int len, int flags) const;
int width(QChar) const;
- int charWidth(const QString &str, int pos) const;
+#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
+ QT_DEPRECATED int charWidth(const QString &str, int pos) const;
+#endif
QRect boundingRect(QChar) const;
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index d5567e173d..0fd5f510c7 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE
also have accessors to some relevant data in the physical font.
QRawFont only provides support for the main font technologies: GDI and DirectWrite on Windows
- platforms, FreeType on Linux platforms and CoreText on Mac OS X. For other
+ platforms, FreeType on Linux platforms and CoreText on OS X. For other
font back-ends, the APIs will be disabled.
QRawFont can be constructed in a number of ways:
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index a6b0804023..7dcd060ba1 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -1327,7 +1327,7 @@ bool QTextFormat::operator==(const QTextFormat &rhs) const
\value WaveUnderline The text is underlined using a wave shaped line.
\value SpellCheckUnderline The underline is drawn depending on the QStyle::SH_SpellCeckUnderlineStyle
style hint of the QApplication style. By default this is mapped to
- WaveUnderline, on Mac OS X it is mapped to DashDotLine.
+ WaveUnderline, on OS X it is mapped to DashDotLine.
\sa Qt::PenStyle
*/
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index 927d8614c8..40088d573a 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -38,7 +38,6 @@
#include "qzipreader_p.h"
#include "qzipwriter_p.h"
#include <qdatetime.h>
-#include <qplatformdefs.h>
#include <qendian.h>
#include <qdebug.h>
#include <qdir.h>
@@ -49,44 +48,6 @@
// (actually, the only basic support of this version is implemented but it is enough for now)
#define ZIP_VERSION 20
-#if defined(Q_OS_WIN)
-# undef S_IFREG
-# define S_IFREG 0100000
-# ifndef S_IFDIR
-# define S_IFDIR 0040000
-# endif
-# ifndef S_ISDIR
-# define S_ISDIR(x) ((x) & S_IFDIR) > 0
-# endif
-# ifndef S_ISREG
-# define S_ISREG(x) ((x) & 0170000) == S_IFREG
-# endif
-# define S_IFLNK 020000
-# define S_ISLNK(x) ((x) & S_IFLNK) > 0
-# ifndef S_IRUSR
-# define S_IRUSR 0400
-# endif
-# ifndef S_IWUSR
-# define S_IWUSR 0200
-# endif
-# ifndef S_IXUSR
-# define S_IXUSR 0100
-# endif
-# define S_IRGRP 0040
-# define S_IWGRP 0020
-# define S_IXGRP 0010
-# define S_IROTH 0004
-# define S_IWOTH 0002
-# define S_IXOTH 0001
-#endif
-
-#ifndef FILE_ATTRIBUTE_READONLY
-# define FILE_ATTRIBUTE_READONLY 0x1
-#endif
-#ifndef FILE_ATTRIBUTE_DIRECTORY
-# define FILE_ATTRIBUTE_DIRECTORY 0x10
-#endif
-
#if 0
#define ZDEBUG qDebug
#else
@@ -159,36 +120,6 @@ static void writeMSDosDate(uchar *dest, const QDateTime& dt)
}
}
-static quint32 permissionsToMode(QFile::Permissions perms)
-{
- quint32 mode = 0;
- if (perms & QFile::ReadOwner)
- mode |= S_IRUSR;
- if (perms & QFile::WriteOwner)
- mode |= S_IWUSR;
- if (perms & QFile::ExeOwner)
- mode |= S_IXUSR;
- if (perms & QFile::ReadUser)
- mode |= S_IRUSR;
- if (perms & QFile::WriteUser)
- mode |= S_IWUSR;
- if (perms & QFile::ExeUser)
- mode |= S_IXUSR;
- if (perms & QFile::ReadGroup)
- mode |= S_IRGRP;
- if (perms & QFile::WriteGroup)
- mode |= S_IWGRP;
- if (perms & QFile::ExeGroup)
- mode |= S_IXGRP;
- if (perms & QFile::ReadOther)
- mode |= S_IROTH;
- if (perms & QFile::WriteOther)
- mode |= S_IWOTH;
- if (perms & QFile::ExeOther)
- mode |= S_IXOTH;
- return mode;
-}
-
static int inflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourceLen)
{
z_stream stream;
@@ -253,36 +184,86 @@ static int deflate (Bytef *dest, ulong *destLen, const Bytef *source, ulong sour
return err;
}
+
+namespace WindowsFileAttributes {
+enum {
+ Dir = 0x10, // FILE_ATTRIBUTE_DIRECTORY
+ File = 0x80, // FILE_ATTRIBUTE_NORMAL
+ TypeMask = 0x90,
+
+ ReadOnly = 0x01, // FILE_ATTRIBUTE_READONLY
+ PermMask = 0x01
+};
+}
+
+namespace UnixFileAttributes {
+enum {
+ Dir = 0040000, // __S_IFDIR
+ File = 0100000, // __S_IFREG
+ SymLink = 0120000, // __S_IFLNK
+ TypeMask = 0170000, // __S_IFMT
+
+ ReadUser = 0400, // __S_IRUSR
+ WriteUser = 0200, // __S_IWUSR
+ ExeUser = 0100, // __S_IXUSR
+ ReadGroup = 0040, // __S_IRGRP
+ WriteGroup = 0020, // __S_IWGRP
+ ExeGroup = 0010, // __S_IXGRP
+ ReadOther = 0004, // __S_IROTH
+ WriteOther = 0002, // __S_IWOTH
+ ExeOther = 0001, // __S_IXOTH
+ PermMask = 0777
+};
+}
+
static QFile::Permissions modeToPermissions(quint32 mode)
{
QFile::Permissions ret;
- if (mode & S_IRUSR)
- ret |= QFile::ReadOwner;
- if (mode & S_IWUSR)
- ret |= QFile::WriteOwner;
- if (mode & S_IXUSR)
- ret |= QFile::ExeOwner;
- if (mode & S_IRUSR)
- ret |= QFile::ReadUser;
- if (mode & S_IWUSR)
- ret |= QFile::WriteUser;
- if (mode & S_IXUSR)
- ret |= QFile::ExeUser;
- if (mode & S_IRGRP)
+ if (mode & UnixFileAttributes::ReadUser)
+ ret |= QFile::ReadOwner | QFile::ReadUser;
+ if (mode & UnixFileAttributes::WriteUser)
+ ret |= QFile::WriteOwner | QFile::WriteUser;
+ if (mode & UnixFileAttributes::ExeUser)
+ ret |= QFile::ExeOwner | QFile::ExeUser;
+ if (mode & UnixFileAttributes::ReadGroup)
ret |= QFile::ReadGroup;
- if (mode & S_IWGRP)
+ if (mode & UnixFileAttributes::WriteGroup)
ret |= QFile::WriteGroup;
- if (mode & S_IXGRP)
+ if (mode & UnixFileAttributes::ExeGroup)
ret |= QFile::ExeGroup;
- if (mode & S_IROTH)
+ if (mode & UnixFileAttributes::ReadOther)
ret |= QFile::ReadOther;
- if (mode & S_IWOTH)
+ if (mode & UnixFileAttributes::WriteOther)
ret |= QFile::WriteOther;
- if (mode & S_IXOTH)
+ if (mode & UnixFileAttributes::ExeOther)
ret |= QFile::ExeOther;
return ret;
}
+static quint32 permissionsToMode(QFile::Permissions perms)
+{
+ quint32 mode = 0;
+ if (mode & (QFile::ReadOwner | QFile::ReadUser))
+ mode |= UnixFileAttributes::ReadUser;
+ if (mode & (QFile::WriteOwner | QFile::WriteUser))
+ mode |= UnixFileAttributes::WriteUser;
+ if (mode & (QFile::ExeOwner | QFile::ExeUser))
+ mode |= UnixFileAttributes::WriteUser;
+ if (perms & QFile::ReadGroup)
+ mode |= UnixFileAttributes::ReadGroup;
+ if (perms & QFile::WriteGroup)
+ mode |= UnixFileAttributes::WriteGroup;
+ if (perms & QFile::ExeGroup)
+ mode |= UnixFileAttributes::ExeGroup;
+ if (perms & QFile::ReadOther)
+ mode |= UnixFileAttributes::ReadOther;
+ if (perms & QFile::WriteOther)
+ mode |= UnixFileAttributes::WriteOther;
+ if (perms & QFile::ExeOther)
+ mode |= UnixFileAttributes::ExeOther;
+ return mode;
+}
+
static QDateTime readMSDosDate(const uchar *src)
{
uint dosDate = readUInt(src);
@@ -494,27 +475,38 @@ void QZipPrivate::fillFileInfo(int index, QZipReader::FileInfo &fileInfo) const
switch (hostOS) {
case HostUnix:
mode = (mode >> 16) & 0xffff;
- if (S_ISDIR(mode))
+ switch (mode & UnixFileAttributes::TypeMask) {
+ case UnixFileAttributes::SymLink:
+ fileInfo.isSymLink = true;
+ break;
+ case UnixFileAttributes::Dir:
fileInfo.isDir = true;
- else if (S_ISREG(mode))
+ break;
+ case UnixFileAttributes::File:
+ default: // ### just for the case; should we warn?
fileInfo.isFile = true;
- else if (S_ISLNK(mode))
- fileInfo.isSymLink = true;
+ break;
+ }
fileInfo.permissions = modeToPermissions(mode);
break;
case HostFAT:
case HostNTFS:
case HostHPFS:
case HostVFAT:
- fileInfo.permissions |= QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther;
- if ((mode & FILE_ATTRIBUTE_READONLY) == 0)
- fileInfo.permissions |= QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther;
- if ((mode & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
+ switch (mode & WindowsFileAttributes::TypeMask) {
+ case WindowsFileAttributes::Dir:
fileInfo.isDir = true;
- fileInfo.permissions |= QFile::ExeOwner | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther;
- } else {
+ break;
+ case WindowsFileAttributes::File:
+ default:
fileInfo.isFile = true;
+ break;
}
+ fileInfo.permissions |= QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther;
+ if ((mode & WindowsFileAttributes::ReadOnly) == 0)
+ fileInfo.permissions |= QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther;
+ if (fileInfo.isDir)
+ fileInfo.permissions |= QFile::ExeOwner | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther;
break;
default:
qWarning("QZip: Zip entry format at %d is not supported.", index);
@@ -761,9 +753,18 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const
//uchar external_file_attributes[4];
quint32 mode = permissionsToMode(permissions);
switch (type) {
- case File: mode |= S_IFREG; break;
- case Directory: mode |= S_IFDIR; break;
- case Symlink: mode |= S_IFLNK; break;
+ case Symlink:
+ mode |= UnixFileAttributes::SymLink;
+ break;
+ case Directory:
+ mode |= UnixFileAttributes::Dir;
+ break;
+ case File:
+ mode |= UnixFileAttributes::File;
+ break;
+ default:
+ Q_UNREACHABLE();
+ break;
}
writeUInt(header.h.external_file_attributes, mode << 16);
writeUInt(header.h.offset_local_header, start_of_directory);