summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-08-01 09:48:40 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-08-01 09:48:40 (GMT)
commit0f10e3603fc5f24ebd3773cb2976d0bb24fcbd17 (patch)
tree4bfa9c57e62b023730ec5fc7dafbd45cfc33c086 /src/gui/text
parentc9fb043d9fa38dd8eec6976e7a338dc89ddc5b0e (diff)
parentbf8f39329c05a92c3da2b73b4e555dc9980e6008 (diff)
downloadQt-0f10e3603fc5f24ebd3773cb2976d0bb24fcbd17.zip
Qt-0f10e3603fc5f24ebd3773cb2976d0bb24fcbd17.tar.gz
Qt-0f10e3603fc5f24ebd3773cb2976d0bb24fcbd17.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging: Make macdeployqt more robust against usage of symbolic links. Document support for Linguist on Mac. Make mac(deploy|change)qt handle dylibs that use Qt inside an app bundle. Guard macdeployqt against @rpath and @loader_path too. Fix typo. OpenVG cleanup. Include trailing space width in RTL text line width Fix the compilation error when QT_NO_PLUGIN_CHECK was set. Fixed holes in border image drawing by introducing new API. Properly resolve and use glMapBuffer / glUnmapBuffer on GLES2. Revert "fix QFileInfo::isSymLink() for NTFS mount points" Remove debug output. Add some sound support to the uikit platform. Add flickrdemo uikit example project. Fix uikit simulator build. Get subpixel antialiasing again w/combo of raster and affine transform Add initial support for bitmap version 4/5 headers. optimize QRawFont::supportsCharacter() Switch to use floating point pixelSize in QRawFont completely Add a way to check if we have a matching family in the database.
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontdatabase.cpp10
-rw-r--r--src/gui/text/qfontdatabase.h2
-rw-r--r--src/gui/text/qrawfont.cpp25
-rw-r--r--src/gui/text/qrawfont.h10
-rw-r--r--src/gui/text/qrawfont_ft.cpp2
-rw-r--r--src/gui/text/qrawfont_mac.cpp2
-rw-r--r--src/gui/text/qrawfont_p.h2
-rw-r--r--src/gui/text/qrawfont_qpa.cpp2
-rw-r--r--src/gui/text/qrawfont_win.cpp2
-rw-r--r--src/gui/text/qtextlayout.cpp6
10 files changed, 45 insertions, 18 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 26d9f2c..79503f9 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -2240,6 +2240,16 @@ int QFontDatabase::weight(const QString &family,
}
+/*! \internal */
+bool QFontDatabase::hasFamily(const QString &family) const
+{
+ QString parsedFamily, foundry;
+ parseFontName(family, foundry, parsedFamily);
+ const QString familyAlias = resolveFontFamilyAlias(parsedFamily);
+ return families().contains(familyAlias, Qt::CaseInsensitive);
+}
+
+
/*!
Returns the names the \a writingSystem (e.g. for displaying to the
user in a dialog).
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index d3463a0..b1f370e 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -138,6 +138,8 @@ public:
bool bold(const QString &family, const QString &style) const;
int weight(const QString &family, const QString &style) const;
+ bool hasFamily(const QString &family) const;
+
static QString writingSystemName(WritingSystem writingSystem);
static QString writingSystemSample(WritingSystem writingSystem);
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index ec5cc18..e3e5c57 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -139,7 +139,7 @@ QRawFont::QRawFont()
\note The referenced file must contain a TrueType or OpenType font.
*/
QRawFont::QRawFont(const QString &fileName,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference)
: d(new QRawFontPrivate)
{
@@ -154,7 +154,7 @@ QRawFont::QRawFont(const QString &fileName,
\note The data must contain a TrueType or OpenType font.
*/
QRawFont::QRawFont(const QByteArray &fontData,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference)
: d(new QRawFontPrivate)
{
@@ -204,7 +204,7 @@ bool QRawFont::isValid() const
\sa loadFromData()
*/
void QRawFont::loadFromFile(const QString &fileName,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference)
{
QFile file(fileName);
@@ -222,7 +222,7 @@ void QRawFont::loadFromFile(const QString &fileName,
\sa loadFromFile()
*/
void QRawFont::loadFromData(const QByteArray &fontData,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference)
{
detach();
@@ -624,7 +624,7 @@ QList<QFontDatabase::WritingSystem> QRawFont::supportedWritingSystems() const
\sa supportedWritingSystems()
*/
-bool QRawFont::supportsCharacter(const QChar &character) const
+bool QRawFont::supportsCharacter(QChar character) const
{
if (!isValid())
return false;
@@ -633,6 +633,7 @@ bool QRawFont::supportsCharacter(const QChar &character) const
}
/*!
+ \overload
Returns true if the font has a glyph that corresponds to the UCS-4 encoded character \a ucs4.
\sa supportedWritingSystems()
@@ -642,8 +643,18 @@ bool QRawFont::supportsCharacter(quint32 ucs4) const
if (!isValid())
return false;
- QString str = QString::fromUcs4(&ucs4, 1);
- return d->fontEngine->canRender(str.constData(), str.size());
+ QChar str[2];
+ int len;
+ if (!QChar::requiresSurrogates(ucs4)) {
+ str[0] = QChar(ucs4);
+ len = 1;
+ } else {
+ str[0] = QChar(QChar::highSurrogate(ucs4));
+ str[1] = QChar(QChar::lowSurrogate(ucs4));
+ len = 2;
+ }
+
+ return d->fontEngine->canRender(str, len);
}
// qfontdatabase.cpp
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index 99e0837..d5b5680 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -70,10 +70,10 @@ public:
QRawFont();
QRawFont(const QString &fileName,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting);
QRawFont(const QByteArray &fontData,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting);
QRawFont(const QRawFont &other);
~QRawFont();
@@ -114,15 +114,15 @@ public:
qreal unitsPerEm() const;
void loadFromFile(const QString &fileName,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference);
void loadFromData(const QByteArray &fontData,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference);
bool supportsCharacter(quint32 ucs4) const;
- bool supportsCharacter(const QChar &character) const;
+ bool supportsCharacter(QChar character) const;
QList<QFontDatabase::WritingSystem> supportedWritingSystems() const;
QByteArray fontTable(const char *tagName) const;
diff --git a/src/gui/text/qrawfont_ft.cpp b/src/gui/text/qrawfont_ft.cpp
index db60459..5bba221 100644
--- a/src/gui/text/qrawfont_ft.cpp
+++ b/src/gui/text/qrawfont_ft.cpp
@@ -98,7 +98,7 @@ void QRawFontPrivate::platformCleanUp()
// Font engine handles all resources
}
-void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData, int pixelSize,
+void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData, qreal pixelSize,
QFont::HintingPreference hintingPreference)
{
Q_ASSERT(fontEngine == 0);
diff --git a/src/gui/text/qrawfont_mac.cpp b/src/gui/text/qrawfont_mac.cpp
index df68eb7..40c719a 100644
--- a/src/gui/text/qrawfont_mac.cpp
+++ b/src/gui/text/qrawfont_mac.cpp
@@ -55,7 +55,7 @@ void QRawFontPrivate::platformCleanUp()
extern int qt_defaultDpi();
void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference)
{
// Mac OS X ignores it
diff --git a/src/gui/text/qrawfont_p.h b/src/gui/text/qrawfont_p.h
index a7a03b7..fdf7cad 100644
--- a/src/gui/text/qrawfont_p.h
+++ b/src/gui/text/qrawfont_p.h
@@ -99,7 +99,7 @@ public:
void cleanUp();
void platformCleanUp();
void platformLoadFromData(const QByteArray &fontData,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference);
static QRawFontPrivate *get(const QRawFont &font) { return font.d.data(); }
diff --git a/src/gui/text/qrawfont_qpa.cpp b/src/gui/text/qrawfont_qpa.cpp
index 3492946..6a69804 100644
--- a/src/gui/text/qrawfont_qpa.cpp
+++ b/src/gui/text/qrawfont_qpa.cpp
@@ -53,7 +53,7 @@ void QRawFontPrivate::platformCleanUp()
{
}
-void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData, int pixelSize,
+void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData, qreal pixelSize,
QFont::HintingPreference hintingPreference)
{
Q_ASSERT(fontEngine == 0);
diff --git a/src/gui/text/qrawfont_win.cpp b/src/gui/text/qrawfont_win.cpp
index 6c62673..779652f 100644
--- a/src/gui/text/qrawfont_win.cpp
+++ b/src/gui/text/qrawfont_win.cpp
@@ -545,7 +545,7 @@ void QRawFontPrivate::platformCleanUp()
}
void QRawFontPrivate::platformLoadFromData(const QByteArray &_fontData,
- int pixelSize,
+ qreal pixelSize,
QFont::HintingPreference hintingPreference)
{
QByteArray fontData(_fontData);
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 4fd6ddf..515915a 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1928,8 +1928,12 @@ found:
if (line.textWidth > 0 && item < eng->layoutData->items.size())
eng->maxWidth += lbh.spaceData.textWidth;
- if (eng->option.flags() & QTextOption::IncludeTrailingSpaces)
+ // In the latter case, text are drawn with trailing spaces at the beginning
+ // of a line, so the naturalTextWidth should contain the space width
+ if ((eng->option.flags() & QTextOption::IncludeTrailingSpaces) ||
+ (line.width == QFIXED_MAX && eng->isRightToLeft())) {
line.textWidth += lbh.spaceData.textWidth;
+ }
if (lbh.spaceData.length) {
line.length += lbh.spaceData.length;
line.hasTrailingSpaces = true;