text/qplatformfontdatabase.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4extern void qt_registerFont(const QString &familyname, const QString &stylename, -
5 const QString &foundryname, int weight, -
6 QFont::Style style, int stretch, bool antialiased, -
7 bool scalable, int pixelSize, bool fixedPitch, -
8 const QSupportedWritingSystems &writingSystems, void *hanlde); -
9void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *handle) -
10{ -
11 if (dataArray.size() == 0)
never evaluated: dataArray.size() == 0
0
12 return;
never executed: return;
0
13 -
14 const uchar *data = reinterpret_cast<const uchar *>(dataArray.constData()); -
15 if (QFontEngineQPA::verifyHeader(data, dataArray.size())) {
never evaluated: QFontEngineQPA::verifyHeader(data, dataArray.size())
0
16 QString fontName = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_FontName).toString(); -
17 int pixelSize = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_PixelSize).toInt(); -
18 QVariant weight = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_Weight); -
19 QVariant style = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_Style); -
20 QByteArray writingSystemBits = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_WritingSystems).toByteArray(); -
21 -
22 if (!fontName.isEmpty() && pixelSize) {
never evaluated: !fontName.isEmpty()
never evaluated: pixelSize
0
23 QFont::Weight fontWeight = QFont::Normal; -
24 if (weight.type() == QVariant::Int || weight.type() == QVariant::UInt)
never evaluated: weight.type() == QVariant::Int
never evaluated: weight.type() == QVariant::UInt
0
25 fontWeight = QFont::Weight(weight.toInt());
never executed: fontWeight = QFont::Weight(weight.toInt());
0
26 -
27 QFont::Style fontStyle = static_cast<QFont::Style>(style.toInt()); -
28 -
29 QSupportedWritingSystems writingSystems; -
30 for (int i = 0; i < writingSystemBits.count(); ++i) {
never evaluated: i < writingSystemBits.count()
0
31 uchar currentByte = writingSystemBits.at(i); -
32 for (int j = 0; j < 8; ++j) {
never evaluated: j < 8
0
33 if (currentByte & 1)
never evaluated: currentByte & 1
0
34 writingSystems.setSupported(QFontDatabase::WritingSystem(i * 8 + j));
never executed: writingSystems.setSupported(QFontDatabase::WritingSystem(i * 8 + j));
0
35 currentByte >>= 1; -
36 }
never executed: }
0
37 }
never executed: }
0
38 QFont::Stretch stretch = QFont::Unstretched; -
39 registerFont(fontName,QString(),QString(),fontWeight,fontStyle,stretch,true,false,pixelSize,false,writingSystems,handle); -
40 }
never executed: }
0
41 } else {
never executed: }
0
42 QMessageLogger("text/qplatformfontdatabase.cpp", 96, __PRETTY_FUNCTION__).debug() << "header verification of QPF2 font failed. maybe it is corrupt?"; -
43 }
never executed: }
0
44} -
45void QPlatformFontDatabase::registerFont(const QString &familyname, const QString &stylename, -
46 const QString &foundryname, QFont::Weight weight, -
47 QFont::Style style, QFont::Stretch stretch, bool antialiased, -
48 bool scalable, int pixelSize, bool fixedPitch, -
49 const QSupportedWritingSystems &writingSystems, void *usrPtr) -
50{ -
51 if (scalable)
partially evaluated: scalable
TRUEFALSE
yes
Evaluation Count:51534
no
Evaluation Count:0
0-51534
52 pixelSize = 0;
executed: pixelSize = 0;
Execution Count:51534
51534
53 -
54 qt_registerFont(familyname, stylename, foundryname, weight, style, -
55 stretch, antialiased, scalable, pixelSize, -
56 fixedPitch, writingSystems, usrPtr); -
57}
executed: }
Execution Count:51534
51534
58 -
59class QWritingSystemsPrivate -
60{ -
61public: -
62 QWritingSystemsPrivate() -
63 : ref(1) -
64 , vector(QFontDatabase::WritingSystemsCount,false) -
65 { -
66 }
executed: }
Execution Count:50326
50326
67 -
68 QWritingSystemsPrivate(const QWritingSystemsPrivate *other) -
69 : ref(1) -
70 , vector(other->vector) -
71 { -
72 }
never executed: }
0
73 -
74 QAtomicInt ref; -
75 QVector<bool> vector; -
76}; -
77 -
78 -
79 -
80 -
81QSupportedWritingSystems::QSupportedWritingSystems() -
82{ -
83 d = new QWritingSystemsPrivate; -
84}
executed: }
Execution Count:50326
50326
85 -
86 -
87 -
88 -
89QSupportedWritingSystems::QSupportedWritingSystems(const QSupportedWritingSystems &other) -
90{ -
91 d = other.d; -
92 d->ref.ref(); -
93}
never executed: }
0
94 -
95 -
96 -
97 -
98QSupportedWritingSystems &QSupportedWritingSystems::operator=(const QSupportedWritingSystems &other) -
99{ -
100 if (d != other.d) {
never evaluated: d != other.d
0
101 other.d->ref.ref(); -
102 if (!d->ref.deref())
never evaluated: !d->ref.deref()
0
103 delete d;
never executed: delete d;
0
104 d = other.d; -
105 }
never executed: }
0
106 return *this;
never executed: return *this;
0
107} -
108 -
109 -
110 -
111 -
112QSupportedWritingSystems::~QSupportedWritingSystems() -
113{ -
114 if (!d->ref.deref())
partially evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:50326
no
Evaluation Count:0
0-50326
115 delete d;
executed: delete d;
Execution Count:50326
50326
116}
executed: }
Execution Count:50326
50326
117 -
118 -
119 -
120 -
121void QSupportedWritingSystems::detach() -
122{ -
123 if (d->ref.load() != 1) {
partially evaluated: d->ref.load() != 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:89607
0-89607
124 QWritingSystemsPrivate *newd = new QWritingSystemsPrivate(d); -
125 if (!d->ref.deref())
never evaluated: !d->ref.deref()
0
126 delete d;
never executed: delete d;
0
127 d = newd; -
128 }
never executed: }
0
129}
executed: }
Execution Count:89607
89607
130 -
131 -
132 -
133 -
134 -
135void QSupportedWritingSystems::setSupported(QFontDatabase::WritingSystem writingSystem, bool support) -
136{ -
137 detach(); -
138 d->vector[writingSystem] = support; -
139}
executed: }
Execution Count:89607
89607
140 -
141 -
142 -
143 -
144 -
145bool QSupportedWritingSystems::supported(QFontDatabase::WritingSystem writingSystem) const -
146{ -
147 return d->vector.at(writingSystem);
executed: return d->vector.at(writingSystem);
Execution Count:3407931
3407931
148} -
149QPlatformFontDatabase::~QPlatformFontDatabase() -
150{ -
151} -
152void QPlatformFontDatabase::populateFontDatabase() -
153{ -
154 QString fontpath = fontDir(); -
155 if(!QFile::exists(fontpath)) {
never evaluated: !QFile::exists(fontpath)
0
156 QMessageLogger("text/qplatformfontdatabase.cpp", 257, __PRETTY_FUNCTION__).warning("QFontDatabase: Cannot find font directory '%s' - is Qt installed correctly?", -
157 QString(QDir::toNativeSeparators(fontpath)).toLocal8Bit().constData()); -
158 return;
never executed: return;
0
159 } -
160 -
161 QDir dir(fontpath); -
162 dir.setNameFilters(QStringList() << QLatin1String("*.qpf2")); -
163 dir.refresh(); -
164 for (int i = 0; i < int(dir.count()); ++i) {
never evaluated: i < int(dir.count())
0
165 const QByteArray fileName = QFile::encodeName(dir.absoluteFilePath(dir[i])); -
166 QFile file(QString::fromLocal8Bit(fileName)); -
167 if (file.open(QFile::ReadOnly)) {
never evaluated: file.open(QFile::ReadOnly)
0
168 const QByteArray fileData = file.readAll(); -
169 QByteArray *fileDataPtr = new QByteArray(fileData); -
170 registerQPF2Font(fileData, fileDataPtr); -
171 }
never executed: }
0
172 }
never executed: }
0
173}
never executed: }
0
174 -
175 -
176 -
177 -
178 -
179 -
180QFontEngineMulti *QPlatformFontDatabase::fontEngineMulti(QFontEngine *fontEngine, -
181 QUnicodeTables::Script script) -
182{ -
183 return new QFontEngineMultiQPA(fontEngine, script);
never executed: return new QFontEngineMultiQPA(fontEngine, script);
0
184} -
185 -
186 -
187 -
188 -
189 -
190QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle) -
191{ -
192 (void)script;; -
193 (void)handle;; -
194 QByteArray *fileDataPtr = static_cast<QByteArray *>(handle); -
195 QFontEngineQPA *engine = new QFontEngineQPA(fontDef,*fileDataPtr); -
196 -
197 return engine;
never executed: return engine;
0
198} -
199 -
200QFontEngine *QPlatformFontDatabase::fontEngine(const QByteArray &fontData, qreal pixelSize, -
201 QFont::HintingPreference hintingPreference) -
202{ -
203 (void)fontData;; -
204 (void)pixelSize;; -
205 (void)hintingPreference;; -
206 QMessageLogger("text/qplatformfontdatabase.cpp", 307, __PRETTY_FUNCTION__).warning("This plugin does not support font engines created directly from font data"); -
207 return 0;
never executed: return 0;
0
208} -
209 -
210 -
211 -
212 -
213 -
214QStringList QPlatformFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const -
215{ -
216 (void)family;; -
217 (void)style;; -
218 (void)styleHint;; -
219 (void)script;; -
220 return QStringList();
never executed: return QStringList();
0
221} -
222QStringList QPlatformFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) -
223{ -
224 (void)fontData;; -
225 (void)fileName;; -
226 -
227 QMessageLogger("text/qplatformfontdatabase.cpp", 338, __PRETTY_FUNCTION__).warning("This plugin does not support application fonts"); -
228 return QStringList();
never executed: return QStringList();
0
229} -
230 -
231 -
232 -
233 -
234void QPlatformFontDatabase::releaseHandle(void *handle) -
235{ -
236 QByteArray *fileDataPtr = static_cast<QByteArray *>(handle); -
237 delete fileDataPtr; -
238}
never executed: }
0
239 -
240 -
241 -
242 -
243QString QPlatformFontDatabase::fontDir() const -
244{ -
245 QString fontpath = QString::fromLocal8Bit(qgetenv("QT_QPA_FONTDIR")); -
246 if (fontpath.isEmpty()) {
never evaluated: fontpath.isEmpty()
0
247 fontpath = QLibraryInfo::location(QLibraryInfo::LibrariesPath); -
248 fontpath += QLatin1String("/fonts"); -
249 }
never executed: }
0
250 -
251 return fontpath;
never executed: return fontpath;
0
252} -
253QFont QPlatformFontDatabase::defaultFont() const -
254{ -
255 return QFont(QLatin1String("Helvetica"));
never executed: return QFont(QLatin1String("Helvetica"));
0
256} -
257 -
258 -
259 -
260 -
261 -
262 -
263 -
264QString QPlatformFontDatabase::resolveFontFamilyAlias(const QString &family) const -
265{ -
266 return family;
never executed: return family;
0
267} -
268bool QPlatformFontDatabase::fontsAlwaysScalable() const -
269{ -
270 return false;
executed: return false;
Execution Count:209
209
271} -
272 -
273 -
274 -
275 -
276 -
277 -
278 -
279 QList<int> QPlatformFontDatabase::standardSizes() const -
280{ -
281 QList<int> ret; -
282 static const unsigned short standard[] = -
283 { 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72, 0 }; -
284 ret.reserve(int(sizeof(standard) / sizeof(standard[0]))); -
285 const unsigned short *sizes = standard; -
286 while (*sizes) ret << *sizes++;
executed: ret << *sizes++;
Execution Count:3762
evaluated: *sizes
TRUEFALSE
yes
Evaluation Count:3762
yes
Evaluation Count:209
209-3762
287 return ret;
executed: return ret;
Execution Count:209
209
288} -
289 -
290 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial