Changeset 318


Ignore:
Timestamp:
Nov 13, 2009, 11:57:53 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

gui/text: Keep track of scripts supported by individual styles within a font family to make sure that if some style doesn't support all scripts the other style does, the font matching algorithm will select another family for this style instead of drawing empty boxes.

Location:
trunk/src/gui/text
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/gui/text/qfontdatabase.cpp

    r223 r318  
    145145                                uint yres = 0, uint avgwidth = 0, bool add = false);
    146146#endif // Q_WS_X11
     147#ifdef Q_WS_PM
     148    QList<QFontDatabase::WritingSystem> systems;
     149#endif
    147150#if defined(Q_WS_QWS) || defined(Q_WS_PM)
    148151    QByteArray fileName;
     
    224227            free(pixelSizes[count].encodings);
    225228#endif
     229#ifdef Q_WS_PM
     230            pixelSizes[count].systems.~QList<QFontDatabase::WritingSystem>();
     231#endif
    226232#if defined(Q_WS_QWS) || defined(Q_WS_PM)
    227233            pixelSizes[count].fileName.~QByteArray();
     
    279285    pixelSizes[count].count = 0;
    280286    pixelSizes[count].encodings = 0;
     287#endif
     288#ifdef Q_WS_PM
     289    new (&pixelSizes[count].systems) QList<QFontDatabase::WritingSystem>;
    281290#endif
    282291#if defined(Q_WS_QWS) || defined(Q_WS_PM)
     
    965974#endif // Q_WS_X11
    966975
     976#if defined(Q_WS_PM)
     977static bool sizeSupportsScript(int script, QtFontSize *size)
     978{
     979    // empty writing system list means we support all
     980    // (see qfontdatabase_pm.cpp for explanation)
     981    if (size->systems.isEmpty())
     982        return true;
     983    foreach (QFontDatabase::WritingSystem ws, size->systems) {
     984        if (scriptForWritingSystem[ws] == script)
     985            return true;
     986    }
     987    return false;
     988}
     989#endif // Q_WS_PM
     990
    967991#if !defined(Q_WS_MAC)
    968992static
     
    10461070                }
    10471071#endif
     1072#ifdef Q_WS_PM
     1073                if (!sizeSupportsScript(script, style->pixelSizes + x)) {
     1074                    FM_DEBUG("          size %3d does not support the script we want",
     1075                             style->pixelSizes[x].pixelSize);
     1076                    continue;
     1077                }
     1078#endif
    10481079
    10491080                unsigned int d;
     
    10901121        }
    10911122#endif // Q_WS_X11
     1123#ifdef Q_WS_PM
     1124        if (size) {
     1125            if (!sizeSupportsScript(script, size)) {
     1126                size = 0;
     1127                FM_DEBUG("          foundry doesn't support the script we want");
     1128                continue;
     1129            }
     1130        }
     1131#endif
    10921132
    10931133        unsigned int this_score = 0x0000;
  • TabularUnified trunk/src/gui/text/qfontdatabase_pm.cpp

    r238 r318  
    295295                    else
    296296                        cached.styleKey.weight = QFont::Black;
    297 
    298                     // @todo "Workplace Sans" from Alex Taylor has weight class
    299                     // < 400 whic makes it Light. It has some bad side effects
    300                     // in Qt, in particular, requesting Normal will select Bold
    301                     // instead of Light if "Workplace Sans Bold" is also installed.
    302                     // For this reason, we override the weight here. Remove the
    303                     // hack if the font is changed to Normal.
    304                     if (cached.familyName == QLatin1String("Workplace Sans")) {
    305                         if (cached.styleKey.weight == QFont::Light)
    306                             cached.styleKey.weight = QFont::Normal;
    307                     }
     297FD_DEBUG("os2_table->usWeightClass %u", os2_table->usWeightClass);
    308298
    309299                    switch (os2_table->usWidthClass) {
     
    329319                    cached.systems =
    330320                        determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
     321FD_DEBUG() << "cached.systems" << cached.systems;
    331322                } else {
    332323                    // we've only got simple weight information and no stretch
     
    402393            family->fixedPitch = cached.fixedPitch;
    403394
    404             if (cached.systems.isEmpty() || cached.familyName == QLatin1String("Workplace Sans")) {
     395            if (cached.systems.isEmpty()) {
    405396                // it was hard or impossible to determine the actual writing system
    406397                // of the font (as in case of OS/2 bitmap and PFB fonts for which it is
    407398                // usually simply reported that they support standard/system codepages).
    408399                // Pretend that we support all writing systems to not miss the one.
    409                 // Note that "Workplace Sans" TTF by Alex Taylor doesn't provide correct
    410                 // unicode and codepage ranges in os2_table for some reason but versions
    411                 // 0.4 and earlier are known to support many popular scripts so hack it.
    412400                //
    413401                // @todo find a proper way to detect actual supported scripts to make
    414402                // sure these fonts are not matched for scripts they don't support.
    415                 //
    416                 // @todo remove the hack for "Workplace Sans" once it is corrected
    417403                for (int ws = 0; ws < QFontDatabase::WritingSystemsCount; ++ws)
    418404                    family->writingSystems[ws] = QtFontFamily::Supported;
     
    437423                size->fileName = file;
    438424                size->fileIndex = cached.index;
     425                size->systems = cached.systems;
    439426            }
    440427
     
    446433                size->fileName = file;
    447434                size->fileIndex = cached.index;
     435                size->systems = cached.systems;
    448436            }
    449437        }
Note: See TracChangeset for help on using the changeset viewer.