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_x11.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**
     
    5252#include <qtemporaryfile.h>
    5353#include <qabstractfileengine.h>
     54#include <qmath.h>
    5455
    5556#include <ctype.h>
     
    155156      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    156157      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    157       0 },
     158      0, 0 },
    158159    // iso8859-2
    159160    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
    160161      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    161162      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    162       0 },
     163      0, 0 },
    163164    // iso8859-3
    164165    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
    165166      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    166167      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    167       0 },
     168      0, 0 },
    168169    // iso8859-4
    169170    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
    170171      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    171172      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    172       0 },
     173      0, 0 },
    173174    // iso8859-9
    174175    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
    175176      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    176177      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    177       0 },
     178      0, 0 },
    178179    // iso8859-10
    179180    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
    180181      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    181182      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    182       0 },
     183      0, 0 },
    183184    // iso8859-13
    184185    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
    185186      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    186187      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    187       0 },
     188      0, 0 },
    188189    // iso8859-14
    189190    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
    190191      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    191192      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    192       0 },
     193      0, 0 },
    193194    // iso8859-15
    194195    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
    195196      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    196197      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    197       0 },
     198      0, 0 },
    198199    // hp-roman8
    199200    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
    200201      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    201202      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    202       0 },
     203      0, 0 },
    203204    // iso8859-5
    204205    { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
    205206      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    206207      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    207       0 },
     208      0, 0 },
    208209    // *-cp1251
    209210    { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
    210211      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    211212      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    212       0 },
     213      0, 0 },
    213214    // koi8-ru
    214215    { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
    215216      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    216217      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    217       0 },
     218      0, 0 },
    218219    // koi8-u
    219220    { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
    220221      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    221222      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    222       0 },
     223      0, 0 },
    223224    // koi8-r
    224225    { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
    225226      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    226227      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    227       0 },
     228      0, 0 },
    228229    // iso8859-7
    229230    { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
    230231      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    231232      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    232       0 },
     233      0, 0 },
    233234    // iso8859-8
    234235    { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
    235236      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    236237      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    237       0 },
     238      0, 0 },
    238239    // gb18030-0
    239240    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    240241      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    241242      0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
    242       0 },
     243      0, 0 },
    243244    // gb18030.2000-0
    244245    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    245246      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    246247      0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
    247       0 },
     248      0, 0 },
    248249    // gbk-0
    249250    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    250251      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    251252      0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
    252       0 },
     253      0, 0 },
    253254    // gb2312.*-0
    254255    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    255256      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    256257      0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
    257       0 },
     258      0, 0 },
    258259    // jisx0201*-0
    259260    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    260261      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    261262      0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
    262       0 },
     263      0, 0 },
    263264    // jisx0208*-0
    264265    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    265266      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    266267      0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
    267       0 },
     268      0, 0 },
    268269    // ksc5601*-*
    269270    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    270271      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    271272      0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
    272       0 },
     273      0, 0 },
    273274    // big5hkscs-0
    274275    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    275276      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    276277      0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
    277       0 },
     278      0, 0 },
    278279    // hkscs-1
    279280    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    280281      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    281282      0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
    282       0 },
     283      0, 0 },
    283284    // big5*-*
    284285    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    285286      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    286287      0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
    287       0 },
     288      0, 0 },
    288289    // tscii-*
    289290    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    290291      0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
    291292      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    292       0 },
     293      0, 0 },
    293294    // tis620*-*
    294295    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    295296      0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
    296297      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    297       0 },
     298      0, 0 },
    298299    // iso8859-11
    299300    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    300301      0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
    301302      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    302       0 },
     303      0, 0 },
    303304    // mulelao-1
    304305    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    305306      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    306307      1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    307       0 },
     308      0, 0 },
    308309    // ethiopic-unicode
    309310    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    310311      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    311312      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    312       0 },
     313      0, 0 },
    313314    // iso10646-1
    314315    { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0,
    315316      0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
    316317      1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
    317       0 },
     318      0, 0 },
    318319    // unicode-*
    319320    { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0,
    320321      0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
    321322      1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
    322       0 },
     323      0, 0 },
    323324    // *-symbol
    324325    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    325326      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    326327      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    327       1 },
     328      1, 0 },
    328329    // *-fontspecific
    329330    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    330331      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    331332      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    332       1 },
     333      1, 0 },
    333334    // fontspecific-*
    334335    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    335336      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    336337      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    337       1 }
     338      1, 0 }
    338339
    339340};
     
    393394    if (id != -1) return xlfd_encoding[id].mib;
    394395    return 0;
    395 };
     396}
    396397
    397398int qt_encoding_id_for_mib(int mib)
     
    495496  Description).
    496497
    497   Returns true if the the given xlfd is valid.
     498  Returns true if the given xlfd is valid.
    498499*/
    499500bool qt_fillFontDef(const QByteArray &xlfd, QFontDef *fd, int dpi, QtFontDesc *desc)
     
    510511    fd->family = QString::fromLatin1(tokens[Family]);
    511512    QString foundry = QString::fromLatin1(tokens[Foundry]);
    512     if (! foundry.isEmpty() && foundry != QString::fromLatin1("*") && (!desc || desc->family->count > 1))
     513    if (! foundry.isEmpty() && foundry != QLatin1String("*") && (!desc || desc->family->count > 1))
    513514        fd->family +=
    514             QString::fromLatin1(" [") + foundry + QString::fromLatin1("]");
     515            QLatin1String(" [") + foundry + QLatin1Char(']');
    515516
    516517    if (qstrlen(tokens[AddStyle]) > 0)
     
    753754            dpi = QX11Info::appDpiY();
    754755        else
    755             dpi = 96; // ####
     756            dpi = qt_defaultDpiY();
    756757    }
    757758
    758759    double size;
    759760    if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
    760         fontDef.pixelSize = qRound(size);
     761        fontDef.pixelSize = size;
    761762    else
    762763        fontDef.pixelSize = 12;
     
    835836    "", // Ogham
    836837    "", // Runic
    837     "km" // Khmer
     838    "km", // Khmer
     839    "" // N'Ko
    838840};
    839841enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) };
     
    866868    0x1681, // Ogham
    867869    0x16a0, // Runic
    868     0  // Khmer
     870    0,  // Khmer
     871    0x7ca // N'Ko
    869872};
    870873enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) };
     
    905908    0, // Symbol
    906909    0, // Ogham
    907     0 // Runic
     910    0, // Runic
     911    0 // N'Ko
    908912};
    909913enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
     
    944948    0, // Symbol
    945949    0x1681, // Ogham
    946     0x16a0 // Runic
     950    0x16a0, // Runic
     951    0x7ca // N'Ko
    947952};
    948953enum { SampleCharCount = sizeof(sampleCharForWritingSystem) / sizeof(ushort) };
     
    984989    0, // Symbol
    985990    0, // Ogham
    986     0 // Runic
     991    0, // Runic
     992    "nko " // N'Ko
    987993};
    988994enum { OpenTypeCount = sizeof(openType) / sizeof(const char *) };
     
    12051211static void initializeDb();
    12061212
    1207 static void load(const QString &family = QString(), int script = -1)
    1208 {
    1209     if (X11->has_fontconfig) {
     1213static void load(const QString &family = QString(), int script = -1, bool forceXLFD = false)
     1214{
     1215    if (X11->has_fontconfig && !forceXLFD) {
    12101216        initializeDb();
    12111217        return;
     
    14561462    FcPatternAddInteger(pattern, FC_SLANT, slant_value);
    14571463
    1458     double size_value = qMax(1, request.pixelSize);
     1464    double size_value = qMax(qreal(1.), request.pixelSize);
    14591465    FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value);
    14601466
     
    14721478    }
    14731479
    1474     if (script != QUnicodeTables::Common) {
     1480    if (script != QUnicodeTables::Common && *specialLanguages[script] != '\0') {
    14751481        Q_ASSERT(script < QUnicodeTables::ScriptCount);
    14761482        FcLangSet *ls = FcLangSetCreate();
     
    16151621            if (!FcCharSetHasChar(cs, specialChars[script]))
    16161622                goto done;
    1617         } else {
     1623        } else if (*specialLanguages[script] != '\0'){
    16181624            FcLangSet *langSet = 0;
    16191625            if (FcPatternGetLangSet(match, FC_LANG, 0, &langSet) != FcResultMatch)
     
    17851791        QT_PREPEND_NAMESPACE(parseFontName)(families_and_foundries.at(i), foundry, family);
    17861792        FM_DEBUG("loadXlfd: >>>>>>>>>>>>>>trying to match '%s' encoding=%d", family.toLatin1().data(), force_encoding_id);
    1787         QT_PREPEND_NAMESPACE(match)(script, request, family, foundry, force_encoding_id, &desc);
     1793        QT_PREPEND_NAMESPACE(match)(script, request, family, foundry, force_encoding_id, &desc, QList<int>(), true);
    17881794        if (desc.family)
    17891795            break;
     
    18031809            QByteArray xlfd("-");
    18041810            xlfd += desc.foundry->name.isEmpty() ? QByteArray("*") : desc.foundry->name.toLatin1();
    1805             xlfd += "-";
     1811            xlfd += '-';
    18061812            xlfd += desc.family->name.isEmpty() ? QByteArray("*") : desc.family->name.toLatin1();
    1807             xlfd += "-";
     1813            xlfd += '-';
    18081814            xlfd += desc.style->weightName ? desc.style->weightName : "*";
    1809             xlfd += "-";
     1815            xlfd += '-';
    18101816            xlfd += (desc.style->key.style == QFont::StyleItalic
    1811                      ? "i"
    1812                      : (desc.style->key.style == QFont::StyleOblique ? "o" : "r"));
    1813             xlfd += "-";
     1817                     ? 'i'
     1818                     : (desc.style->key.style == QFont::StyleOblique ? 'o' : 'r'));
     1819            xlfd += '-';
    18141820            xlfd += desc.style->setwidthName ? desc.style->setwidthName : "*";
    18151821            // ### handle add-style
    18161822            xlfd += "-*-";
    18171823            xlfd += QByteArray::number(px);
    1818             xlfd += "-";
     1824            xlfd += '-';
    18191825            xlfd += QByteArray::number(desc.encoding->xpoint);
    1820             xlfd += "-";
     1826            xlfd += '-';
    18211827            xlfd += QByteArray::number(desc.encoding->xres);
    1822             xlfd += "-";
     1828            xlfd += '-';
    18231829            xlfd += QByteArray::number(desc.encoding->yres);
    1824             xlfd += "-";
     1830            xlfd += '-';
    18251831            xlfd += desc.encoding->pitch;
    1826             xlfd += "-";
     1832            xlfd += '-';
    18271833            xlfd += QByteArray::number(desc.encoding->avgwidth);
    1828             xlfd += "-";
     1834            xlfd += '-';
    18291835            xlfd += xlfd_for_id(desc.encoding->encoding);
    18301836
     
    18481854    } else {
    18491855        QList<int> encodings;
    1850         if (desc.encoding)
    1851             encodings.append(int(desc.encoding->encoding));
     1856        if (desc.encoding) {
     1857            if (desc.encoding->encoding >= 0)
     1858                encodings.append(int(desc.encoding->encoding));
     1859        }
    18521860
    18531861        if (desc.size) {
     
    18551863            for (int i = 0; i < desc.size->count; ++i) {
    18561864                QtFontEncoding *e = desc.size->encodings + i;
    1857                 if (e == desc.encoding)
    1858                     continue;
     1865                if (e == desc.encoding || e->encoding < 0)
     1866                    continue;               
    18591867                encodings.append(int(e->encoding));
    18601868            }
     
    18631871        const XlfdEncoding *enc = xlfd_encoding;
    18641872        for (; enc->name; ++enc) {
    1865             if (!encodings.contains(enc->id))
     1873            if (!encodings.contains(enc->id) && enc->id >= 0) {
    18661874                encodings.append(enc->id);
     1875            }
    18671876        }
    18681877
     
    18911900    QFontDef req = d->request;
    18921901    if (req.pixelSize <= 0)
    1893         req.pixelSize = qRound(qt_pixelSize(req.pointSize, d->dpi));
    1894     req.pointSize = 0;
     1902        req.pixelSize = floor(qt_pixelSize(req.pointSize, d->dpi) * 100 + 0.5) / 100;
     1903    if (req.pixelSize < 1)
     1904        req.pixelSize = 1;
    18951905    if (req.weight == 0)
    18961906        req.weight = QFont::Normal;
     
    19071917
    19081918    // set it to the actual pointsize, so QFontInfo will do the right thing
    1909     req.pointSize = qt_pointSize(req.pixelSize, d->dpi);
     1919    if (req.pointSize < 0)
     1920        req.pointSize = qt_pointSize(req.pixelSize, d->dpi);
     1921
    19101922
    19111923    QFontEngine *fe = QFontCache::instance()->findEngine(key);
     
    19261938        } else if (X11->has_fontconfig) {
    19271939            fe = loadFc(d, script, req);
     1940
     1941            if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize) {
     1942                delete fe;
     1943                fe = loadXlfd(d->screen, script, req);
     1944            }
     1945
     1946
    19281947#endif
    19291948        } else if (mainThread) {
Note: See TracChangeset for help on using the changeset viewer.