Ticket #102: once.diff

File once.diff, 2.9 KB (added by KO Myung-Hun, 14 years ago)

Check PM_AssociateFont only once

  • src/gui/text/qfontdatabase_pm.cpp

     
    751751    return fe;
    752752}
    753753
     754static void addAssociateFont(QStringList &families)
     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        families << QString::fromLocal8Bit(szFontName);
     781}
     782
    754783static QFontEngine *loadPM(const QFontPrivate *d, int script, const QFontDef &req)
    755784{
    756785    // list of families to try
     
    769798    // previous versions
    770799    families << QApplication::font().defaultFamily();
    771800
     801    // add PM_AssociateFont to the list
     802    addAssociateFont(families);
     803
    772804    // null family means find the first font matching the specified script
    773805    families << QString();
    774806
  • src/gui/text/qfont_pm.cpp

     
    7070        break;
    7171    case QFont::AnyStyle:
    7272    default:
    73         static char szFontName[FACESIZE + 1] = {0,};
    74 
    75         // already queried ?
    76         if (szFontName[0] != ';') {
    77             szFontName[0] = ';';
    78             // query the associated font
    79             if (PrfQueryProfileString(HINI_USERPROFILE,
    80                                       "PM_SystemFonts", "PM_AssociateFont", 0,
    81                                       szFontName, sizeof(szFontName))) {
    82                 szFontName[FACESIZE] = '\0';
    83 
    84                 // the format of the associated font is face_name;point_size
    85                 // so remove ';' and later
    86                 for (PSZ pch = szFontName; *pch; pch++)
    87                     if (*pch == ';') {
    88                         *pch = '\0';
    89                         break;
    90                     }
    91             }
    92         }
    93 
    94         // is the associated font available ?
    95         if (szFontName[0] != '\0' && szFontName[0] != ';')
    96             family = szFontName;
    97         else if (request.fixedPitch)
     73        if (request.fixedPitch)
    9874            family = "Courier";
    9975        else
    10076            family = "Helvetica";