OpenCoverage

qplatformfontdatabase.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qplatformfontdatabase.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qplatformfontdatabase.h"-
41#include <QtGui/private/qfontengine_p.h>-
42#include <QtGui/private/qfontengine_qpf2_p.h>-
43#include <QtGui/QGuiApplication>-
44#include <QtGui/QScreen>-
45#include <qpa/qplatformscreen.h>-
46#include <QtCore/QLibraryInfo>-
47#include <QtCore/QDir>-
48-
49#include <algorithm>-
50#include <iterator>-
51-
52QT_BEGIN_NAMESPACE-
53-
54void qt_registerFont(const QString &familyname, const QString &stylename,-
55 const QString &foundryname, int weight,-
56 QFont::Style style, int stretch, bool antialiased,-
57 bool scalable, int pixelSize, bool fixedPitch,-
58 const QSupportedWritingSystems &writingSystems, void *hanlde);-
59-
60void qt_registerFontFamily(const QString &familyName);-
61void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias);-
62-
63/*!-
64 \fn void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *handle)-
65-
66 Registers the pre-rendered QPF2 font contained in the given \a dataArray.-
67-
68 \sa registerFont()-
69*/-
70void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *handle)-
71{-
72 if (dataArray.size() == 0)
dataArray.size() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
73 return;
never executed: return;
0
74-
75 const uchar *data = reinterpret_cast<const uchar *>(dataArray.constData());-
76 if (QFontEngineQPF2::verifyHeader(data, dataArray.size())) {
QFontEngineQPF...aArray.size())Description
TRUEnever evaluated
FALSEnever evaluated
0
77 QString fontName = QFontEngineQPF2::extractHeaderField(data, QFontEngineQPF2::Tag_FontName).toString();-
78 int pixelSize = QFontEngineQPF2::extractHeaderField(data, QFontEngineQPF2::Tag_PixelSize).toInt();-
79 QVariant weight = QFontEngineQPF2::extractHeaderField(data, QFontEngineQPF2::Tag_Weight);-
80 QVariant style = QFontEngineQPF2::extractHeaderField(data, QFontEngineQPF2::Tag_Style);-
81 QByteArray writingSystemBits = QFontEngineQPF2::extractHeaderField(data, QFontEngineQPF2::Tag_WritingSystems).toByteArray();-
82-
83 if (!fontName.isEmpty() && pixelSize) {
!fontName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
pixelSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
84 QFont::Weight fontWeight = QFont::Normal;-
85 if (weight.type() == QVariant::Int || weight.type() == QVariant::UInt)
weight.type() == QVariant::IntDescription
TRUEnever evaluated
FALSEnever evaluated
weight.type() ...QVariant::UIntDescription
TRUEnever evaluated
FALSEnever evaluated
0
86 fontWeight = QFont::Weight(weight.toInt());
never executed: fontWeight = QFont::Weight(weight.toInt());
0
87-
88 QFont::Style fontStyle = static_cast<QFont::Style>(style.toInt());-
89-
90 QSupportedWritingSystems writingSystems;-
91 for (int i = 0; i < writingSystemBits.count(); ++i) {
i < writingSystemBits.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
92 uchar currentByte = writingSystemBits.at(i);-
93 for (int j = 0; j < 8; ++j) {
j < 8Description
TRUEnever evaluated
FALSEnever evaluated
0
94 if (currentByte & 1)
currentByte & 1Description
TRUEnever evaluated
FALSEnever evaluated
0
95 writingSystems.setSupported(QFontDatabase::WritingSystem(i * 8 + j));
never executed: writingSystems.setSupported(QFontDatabase::WritingSystem(i * 8 + j));
0
96 currentByte >>= 1;-
97 }
never executed: end of block
0
98 }
never executed: end of block
0
99 QFont::Stretch stretch = QFont::Unstretched;-
100 registerFont(fontName,QString(),QString(),fontWeight,fontStyle,stretch,true,false,pixelSize,false,writingSystems,handle);-
101 }
never executed: end of block
0
102 } else {
never executed: end of block
0
103 qDebug("header verification of QPF2 font failed. maybe it is corrupt?");-
104 }
never executed: end of block
0
105}-
106-
107/*!-
108 Registers a font with the given set of attributes describing the font's-
109 foundry, family name, style and stretch information, pixel size, and-
110 supported writing systems. Additional information about whether the font-
111 can be scaled and antialiased can also be provided.-
112-
113 The foundry name and font family are described by \a foundryName and-
114 \a familyName. The font weight (light, normal, bold, etc.), style (normal,-
115 oblique, italic) and stretch information (condensed, expanded, unstretched,-
116 etc.) are specified by \a weight, \a style and \a stretch.-
117-
118 Some fonts can be antialiased and scaled; \a scalable and \a antialiased-
119 can be set to true for fonts with these attributes. The intended pixel-
120 size of non-scalable fonts is specified by \a pixelSize; this value will be-
121 ignored for scalable fonts.-
122-
123 The writing systems supported by the font are specified by the-
124 \a writingSystems argument.-
125-
126 \sa registerQPF2Font(), registerFontFamily()-
127*/-
128void QPlatformFontDatabase::registerFont(const QString &familyname, const QString &stylename,-
129 const QString &foundryname, QFont::Weight weight,-
130 QFont::Style style, QFont::Stretch stretch, bool antialiased,-
131 bool scalable, int pixelSize, bool fixedPitch,-
132 const QSupportedWritingSystems &writingSystems, void *usrPtr)-
133{-
134 if (scalable)
scalableDescription
TRUEnever evaluated
FALSEnever evaluated
0
135 pixelSize = 0;
never executed: pixelSize = 0;
0
136-
137 qt_registerFont(familyname, stylename, foundryname, weight, style,-
138 stretch, antialiased, scalable, pixelSize,-
139 fixedPitch, writingSystems, usrPtr);-
140}
never executed: end of block
0
141-
142/*!-
143 Registers a font family with the font database. The font will be-
144 lazily populated by a callback to populateFamily() when the font-
145 database determines that the family needs population.-
146-
147 \sa populateFamily(), registerFont()-
148*/-
149void QPlatformFontDatabase::registerFontFamily(const QString &familyName)-
150{-
151 qt_registerFontFamily(familyName);-
152}
never executed: end of block
0
153-
154class QWritingSystemsPrivate-
155{-
156public:-
157 QWritingSystemsPrivate()-
158 : ref(1)-
159 , vector(QFontDatabase::WritingSystemsCount,false)-
160 {-
161 }
never executed: end of block
0
162-
163 QWritingSystemsPrivate(const QWritingSystemsPrivate *other)-
164 : ref(1)-
165 , vector(other->vector)-
166 {-
167 }
never executed: end of block
0
168-
169 QAtomicInt ref;-
170 QVector<bool> vector;-
171};-
172-
173/*!-
174 Constructs a new object to handle supported writing systems.-
175*/-
176QSupportedWritingSystems::QSupportedWritingSystems()-
177{-
178 d = new QWritingSystemsPrivate;-
179}
never executed: end of block
0
180-
181/*!-
182 Constructs a copy of the \a other writing systems object.-
183*/-
184QSupportedWritingSystems::QSupportedWritingSystems(const QSupportedWritingSystems &other)-
185{-
186 d = other.d;-
187 d->ref.ref();-
188}
never executed: end of block
0
189-
190/*!-
191 Constructs a copy of the \a other writing systems object.-
192*/-
193QSupportedWritingSystems &QSupportedWritingSystems::operator=(const QSupportedWritingSystems &other)-
194{-
195 if (d != other.d) {
d != other.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
196 other.d->ref.ref();-
197 if (!d->ref.deref())
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
198 delete d;
never executed: delete d;
0
199 d = other.d;-
200 }
never executed: end of block
0
201 return *this;
never executed: return *this;
0
202}-
203-
204/*!-
205 Destroys the supported writing systems object.-
206*/-
207QSupportedWritingSystems::~QSupportedWritingSystems()-
208{-
209 if (!d->ref.deref())
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
210 delete d;
never executed: delete d;
0
211}
never executed: end of block
0
212-
213/*!-
214 \internal-
215*/-
216void QSupportedWritingSystems::detach()-
217{-
218 if (d->ref.load() != 1) {
d->ref.load() != 1Description
TRUEnever evaluated
FALSEnever evaluated
0
219 QWritingSystemsPrivate *newd = new QWritingSystemsPrivate(d);-
220 if (!d->ref.deref())
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
221 delete d;
never executed: delete d;
0
222 d = newd;-
223 }
never executed: end of block
0
224}
never executed: end of block
0
225-
226/*!-
227 Sets or clears support for the specified \a writingSystem based on the-
228 value given by \a support.-
229*/-
230void QSupportedWritingSystems::setSupported(QFontDatabase::WritingSystem writingSystem, bool support)-
231{-
232 detach();-
233 d->vector[writingSystem] = support;-
234}
never executed: end of block
0
235-
236/*!-
237 Returns \c true if the writing system specified by \a writingSystem is-
238 supported; otherwise returns \c false.-
239*/-
240bool QSupportedWritingSystems::supported(QFontDatabase::WritingSystem writingSystem) const-
241{-
242 return d->vector.at(writingSystem);
never executed: return d->vector.at(writingSystem);
0
243}-
244-
245/*!-
246 \class QSupportedWritingSystems-
247 \brief The QSupportedWritingSystems class is used when registering fonts with the internal Qt-
248 fontdatabase-
249 \ingroup painting-
250 \inmodule QtGui-
251-
252 Its to provide an easy to use interface for indicating what writing systems a specific font-
253 supports.-
254-
255*/-
256-
257/*!-
258 \internal-
259 */-
260QPlatformFontDatabase::~QPlatformFontDatabase()-
261{-
262}-
263-
264/*!-
265 This function is called once at startup by Qt's internal font database.-
266 Reimplement this function in a subclass for a convenient place to initialize-
267 the internal font database.-
268-
269 You may lazily populate the database by calling registerFontFamily() instead-
270 of registerFont(), in which case you'll get a callback to populateFamily()-
271 when the required family needs population. You then call registerFont() to-
272 finish population of the family.-
273-
274 The default implementation looks in the fontDir() location and registers all-
275 QPF2 fonts.-
276*/-
277void QPlatformFontDatabase::populateFontDatabase()-
278{-
279 QString fontpath = fontDir();-
280 if(!QFile::exists(fontpath)) {
!QFile::exists(fontpath)Description
TRUEnever evaluated
FALSEnever evaluated
0
281 qWarning("QFontDatabase: Cannot find font directory '%s' - is Qt installed correctly?",-
282 qPrintable(QDir::toNativeSeparators(fontpath)));-
283 return;
never executed: return;
0
284 }-
285-
286 QDir dir(fontpath);-
287 dir.setNameFilters(QStringList() << QLatin1String("*.qpf2"));-
288 dir.refresh();-
289 for (int i = 0; i < int(dir.count()); ++i) {
i < int(dir.count())Description
TRUEnever evaluated
FALSEnever evaluated
0
290 const QByteArray fileName = QFile::encodeName(dir.absoluteFilePath(dir[i]));-
291 QFile file(QString::fromLocal8Bit(fileName));-
292 if (file.open(QFile::ReadOnly)) {
file.open(QFile::ReadOnly)Description
TRUEnever evaluated
FALSEnever evaluated
0
293 const QByteArray fileData = file.readAll();-
294 QByteArray *fileDataPtr = new QByteArray(fileData);-
295 registerQPF2Font(fileData, fileDataPtr);-
296 }
never executed: end of block
0
297 }
never executed: end of block
0
298}
never executed: end of block
0
299-
300/*!-
301 This function is called whenever a lazily populated family, populated-
302 through registerFontFamily(), needs full population.-
303-
304 You are expected to fully populate the family by calling registerFont()-
305 for each font that matches the family name.-
306*/-
307void QPlatformFontDatabase::populateFamily(const QString &familyName)-
308{-
309 Q_UNUSED(familyName);-
310}
never executed: end of block
0
311-
312/*!-
313 This function is called whenever the font database is invalidated.-
314-
315 Reimplement this function to clear any internal data structures that-
316 will need to be rebuilt at the next call to populateFontDatabase().-
317*/-
318void QPlatformFontDatabase::invalidate()-
319{-
320}-
321-
322/*!-
323 Returns a multi font engine in the specified \a script to encapsulate \a fontEngine with the-
324 option to fall back to the fonts given by \a fallbacks if \a fontEngine does not support-
325 a certain character.-
326*/-
327QFontEngineMulti *QPlatformFontDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script)-
328{-
329 return new QFontEngineMulti(fontEngine, script);
never executed: return new QFontEngineMulti(fontEngine, script);
0
330}-
331-
332/*!-
333 Returns the font engine that can be used to render the font described by-
334 the font definition, \a fontDef, in the specified \a script.-
335*/-
336QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, void *handle)-
337{-
338 QByteArray *fileDataPtr = static_cast<QByteArray *>(handle);-
339 QFontEngineQPF2 *engine = new QFontEngineQPF2(fontDef,*fileDataPtr);-
340 //qDebug() << fontDef.pixelSize << fontDef.weight << fontDef.style << fontDef.stretch << fontDef.styleHint << fontDef.styleStrategy << fontDef.family;-
341 return engine;
never executed: return engine;
0
342}-
343-
344QFontEngine *QPlatformFontDatabase::fontEngine(const QByteArray &fontData, qreal pixelSize,-
345 QFont::HintingPreference hintingPreference)-
346{-
347 Q_UNUSED(fontData);-
348 Q_UNUSED(pixelSize);-
349 Q_UNUSED(hintingPreference);-
350 qWarning("This plugin does not support font engines created directly from font data");-
351 return 0;
never executed: return 0;
0
352}-
353-
354/*!-
355 \fn QStringList QPlatformFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const-
356-
357 Returns a list of alternative fonts for the specified \a family and-
358 \a style and \a script using the \a styleHint given.-
359-
360 Default implementation returns a list of fonts for which \a style and \a script support-
361 has been reported during the font database population.-
362*/-
363// implemented in qfontdatabase.cpp-
364-
365/*!-
366 Adds an application font described by the font contained supplied \a fontData-
367 or using the font contained in the file referenced by \a fileName. Returns-
368 a list of family names, or an empty list if the font could not be added.-
369-
370 \note The default implementation of this function does not add an application-
371 font. Subclasses should reimplement this function to perform the necessary-
372 loading and registration of fonts.-
373*/-
374QStringList QPlatformFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName)-
375{-
376 Q_UNUSED(fontData);-
377 Q_UNUSED(fileName);-
378-
379 qWarning("This plugin does not support application fonts");-
380 return QStringList();
never executed: return QStringList();
0
381}-
382-
383/*!-
384 Releases the specified font \a handle.-
385*/-
386void QPlatformFontDatabase::releaseHandle(void *handle)-
387{-
388 QByteArray *fileDataPtr = static_cast<QByteArray *>(handle);-
389 delete fileDataPtr;-
390}
never executed: end of block
0
391-
392/*!-
393 Returns the directory containing the fonts used by the database.-
394*/-
395QString QPlatformFontDatabase::fontDir() const-
396{-
397 QString fontpath = QString::fromLocal8Bit(qgetenv("QT_QPA_FONTDIR"));-
398 if (fontpath.isEmpty()) {
fontpath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
399 fontpath = QLibraryInfo::location(QLibraryInfo::LibrariesPath);-
400 fontpath += QLatin1String("/fonts");-
401 }
never executed: end of block
0
402-
403 return fontpath;
never executed: return fontpath;
0
404}-
405-
406/*!-
407 Returns true if the font family is private. For any given family name,-
408 the result is platform dependent.-
409*/-
410bool QPlatformFontDatabase::isPrivateFontFamily(const QString &family) const-
411{-
412 Q_UNUSED(family);-
413 return false;
never executed: return false;
0
414}-
415-
416/*!-
417 Returns the default system font.-
418-
419 \sa QGuiApplication::font()-
420 \since 5.0-
421*/-
422-
423QFont QPlatformFontDatabase::defaultFont() const-
424{-
425 return QFont(QLatin1String("Helvetica"));
never executed: return QFont(QLatin1String("Helvetica"));
0
426}-
427-
428/*!-
429 Resolve alias to actual font family names.-
430-
431 \since 5.0-
432 */-
433-
434QString qt_resolveFontFamilyAlias(const QString &alias);-
435-
436QString QPlatformFontDatabase::resolveFontFamilyAlias(const QString &family) const-
437{-
438 return qt_resolveFontFamilyAlias(family);
never executed: return qt_resolveFontFamilyAlias(family);
0
439}-
440-
441/*!-
442 Return true if all fonts are considered scalable when using this font database.-
443 Defaults to false.-
444-
445 \since 5.0-
446 */-
447-
448bool QPlatformFontDatabase::fontsAlwaysScalable() const-
449{-
450 return false;
never executed: return false;
0
451}-
452-
453/*!-
454 Return list of standard font sizes when using this font database.-
455-
456 \since 5.0-
457 */-
458-
459 QList<int> QPlatformFontDatabase::standardSizes() const-
460{-
461 QList<int> ret;-
462 static const quint8 standard[] =-
463 { 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 };-
464 static const int num_standards = int(sizeof standard / sizeof *standard);-
465 ret.reserve(num_standards);-
466 std::copy(standard, standard + num_standards, std::back_inserter(ret));-
467 return ret;
never executed: return ret;
0
468}-
469-
470QFontEngine::SubpixelAntialiasingType QPlatformFontDatabase::subpixelAntialiasingTypeHint() const-
471{-
472 static int type = -1;-
473 if (type == -1) {
type == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
474 if (QScreen *screen = QGuiApplication::primaryScreen())
QScreen *scree...rimaryScreen()Description
TRUEnever evaluated
FALSEnever evaluated
0
475 type = screen->handle()->subpixelAntialiasingTypeHint();
never executed: type = screen->handle()->subpixelAntialiasingTypeHint();
0
476 }
never executed: end of block
0
477 return static_cast<QFontEngine::SubpixelAntialiasingType>(type);
never executed: return static_cast<QFontEngine::SubpixelAntialiasingType>(type);
0
478}-
479-
480// ### copied to tools/makeqpf/qpf2.cpp-
481-
482// see the Unicode subset bitfields in the MSDN docs-
483static const quint8 requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {-
484 { 127, 127 }, // Any-
485 { 0, 127 }, // Latin-
486 { 7, 127 }, // Greek-
487 { 9, 127 }, // Cyrillic-
488 { 10, 127 }, // Armenian-
489 { 11, 127 }, // Hebrew-
490 { 13, 127 }, // Arabic-
491 { 71, 127 }, // Syriac-
492 { 72, 127 }, // Thaana-
493 { 15, 127 }, // Devanagari-
494 { 16, 127 }, // Bengali-
495 { 17, 127 }, // Gurmukhi-
496 { 18, 127 }, // Gujarati-
497 { 19, 127 }, // Oriya-
498 { 20, 127 }, // Tamil-
499 { 21, 127 }, // Telugu-
500 { 22, 127 }, // Kannada-
501 { 23, 127 }, // Malayalam-
502 { 73, 127 }, // Sinhala-
503 { 24, 127 }, // Thai-
504 { 25, 127 }, // Lao-
505 { 70, 127 }, // Tibetan-
506 { 74, 127 }, // Myanmar-
507 { 26, 127 }, // Georgian-
508 { 80, 127 }, // Khmer-
509 { 126, 127 }, // SimplifiedChinese-
510 { 126, 127 }, // TraditionalChinese-
511 { 126, 127 }, // Japanese-
512 { 56, 127 }, // Korean-
513 { 0, 127 }, // Vietnamese (same as latin1)-
514 { 126, 127 }, // Other-
515 { 78, 127 }, // Ogham-
516 { 79, 127 }, // Runic-
517 { 14, 127 }, // Nko-
518};-
519-
520enum CsbBits {-
521 Latin1CsbBit = 0,-
522 CentralEuropeCsbBit = 1,-
523 TurkishCsbBit = 4,-
524 BalticCsbBit = 7,-
525 CyrillicCsbBit = 2,-
526 GreekCsbBit = 3,-
527 HebrewCsbBit = 5,-
528 ArabicCsbBit = 6,-
529 VietnameseCsbBit = 8,-
530 SimplifiedChineseCsbBit = 18,-
531 TraditionalChineseCsbBit = 20,-
532 ThaiCsbBit = 16,-
533 JapaneseCsbBit = 17,-
534 KoreanCsbBit = 19,-
535 KoreanJohabCsbBit = 21,-
536 SymbolCsbBit = 31-
537};-
538-
539/*!-
540 Helper function that determines the writing systems support by a given-
541 \a unicodeRange and \a codePageRange.-
542-
543 \since 5.1-
544*/-
545QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2])-
546{-
547 QSupportedWritingSystems writingSystems;-
548-
549 bool hasScript = false;-
550 for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
i < QFontDatab...ngSystemsCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
551 int bit = requiredUnicodeBits[i][0];-
552 int index = bit/32;-
553 int flag = 1 << (bit&31);-
554 if (bit != 126 && (unicodeRange[index] & flag)) {
bit != 126Description
TRUEnever evaluated
FALSEnever evaluated
(unicodeRange[index] & flag)Description
TRUEnever evaluated
FALSEnever evaluated
0
555 bit = requiredUnicodeBits[i][1];-
556 index = bit/32;-
557-
558 flag = 1 << (bit&31);-
559 if (bit == 127 || (unicodeRange[index] & flag)) {
bit == 127Description
TRUEnever evaluated
FALSEnever evaluated
(unicodeRange[index] & flag)Description
TRUEnever evaluated
FALSEnever evaluated
0
560 writingSystems.setSupported(QFontDatabase::WritingSystem(i));-
561 hasScript = true;-
562 // qDebug("font %s: index=%d, flag=%8x supports script %d", familyName.latin1(), index, flag, i);-
563 }
never executed: end of block
0
564 }
never executed: end of block
0
565 }
never executed: end of block
0
566 if (codePageRange[0] & ((1 << Latin1CsbBit) | (1 << CentralEuropeCsbBit) | (1 << TurkishCsbBit) | (1 << BalticCsbBit))) {
codePageRange[...BalticCsbBit))Description
TRUEnever evaluated
FALSEnever evaluated
0
567 writingSystems.setSupported(QFontDatabase::Latin);-
568 hasScript = true;-
569 //qDebug("font %s supports Latin", familyName.latin1());-
570 }
never executed: end of block
0
571 if (codePageRange[0] & (1 << CyrillicCsbBit)) {
codePageRange[...yrillicCsbBit)Description
TRUEnever evaluated
FALSEnever evaluated
0
572 writingSystems.setSupported(QFontDatabase::Cyrillic);-
573 hasScript = true;-
574 //qDebug("font %s supports Cyrillic", familyName.latin1());-
575 }
never executed: end of block
0
576 if (codePageRange[0] & (1 << GreekCsbBit)) {
codePageRange[...< GreekCsbBit)Description
TRUEnever evaluated
FALSEnever evaluated
0
577 writingSystems.setSupported(QFontDatabase::Greek);-
578 hasScript = true;-
579 //qDebug("font %s supports Greek", familyName.latin1());-
580 }
never executed: end of block
0
581 if (codePageRange[0] & (1 << HebrewCsbBit)) {
codePageRange[... HebrewCsbBit)Description
TRUEnever evaluated
FALSEnever evaluated
0
582 writingSystems.setSupported(QFontDatabase::Hebrew);-
583 hasScript = true;-
584 //qDebug("font %s supports Hebrew", familyName.latin1());-
585 }
never executed: end of block
0
586 if (codePageRange[0] & (1 << ArabicCsbBit)) {
codePageRange[... ArabicCsbBit)Description
TRUEnever evaluated
FALSEnever evaluated
0
587 writingSystems.setSupported(QFontDatabase::Arabic);-
588 hasScript = true;-
589 //qDebug("font %s supports Arabic", familyName.latin1());-
590 }
never executed: end of block
0
591 if (codePageRange[0] & (1 << ThaiCsbBit)) {
codePageRange[...<< ThaiCsbBit)Description
TRUEnever evaluated
FALSEnever evaluated
0
592 writingSystems.setSupported(QFontDatabase::Thai);-
593 hasScript = true;-
594 //qDebug("font %s supports Thai", familyName.latin1());-
595 }
never executed: end of block
0
596 if (codePageRange[0] & (1 << VietnameseCsbBit)) {
codePageRange[...tnameseCsbBit)Description
TRUEnever evaluated
FALSEnever evaluated
0
597 writingSystems.setSupported(QFontDatabase::Vietnamese);-
598 hasScript = true;-
599 //qDebug("font %s supports Vietnamese", familyName.latin1());-
600 }
never executed: end of block
0
601 if (codePageRange[0] & (1 << SimplifiedChineseCsbBit)) {
codePageRange[...ChineseCsbBit)Description
TRUEnever evaluated
FALSEnever evaluated
0
602 writingSystems.setSupported(QFontDatabase::SimplifiedChinese);-
603 hasScript = true;-
604 //qDebug("font %s supports Simplified Chinese", familyName.latin1());-
605 }
never executed: end of block
0
606 if (codePageRange[0] & (1 << TraditionalChineseCsbBit)) {
codePageRange[...ChineseCsbBit)Description
TRUEnever evaluated
FALSEnever evaluated
0
607 writingSystems.setSupported(QFontDatabase::TraditionalChinese);-
608 hasScript = true;-
609 //qDebug("font %s supports Traditional Chinese", familyName.latin1());-
610 }
never executed: end of block
0
611 if (codePageRange[0] & (1 << JapaneseCsbBit)) {
codePageRange[...apaneseCsbBit)Description
TRUEnever evaluated
FALSEnever evaluated
0
612 writingSystems.setSupported(QFontDatabase::Japanese);-
613 hasScript = true;-
614 //qDebug("font %s supports Japanese", familyName.latin1());-
615 }
never executed: end of block
0
616 if (codePageRange[0] & ((1 << KoreanCsbBit) | (1 << KoreanJohabCsbBit))) {
codePageRange[...nJohabCsbBit))Description
TRUEnever evaluated
FALSEnever evaluated
0
617 writingSystems.setSupported(QFontDatabase::Korean);-
618 hasScript = true;-
619 //qDebug("font %s supports Korean", familyName.latin1());-
620 }
never executed: end of block
0
621 if (codePageRange[0] & (1U << SymbolCsbBit)) {
codePageRange[... SymbolCsbBit)Description
TRUEnever evaluated
FALSEnever evaluated
0
622 writingSystems = QSupportedWritingSystems();-
623 hasScript = false;-
624 }
never executed: end of block
0
625-
626 if (!hasScript)
!hasScriptDescription
TRUEnever evaluated
FALSEnever evaluated
0
627 writingSystems.setSupported(QFontDatabase::Symbol);
never executed: writingSystems.setSupported(QFontDatabase::Symbol);
0
628-
629 return writingSystems;
never executed: return writingSystems;
0
630}-
631-
632/*!-
633 Helper function that returns the Qt font weight matching a given opentype integer value.-
634-
635 \since 5.5-
636*/-
637-
638// convert 0 ~ 1000 integer to QFont::Weight-
639QFont::Weight QPlatformFontDatabase::weightFromInteger(int weight)-
640{-
641 if (weight < 150)
weight < 150Description
TRUEnever evaluated
FALSEnever evaluated
0
642 return QFont::Thin;
never executed: return QFont::Thin;
0
643 if (weight < 250)
weight < 250Description
TRUEnever evaluated
FALSEnever evaluated
0
644 return QFont::ExtraLight;
never executed: return QFont::ExtraLight;
0
645 if (weight < 350)
weight < 350Description
TRUEnever evaluated
FALSEnever evaluated
0
646 return QFont::Light;
never executed: return QFont::Light;
0
647 if (weight < 450)
weight < 450Description
TRUEnever evaluated
FALSEnever evaluated
0
648 return QFont::Normal;
never executed: return QFont::Normal;
0
649 if (weight < 550)
weight < 550Description
TRUEnever evaluated
FALSEnever evaluated
0
650 return QFont::Medium;
never executed: return QFont::Medium;
0
651 if (weight < 650)
weight < 650Description
TRUEnever evaluated
FALSEnever evaluated
0
652 return QFont::DemiBold;
never executed: return QFont::DemiBold;
0
653 if (weight < 750)
weight < 750Description
TRUEnever evaluated
FALSEnever evaluated
0
654 return QFont::Bold;
never executed: return QFont::Bold;
0
655 if (weight < 850)
weight < 850Description
TRUEnever evaluated
FALSEnever evaluated
0
656 return QFont::ExtraBold;
never executed: return QFont::ExtraBold;
0
657 return QFont::Black;
never executed: return QFont::Black;
0
658}-
659-
660/*!-
661 Helper function that register the \a alias for the \a familyName.-
662-
663 \since 5.2-
664*/-
665-
666void QPlatformFontDatabase::registerAliasToFontFamily(const QString &familyName, const QString &alias)-
667{-
668 qt_registerAliasToFontFamily(familyName, alias);-
669}
never executed: end of block
0
670-
671/*!-
672 \class QPlatformFontDatabase-
673 \since 5.0-
674 \internal-
675 \preliminary-
676 \ingroup qpa-
677 \ingroup painting-
678-
679 \brief The QPlatformFontDatabase class makes it possible to customize how fonts-
680 are discovered and how they are rendered-
681-
682 QPlatformFontDatabase is the superclass which is intended to let platform implementations use-
683 native font handling.-
684-
685 Qt has its internal font database which it uses to discover available fonts on the-
686 user's system. To be able to populate this database subclass this class, and-
687 reimplement populateFontDatabase().-
688-
689 Use the function registerFont() to populate the internal font database.-
690-
691 Sometimes a specified font does not have the required glyphs; in such a case, the-
692 fallbackForFamily() function is called automatically to find alternative font-
693 families that can supply alternatives to the missing glyphs.-
694-
695 \sa QSupportedWritingSystems-
696*/-
697QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9