Ignore:
Timestamp:
Dec 2, 2009, 5:16:18 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Correction for r372: Don't query PM_AssociateFont too often (patch by komh).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/text/qfontdatabase_pm.cpp

    r371 r373  
    752752}
    753753
     754static QString getAssociateFont()
     755{
     756    static char szFontName[FACESIZE + 1] = {0,};
     757
     758    // already queried ?
     759    if (szFontName[0] == '\0') {
     760        // query the associated font
     761        if (PrfQueryProfileString(HINI_USERPROFILE,
     762                                  "PM_SystemFonts", "PM_AssociateFont", 0,
     763                                  szFontName, sizeof(szFontName))) {
     764            szFontName[FACESIZE] = '\0';
     765
     766            // the format of the associated font is face_name;point_size
     767            // so remove ';' and later
     768            for (PSZ pch = szFontName; *pch; pch++)
     769                if (*pch == ';') {
     770                    *pch = '\0';
     771                    break;
     772                }
     773        }
     774
     775        if (szFontName[0] == '\0')
     776            szFontName[0] = ';';
     777    }
     778
     779    if (szFontName[0] != ';')
     780        return QString::fromLocal8Bit(szFontName);
     781
     782    return QString::null;
     783}
     784
    754785static QFontEngine *loadPM(const QFontPrivate *d, int script, const QFontDef &req)
    755786{
     
    763794    // add the default family
    764795    QString defaultFamily = QApplication::font().family();
    765     if (! families.contains(defaultFamily))
     796    if (!families.contains(defaultFamily))
    766797        families << defaultFamily;
    767798
     
    769800    // previous versions
    770801    families << QApplication::font().defaultFamily();
     802
     803    // add PM_AssociateFont to the list (used on DBCS systems to take the
     804    // missing glyphs from)
     805    QString associateFont = getAssociateFont();
     806    if (!associateFont.isEmpty() && !families.contains(associateFont))
     807        families << associateFont;
    771808
    772809    // null family means find the first font matching the specified script
Note: See TracChangeset for help on using the changeset viewer.