Ignore:
Timestamp:
Nov 6, 2007, 11:27:57 PM (18 years ago)
Author:
dmik
Message:

Styles: Implemented the first version of the Warp4 style (contributed by Cornelis Bockemuehl).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel/qfont_pm.cpp

    r8 r174  
    5858{
    5959    switch( styleHint ) {
    60         case QFont::Times:
    61             return QString::fromLatin1("Times New Roman");
    62         case QFont::Courier:
    63             return QString::fromLatin1("Courier");
    64         case QFont::Decorative:
    65             return QString::fromLatin1("Times New Roman");
    66         case QFont::Helvetica:
    67             return QString::fromLatin1("Helvetica");
    68         case QFont::System:
    69 //@@TODO (dmik): check for OS/2 ver and return the appropriate system font
    70 //  (i.e. "System Proportional" for ver <= Warp 3)
    71             return QString::fromLatin1("WarpSans");
    72         default:
     60        case QFont::Times:
     61            return QString::fromLatin1( "Times New Roman" );
     62        case QFont::Courier:
     63            return QString::fromLatin1( "Courier" );
     64        case QFont::Decorative:
     65            return QString::fromLatin1( "Times New Roman" );
     66        case QFont::Helvetica:
     67            return QString::fromLatin1( "Helvetica" );
     68        case QFont::System: {
     69#ifndef QT_PM_NO_DEFAULTFONT_OVERRIDE
     70            static ULONG ver[2] = {0};
     71            if ( ver[0] == ver[1] == 0 ) {
     72                DosQuerySysInfo( QSV_VERSION_MAJOR, QSV_VERSION_MINOR,
     73                                 &ver, sizeof(ver) );
     74            }
     75            if ( ver[0] == 20 && ver[1] >= 40 )
     76                return QString::fromLatin1( "WarpSans" );
     77            else
     78#endif
     79            return QString::fromLatin1( "System Proportional" );
     80        }
     81        default:
    7382            // the family to be used when no StyleHint is set (in accordance
    7483            // with the font matching algorithm stated in QFont docs)
    75             return QString::fromLatin1("Helvetica");
     84            return QString::fromLatin1( "Helvetica" );
    7685    }
    7786//@@TODO (dmik): should we also add default font substitutions to
     
    7988}
    8089
    81 //@@TODO (dmik): remove
    82 //extern HDC   shared_dc;               // common dc for all fonts
    83 
    84 //@@TODO (dmik): remove?
    85 //// ### maybe move to qapplication_win
    86 //QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/)
    87 //{
    88 //    QString family = QT_WA_INLINE( QString::fromUcs2((ushort*)lf.lfFaceName),
    89 //                                 QString::fromLocal8Bit((char*)lf.lfFaceName) );
    90 //    QFont qf(family);
    91 //    qf.setItalic(lf.lfItalic);
    92 //    if (lf.lfWeight != FW_DONTCARE) {
    93 //      int weight;
    94 //      if ( lf.lfWeight < 400 )
    95 //          weight = QFont::Light;
    96 //      else if ( lf.lfWeight < 600 )
    97 //          weight = QFont::Normal;
    98 //      else if ( lf.lfWeight < 700 )
    99 //          weight = QFont::DemiBold;
    100 //      else if ( lf.lfWeight < 800 )
    101 //          weight = QFont::Bold;
    102 //      else
    103 //          weight = QFont::Black;
    104 //      qf.setWeight(weight);
    105 //    }
    106 //    int lfh = QABS( lf.lfHeight );
    107 //    Q_ASSERT(shared_dc);
    108 //    qf.setPointSizeFloat( lfh * 72.0 / GetDeviceCaps(shared_dc,LOGPIXELSY) );
    109 //    qf.setUnderline(FALSE);
    110 //    qf.setOverline(FALSE);
    111 //    qf.setStrikeOut(FALSE);
    112 //    return qf;
    113 //}
    114 
    115 
    116 //@@TODO (dmik): need these two funcs?
    117 //static inline float pixelSize( const QFontDef &request, QPaintDevice *paintdevice,
    118 //                             int )
    119 //{
    120 //    float pSize;
    121 //    if ( request.pointSize != -1 ) {
    122 //      if ( paintdevice ) {
    123 //          pSize = request.pointSize *
    124 //                  QPaintDeviceMetrics( paintdevice ).logicalDpiY() / 720.;
    125 //      } else {
    126 //            LONG dpi;
    127 //            DevQueryCaps( GpiQueryDevice( qt_display_ps() ),
    128 //                CAPS_VERTICAL_FONT_RES, 1, &val );
    129 //          pSize = (request.pointSize*dpi + 360) / 720;
    130 //        }
    131 //    } else {
    132 //      pSize = request.pixelSize;
    133 //    }
    134 //    return pSize;
    135 //}
    136 //
    137 //static inline float pointSize( const QFontDef &fd, QPaintDevice *paintdevice,
    138 //                             int )
    139 //{
    140 //    float pSize;
    141 //    if ( fd.pointSize == -1 ) {
    142 //      if ( paintdevice ) {
    143 //          pSize = fd.pixelSize * 720. /
    144 //                  QPaintDeviceMetrics( paintdevice ).logicalDpiY();
    145 //      } else {
    146 //            LONG dpi;
    147 //            DevQueryCaps( GpiQueryDevice( qt_display_ps() ),
    148 //                CAPS_VERTICAL_FONT_RES, 1, &val );
    149 //          pSize = fd.pixelSize * 72.0 / dpi;
    150 //        }
    151 //    } else {
    152 //      pSize = fd.pointSize;
    153 //    }
    154 //    return pSize;
    155 //}
    156 
    15790/*****************************************************************************
    15891  QFont member functions
     
    16598    if ( QFontCache::instance )
    16699        return;
    167 //@@TODO (dmik): remove
    168 //    shared_dc = CreateCompatibleDC( qt_display_dc() );
    169 //#if defined(QT_CHECK_RANGE)
    170 //    if ( !shared_dc )
    171 //      qSystemWarning( "QFont::initialize() (qfont_win.cpp, 163): couldn't create device context" );
    172 //#endif
    173100    new QFontCache();
    174101
     
    180107{
    181108    delete QFontCache::instance;
    182 //@@TODO (dmik): remove
    183 //    DeleteDC( shared_dc );
    184 //    shared_dc = 0;
    185109}
    186110
     
    194118    // sanity checks
    195119    if (!QFontCache::instance)
    196         qWarning("Must construct a QApplication before a QFont");
     120        qWarning("Must construct a QApplication before a QFont");
    197121    Q_ASSERT( script >= 0 && script < QFont::LastPrivateScript );
    198122#endif // QT_CHECK_STATE
     
    204128    } else {
    205129        DevQueryCaps( GpiQueryDevice( qt_display_ps() ),
    206             CAPS_VERTICAL_FONT_RES, 1, (PLONG) &dpi );
     130                      CAPS_VERTICAL_FONT_RES, 1, (PLONG) &dpi );
    207131    }
    208132    if (req.pointSize != -1)
     
    212136
    213137    if ( ! engineData ) {
    214         QFontCache::Key key( req, QFont::NoScript, (int)paintdevice );
    215 
    216         // look for the requested font in the engine data cache
    217         engineData = QFontCache::instance->findEngineData( key );
    218 
    219         if ( ! engineData) {
    220             // create a new one
    221             engineData = new QFontEngineData;
    222             QFontCache::instance->insertEngineData( key, engineData );
    223         } else {
    224             engineData->ref();
    225         }
     138        QFontCache::Key key( req, QFont::NoScript, (int)paintdevice );
     139
     140        // look for the requested font in the engine data cache
     141        engineData = QFontCache::instance->findEngineData( key );
     142
     143        if ( ! engineData) {
     144            // create a new one
     145            engineData = new QFontEngineData;
     146            QFontCache::instance->insertEngineData( key, engineData );
     147        } else {
     148            engineData->ref();
     149        }
    226150    }
    227151
     
    239163
    240164    if (!req.family.isEmpty()) {
    241         family_list = QStringList::split( ',', req.family );
    242 
    243         // append the substitute list for each family in family_list
    244         QStringList subs_list;
    245         QStringList::ConstIterator it = family_list.begin(), end = family_list.end();
    246         for ( ; it != end; ++it )
    247             subs_list += QFont::substitutes( *it );
    248         family_list += subs_list;
     165        family_list = QStringList::split( ',', req.family );
     166
     167        // append the substitute list for each family in family_list
     168        QStringList subs_list;
     169        QStringList::ConstIterator it = family_list.begin(), end = family_list.end();
     170        for ( ; it != end; ++it )
     171            subs_list += QFont::substitutes( *it );
     172        family_list += subs_list;
    249173
    250174//@@TODO (dmik): need something here?
    251         // append the default fallback font for the specified script
    252         // family_list << ... ; ###########
     175        // append the default fallback font for the specified script
     176        // family_list << ... ; ###########
    253177
    254178        // add the family corresponding to font's styleHint
    255179        QString hintFamily = qt_pm_default_family( request.styleHint );
    256         if ( ! family_list.contains( hintFamily ) )
     180        if ( ! family_list.contains( hintFamily ) )
    257181            family_list << hintFamily;
    258182
     
    262186//  below added to the list.
    263187
    264         // add the default family
    265         QString defaultFamily = QApplication::font().family();
    266         if ( ! family_list.contains( defaultFamily ) )
    267             family_list << defaultFamily;
    268 
    269         // add QFont::defaultFamily() to the list, for compatibility with
    270         // previous versions
    271         family_list << QApplication::font().defaultFamily();
     188        // add the default family
     189        QString defaultFamily = QApplication::font().family();
     190        if ( ! family_list.contains( defaultFamily ) )
     191            family_list << defaultFamily;
     192
     193        // add QFont::defaultFamily() to the list, for compatibility with
     194        // previous versions
     195        family_list << QApplication::font().defaultFamily();
    272196    }
    273197
     
    277201    QStringList::ConstIterator it = family_list.begin(), end = family_list.end();
    278202    for ( ; ! engine && it != end; ++it ) {
    279         req.family = *it;
    280 
    281         engine = QFontDatabase::findFont( script, this, req );
    282         if ( engine ) {
    283             if ( engine->type() != QFontEngine::Box )
    284                 break;
    285 
    286             if ( ! req.family.isEmpty() )
    287                 engine = 0;
    288 
    289             continue;
    290         }
     203        req.family = *it;
     204
     205        engine = QFontDatabase::findFont( script, this, req );
     206        if ( engine ) {
     207            if ( engine->type() != QFontEngine::Box )
     208                break;
     209
     210            if ( ! req.family.isEmpty() )
     211                engine = 0;
     212
     213            continue;
     214        }
    291215    }
    292216
     
    343267QString QFont::lastResortFont() const
    344268{
    345     return QString::fromLatin1("System Proportional");
     269    return QString::fromLatin1( "System Proportional" );
    346270}
    347271
     
    351275  QFontMetrics member functions
    352276 *****************************************************************************/
    353 
    354 //@@TODO (dmik): remove
    355 //#define IS_TRUETYPE (QT_WA_INLINE( engine->tm.w.tmPitchAndFamily, engine->tm.a.tmPitchAndFamily ) & TMPF_TRUETYPE)
    356 //#define TMX engine->tm.w
    357 //#define TMW engine->tm.w
    358 //#define TMA engine->tm.a
    359277
    360278//@@TODO (dmik): do we need a separate (other than in qfont.cpp)
Note: See TracChangeset for help on using the changeset viewer.