summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@nokia.com>2010-09-02 19:33:06 (GMT)
committerAlessandro Portale <alessandro.portale@nokia.com>2010-09-02 19:33:06 (GMT)
commit41a8c2280a3f454c457f811fc6428826b11b4754 (patch)
tree5edfb613b2207e427e38445645cb0c9f89f34f3a /src/gui
parentc229d4c1cb4c5aa0be22dddd5e8d8436a29cf103 (diff)
downloadQt-41a8c2280a3f454c457f811fc6428826b11b4754.zip
Qt-41a8c2280a3f454c457f811fc6428826b11b4754.tar.gz
Qt-41a8c2280a3f454c457f811fc6428826b11b4754.tar.bz2
Symbian: return better default font for SansSerif style hint
The latest QtWebkit will use QFont::defaultFamily() with style hints to ask for the appropriate default fonts on a system. This patch makes sure thath "Nokia Sans S60" and "Series 60 Sans" are prioritized for QFont::SansSerif, if they are present. Task-Number: QTBUG-12611
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qfont_s60.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gui/text/qfont_s60.cpp b/src/gui/text/qfont_s60.cpp
index f303419..2d547a9 100644
--- a/src/gui/text/qfont_s60.cpp
+++ b/src/gui/text/qfont_s60.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qfont.h"
+#include "qfont_p.h"
#include <private/qt_s60_p.h>
#include <private/qpixmap_s60_p.h>
#include "qmutex.h"
@@ -48,6 +49,17 @@ QT_BEGIN_NAMESPACE
#ifdef QT_NO_FREETYPE
Q_GLOBAL_STATIC(QMutex, lastResortFamilyMutex);
+Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, fontFamiliesOnFontServer, {
+ QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
+ const int numTypeFaces = S60->screenDevice()->NumTypefaces();
+ for (int i = 0; i < numTypeFaces; i++) {
+ TTypefaceSupport typefaceSupport;
+ S60->screenDevice()->TypefaceSupport(typefaceSupport, i);
+ const QString familyName((const QChar *)typefaceSupport.iTypeface.iName.Ptr(), typefaceSupport.iTypeface.iName.Length());
+ x->append(familyName);
+ }
+ lock.relock();
+});
#endif // QT_NO_FREETYPE
QString QFont::lastResortFamily() const
@@ -84,6 +96,21 @@ QString QFont::lastResortFamily() const
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;
+ }
+ }
+ // No break. Intentional fall through.
+ default:
+ return lastResortFamily();
+ }
+#endif // QT_NO_FREETYPE
return lastResortFamily();
}