summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfont_s60.cpp36
-rw-r--r--src/gui/text/qfontdatabase.cpp10
-rw-r--r--src/gui/text/qfontdatabase.h2
-rw-r--r--src/gui/text/qfontdatabase_s60.cpp19
-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/qtextengine.cpp18
-rw-r--r--src/gui/text/qtextlayout.cpp25
13 files changed, 110 insertions, 45 deletions
diff --git a/src/gui/text/qfont_s60.cpp b/src/gui/text/qfont_s60.cpp
index 0fc8a97..76133fa 100644
--- a/src/gui/text/qfont_s60.cpp
+++ b/src/gui/text/qfont_s60.cpp
@@ -49,8 +49,6 @@ QT_BEGIN_NAMESPACE
#ifdef QT_NO_FREETYPE
Q_GLOBAL_STATIC(QMutex, lastResortFamilyMutex);
-#endif // QT_NO_FREETYPE
-
extern QStringList qt_symbian_fontFamiliesOnFontServer(); // qfontdatabase_s60.cpp
Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, fontFamiliesOnFontServer, {
// We are only interested in the initial font families. No Application fonts.
@@ -58,6 +56,25 @@ Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, fontFamiliesOnFontServer, {
x->append(qt_symbian_fontFamiliesOnFontServer());
});
+extern bool qt_symbian_isLinkedFont(const TDesC &typefaceName); // qfontdatabase_s60.cpp
+
+static QString classicalSymbianSystemFont()
+{
+ static QString font;
+ if (font.isEmpty()) {
+ static const char* const classicSymbianSystemFonts[] = { "Nokia Sans S60", "Series 60 Sans" };
+ for (int i = 0; i < sizeof classicSymbianSystemFonts / sizeof classicSymbianSystemFonts[0]; ++i) {
+ const QString classicFont = QLatin1String(classicSymbianSystemFonts[i]);
+ if (fontFamiliesOnFontServer()->contains(classicFont)) {
+ font = classicFont;
+ break;
+ }
+ }
+ }
+ return font;
+}
+#endif // QT_NO_FREETYPE
+
QString QFont::lastResortFont() const
{
// Symbian's font Api does not distinguish between font and family.
@@ -85,6 +102,10 @@ QString QFont::lastResortFamily() const
S60->screenDevice()->ReleaseFont(font);
lock.relock();
+
+ // We must not return a Symbian Linked Font. See QTBUG-20007
+ if (qt_symbian_isLinkedFont(spec.iTypeface.iName) && !classicalSymbianSystemFont().isEmpty())
+ family = classicalSymbianSystemFont();
}
return family;
#else // QT_NO_FREETYPE
@@ -117,14 +138,9 @@ QString QFont::defaultFamily() const
{
#ifdef QT_NO_FREETYPE
switch(d->request.styleHint) {
- case QFont::SansSerif: {
- static const char* const preferredSansSerif[] = {"Nokia Sans S60", "Series 60 Sans"};
- for (int i = 0; i < sizeof preferredSansSerif / sizeof preferredSansSerif[0]; ++i) {
- const QString sansSerif = QLatin1String(preferredSansSerif[i]);
- if (fontFamiliesOnFontServer()->contains(sansSerif))
- return sansSerif;
- }
- }
+ case QFont::SansSerif:
+ if (!classicalSymbianSystemFont().isEmpty())
+ return classicalSymbianSystemFont();
// No break. Intentional fall through.
default:
return lastResortFamily();
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/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp
index 2f4d055..cf96733 100644
--- a/src/gui/text/qfontdatabase_s60.cpp
+++ b/src/gui/text/qfontdatabase_s60.cpp
@@ -58,8 +58,22 @@
#endif // SYMBIAN_ENABLE_SPLIT_HEADERS
#endif // QT_NO_FREETYPE
+#ifndef SYMBIAN_VERSION_9_4
+#define SYMBIAN_LINKEDFONTS_SUPPORTED
+#endif // !SYMBIAN_VERSION_9_4
+
QT_BEGIN_NAMESPACE
+bool qt_symbian_isLinkedFont(const TDesC &typefaceName) // Also used in qfont_s60.cpp
+{
+ bool isLinkedFont = false;
+#ifdef SYMBIAN_LINKEDFONTS_SUPPORTED
+ const QString name((const QChar*)typefaceName.Ptr(), typefaceName.Length());
+ isLinkedFont = name.endsWith(QLatin1String("LF")) && name == name.toUpper();
+#endif // SYMBIAN_LINKEDFONTS_SUPPORTED
+ return isLinkedFont;
+}
+
QStringList qt_symbian_fontFamiliesOnFontServer() // Also used in qfont_s60.cpp
{
QStringList result;
@@ -477,7 +491,10 @@ static bool registerScreenDeviceFont(int screenDeviceFontIndex,
const QSymbianFontDatabaseExtrasImplementation *dbExtras)
{
TTypefaceSupport typefaceSupport;
- S60->screenDevice()->TypefaceSupport(typefaceSupport, screenDeviceFontIndex);
+ S60->screenDevice()->TypefaceSupport(typefaceSupport, screenDeviceFontIndex);
+
+ if (qt_symbian_isLinkedFont(typefaceSupport.iTypeface.iName))
+ return false;
QString familyName((const QChar*)typefaceSupport.iTypeface.iName.Ptr(), typefaceSupport.iTypeface.iName.Length());
if (qt_symbian_fontNameHasAppFontMarker(familyName)) {
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/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 41ea56a..093b43d 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1632,19 +1632,13 @@ bool QTextEngine::isRightToLeft() const
int QTextEngine::findItem(int strPos) const
{
itemize();
- int left = 0;
- int right = layoutData->items.size()-1;
- while(left <= right) {
- int middle = ((right-left)/2)+left;
- if (strPos > layoutData->items[middle].position)
- left = middle+1;
- else if(strPos < layoutData->items[middle].position)
- right = middle-1;
- else {
- return middle;
- }
+
+ int item;
+ for (item = layoutData->items.size()-1; item > 0; --item) {
+ if (layoutData->items[item].position <= strPos)
+ break;
}
- return right;
+ return item;
}
QFixed QTextEngine::width(int from, int len) const
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 3f0b9e8..515915a 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1591,6 +1591,7 @@ namespace {
QFixed minimumRightBearing;
QFontEngine *fontEngine;
+ QFontEngine *previousFontEngine;
const unsigned short *logClusters;
bool manualWrap;
@@ -1611,12 +1612,19 @@ namespace {
return glyphs.glyphs[logClusters[currentPosition - 1]];
}
- inline void saveCurrentGlyph()
+ inline void resetPreviousGlyph()
{
previousGlyph = 0;
+ previousFontEngine = 0;
+ }
+
+ inline void saveCurrentGlyph()
+ {
+ resetPreviousGlyph();
if (currentPosition > 0 &&
logClusters[currentPosition - 1] < glyphs.numGlyphs) {
previousGlyph = currentGlyph(); // needed to calculate right bearing later
+ previousFontEngine = fontEngine;
}
}
@@ -1636,8 +1644,11 @@ namespace {
inline void adjustPreviousRightBearing()
{
- if (previousGlyph > 0)
- adjustRightBearing(previousGlyph);
+ if (previousGlyph > 0 && previousFontEngine) {
+ qreal rb;
+ previousFontEngine->getGlyphBearings(previousGlyph, 0, &rb);
+ rightBearing = qMin(QFixed(), QFixed::fromReal(rb));
+ }
}
inline void resetRightBearing()
@@ -1728,7 +1739,7 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.currentPosition = line.from;
int end = 0;
lbh.logClusters = eng->layoutData->logClustersPtr;
- lbh.previousGlyph = 0;
+ lbh.resetPreviousGlyph();
while (newItem < eng->layoutData->items.size()) {
lbh.resetRightBearing();
@@ -1917,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;