Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5252int qt_mac_pointsize(const QFontDef &def, int dpi); //qfont_mac.cpp
    5353
     54#ifndef QT_MAC_USE_COCOA
    5455static void initWritingSystems(QtFontFamily *family, ATSFontRef atsFont)
    5556{
     
    8283        family->writingSystems[systems.at(i)] = QtFontFamily::Supported;
    8384}
     85#endif
    8486
    8587static void initializeDb()
     
    151153#endif
    152154    {
    153 #ifndef Q_WS_MAC64
     155#ifndef QT_MAC_USE_COCOA
    154156        FMFontIterator it;
    155157        if (!FMCreateFontIterator(0, 0, kFMUseGlobalScopeOption, &it)) {
     
    282284
    283285    //find the font
    284     QStringList family_list = req.family.split(QLatin1Char(','));
    285     // append the substitute list for each family in family_list
    286     {
    287             QStringList subs_list;
    288             for(QStringList::ConstIterator it = family_list.constBegin(); it != family_list.constEnd(); ++it)
    289                     subs_list += QFont::substitutes(*it);
    290             family_list += subs_list;
    291     }
     286    QStringList family_list = familyList(req);
    292287
    293288    const char *stylehint = styleHint(req);
     
    314309                    fontRef = ATSFontFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
    315310                    goto FamilyFound;
     311                } else {
     312#if defined(QT_MAC_USE_COCOA)
     313                    // ATS and CT disagrees on what the family name should be,
     314                    // use CT to look up the font if ATS fails.
     315                    QCFString familyName = QString::fromAscii(family_name);
     316                    QCFType<CTFontRef> CTfontRef = CTFontCreateWithName(familyName, 12, NULL);
     317                    QCFType<CTFontDescriptorRef> fontDescriptor = CTFontCopyFontDescriptor(CTfontRef);
     318                    QCFString displayName = (CFStringRef)CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontDisplayNameAttribute);
     319
     320                    familyRef = ATSFontFamilyFindFromName(displayName, kATSOptionFlagsDefault);
     321                    if (familyRef) {
     322                        fontRef = ATSFontFindFromName(displayName, kATSOptionFlagsDefault);
     323                        goto FamilyFound;
     324                    }
     325#endif
    316326                }
    317327            }
     
    462472
    463473    fnt->families.clear();
     474#if defined(QT_MAC_USE_COCOA)
     475    // Make sure that the family name set on the font matches what
     476    // kCTFontFamilyNameAttribute returns in initializeDb().
     477    // So far the best solution seems find the installed font
     478    // using CoreText and get the family name from it.
     479    // (ATSFontFamilyGetName appears to be the correct API, but also
     480    // returns the font display name.)
     481    for(int i = 0; i < containedFonts.size(); ++i) {
     482        QCFString fontPostScriptName;
     483        ATSFontGetPostScriptName(containedFonts[i], kATSOptionFlagsDefault, &fontPostScriptName);
     484        QCFType<CTFontDescriptorRef> font = CTFontDescriptorCreateWithNameAndSize(fontPostScriptName, 14);
     485        QCFString familyName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
     486        fnt->families.append(familyName);
     487    }
     488#else
    464489    for(int i = 0; i < containedFonts.size(); ++i) {
    465490        QCFString family;
     
    467492        fnt->families.append(family);
    468493    }
     494#endif
    469495
    470496    fnt->handle = handle;
Note: See TracChangeset for help on using the changeset viewer.