Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/text/qfont_s60.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4141
    4242#include "qfont.h"
    43 #include "qt_s60_p.h"
    44 #include "qpixmap_s60_p.h"
     43#include "qfont_p.h"
     44#include <private/qt_s60_p.h>
     45#include <private/qpixmap_s60_p.h>
    4546#include "qmutex.h"
    4647
    4748QT_BEGIN_NAMESPACE
    4849
    49 #if 1
    5050#ifdef QT_NO_FREETYPE
    5151Q_GLOBAL_STATIC(QMutex, lastResortFamilyMutex);
     52extern QStringList qt_symbian_fontFamiliesOnFontServer(); // qfontdatabase_s60.cpp
     53Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, fontFamiliesOnFontServer, {
     54    // We are only interested in the initial font families. No Application fonts.
     55    // Therefore, we are allowed to cache the list.
     56    x->append(qt_symbian_fontFamiliesOnFontServer());
     57});
    5258#endif // QT_NO_FREETYPE
     59
     60QString QFont::lastResortFont() const
     61{
     62    // Symbian's font Api does not distinguish between font and family.
     63    // Therefore we try to get a "Family" first, then fall back to "Sans".
     64    static QString font = lastResortFamily();
     65    if (font.isEmpty())
     66        font = QLatin1String("Sans");
     67    return font;
     68}
    5369
    5470QString QFont::lastResortFamily() const
     
    7187    }
    7288    return family;
    73 #else
     89#else // QT_NO_FREETYPE
    7490    // For the FreeType case we just hard code the face name, since otherwise on
    7591    // East Asian systems we may get a name for a stroke based (non-ttf) font.
     
    8399#endif // QT_NO_FREETYPE
    84100}
    85 #else // 0
    86 QString QFont::lastResortFamily() const
    87 {
    88     return QLatin1String("Series 60 Sans");
    89 }
    90 #endif // 0
    91101
    92102QString QFont::defaultFamily() const
    93103{
     104#ifdef QT_NO_FREETYPE
     105    switch(d->request.styleHint) {
     106        case QFont::SansSerif: {
     107            static const char* const preferredSansSerif[] = {"Nokia Sans S60", "Series 60 Sans"};
     108            for (int i = 0; i < sizeof preferredSansSerif / sizeof preferredSansSerif[0]; ++i) {
     109                const QString sansSerif = QLatin1String(preferredSansSerif[i]);
     110                if (fontFamiliesOnFontServer()->contains(sansSerif))
     111                    return sansSerif;
     112            }
     113        }
     114        // No break. Intentional fall through.
     115        default:
     116            return lastResortFamily();
     117    }
     118#endif // QT_NO_FREETYPE
    94119    return lastResortFamily();
    95120}
Note: See TracChangeset for help on using the changeset viewer.