~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/text/qfontdatabase.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
2
**
3
3
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
 
4
** All rights reserved.
4
5
** Contact: Nokia Corporation (qt-info@nokia.com)
5
6
**
6
7
** This file is part of the QtGui module of the Qt Toolkit.
7
8
**
8
9
** $QT_BEGIN_LICENSE:LGPL$
9
 
** Commercial Usage
10
 
** Licensees holding valid Qt Commercial licenses may use this file in
11
 
** accordance with the Qt Commercial License Agreement provided with the
12
 
** Software or, alternatively, in accordance with the terms contained in
13
 
** a written agreement between you and Nokia.
 
10
** No Commercial Usage
 
11
** This file contains pre-release code and may not be distributed.
 
12
** You may use this file in accordance with the terms and conditions
 
13
** contained in the Technology Preview License Agreement accompanying
 
14
** this package.
14
15
**
15
16
** GNU Lesser General Public License Usage
16
17
** Alternatively, this file may be used under the terms of the GNU Lesser
20
21
** ensure the GNU Lesser General Public License version 2.1 requirements
21
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22
23
**
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.
27
 
**
28
 
** GNU General Public License Usage
29
 
** Alternatively, this file may be used under the terms of the GNU
30
 
** General Public License version 3.0 as published by the Free Software
31
 
** Foundation and appearing in the file LICENSE.GPL included in the
32
 
** packaging of this file.  Please review the following information to
33
 
** ensure the GNU General Public License version 3.0 requirements will be
34
 
** met: http://www.gnu.org/copyleft/gpl.html.
35
 
**
36
 
** If you are unsure which license is appropriate for your use, please
37
 
** contact the sales department at http://www.qtsoftware.com/contact.
 
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.
 
27
**
 
28
** If you have questions regarding the use of this file, please contact
 
29
** Nokia at qt-info@nokia.com.
 
30
**
 
31
**
 
32
**
 
33
**
 
34
**
 
35
**
 
36
**
 
37
**
38
38
** $QT_END_LICENSE$
39
39
**
40
40
****************************************************************************/
56
56
#include <stdlib.h>
57
57
#include <limits.h>
58
58
 
 
59
#if (defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
 
60
#  include <ft2build.h>
 
61
#  include FT_TRUETYPE_TABLES_H
 
62
#endif
 
63
 
59
64
// #define QFONTDATABASE_DEBUG
60
65
#ifdef QFONTDATABASE_DEBUG
61
66
#  define FD_DEBUG qDebug
76
81
 
77
82
QT_BEGIN_NAMESPACE
78
83
 
 
84
#define SMOOTH_SCALABLE 0xffff
 
85
 
79
86
extern int qt_defaultDpiY(); // in qfont.cpp
80
87
 
81
 
Q_GUI_EXPORT bool qt_enable_test_font = false;
 
88
bool qt_enable_test_font = false;
 
89
 
 
90
Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont(bool value)
 
91
{
 
92
    qt_enable_test_font = value;
 
93
}
82
94
 
83
95
static int getFontWeight(const QString &weightString)
84
96
{
87
99
    // Test in decreasing order of commonness
88
100
    if (s == QLatin1String("medium") ||
89
101
        s == QLatin1String("normal")
90
 
        || s.compare(qApp->translate("QFontDatabase", "Normal"), Qt::CaseInsensitive) == 0)
 
102
        || s.compare(QApplication::translate("QFontDatabase", "Normal"), Qt::CaseInsensitive) == 0)
91
103
        return QFont::Normal;
92
104
    if (s == QLatin1String("bold")
93
 
        || s.compare(qApp->translate("QFontDatabase", "Bold"), Qt::CaseInsensitive) == 0)
 
105
        || s.compare(QApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive) == 0)
94
106
        return QFont::Bold;
95
107
    if (s == QLatin1String("demibold") || s == QLatin1String("demi bold")
96
 
        || s.compare(qApp->translate("QFontDatabase", "Demi Bold"), Qt::CaseInsensitive) == 0)
 
108
        || s.compare(QApplication::translate("QFontDatabase", "Demi Bold"), Qt::CaseInsensitive) == 0)
97
109
        return QFont::DemiBold;
98
110
    if (s == QLatin1String("black")
99
 
        || s.compare(qApp->translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
 
111
        || s.compare(QApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
100
112
        return QFont::Black;
101
113
    if (s == QLatin1String("light"))
102
114
        return QFont::Light;
103
115
 
104
116
    if (s.contains(QLatin1String("bold"))
105
 
        || s.contains(qApp->translate("QFontDatabase", "Bold"), Qt::CaseInsensitive)) {
 
117
        || s.contains(QApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive)) {
106
118
        if (s.contains(QLatin1String("demi"))
107
 
            || s.compare(qApp->translate("QFontDatabase", "Demi"), Qt::CaseInsensitive) == 0)
 
119
            || s.compare(QApplication::translate("QFontDatabase", "Demi"), Qt::CaseInsensitive) == 0)
108
120
            return (int) QFont::DemiBold;
109
121
        return (int) QFont::Bold;
110
122
    }
111
123
 
112
124
    if (s.contains(QLatin1String("light"))
113
 
        || s.compare(qApp->translate("QFontDatabase", "Light"), Qt::CaseInsensitive) == 0)
 
125
        || s.compare(QApplication::translate("QFontDatabase", "Light"), Qt::CaseInsensitive) == 0)
114
126
        return (int) QFont::Light;
115
127
 
116
128
    if (s.contains(QLatin1String("black"))
117
 
        || s.compare(qApp->translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
 
129
        || s.compare(QApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
118
130
        return (int) QFont::Black;
119
131
 
120
132
    return (int) QFont::Normal;
141
153
    QtFontEncoding *encodingID(int id, uint xpoint = 0, uint xres = 0,
142
154
                                uint yres = 0, uint avgwidth = 0, bool add = false);
143
155
#endif // Q_WS_X11
144
 
#ifdef Q_WS_QWS
 
156
#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
145
157
    QByteArray fileName;
146
158
    int fileIndex;
147
 
#endif
 
159
#endif // defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
148
160
};
149
161
 
150
162
 
160
172
 
161
173
    if (!add) return 0;
162
174
 
163
 
    if (!(count % 4))
164
 
        encodings = (QtFontEncoding *)
 
175
    if (!(count % 4)) {
 
176
        QtFontEncoding *newEncodings = (QtFontEncoding *)
165
177
                    realloc(encodings,
166
178
                             (((count+4) >> 2) << 2) * sizeof(QtFontEncoding));
 
179
        Q_CHECK_PTR(newEncodings);
 
180
        encodings = newEncodings;
 
181
    }
167
182
    encodings[count].encoding = id;
168
183
    encodings[count].xpoint = xpoint;
169
184
    encodings[count].xres = xres;
215
230
        delete [] weightName;
216
231
        delete [] setwidthName;
217
232
#endif
218
 
#if defined(Q_WS_X11) || defined(Q_WS_QWS)
219
 
        while (count--) {
 
233
#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
 
234
        while (count) {
 
235
            // bitfield count-- in while condition does not work correctly in mwccsym2
 
236
            count--;
220
237
#ifdef Q_WS_X11
221
238
            free(pixelSizes[count].encodings);
222
239
#endif
223
 
#ifdef Q_WS_QWS
 
240
#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
224
241
            pixelSizes[count].fileName.~QByteArray();
225
242
#endif
226
243
        }
238
255
    const char *weightName;
239
256
    const char *setwidthName;
240
257
#endif // Q_WS_X11
241
 
#ifdef Q_WS_QWS
 
258
#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
242
259
    bool antialiased;
243
260
#endif
244
261
 
251
268
    weight = getFontWeight(styleString);
252
269
 
253
270
    if (styleString.contains(QLatin1String("Italic"))
254
 
        || styleString.contains(qApp->translate("QFontDatabase", "Italic")))
 
271
        || styleString.contains(QApplication::translate("QFontDatabase", "Italic")))
255
272
        style = QFont::StyleItalic;
256
273
    else if (styleString.contains(QLatin1String("Oblique"))
257
 
             || styleString.contains(qApp->translate("QFontDatabase", "Oblique")))
 
274
             || styleString.contains(QApplication::translate("QFontDatabase", "Oblique")))
258
275
        style = QFont::StyleOblique;
259
276
}
260
277
 
267
284
    if (!add)
268
285
        return 0;
269
286
 
270
 
    if (!(count % 8))
271
 
        pixelSizes = (QtFontSize *)
 
287
    if (!(count % 8)) {
 
288
        QtFontSize *newPixelSizes = (QtFontSize *)
272
289
                     realloc(pixelSizes,
273
290
                              (((count+8) >> 3) << 3) * sizeof(QtFontSize));
 
291
        Q_CHECK_PTR(newPixelSizes);
 
292
        pixelSizes = newPixelSizes;
 
293
    }
274
294
    pixelSizes[count].pixelSize = size;
275
295
#ifdef Q_WS_X11
276
296
    pixelSizes[count].count = 0;
277
297
    pixelSizes[count].encodings = 0;
278
298
#endif
279
 
#ifdef Q_WS_QWS
 
299
#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
280
300
    new (&pixelSizes[count].fileName) QByteArray;
281
301
    pixelSizes[count].fileIndex = 0;
282
302
#endif
314
334
            else
315
335
                high = pos;
316
336
            pos = (high + low) / 2;
317
 
        };
 
337
        }
318
338
        pos = low;
319
339
    }
320
340
    if (!create)
321
341
        return 0;
322
342
 
323
343
//     qDebug("adding key (weight=%d, style=%d, oblique=%d stretch=%d) at %d", key.weight, key.style, key.oblique, key.stretch, pos);
324
 
    if (!(count % 8))
325
 
        styles = (QtFontStyle **)
 
344
    if (!(count % 8)) {
 
345
        QtFontStyle **newStyles = (QtFontStyle **)
326
346
                 realloc(styles, (((count+8) >> 3) << 3) * sizeof(QtFontStyle *));
 
347
        Q_CHECK_PTR(newStyles);
 
348
        styles = newStyles;
 
349
    }
327
350
 
 
351
    QtFontStyle *style = new QtFontStyle(key);
328
352
    memmove(styles + pos + 1, styles + pos, (count-pos)*sizeof(QtFontStyle *));
329
 
    styles[pos] = new QtFontStyle(key);
 
353
    styles[pos] = style;
330
354
    count++;
331
355
    return styles[pos];
332
356
}
358
382
        fixedPitchComputed(false),
359
383
#endif
360
384
        name(n), count(0), foundries(0)
361
 
#if defined(Q_WS_QWS)
 
385
#if defined(Q_WS_QWS) ||   defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
362
386
        , bogusWritingSystems(false)
363
387
#endif
364
388
    {
388
412
#endif
389
413
 
390
414
    QString name;
391
 
#ifdef Q_WS_X11
 
415
#if defined(Q_WS_X11) ||   defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
392
416
    QByteArray fontFilename;
393
417
    int fontFileIndex;
394
418
#endif
398
422
    int count;
399
423
    QtFontFoundry **foundries;
400
424
 
401
 
#ifdef Q_WS_QWS
 
425
#if defined(Q_WS_QWS) ||   defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
402
426
    bool bogusWritingSystems;
403
427
    QStringList fallbackFamilies;
404
428
#endif
431
455
    if (!create)
432
456
        return 0;
433
457
 
434
 
    if (!(count % 8))
435
 
        foundries = (QtFontFoundry **)
 
458
    if (!(count % 8)) {
 
459
        QtFontFoundry **newFoundries = (QtFontFoundry **)
436
460
                    realloc(foundries,
437
461
                             (((count+8) >> 3) << 3) * sizeof(QtFontFoundry *));
 
462
        Q_CHECK_PTR(newFoundries);
 
463
        foundries = newFoundries;
 
464
    }
438
465
 
439
466
    foundries[count] = new QtFontFoundry(f);
440
467
    return foundries[count++];
442
469
 
443
470
// ### copied to tools/makeqpf/qpf2.cpp
444
471
 
445
 
#if (defined(Q_WS_QWS) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_WS_MAC)
 
472
#if (defined(Q_WS_QWS) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN)  || defined(Q_OS_SYMBIAN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA))
446
473
// see the Unicode subset bitfields in the MSDN docs
447
474
static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {
448
475
        // Any,
563
590
}
564
591
#endif
565
592
 
 
593
#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
 
594
// class with virtual destructor, derived in qfontdatabase_s60.cpp
 
595
class QFontDatabaseS60Store
 
596
{
 
597
public:
 
598
    virtual ~QFontDatabaseS60Store() {}
 
599
};
 
600
#endif
 
601
 
566
602
class QFontDatabasePrivate
567
603
{
568
604
public:
571
607
#if defined(Q_WS_QWS)
572
608
          , stream(0)
573
609
#endif
 
610
#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
 
611
          , s60Store(0)
 
612
#endif
574
613
    { }
575
614
    ~QFontDatabasePrivate() {
576
615
        free();
582
621
        ::free(families);
583
622
        families = 0;
584
623
        count = 0;
 
624
#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
 
625
        if (s60Store) {
 
626
            delete s60Store;
 
627
            s60Store = 0;
 
628
        }
 
629
#endif
585
630
        // don't clear the memory fonts!
586
631
    }
587
632
 
609
654
 
610
655
#if defined(Q_WS_QWS)
611
656
    bool loadFromCache(const QString &fontPath);
 
657
    void addQPF2File(const QByteArray &file);
 
658
#endif // Q_WS_QWS
 
659
#if defined(Q_WS_QWS) ||   defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
612
660
    void addFont(const QString &familyname, const char *foundryname, int weight,
613
661
                 bool italic, int pixelSize, const QByteArray &file, int fileIndex,
614
662
                 bool antialiased,
615
663
                 const QList<QFontDatabase::WritingSystem> &writingSystems = QList<QFontDatabase::WritingSystem>());
616
 
    void addQPF2File(const QByteArray &file);
617
664
#ifndef QT_NO_FREETYPE
618
665
    QStringList addTTFile(const QByteArray &file, const QByteArray &fontData = QByteArray());
 
666
#endif // QT_NO_FREETYPE
619
667
#endif
620
 
 
 
668
#if defined(Q_WS_QWS)
621
669
    QDataStream *stream;
622
670
    QStringList fallbackFamilies;
 
671
#elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
 
672
    const QFontDatabaseS60Store *s60Store;
623
673
#endif
624
674
};
625
675
 
643
693
            else
644
694
                low = pos;
645
695
            pos = (high + low) / 2;
646
 
        };
 
696
        }
647
697
        if (!res)
648
698
            return families[pos];
649
699
    }
654
704
        pos++;
655
705
 
656
706
    // qDebug("adding family %s at %d total=%d", f.latin1(), pos, count);
657
 
    if (!(count % 8))
658
 
        families = (QtFontFamily **)
 
707
    if (!(count % 8)) {
 
708
        QtFontFamily **newFamilies = (QtFontFamily **)
659
709
                   realloc(families,
660
710
                            (((count+8) >> 3) << 3) * sizeof(QtFontFamily *));
 
711
        Q_CHECK_PTR(newFamilies);
 
712
        families = newFamilies;
 
713
    }
661
714
 
 
715
    QtFontFamily *family = new QtFontFamily(f);
662
716
    memmove(families + pos + 1, families + pos, (count-pos)*sizeof(QtFontFamily *));
663
 
    families[pos] = new QtFontFamily(f);
 
717
    families[pos] = family;
664
718
    count++;
665
719
    return families[pos];
666
720
}
667
721
 
 
722
#if defined(Q_WS_QWS) ||   defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
 
723
void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize,
 
724
                                   const QByteArray &file, int fileIndex, bool antialiased,
 
725
                                   const QList<QFontDatabase::WritingSystem> &writingSystems)
 
726
{
 
727
//    qDebug() << "Adding font" << familyname << weight << italic << pixelSize << file << fileIndex << antialiased;
 
728
    QtFontStyle::Key styleKey;
 
729
    styleKey.style = italic ? QFont::StyleItalic : QFont::StyleNormal;
 
730
    styleKey.weight = weight;
 
731
    styleKey.stretch = 100;
 
732
    QtFontFamily *f = family(familyname, true);
 
733
 
 
734
    if (writingSystems.isEmpty()) {
 
735
        for (int ws = 1; ws < QFontDatabase::WritingSystemsCount; ++ws) {
 
736
            f->writingSystems[ws] = QtFontFamily::Supported;
 
737
        }
 
738
        f->bogusWritingSystems = true;
 
739
    } else {
 
740
        for (int i = 0; i < writingSystems.count(); ++i) {
 
741
            f->writingSystems[writingSystems.at(i)] = QtFontFamily::Supported;
 
742
        }
 
743
    }
 
744
 
 
745
    QtFontFoundry *foundry = f->foundry(QString::fromLatin1(foundryname), true);
 
746
    QtFontStyle *style = foundry->style(styleKey,  true);
 
747
    style->smoothScalable = (pixelSize == 0);
 
748
    style->antialiased = antialiased;
 
749
    QtFontSize *size = style->pixelSize(pixelSize?pixelSize:SMOOTH_SCALABLE, true);
 
750
    size->fileName = file;
 
751
    size->fileIndex = fileIndex;
 
752
 
 
753
#if defined(Q_WS_QWS)
 
754
    if (stream) {
 
755
        *stream << familyname << foundry->name << weight << quint8(italic) << pixelSize
 
756
                << file << fileIndex << quint8(antialiased);
 
757
        *stream << quint8(writingSystems.count());
 
758
        for (int i = 0; i < writingSystems.count(); ++i)
 
759
            *stream << quint8(writingSystems.at(i));
 
760
    }
 
761
#else // ..in case of defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
 
762
    f->fontFilename = file;
 
763
    f->fontFileIndex = fileIndex;
 
764
#endif
 
765
}
 
766
#endif
 
767
 
 
768
#if (defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
 
769
QStringList QFontDatabasePrivate::addTTFile(const QByteArray &file, const QByteArray &fontData)
 
770
{
 
771
    QStringList families;
 
772
    extern FT_Library qt_getFreetype();
 
773
    FT_Library library = qt_getFreetype();
 
774
 
 
775
    int index = 0;
 
776
    int numFaces = 0;
 
777
    do {
 
778
        FT_Face face;
 
779
        FT_Error error;
 
780
        if (!fontData.isEmpty()) {
 
781
            error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
 
782
        } else {
 
783
            error = FT_New_Face(library, file, index, &face);
 
784
        }
 
785
        if (error != FT_Err_Ok) {
 
786
            qDebug() << "FT_New_Face failed with index" << index << ":" << hex << error;
 
787
            break;
 
788
        }
 
789
        numFaces = face->num_faces;
 
790
 
 
791
        int weight = QFont::Normal;
 
792
        bool italic = face->style_flags & FT_STYLE_FLAG_ITALIC;
 
793
 
 
794
        if (face->style_flags & FT_STYLE_FLAG_BOLD)
 
795
            weight = QFont::Bold;
 
796
 
 
797
        QList<QFontDatabase::WritingSystem> writingSystems;
 
798
        // detect symbol fonts
 
799
        for (int i = 0; i < face->num_charmaps; ++i) {
 
800
            FT_CharMap cm = face->charmaps[i];
 
801
            if (cm->encoding == ft_encoding_adobe_custom
 
802
                    || cm->encoding == ft_encoding_symbol) {
 
803
                writingSystems.append(QFontDatabase::Symbol);
 
804
                break;
 
805
            }
 
806
        }
 
807
        if (writingSystems.isEmpty()) {
 
808
            TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
 
809
            if (os2) {
 
810
                quint32 unicodeRange[4] = {
 
811
                    os2->ulUnicodeRange1, os2->ulUnicodeRange2, os2->ulUnicodeRange3, os2->ulUnicodeRange4
 
812
                };
 
813
                quint32 codePageRange[2] = {
 
814
                    os2->ulCodePageRange1, os2->ulCodePageRange2
 
815
                };
 
816
 
 
817
                writingSystems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
 
818
                //for (int i = 0; i < writingSystems.count(); ++i)
 
819
                //    qDebug() << QFontDatabase::writingSystemName(writingSystems.at(i));
 
820
            }
 
821
        }
 
822
 
 
823
        QString family = QString::fromAscii(face->family_name);
 
824
        families.append(family);
 
825
        addFont(family, /*foundry*/ "", weight, italic,
 
826
                /*pixelsize*/ 0, file, index, /*antialias*/ true, writingSystems);
 
827
 
 
828
        FT_Done_Face(face);
 
829
        ++index;
 
830
    } while (index < numFaces);
 
831
    return families;
 
832
}
 
833
#endif
668
834
 
669
835
static const int scriptForWritingSystem[] = {
670
836
    QUnicodeTables::Common, // Any
792
958
    if (! desc.foundry->name.isEmpty() && desc.family->count > 1) {
793
959
        fontDef->family += QString::fromLatin1(" [");
794
960
        fontDef->family += desc.foundry->name;
795
 
        fontDef->family += QString::fromLatin1("]");
 
961
        fontDef->family += QLatin1Char(']');
796
962
    }
797
963
 
798
964
    if (desc.style->smoothScalable)
814
980
#endif
815
981
#endif
816
982
 
817
 
#if defined(Q_WS_X11) || defined(Q_WS_WIN)
 
983
#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
818
984
static void getEngineData(const QFontPrivate *d, const QFontCache::Key &key)
819
985
{
820
986
    // look for the requested font in the engine data cache
866
1032
    return fontDatabaseMutex();
867
1033
}
868
1034
 
869
 
#define SMOOTH_SCALABLE 0xffff
870
 
 
871
1035
QT_BEGIN_INCLUDE_NAMESPACE
872
1036
#if defined(Q_WS_X11)
873
1037
#  include "qfontdatabase_x11.cpp"
877
1041
#  include "qfontdatabase_win.cpp"
878
1042
#elif defined(Q_WS_QWS)
879
1043
#  include "qfontdatabase_qws.cpp"
 
1044
#elif defined(Q_OS_SYMBIAN)
 
1045
#  include "qfontdatabase_s60.cpp"
880
1046
#endif
881
1047
QT_END_INCLUDE_NAMESPACE
882
1048
 
1249
1415
{
1250
1416
    QString result;
1251
1417
    if (weight >= QFont::Black)
1252
 
        result = qApp->translate("QFontDatabase", "Black");
 
1418
        result = QApplication::translate("QFontDatabase", "Black");
1253
1419
    else if (weight >= QFont::Bold)
1254
 
        result = qApp->translate("QFontDatabase", "Bold");
 
1420
        result = QApplication::translate("QFontDatabase", "Bold");
1255
1421
    else if (weight >= QFont::DemiBold)
1256
 
        result = qApp->translate("QFontDatabase", "Demi Bold");
 
1422
        result = QApplication::translate("QFontDatabase", "Demi Bold");
1257
1423
    else if (weight < QFont::Normal)
1258
 
        result = qApp->translate("QFontDatabase", "Light");
 
1424
        result = QApplication::translate("QFontDatabase", "Light");
1259
1425
 
1260
1426
    if (style == QFont::StyleItalic)
1261
 
        result += QLatin1Char(' ') + qApp->translate("QFontDatabase", "Italic");
 
1427
        result += QLatin1Char(' ') + QApplication::translate("QFontDatabase", "Italic");
1262
1428
    else if (style == QFont::StyleOblique)
1263
 
        result += QLatin1Char(' ') + qApp->translate("QFontDatabase", "Oblique");
 
1429
        result += QLatin1Char(' ') + QApplication::translate("QFontDatabase", "Oblique");
1264
1430
 
1265
1431
    if (result.isEmpty())
1266
 
        result = qApp->translate("QFontDatabase", "Normal");
 
1432
        result = QApplication::translate("QFontDatabase", "Normal");
1267
1433
 
1268
1434
    return result.simplified();
1269
1435
}
1295
1461
 
1296
1462
    \brief The QFontDatabase class provides information about the fonts available in the underlying window system.
1297
1463
 
1298
 
    \ingroup environment
1299
 
    \ingroup multimedia
1300
 
    \ingroup text
 
1464
    \ingroup appearance
1301
1465
 
1302
1466
    The most common uses of this class are to query the database for
1303
1467
    the list of font families() and for the pointSizes() and styles()
1495
1659
                if (!foundry.isEmpty()) {
1496
1660
                    str += QLatin1String(" [");
1497
1661
                    str += foundry;
1498
 
                    str += QLatin1String("]");
 
1662
                    str += QLatin1Char(']');
1499
1663
                }
1500
1664
                flist.append(str);
1501
1665
            }
2067
2231
        Q_ASSERT_X(false, "QFontDatabase::writingSystemName", "invalid 'writingSystem' parameter");
2068
2232
        break;
2069
2233
    }
2070
 
    return qApp ? qApp->translate("QFontDatabase", name) : QString::fromLatin1(name);
 
2234
    return QApplication::translate("QFontDatabase", name);
2071
2235
}
2072
2236
 
2073
2237
 
2254
2418
        sample += QChar(0xac2f);
2255
2419
        break;
2256
2420
    case Vietnamese:
 
2421
    {
 
2422
        static const char vietnameseUtf8[] = {
 
2423
            char(0xef), char(0xbb), char(0xbf), char(0xe1), char(0xbb), char(0x97),
 
2424
            char(0xe1), char(0xbb), char(0x99),
 
2425
            char(0xe1), char(0xbb), char(0x91),
 
2426
            char(0xe1), char(0xbb), char(0x93),
 
2427
        };
 
2428
        sample += QString::fromUtf8(vietnameseUtf8, sizeof(vietnameseUtf8));
2257
2429
        break;
 
2430
    }
2258
2431
    case Ogham:
2259
2432
        sample += QChar(0x1681);
2260
2433
        sample += QChar(0x1682);
2418
2591
    \sa removeApplicationFont(), addApplicationFont(), addApplicationFontFromData()
2419
2592
*/
2420
2593
 
2421
 
/*! 
 
2594
/*!
2422
2595
    \fn bool QFontDatabase::supportsThreadedFontRendering()
2423
2596
    \since 4.4
2424
2597
 
2427
2600
    means that all QPainter::drawText() calls outside the GUI thread
2428
2601
    will not produce readable output.
2429
2602
 
2430
 
    \sa threads.html#painting-in-threads
 
2603
    \sa {Thread-Support in Qt Modules#Painting In Threads}{Painting In Threads}
2431
2604
*/
2432
2605
 
2433
2606