author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 23 Jun 2010 19:07:03 +0300 | |
changeset 29 | b72c6db6890b |
parent 25 | e24348a560a6 |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
0 | 8 |
** |
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
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. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
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 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include <private/qapplication_p.h> |
|
43 |
#include "qdir.h" |
|
44 |
#include "qfont_p.h" |
|
45 |
#include "qfontengine_s60_p.h" |
|
46 |
#include "qabstractfileengine.h" |
|
47 |
#include "qdesktopservices.h" |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
48 |
#include <private/qpixmap_s60_p.h> |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
49 |
#include <private/qt_s60_p.h> |
0 | 50 |
#include "qendian.h" |
51 |
#include <private/qcore_symbian_p.h> |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
52 |
#ifdef QT_NO_FREETYPE |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
#include <openfont.h> |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
54 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
#include <graphics/openfontrasterizer.h> // COpenFontRasterizer has moved to a new header file |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
56 |
#endif // SYMBIAN_ENABLE_SPLIT_HEADERS |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
57 |
#endif // QT_NO_FREETYPE |
0 | 58 |
|
59 |
QT_BEGIN_NAMESPACE |
|
60 |
||
61 |
QFileInfoList alternativeFilePaths(const QString &path, const QStringList &nameFilters, |
|
62 |
QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort, |
|
63 |
bool uniqueFileNames = true) |
|
64 |
{ |
|
65 |
QFileInfoList result; |
|
66 |
||
67 |
// Prepare a 'soft to hard' drive list: W:, X: ... A:, Z: |
|
68 |
QStringList driveStrings; |
|
69 |
foreach (const QFileInfo &drive, QDir::drives()) |
|
70 |
driveStrings.append(drive.absolutePath()); |
|
71 |
driveStrings.sort(); |
|
72 |
const QString zDriveString(QLatin1String("Z:/")); |
|
73 |
driveStrings.removeAll(zDriveString); |
|
74 |
driveStrings.prepend(zDriveString); |
|
75 |
||
76 |
QStringList uniqueFileNameList; |
|
77 |
for (int i = driveStrings.count() - 1; i >= 0; --i) { |
|
78 |
const QDir dirOnDrive(driveStrings.at(i) + path); |
|
79 |
const QFileInfoList entriesOnDrive = dirOnDrive.entryInfoList(nameFilters, filters, sort); |
|
80 |
if (uniqueFileNames) { |
|
81 |
foreach(const QFileInfo &entry, entriesOnDrive) { |
|
82 |
if (!uniqueFileNameList.contains(entry.fileName())) { |
|
83 |
uniqueFileNameList.append(entry.fileName()); |
|
84 |
result.append(entry); |
|
85 |
} |
|
86 |
} |
|
87 |
} else { |
|
88 |
result.append(entriesOnDrive); |
|
89 |
} |
|
90 |
} |
|
91 |
return result; |
|
92 |
} |
|
93 |
||
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
94 |
#ifdef QT_NO_FREETYPE |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
95 |
class QSymbianFontDatabaseExtrasImplementation : public QSymbianFontDatabaseExtras |
0 | 96 |
{ |
97 |
public: |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
98 |
QSymbianFontDatabaseExtrasImplementation(); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
99 |
~QSymbianFontDatabaseExtrasImplementation(); |
0 | 100 |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
101 |
const QSymbianTypeFaceExtras *extras(const QString &typeface, bool bold, bool italic) const; |
0 | 102 |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
103 |
#ifndef Q_SYMBIAN_HAS_FONTTABLE_API |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
104 |
struct CFontFromFontStoreReleaser { |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
105 |
static inline void cleanup(CFont *font) |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
106 |
{ |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
107 |
if (!font) |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
108 |
return; |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
109 |
const QSymbianFontDatabaseExtrasImplementation *dbExtras = |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
110 |
static_cast<const QSymbianFontDatabaseExtrasImplementation*>(privateDb()->symbianExtras); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
111 |
dbExtras->m_store->ReleaseFont(font); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
112 |
} |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
113 |
}; |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
114 |
#endif // !Q_SYMBIAN_HAS_FONTTABLE_API |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
115 |
|
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
116 |
struct CFontFromScreenDeviceReleaser { |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
117 |
static inline void cleanup(CFont *font) |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
118 |
{ |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
119 |
if (!font) |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
120 |
return; |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
121 |
QS60Data::screenDevice()->ReleaseFont(font); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
122 |
} |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
123 |
}; |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
124 |
|
0 | 125 |
private: |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
126 |
#ifndef Q_SYMBIAN_HAS_FONTTABLE_API |
0 | 127 |
RHeap* m_heap; |
128 |
CFontStore *m_store; |
|
129 |
COpenFontRasterizer *m_rasterizer; |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
130 |
mutable QList<const QSymbianTypeFaceExtras *> m_extras; |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
131 |
#endif // !Q_SYMBIAN_HAS_FONTTABLE_API |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
132 |
mutable QHash<QString, const QSymbianTypeFaceExtras *> m_extrasHash; |
0 | 133 |
}; |
134 |
||
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
135 |
QSymbianFontDatabaseExtrasImplementation::QSymbianFontDatabaseExtrasImplementation() |
0 | 136 |
{ |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
137 |
#ifndef Q_SYMBIAN_HAS_FONTTABLE_API |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
138 |
QStringList filters; |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
139 |
filters.append(QLatin1String("*.ttf")); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
140 |
filters.append(QLatin1String("*.ccc")); |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
141 |
filters.append(QLatin1String("*.ltt")); |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
142 |
const QFileInfoList fontFiles = alternativeFilePaths(QLatin1String("resource\\Fonts"), filters); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
143 |
|
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
144 |
const TInt heapMinLength = 0x1000; |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
145 |
const TInt heapMaxLength = qMax(0x20000 * fontFiles.count(), heapMinLength); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
146 |
m_heap = User::ChunkHeap(NULL, heapMinLength, heapMaxLength); |
0 | 147 |
QT_TRAP_THROWING( |
148 |
m_store = CFontStore::NewL(m_heap); |
|
149 |
m_rasterizer = COpenFontRasterizer::NewL(TUid::Uid(0x101F7F5E)); |
|
150 |
CleanupStack::PushL(m_rasterizer); |
|
151 |
m_store->InstallRasterizerL(m_rasterizer); |
|
152 |
CleanupStack::Pop(m_rasterizer);); |
|
153 |
||
154 |
foreach (const QFileInfo &fontFileInfo, fontFiles) { |
|
155 |
const QString fontFile = QDir::toNativeSeparators(fontFileInfo.absoluteFilePath()); |
|
156 |
TPtrC fontFilePtr(qt_QString2TPtrC(fontFile)); |
|
157 |
QT_TRAP_THROWING(m_store->AddFileL(fontFilePtr)); |
|
158 |
} |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
159 |
#endif // !Q_SYMBIAN_HAS_FONTTABLE_API |
0 | 160 |
} |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
161 |
|
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
162 |
QSymbianFontDatabaseExtrasImplementation::~QSymbianFontDatabaseExtrasImplementation() |
0 | 163 |
{ |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
164 |
#ifdef Q_SYMBIAN_HAS_FONTTABLE_API |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
165 |
qDeleteAll(m_extrasHash); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
166 |
#else // Q_SYMBIAN_HAS_FONTTABLE_API |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
167 |
typedef QList<const QSymbianTypeFaceExtras *>::iterator iterator; |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
168 |
for (iterator p = m_extras.begin(); p != m_extras.end(); ++p) { |
0 | 169 |
m_store->ReleaseFont((*p)->fontOwner()); |
170 |
delete *p; |
|
171 |
} |
|
172 |
||
173 |
delete m_store; |
|
174 |
m_heap->Close(); |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
175 |
#endif // Q_SYMBIAN_HAS_FONTTABLE_API |
0 | 176 |
} |
177 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
178 |
#ifndef FNTSTORE_H_INLINES_SUPPORT_FMM |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
/* |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
180 |
Workaround: fntstore.h has an inlined function 'COpenFont* CBitmapFont::OpenFont()' |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
that returns a private data member. The header will change between SDKs. But Qt has |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
182 |
to build on any SDK version and run on other versions of Symbian OS. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
183 |
This function performs the needed pointer arithmetic to get the right COpenFont* |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
187 |
const TInt offsetIOpenFont = 92; // '_FOFF(CBitmapFont, iOpenFont)' ..if iOpenFont weren't private |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
188 |
const TUint valueIOpenFont = *(TUint*)PtrAdd(aBitmapFont, offsetIOpenFont); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
return (valueIOpenFont & 1) ? |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
190 |
(COpenFont*)PtrAdd(aBitmapFont, valueIOpenFont & ~1) : // New behavior: iOpenFont is offset |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
191 |
(COpenFont*)valueIOpenFont; // Old behavior: iOpenFont is pointer |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
193 |
#endif // FNTSTORE_H_INLINES_SUPPORT_FMM |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
195 |
const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(const QString &typeface, |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
196 |
bool bold, bool italic) const |
0 | 197 |
{ |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
198 |
const QString searchKey = typeface + QString::number(int(bold)) + QString::number(int(italic)); |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
199 |
if (!m_extrasHash.contains(searchKey)) { |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
200 |
TFontSpec searchSpec(qt_QString2TPtrC(typeface), 1); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
201 |
if (bold) |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
202 |
searchSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
203 |
if (italic) |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
204 |
searchSpec.iFontStyle.SetPosture(EPostureItalic); |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
205 |
|
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
206 |
CFont* font = NULL; |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
207 |
#ifdef Q_SYMBIAN_HAS_FONTTABLE_API |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
208 |
const TInt err = QS60Data::screenDevice()->GetNearestFontToDesignHeightInPixels(font, searchSpec); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
209 |
Q_ASSERT(err == KErrNone && font); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
210 |
QScopedPointer<CFont, CFontFromScreenDeviceReleaser> sFont(font); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
211 |
QSymbianTypeFaceExtras *extras = new QSymbianTypeFaceExtras(font); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
212 |
sFont.take(); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
213 |
m_extrasHash.insert(searchKey, extras); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
214 |
#else // Q_SYMBIAN_HAS_FONTTABLE_API |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
215 |
const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, searchSpec); |
0 | 216 |
Q_ASSERT(err == KErrNone && font); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
const CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
COpenFont *openFont = |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
#ifdef FNTSTORE_H_INLINES_SUPPORT_FMM |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
220 |
bitmapFont->OpenFont(); |
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
221 |
#else // FNTSTORE_H_INLINES_SUPPORT_FMM |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
OpenFontFromBitmapFont(bitmapFont); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
#endif // FNTSTORE_H_INLINES_SUPPORT_FMM |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
224 |
const TOpenFontFaceAttrib* const attrib = openFont->FaceAttrib(); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
225 |
const QString foundKey = |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
226 |
QString((const QChar*)attrib->FullName().Ptr(), attrib->FullName().Length()); |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
227 |
if (!m_extrasHash.contains(foundKey)) { |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
228 |
QScopedPointer<CFont, CFontFromFontStoreReleaser> sFont(font); |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
229 |
QSymbianTypeFaceExtras *extras = new QSymbianTypeFaceExtras(font, openFont); |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
230 |
sFont.take(); |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
231 |
m_extras.append(extras); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
232 |
m_extrasHash.insert(searchKey, extras); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
233 |
m_extrasHash.insert(foundKey, extras); |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
234 |
} else { |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
235 |
m_store->ReleaseFont(font); |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
236 |
m_extrasHash.insert(searchKey, m_extrasHash.value(foundKey)); |
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
237 |
} |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
238 |
#endif // Q_SYMBIAN_HAS_FONTTABLE_API |
0 | 239 |
} |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
240 |
return m_extrasHash.value(searchKey); |
0 | 241 |
} |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
242 |
#else // QT_NO_FREETYPE |
0 | 243 |
class QFontEngineFTS60 : public QFontEngineFT |
244 |
{ |
|
245 |
public: |
|
246 |
QFontEngineFTS60(const QFontDef &fd); |
|
247 |
}; |
|
248 |
||
249 |
QFontEngineFTS60::QFontEngineFTS60(const QFontDef &fd) |
|
250 |
: QFontEngineFT(fd) |
|
251 |
{ |
|
252 |
default_hint_style = HintFull; |
|
253 |
} |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
254 |
#endif // QT_NO_FREETYPE |
0 | 255 |
|
256 |
/* |
|
257 |
QFontEngineS60::pixelsToPoints, QFontEngineS60::pointsToPixels, QFontEngineMultiS60::QFontEngineMultiS60 |
|
258 |
and QFontEngineMultiS60::QFontEngineMultiS60 should be in qfontengine_s60.cpp. But since also the |
|
259 |
Freetype based font rendering need them, they are here. |
|
260 |
*/ |
|
261 |
qreal QFontEngineS60::pixelsToPoints(qreal pixels, Qt::Orientation orientation) |
|
262 |
{ |
|
263 |
return (orientation == Qt::Horizontal? |
|
264 |
S60->screenDevice()->HorizontalPixelsToTwips(pixels) |
|
265 |
:S60->screenDevice()->VerticalPixelsToTwips(pixels)) / KTwipsPerPoint; |
|
266 |
} |
|
267 |
||
268 |
qreal QFontEngineS60::pointsToPixels(qreal points, Qt::Orientation orientation) |
|
269 |
{ |
|
270 |
const int twips = points * KTwipsPerPoint; |
|
271 |
return orientation == Qt::Horizontal? |
|
272 |
S60->screenDevice()->HorizontalTwipsToPixels(twips) |
|
273 |
:S60->screenDevice()->VerticalTwipsToPixels(twips); |
|
274 |
} |
|
275 |
||
276 |
QFontEngineMultiS60::QFontEngineMultiS60(QFontEngine *first, int script, const QStringList &fallbackFamilies) |
|
277 |
: QFontEngineMulti(fallbackFamilies.size() + 1) |
|
278 |
, m_script(script) |
|
279 |
, m_fallbackFamilies(fallbackFamilies) |
|
280 |
{ |
|
281 |
engines[0] = first; |
|
282 |
first->ref.ref(); |
|
283 |
fontDef = engines[0]->fontDef; |
|
284 |
} |
|
285 |
||
286 |
void QFontEngineMultiS60::loadEngine(int at) |
|
287 |
{ |
|
288 |
Q_ASSERT(at < engines.size()); |
|
289 |
Q_ASSERT(engines.at(at) == 0); |
|
290 |
||
291 |
QFontDef request = fontDef; |
|
292 |
request.styleStrategy |= QFont::NoFontMerging; |
|
293 |
request.family = m_fallbackFamilies.at(at-1); |
|
294 |
engines[at] = QFontDatabase::findFont(m_script, |
|
295 |
/*fontprivate*/0, |
|
296 |
request); |
|
297 |
Q_ASSERT(engines[at]); |
|
298 |
} |
|
299 |
||
300 |
static void initializeDb() |
|
301 |
{ |
|
302 |
QFontDatabasePrivate *db = privateDb(); |
|
303 |
if(!db || db->count) |
|
304 |
return; |
|
305 |
||
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
306 |
#ifdef QT_NO_FREETYPE |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
307 |
if (!db->symbianExtras) |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
308 |
db->symbianExtras = new QSymbianFontDatabaseExtrasImplementation; |
0 | 309 |
|
310 |
QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
311 |
|
0 | 312 |
const int numTypeFaces = QS60Data::screenDevice()->NumTypefaces(); |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
313 |
const QSymbianFontDatabaseExtrasImplementation *dbExtras = |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
314 |
static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras); |
0 | 315 |
bool fontAdded = false; |
316 |
for (int i = 0; i < numTypeFaces; i++) { |
|
317 |
TTypefaceSupport typefaceSupport; |
|
318 |
QS60Data::screenDevice()->TypefaceSupport(typefaceSupport, i); |
|
319 |
CFont *font; // We have to get a font instance in order to know all the details |
|
320 |
TFontSpec fontSpec(typefaceSupport.iTypeface.iName, 11); |
|
321 |
if (QS60Data::screenDevice()->GetNearestFontInPixels(font, fontSpec) != KErrNone) |
|
322 |
continue; |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
323 |
QScopedPointer<CFont, QSymbianFontDatabaseExtrasImplementation::CFontFromScreenDeviceReleaser> sFont(font); |
0 | 324 |
if (font->TypeUid() == KCFbsFontUid) { |
325 |
TOpenFontFaceAttrib faceAttrib; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
326 |
const CFbsFont *cfbsFont = static_cast<const CFbsFont *>(font); |
0 | 327 |
cfbsFont->GetFaceAttrib(faceAttrib); |
328 |
||
329 |
QtFontStyle::Key styleKey; |
|
330 |
styleKey.style = faceAttrib.IsItalic()?QFont::StyleItalic:QFont::StyleNormal; |
|
331 |
styleKey.weight = faceAttrib.IsBold()?QFont::Bold:QFont::Normal; |
|
332 |
||
333 |
QString familyName((const QChar *)typefaceSupport.iTypeface.iName.Ptr(), typefaceSupport.iTypeface.iName.Length()); |
|
334 |
QtFontFamily *family = db->family(familyName, true); |
|
335 |
family->fixedPitch = faceAttrib.IsMonoWidth(); |
|
336 |
QtFontFoundry *foundry = family->foundry(QString(), true); |
|
337 |
QtFontStyle *style = foundry->style(styleKey, true); |
|
338 |
style->smoothScalable = typefaceSupport.iIsScalable; |
|
339 |
style->pixelSize(0, true); |
|
340 |
||
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
341 |
const QSymbianTypeFaceExtras *typeFaceExtras = |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
342 |
dbExtras->extras(familyName, faceAttrib.IsBold(), faceAttrib.IsItalic()); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
343 |
const QByteArray os2Table = typeFaceExtras->getSfntTable(MAKE_TAG('O', 'S', '/', '2')); |
0 | 344 |
const unsigned char* data = reinterpret_cast<const unsigned char*>(os2Table.constData()); |
345 |
const unsigned char* ulUnicodeRange = data + 42; |
|
346 |
quint32 unicodeRange[4] = { |
|
347 |
qFromBigEndian<quint32>(ulUnicodeRange), |
|
348 |
qFromBigEndian<quint32>(ulUnicodeRange + 4), |
|
349 |
qFromBigEndian<quint32>(ulUnicodeRange + 8), |
|
350 |
qFromBigEndian<quint32>(ulUnicodeRange + 12) |
|
351 |
}; |
|
352 |
const unsigned char* ulCodePageRange = data + 78; |
|
353 |
quint32 codePageRange[2] = { |
|
354 |
qFromBigEndian<quint32>(ulCodePageRange), |
|
355 |
qFromBigEndian<quint32>(ulCodePageRange + 4) |
|
356 |
}; |
|
357 |
const QList<QFontDatabase::WritingSystem> writingSystems = |
|
358 |
determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange); |
|
359 |
foreach (const QFontDatabase::WritingSystem system, writingSystems) |
|
360 |
family->writingSystems[system] = QtFontFamily::Supported; |
|
361 |
||
362 |
fontAdded = true; |
|
363 |
} |
|
364 |
} |
|
365 |
||
366 |
Q_ASSERT(fontAdded); |
|
367 |
||
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
368 |
lock.relock(); |
0 | 369 |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
370 |
#else // QT_NO_FREETYPE |
0 | 371 |
QDir dir(QDesktopServices::storageLocation(QDesktopServices::FontsLocation)); |
372 |
dir.setNameFilters(QStringList() << QLatin1String("*.ttf") |
|
373 |
<< QLatin1String("*.ttc") << QLatin1String("*.pfa") |
|
374 |
<< QLatin1String("*.pfb")); |
|
375 |
for (int i = 0; i < int(dir.count()); ++i) { |
|
376 |
const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i])); |
|
377 |
db->addTTFile(file); |
|
378 |
} |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
379 |
#endif // QT_NO_FREETYPE |
0 | 380 |
} |
381 |
||
382 |
static inline void load(const QString &family = QString(), int script = -1) |
|
383 |
{ |
|
384 |
Q_UNUSED(family) |
|
385 |
Q_UNUSED(script) |
|
386 |
initializeDb(); |
|
387 |
} |
|
388 |
||
389 |
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) |
|
390 |
{ |
|
391 |
Q_UNUSED(fnt); |
|
392 |
} |
|
393 |
||
394 |
bool QFontDatabase::removeApplicationFont(int handle) |
|
395 |
{ |
|
396 |
Q_UNUSED(handle); |
|
397 |
return false; |
|
398 |
} |
|
399 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
400 |
bool QFontDatabase::removeAllApplicationFonts() |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
401 |
{ |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
402 |
return false; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
403 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
404 |
|
0 | 405 |
bool QFontDatabase::supportsThreadedFontRendering() |
406 |
{ |
|
407 |
return false; |
|
408 |
} |
|
409 |
||
410 |
static |
|
411 |
QFontDef cleanedFontDef(const QFontDef &req) |
|
412 |
{ |
|
413 |
QFontDef result = req; |
|
414 |
if (result.pixelSize <= 0) { |
|
415 |
result.pixelSize = QFontEngineS60::pointsToPixels(qMax(qreal(1.0), result.pointSize)); |
|
416 |
result.pointSize = 0; |
|
417 |
} |
|
418 |
return result; |
|
419 |
} |
|
420 |
||
421 |
QFontEngine *QFontDatabase::findFont(int script, const QFontPrivate *, const QFontDef &req) |
|
422 |
{ |
|
423 |
const QFontCache::Key key(cleanedFontDef(req), script); |
|
424 |
||
425 |
if (!privateDb()->count) |
|
426 |
initializeDb(); |
|
427 |
||
428 |
QFontEngine *fe = QFontCache::instance()->findEngine(key); |
|
429 |
if (!fe) { |
|
430 |
// Making sure that fe->fontDef.family will be an existing font. |
|
431 |
initializeDb(); |
|
432 |
QFontDatabasePrivate *db = privateDb(); |
|
433 |
QtFontDesc desc; |
|
434 |
QList<int> blacklistedFamilies; |
|
435 |
match(script, req, req.family, QString(), -1, &desc, blacklistedFamilies); |
|
436 |
if (!desc.family) // falling back to application font |
|
437 |
desc.family = db->family(QApplication::font().defaultFamily()); |
|
438 |
Q_ASSERT(desc.family); |
|
439 |
||
440 |
// Making sure that desc.family supports the requested script |
|
441 |
QtFontDesc mappedDesc; |
|
442 |
bool supportsScript = false; |
|
443 |
do { |
|
444 |
match(script, req, QString(), QString(), -1, &mappedDesc, blacklistedFamilies); |
|
445 |
if (mappedDesc.family == desc.family) { |
|
446 |
supportsScript = true; |
|
447 |
break; |
|
448 |
} |
|
449 |
blacklistedFamilies.append(mappedDesc.familyIndex); |
|
450 |
} while (mappedDesc.family); |
|
451 |
if (!supportsScript) { |
|
452 |
blacklistedFamilies.clear(); |
|
453 |
match(script, req, QString(), QString(), -1, &mappedDesc, blacklistedFamilies); |
|
454 |
if (mappedDesc.family) |
|
455 |
desc = mappedDesc; |
|
456 |
} |
|
457 |
||
458 |
const QString fontFamily = desc.family->name; |
|
459 |
QFontDef request = req; |
|
460 |
request.family = fontFamily; |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
461 |
#ifdef QT_NO_FREETYPE |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
462 |
const QSymbianFontDatabaseExtrasImplementation *dbExtras = |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
463 |
static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
464 |
const QSymbianTypeFaceExtras *typeFaceExtras = |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
465 |
dbExtras->extras(fontFamily, request.weight > QFont::Normal, request.style != QFont::StyleNormal); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
466 |
fe = new QFontEngineS60(request, typeFaceExtras); |
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
467 |
#else // QT_NO_FREETYPE |
0 | 468 |
QFontEngine::FaceId faceId; |
469 |
const QtFontFamily * const reqQtFontFamily = db->family(fontFamily); |
|
470 |
faceId.filename = reqQtFontFamily->fontFilename; |
|
471 |
faceId.index = reqQtFontFamily->fontFileIndex; |
|
472 |
||
473 |
QFontEngineFTS60 *fte = new QFontEngineFTS60(cleanedFontDef(request)); |
|
474 |
if (fte->init(faceId, true, QFontEngineFT::Format_A8)) |
|
475 |
fe = fte; |
|
476 |
else |
|
477 |
delete fte; |
|
29
b72c6db6890b
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
478 |
#endif // QT_NO_FREETYPE |
0 | 479 |
|
480 |
Q_ASSERT(fe); |
|
481 |
if (script == QUnicodeTables::Common |
|
482 |
&& !(req.styleStrategy & QFont::NoFontMerging) |
|
483 |
&& !fe->symbol) { |
|
484 |
||
485 |
QStringList commonFonts; |
|
486 |
for (int ws = 1; ws < QFontDatabase::WritingSystemsCount; ++ws) { |
|
487 |
if (scriptForWritingSystem[ws] != script) |
|
488 |
continue; |
|
489 |
for (int i = 0; i < db->count; ++i) { |
|
490 |
if (db->families[i]->writingSystems[ws] & QtFontFamily::Supported) |
|
491 |
commonFonts.append(db->families[i]->name); |
|
492 |
} |
|
493 |
} |
|
494 |
||
495 |
// Hack: Prioritize .ccc fonts |
|
496 |
const QString niceEastAsianFont(QLatin1String("Sans MT 936_S60")); |
|
497 |
if (commonFonts.removeAll(niceEastAsianFont) > 0) |
|
498 |
commonFonts.prepend(niceEastAsianFont); |
|
499 |
||
500 |
fe = new QFontEngineMultiS60(fe, script, commonFonts); |
|
501 |
} |
|
502 |
} |
|
503 |
fe->ref.ref(); |
|
504 |
QFontCache::instance()->insertEngine(key, fe); |
|
505 |
return fe; |
|
506 |
} |
|
507 |
||
508 |
void QFontDatabase::load(const QFontPrivate *d, int script) |
|
509 |
{ |
|
510 |
QFontEngine *fe = 0; |
|
511 |
QFontDef req = d->request; |
|
512 |
||
513 |
if (!d->engineData) { |
|
514 |
const QFontCache::Key key(cleanedFontDef(req), script); |
|
515 |
getEngineData(d, key); |
|
516 |
} |
|
517 |
||
518 |
// the cached engineData could have already loaded the engine we want |
|
519 |
if (d->engineData->engines[script]) |
|
520 |
fe = d->engineData->engines[script]; |
|
521 |
||
522 |
if (!fe) { |
|
523 |
if (qt_enable_test_font && req.family == QLatin1String("__Qt__Box__Engine__")) { |
|
524 |
fe = new QTestFontEngine(req.pixelSize); |
|
525 |
fe->fontDef = req; |
|
526 |
} else { |
|
527 |
fe = findFont(script, d, req); |
|
528 |
} |
|
529 |
d->engineData->engines[script] = fe; |
|
530 |
} |
|
531 |
} |
|
532 |
||
533 |
QT_END_NAMESPACE |