Changeset 223 for trunk/src


Ignore:
Timestamp:
Oct 14, 2009, 10:16:58 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Fixed broken non-Latin1 text drawing.

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

Legend:

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

    r222 r223  
    446446// ### copied to tools/makeqpf/qpf2.cpp
    447447
    448 #if (defined(Q_WS_QWS) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_WS_MAC)
     448#if ((defined(Q_WS_QWS) || defined(Q_WS_PM)) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_WS_MAC)
    449449// see the Unicode subset bitfields in the MSDN docs
    450450static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {
  • trunk/src/gui/text/qfontdatabase_pm.cpp

    r222 r223  
    133133            QString familyName = QString::fromLatin1(face->family_name);
    134134
     135            // familyName may contain extra spaces (at least this is true for
     136            // TNR.PFB that is reported as "Times New Roman ". Trim them.
     137            familyName = familyName.trimmed();
     138
    135139            QtFontStyle::Key styleKey;
    136140
    137141            styleKey.style = face->style_flags & FT_STYLE_FLAG_ITALIC ?
    138142                QFont::StyleItalic : QFont::StyleNormal;
     143
     144            QList<QFontDatabase::WritingSystem> systems;
    139145
    140146            TT_OS2 *os2_table = 0;
     
    167173                    default: styleKey.stretch = QFont::Unstretched; break;
    168174                }
     175
     176                quint32 unicodeRange[4] = {
     177                    os2_table->ulUnicodeRange1, os2_table->ulUnicodeRange2,
     178                    os2_table->ulUnicodeRange3, os2_table->ulUnicodeRange4
     179                };
     180                quint32 codePageRange[2] = {
     181                    os2_table->ulCodePageRange1, os2_table->ulCodePageRange2
     182                };
     183                systems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
    169184            } else {
    170185                // we've only got simple weight information and no stretch
     
    180195            family->fixedPitch = face->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
    181196
    182             // writing systems aren't used ATM, let's support just Any
    183             family->writingSystems[QFontDatabase::Any] = QtFontFamily::Supported;
     197            if (systems.isEmpty()) {
     198                // it was hard or impossible to determine the actual writing system
     199                // of the font (as in case of OS/2 bitmap and PFB fonts for which it is
     200                // usually simply reported that they support standard/system codepages).
     201                // Pretend that we support all writing systems to not miss the one.
     202                // @todo find a way to detect it properly to make sure these fonts
     203                // are not matched for scripts they don't support
     204                for (int ws = 0; ws < QFontDatabase::WritingSystemsCount; ++ws)
     205                    family->writingSystems[ws] = QtFontFamily::Supported;
     206            } else {
     207                for (int i = 0; i < systems.count(); ++i)
     208                    family->writingSystems[systems.at(i)] = QtFontFamily::Supported;
     209            }
    184210
    185211            QtFontFoundry *foundry = family->foundry(foundryName, true);
     
    235261        populateDatabase(family->name);
    236262#if 1
    237         qDebug("        scripts supported:");
    238         for (int i = 0; i < QUnicodeTables::ScriptCount; i++)
    239             if(family->writingSystems[i] & QtFontFamily::Supported)
    240                 qDebug("            %d", i);
     263        qDebug("        writing systems supported:");
     264        QStringList systems;
     265        for (int ws = 0; ws < QFontDatabase::WritingSystemsCount; ++ws)
     266            if (family->writingSystems[ws] & QtFontFamily::Supported)
     267                systems << QFontDatabase::writingSystemName((QFontDatabase::WritingSystem)ws);
     268        qDebug() << "            " << systems;
    241269        for (int fd = 0; fd < family->count; fd++) {
    242270            QtFontFoundry *foundry = family->foundries[fd];
Note: See TracChangeset for help on using the changeset viewer.