qfontdatabase.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qfontdatabase.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qfontdatabase.h"-
35#include "qdebug.h"-
36#include "qalgorithms.h"-
37#include "qguiapplication.h"-
38#include "qvarlengtharray.h" // here or earlier - workaround for VC++6-
39#include "qthread.h"-
40#include "qmutex.h"-
41#include "qfile.h"-
42#include "qfileinfo.h"-
43#include "qfontengine_p.h"-
44#include <qpa/qplatformintegration.h>-
45-
46#include <QtGui/private/qguiapplication_p.h>-
47#include <qpa/qplatformfontdatabase.h>-
48#include <qpa/qplatformtheme.h>-
49-
50#include <QtCore/qcache.h>-
51#include <QtCore/qmath.h>-
52-
53#include <stdlib.h>-
54#include <algorithm>-
55-
56-
57// #define QFONTDATABASE_DEBUG-
58#ifdef QFONTDATABASE_DEBUG-
59# define FD_DEBUG qDebug-
60#else-
61# define FD_DEBUG if (false) qDebug-
62#endif-
63-
64// #define FONT_MATCH_DEBUG-
65#ifdef FONT_MATCH_DEBUG-
66# define FM_DEBUG qDebug-
67#else-
68# define FM_DEBUG if (false) qDebug-
69#endif-
70-
71-
72QT_BEGIN_NAMESPACE-
73-
74#define SMOOTH_SCALABLE 0xffff-
75-
76#if defined(QT_BUILD_INTERNAL)-
77bool qt_enable_test_font = false;-
78-
79Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont(bool value)-
80{-
81 qt_enable_test_font = value;-
82}
never executed: end of block
0
83#endif-
84-
85static int getFontWeight(const QString &weightString)-
86{-
87 QString s = weightString.toLower();-
88-
89 // Order here is important. We want to match the common cases first, but we-
90 // must also take care to acknowledge the cost of our tests.-
91 //-
92 // As a result, we test in two orders; the order of commonness, and the-
93 // order of "expense".-
94 //-
95 // A simple string test is the cheapest, so let's do that first.-
96 // Test in decreasing order of commonness-
97 if (s == QLatin1String("normal") || s == QLatin1String("regular"))
s == QLatin1String("normal")Description
TRUEnever evaluated
FALSEnever evaluated
s == QLatin1String("regular")Description
TRUEnever evaluated
FALSEnever evaluated
0
98 return QFont::Normal;
never executed: return QFont::Normal;
0
99 if (s == QLatin1String("bold"))
s == QLatin1String("bold")Description
TRUEnever evaluated
FALSEnever evaluated
0
100 return QFont::Bold;
never executed: return QFont::Bold;
0
101 if (s == QLatin1String("semibold") || s == QLatin1String("semi bold")
s == QLatin1String("semibold")Description
TRUEnever evaluated
FALSEnever evaluated
s == QLatin1St...g("semi bold")Description
TRUEnever evaluated
FALSEnever evaluated
0
102 || s == QLatin1String("demibold") || s == QLatin1String("demi bold"))
s == QLatin1String("demibold")Description
TRUEnever evaluated
FALSEnever evaluated
s == QLatin1St...g("demi bold")Description
TRUEnever evaluated
FALSEnever evaluated
0
103 return QFont::DemiBold;
never executed: return QFont::DemiBold;
0
104 if (s == QLatin1String("medium"))
s == QLatin1String("medium")Description
TRUEnever evaluated
FALSEnever evaluated
0
105 return QFont::Medium;
never executed: return QFont::Medium;
0
106 if (s == QLatin1String("black"))
s == QLatin1String("black")Description
TRUEnever evaluated
FALSEnever evaluated
0
107 return QFont::Black;
never executed: return QFont::Black;
0
108 if (s == QLatin1String("light"))
s == QLatin1String("light")Description
TRUEnever evaluated
FALSEnever evaluated
0
109 return QFont::Light;
never executed: return QFont::Light;
0
110 if (s == QLatin1String("thin"))
s == QLatin1String("thin")Description
TRUEnever evaluated
FALSEnever evaluated
0
111 return QFont::Thin;
never executed: return QFont::Thin;
0
112 const QStringRef s2 = s.midRef(2);-
113 if (s.startsWith(QLatin1String("ex")) || s.startsWith(QLatin1String("ul"))) {
s.startsWith(Q...1String("ex"))Description
TRUEnever evaluated
FALSEnever evaluated
s.startsWith(Q...1String("ul"))Description
TRUEnever evaluated
FALSEnever evaluated
0
114 if (s2 == QLatin1String("tralight") || s == QLatin1String("tra light"))
s2 == QLatin1S...ng("tralight")Description
TRUEnever evaluated
FALSEnever evaluated
s == QLatin1St...g("tra light")Description
TRUEnever evaluated
FALSEnever evaluated
0
115 return QFont::ExtraLight;
never executed: return QFont::ExtraLight;
0
116 if (s2 == QLatin1String("trabold") || s2 == QLatin1String("tra bold"))
s2 == QLatin1String("trabold")Description
TRUEnever evaluated
FALSEnever evaluated
s2 == QLatin1S...ng("tra bold")Description
TRUEnever evaluated
FALSEnever evaluated
0
117 return QFont::ExtraBold;
never executed: return QFont::ExtraBold;
0
118 }
never executed: end of block
0
119-
120 // Next up, let's see if contains() matches: slightly more expensive, but-
121 // still fast enough.-
122 if (s.contains(QLatin1String("bold"))) {
s.contains(QLa...tring("bold"))Description
TRUEnever evaluated
FALSEnever evaluated
0
123 if (s.contains(QLatin1String("demi")))
s.contains(QLa...tring("demi"))Description
TRUEnever evaluated
FALSEnever evaluated
0
124 return QFont::DemiBold;
never executed: return QFont::DemiBold;
0
125 return QFont::Bold;
never executed: return QFont::Bold;
0
126 }-
127 if (s.contains(QLatin1String("thin")))
s.contains(QLa...tring("thin"))Description
TRUEnever evaluated
FALSEnever evaluated
0
128 return QFont::Thin;
never executed: return QFont::Thin;
0
129 if (s.contains(QLatin1String("light")))
s.contains(QLa...ring("light"))Description
TRUEnever evaluated
FALSEnever evaluated
0
130 return QFont::Light;
never executed: return QFont::Light;
0
131 if (s.contains(QLatin1String("black")))
s.contains(QLa...ring("black"))Description
TRUEnever evaluated
FALSEnever evaluated
0
132 return QFont::Black;
never executed: return QFont::Black;
0
133-
134 // Now, we perform string translations & comparisons with those.-
135 // These are (very) slow compared to simple string ops, so we do these last.-
136 // As using translated values for such things is not very common, this should-
137 // not be too bad.-
138 if (s.compare(QCoreApplication::translate("QFontDatabase", "Normal", "The Normal or Regular font weight"), Qt::CaseInsensitive) == 0)
s.compare(QCor...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
139 return QFont::Normal;
never executed: return QFont::Normal;
0
140 const QString translatedBold = QCoreApplication::translate("QFontDatabase", "Bold").toLower();-
141 if (s == translatedBold)
s == translatedBoldDescription
TRUEnever evaluated
FALSEnever evaluated
0
142 return QFont::Bold;
never executed: return QFont::Bold;
0
143 if (s.compare(QCoreApplication::translate("QFontDatabase", "Demi Bold"), Qt::CaseInsensitive) == 0)
s.compare(QCor...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
144 return QFont::DemiBold;
never executed: return QFont::DemiBold;
0
145 if (s.compare(QCoreApplication::translate("QFontDatabase", "Medium", "The Medium font weight"), Qt::CaseInsensitive) == 0)
s.compare(QCor...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
146 return QFont::Medium;
never executed: return QFont::Medium;
0
147 if (s.compare(QCoreApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
s.compare(QCor...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
148 return QFont::Black;
never executed: return QFont::Black;
0
149 const QString translatedLight = QCoreApplication::translate("QFontDatabase", "Light").toLower();-
150 if (s == translatedLight)
s == translatedLightDescription
TRUEnever evaluated
FALSEnever evaluated
0
151 return QFont::Light;
never executed: return QFont::Light;
0
152 if (s.compare(QCoreApplication::translate("QFontDatabase", "Thin"), Qt::CaseInsensitive) == 0)
s.compare(QCor...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
153 return QFont::Thin;
never executed: return QFont::Thin;
0
154 if (s.compare(QCoreApplication::translate("QFontDatabase", "Extra Light"), Qt::CaseInsensitive) == 0)
s.compare(QCor...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
155 return QFont::ExtraLight;
never executed: return QFont::ExtraLight;
0
156 if (s.compare(QCoreApplication::translate("QFontDatabase", "Extra Bold"), Qt::CaseInsensitive) == 0)
s.compare(QCor...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
157 return QFont::ExtraBold;
never executed: return QFont::ExtraBold;
0
158-
159 // And now the contains() checks for the translated strings.-
160 //: The word for "Extra" as in "Extra Bold, Extra Thin" used as a pattern for string searches-
161 const QString translatedExtra = QCoreApplication::translate("QFontDatabase", "Extra").toLower();-
162 if (s.contains(translatedBold)) {
s.contains(translatedBold)Description
TRUEnever evaluated
FALSEnever evaluated
0
163 //: The word for "Demi" as in "Demi Bold" used as a pattern for string searches-
164 QString translatedDemi = QCoreApplication::translate("QFontDatabase", "Demi").toLower();-
165 if (s .contains(translatedDemi))
s .contains(translatedDemi)Description
TRUEnever evaluated
FALSEnever evaluated
0
166 return QFont::DemiBold;
never executed: return QFont::DemiBold;
0
167 if (s.contains(translatedExtra))
s.contains(translatedExtra)Description
TRUEnever evaluated
FALSEnever evaluated
0
168 return QFont::ExtraBold;
never executed: return QFont::ExtraBold;
0
169 return QFont::Bold;
never executed: return QFont::Bold;
0
170 }-
171-
172 if (s.contains(translatedLight)) {
s.contains(translatedLight)Description
TRUEnever evaluated
FALSEnever evaluated
0
173 if (s.contains(translatedExtra))
s.contains(translatedExtra)Description
TRUEnever evaluated
FALSEnever evaluated
0
174 return QFont::ExtraLight;
never executed: return QFont::ExtraLight;
0
175 return QFont::Light;
never executed: return QFont::Light;
0
176 }-
177 return QFont::Normal;
never executed: return QFont::Normal;
0
178}-
179-
180-
181struct QtFontSize-
182{-
183-
184 void *handle;-
185-
186 unsigned short pixelSize : 16;-
187};-
188-
189-
190-
191struct QtFontStyle-
192{-
193 struct Key {-
194 Key(const QString &styleString);-
195 Key() : style(QFont::StyleNormal),-
196 weight(QFont::Normal), stretch(0) { }
never executed: end of block
0
197 Key(const Key &o) : style(o.style), weight(o.weight), stretch(o.stretch) { }
never executed: end of block
0
198 uint style : 2;-
199 signed int weight : 8;-
200 signed int stretch : 12;-
201-
202 bool operator==(const Key & other) {-
203 return (style == other.style && weight == other.weight &&
never executed: return (style == other.style && weight == other.weight && (stretch == 0 || other.stretch == 0 || stretch == other.stretch));
style == other.styleDescription
TRUEnever evaluated
FALSEnever evaluated
weight == other.weightDescription
TRUEnever evaluated
FALSEnever evaluated
0
204 (stretch == 0 || other.stretch == 0 || stretch == other.stretch));
never executed: return (style == other.style && weight == other.weight && (stretch == 0 || other.stretch == 0 || stretch == other.stretch));
stretch == 0Description
TRUEnever evaluated
FALSEnever evaluated
other.stretch == 0Description
TRUEnever evaluated
FALSEnever evaluated
stretch == other.stretchDescription
TRUEnever evaluated
FALSEnever evaluated
0
205 }-
206 bool operator!=(const Key &other) {-
207 return !operator==(other);
never executed: return !operator==(other);
0
208 }-
209 bool operator <(const Key &o) {-
210 int x = (style << 12) + (weight << 14) + stretch;-
211 int y = (o.style << 12) + (o.weight << 14) + o.stretch;-
212 return (x < y);
never executed: return (x < y);
0
213 }-
214 };-
215-
216 QtFontStyle(const Key &k)-
217 : key(k), bitmapScalable(false), smoothScalable(false),-
218 count(0), pixelSizes(0)-
219 {-
220 }
never executed: end of block
0
221-
222 ~QtFontStyle() {-
223 while (count) {
countDescription
TRUEnever evaluated
FALSEnever evaluated
0
224 // bitfield count-- in while condition does not work correctly in mwccsym2-
225 count--;-
226 QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration();-
227 if (integration) {
integrationDescription
TRUEnever evaluated
FALSEnever evaluated
0
228 integration->fontDatabase()->releaseHandle(pixelSizes[count].handle);-
229 }
never executed: end of block
0
230 }
never executed: end of block
0
231 free(pixelSizes);-
232 }
never executed: end of block
0
233-
234 Key key;-
235 bool bitmapScalable : 1;-
236 bool smoothScalable : 1;-
237 signed int count : 30;-
238 QtFontSize *pixelSizes;-
239 QString styleName;-
240-
241 bool antialiased;-
242-
243 QtFontSize *pixelSize(unsigned short size, bool = false);-
244};-
245-
246QtFontStyle::Key::Key(const QString &styleString)-
247 : style(QFont::StyleNormal), weight(QFont::Normal), stretch(0)-
248{-
249 weight = getFontWeight(styleString);-
250-
251 if (!styleString.isEmpty()) {
!styleString.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
252 // First the straightforward no-translation checks, these are fast.-
253 if (styleString.contains(QLatin1String("Italic")))
styleString.co...ing("Italic"))Description
TRUEnever evaluated
FALSEnever evaluated
0
254 style = QFont::StyleItalic;
never executed: style = QFont::StyleItalic;
0
255 else if (styleString.contains(QLatin1String("Oblique")))
styleString.co...ng("Oblique"))Description
TRUEnever evaluated
FALSEnever evaluated
0
256 style = QFont::StyleOblique;
never executed: style = QFont::StyleOblique;
0
257-
258 // Then the translation checks. These aren't as fast.-
259 else if (styleString.contains(QCoreApplication::translate("QFontDatabase", "Italic")))
styleString.co...e", "Italic"))Description
TRUEnever evaluated
FALSEnever evaluated
0
260 style = QFont::StyleItalic;
never executed: style = QFont::StyleItalic;
0
261 else if (styleString.contains(QCoreApplication::translate("QFontDatabase", "Oblique")))
styleString.co...", "Oblique"))Description
TRUEnever evaluated
FALSEnever evaluated
0
262 style = QFont::StyleOblique;
never executed: style = QFont::StyleOblique;
0
263 }
never executed: end of block
0
264}
never executed: end of block
0
265-
266QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add)-
267{-
268 for (int i = 0; i < count; i++) {
i < countDescription
TRUEnever evaluated
FALSEnever evaluated
0
269 if (pixelSizes[i].pixelSize == size)
pixelSizes[i]....elSize == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
270 return pixelSizes + i;
never executed: return pixelSizes + i;
0
271 }
never executed: end of block
0
272 if (!add)
!addDescription
TRUEnever evaluated
FALSEnever evaluated
0
273 return 0;
never executed: return 0;
0
274-
275 if (!pixelSizes) {
!pixelSizesDescription
TRUEnever evaluated
FALSEnever evaluated
0
276 // Most style have only one font size, we avoid waisting memory-
277 QtFontSize *newPixelSizes = (QtFontSize *)malloc(sizeof(QtFontSize));-
278 Q_CHECK_PTR(newPixelSizes);
never executed: qt_check_pointer(__FILE__,278);
!(newPixelSizes)Description
TRUEnever evaluated
FALSEnever evaluated
0
279 pixelSizes = newPixelSizes;-
280 } else if (!(count % 8) || count == 1) {
never executed: end of block
!(count % 8)Description
TRUEnever evaluated
FALSEnever evaluated
count == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
281 QtFontSize *newPixelSizes = (QtFontSize *)-
282 realloc(pixelSizes,-
283 (((count+8) >> 3) << 3) * sizeof(QtFontSize));-
284 Q_CHECK_PTR(newPixelSizes);
never executed: qt_check_pointer(__FILE__,284);
!(newPixelSizes)Description
TRUEnever evaluated
FALSEnever evaluated
0
285 pixelSizes = newPixelSizes;-
286 }
never executed: end of block
0
287 pixelSizes[count].pixelSize = size;-
288 pixelSizes[count].handle = 0;-
289 return pixelSizes + (count++);
never executed: return pixelSizes + (count++);
0
290}-
291-
292struct QtFontFoundry-
293{-
294 QtFontFoundry(const QString &n) : name(n), count(0), styles(0) {}
never executed: end of block
0
295 ~QtFontFoundry() {-
296 while (count--)
count--Description
TRUEnever evaluated
FALSEnever evaluated
0
297 delete styles[count];
never executed: delete styles[count];
0
298 free(styles);-
299 }
never executed: end of block
0
300-
301 QString name;-
302-
303 int count;-
304 QtFontStyle **styles;-
305 QtFontStyle *style(const QtFontStyle::Key &, const QString & = QString(), bool = false);-
306};-
307-
308QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, const QString &styleName, bool create)-
309{-
310 int pos = 0;-
311 for (; pos < count; pos++) {
pos < countDescription
TRUEnever evaluated
FALSEnever evaluated
0
312 bool hasStyleName = !styleName.isEmpty(); // search styleName first if available-
313 if (hasStyleName && !styles[pos]->styleName.isEmpty()) {
hasStyleNameDescription
TRUEnever evaluated
FALSEnever evaluated
!styles[pos]->...Name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
314 if (styles[pos]->styleName == styleName)
styles[pos]->s...e == styleNameDescription
TRUEnever evaluated
FALSEnever evaluated
0
315 return styles[pos];
never executed: return styles[pos];
0
316 } else {
never executed: end of block
0
317 if (styles[pos]->key == key)
styles[pos]->key == keyDescription
TRUEnever evaluated
FALSEnever evaluated
0
318 return styles[pos];
never executed: return styles[pos];
0
319 }
never executed: end of block
0
320 }-
321 if (!create)
!createDescription
TRUEnever evaluated
FALSEnever evaluated
0
322 return 0;
never executed: return 0;
0
323-
324// qDebug("adding key (weight=%d, style=%d, oblique=%d stretch=%d) at %d", key.weight, key.style, key.oblique, key.stretch, pos);-
325 if (!(count % 8)) {
!(count % 8)Description
TRUEnever evaluated
FALSEnever evaluated
0
326 QtFontStyle **newStyles = (QtFontStyle **)-
327 realloc(styles, (((count+8) >> 3) << 3) * sizeof(QtFontStyle *));-
328 Q_CHECK_PTR(newStyles);
never executed: qt_check_pointer(__FILE__,328);
!(newStyles)Description
TRUEnever evaluated
FALSEnever evaluated
0
329 styles = newStyles;-
330 }
never executed: end of block
0
331-
332 QtFontStyle *style = new QtFontStyle(key);-
333 style->styleName = styleName;-
334 styles[pos] = style;-
335 count++;-
336 return styles[pos];
never executed: return styles[pos];
0
337}-
338-
339-
340struct QtFontFamily-
341{-
342 enum WritingSystemStatus {-
343 Unknown = 0,-
344 Supported = 1,-
345 UnsupportedFT = 2,-
346 Unsupported = UnsupportedFT-
347 };-
348-
349 QtFontFamily(const QString &n)-
350 :-
351 populated(false),-
352 fixedPitch(false),-
353 name(n), count(0), foundries(0)-
354 {-
355 memset(writingSystems, 0, sizeof(writingSystems));-
356 }
never executed: end of block
0
357 ~QtFontFamily() {-
358 while (count--)
count--Description
TRUEnever evaluated
FALSEnever evaluated
0
359 delete foundries[count];
never executed: delete foundries[count];
0
360 free(foundries);-
361 }
never executed: end of block
0
362-
363 bool populated : 1;-
364 bool fixedPitch : 1;-
365-
366 QString name;-
367 QStringList aliases;-
368 int count;-
369 QtFontFoundry **foundries;-
370-
371 unsigned char writingSystems[QFontDatabase::WritingSystemsCount];-
372-
373 bool matchesFamilyName(const QString &familyName) const;-
374 QtFontFoundry *foundry(const QString &f, bool = false);-
375-
376 void ensurePopulated();-
377};-
378-
379QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create)-
380{-
381 if (f.isNull() && count == 1)
f.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
count == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
382 return foundries[0];
never executed: return foundries[0];
0
383-
384 for (int i = 0; i < count; i++) {
i < countDescription
TRUEnever evaluated
FALSEnever evaluated
0
385 if (foundries[i]->name.compare(f, Qt::CaseInsensitive) == 0)
foundries[i]->...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
386 return foundries[i];
never executed: return foundries[i];
0
387 }
never executed: end of block
0
388 if (!create)
!createDescription
TRUEnever evaluated
FALSEnever evaluated
0
389 return 0;
never executed: return 0;
0
390-
391 if (!(count % 8)) {
!(count % 8)Description
TRUEnever evaluated
FALSEnever evaluated
0
392 QtFontFoundry **newFoundries = (QtFontFoundry **)-
393 realloc(foundries,-
394 (((count+8) >> 3) << 3) * sizeof(QtFontFoundry *));-
395 Q_CHECK_PTR(newFoundries);
never executed: qt_check_pointer(__FILE__,395);
!(newFoundries)Description
TRUEnever evaluated
FALSEnever evaluated
0
396 foundries = newFoundries;-
397 }
never executed: end of block
0
398-
399 foundries[count] = new QtFontFoundry(f);-
400 return foundries[count++];
never executed: return foundries[count++];
0
401}-
402-
403bool QtFontFamily::matchesFamilyName(const QString &familyName) const-
404{-
405 return name.compare(familyName, Qt::CaseInsensitive) == 0 || aliases.contains(familyName, Qt::CaseInsensitive);
never executed: return name.compare(familyName, Qt::CaseInsensitive) == 0 || aliases.contains(familyName, Qt::CaseInsensitive);
name.compare(f...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
aliases.contai...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
0
406}-
407-
408void QtFontFamily::ensurePopulated()-
409{-
410 if (populated)
populatedDescription
TRUEnever evaluated
FALSEnever evaluated
0
411 return;
never executed: return;
0
412-
413 QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFamily(name);-
414 Q_ASSERT_X(populated, Q_FUNC_INFO, qPrintable(name));-
415}
never executed: end of block
0
416-
417-
418struct FallbacksCacheKey {-
419 QString family;-
420 QFont::Style style;-
421 QFont::StyleHint styleHint;-
422 QChar::Script script;-
423};-
424-
425inline bool operator==(const FallbacksCacheKey &lhs, const FallbacksCacheKey &rhs) Q_DECL_NOTHROW-
426{-
427 return lhs.script == rhs.script &&
never executed: return lhs.script == rhs.script && lhs.styleHint == rhs.styleHint && lhs.style == rhs.style && lhs.family == rhs.family;
lhs.script == rhs.scriptDescription
TRUEnever evaluated
FALSEnever evaluated
0
428 lhs.styleHint == rhs.styleHint &&
never executed: return lhs.script == rhs.script && lhs.styleHint == rhs.styleHint && lhs.style == rhs.style && lhs.family == rhs.family;
lhs.styleHint == rhs.styleHintDescription
TRUEnever evaluated
FALSEnever evaluated
0
429 lhs.style == rhs.style &&
never executed: return lhs.script == rhs.script && lhs.styleHint == rhs.styleHint && lhs.style == rhs.style && lhs.family == rhs.family;
lhs.style == rhs.styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
430 lhs.family == rhs.family;
never executed: return lhs.script == rhs.script && lhs.styleHint == rhs.styleHint && lhs.style == rhs.style && lhs.family == rhs.family;
lhs.family == rhs.familyDescription
TRUEnever evaluated
FALSEnever evaluated
0
431}-
432-
433inline bool operator!=(const FallbacksCacheKey &lhs, const FallbacksCacheKey &rhs) Q_DECL_NOTHROW-
434{-
435 return !operator==(lhs, rhs);
never executed: return !operator==(lhs, rhs);
0
436}-
437-
438inline uint qHash(const FallbacksCacheKey &key, uint seed = 0) Q_DECL_NOTHROW-
439{-
440 QtPrivate::QHashCombine hash;-
441 seed = hash(seed, key.family);-
442 seed = hash(seed, int(key.style));-
443 seed = hash(seed, int(key.styleHint));-
444 seed = hash(seed, int(key.script));-
445 return seed;
never executed: return seed;
0
446}-
447-
448-
449class QFontDatabasePrivate-
450{-
451public:-
452 QFontDatabasePrivate()-
453 : count(0), families(0),-
454 fallbacksCache(64),-
455 reregisterAppFonts(false)-
456 { }
never executed: end of block
0
457-
458 ~QFontDatabasePrivate() {-
459 free();-
460 }
never executed: end of block
0
461-
462 enum FamilyRequestFlags {-
463 RequestFamily = 0,-
464 EnsureCreated,-
465 EnsurePopulated-
466 };-
467-
468 QtFontFamily *family(const QString &f, FamilyRequestFlags flags = EnsurePopulated);-
469 void free() {-
470 while (count--)
count--Description
TRUEnever evaluated
FALSEnever evaluated
0
471 delete families[count];
never executed: delete families[count];
0
472 ::free(families);-
473 families = 0;-
474 count = 0;-
475 // don't clear the memory fonts!-
476 }
never executed: end of block
0
477-
478 int count;-
479 QtFontFamily **families;-
480-
481 QCache<FallbacksCacheKey, QStringList> fallbacksCache;-
482-
483-
484 struct ApplicationFont {-
485 QString fileName;-
486 QByteArray data;-
487 QStringList families;-
488 };-
489 QVector<ApplicationFont> applicationFonts;-
490 int addAppFont(const QByteArray &fontData, const QString &fileName);-
491 bool reregisterAppFonts;-
492 bool isApplicationFont(const QString &fileName);-
493-
494 void invalidate();-
495};-
496-
497void QFontDatabasePrivate::invalidate()-
498{-
499 QFontCache::instance()->clear();-
500-
501 fallbacksCache.clear();-
502 free();-
503 QGuiApplicationPrivate::platformIntegration()->fontDatabase()->invalidate();-
504 emit static_cast<QGuiApplication *>(QCoreApplication::instance())->fontDatabaseChanged();-
505}
never executed: end of block
0
506-
507QtFontFamily *QFontDatabasePrivate::family(const QString &f, FamilyRequestFlags flags)-
508{-
509 QtFontFamily *fam = 0;-
510-
511 int low = 0;-
512 int high = count;-
513 int pos = count / 2;-
514 int res = 1;-
515 if (count) {
countDescription
TRUEnever evaluated
FALSEnever evaluated
0
516 while ((res = families[pos]->name.compare(f, Qt::CaseInsensitive)) && pos != low) {
(res = familie...eInsensitive))Description
TRUEnever evaluated
FALSEnever evaluated
pos != lowDescription
TRUEnever evaluated
FALSEnever evaluated
0
517 if (res > 0)
res > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
518 high = pos;
never executed: high = pos;
0
519 else-
520 low = pos;
never executed: low = pos;
0
521 pos = (high + low) / 2;-
522 }
never executed: end of block
0
523 if (!res)
!resDescription
TRUEnever evaluated
FALSEnever evaluated
0
524 fam = families[pos];
never executed: fam = families[pos];
0
525 }
never executed: end of block
0
526-
527 if (!fam && (flags & EnsureCreated)) {
!famDescription
TRUEnever evaluated
FALSEnever evaluated
(flags & EnsureCreated)Description
TRUEnever evaluated
FALSEnever evaluated
0
528 if (res < 0)
res < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
529 pos++;
never executed: pos++;
0
530-
531 // qDebug() << "adding family " << f.toLatin1() << " at " << pos << " total=" << count;-
532 if (!(count % 8)) {
!(count % 8)Description
TRUEnever evaluated
FALSEnever evaluated
0
533 QtFontFamily **newFamilies = (QtFontFamily **)-
534 realloc(families,-
535 (((count+8) >> 3) << 3) * sizeof(QtFontFamily *));-
536 Q_CHECK_PTR(newFamilies);
never executed: qt_check_pointer(__FILE__,536);
!(newFamilies)Description
TRUEnever evaluated
FALSEnever evaluated
0
537 families = newFamilies;-
538 }
never executed: end of block
0
539-
540 QtFontFamily *family = new QtFontFamily(f);-
541 memmove(families + pos + 1, families + pos, (count-pos)*sizeof(QtFontFamily *));-
542 families[pos] = family;-
543 count++;-
544-
545 fam = families[pos];-
546 }
never executed: end of block
0
547-
548 if (fam && (flags & EnsurePopulated))
famDescription
TRUEnever evaluated
FALSEnever evaluated
(flags & EnsurePopulated)Description
TRUEnever evaluated
FALSEnever evaluated
0
549 fam->ensurePopulated();
never executed: fam->ensurePopulated();
0
550-
551 return fam;
never executed: return fam;
0
552}-
553-
554-
555-
556static const int scriptForWritingSystem[] = {-
557 QChar::Script_Common, // Any-
558 QChar::Script_Latin, // Latin-
559 QChar::Script_Greek, // Greek-
560 QChar::Script_Cyrillic, // Cyrillic-
561 QChar::Script_Armenian, // Armenian-
562 QChar::Script_Hebrew, // Hebrew-
563 QChar::Script_Arabic, // Arabic-
564 QChar::Script_Syriac, // Syriac-
565 QChar::Script_Thaana, // Thaana-
566 QChar::Script_Devanagari, // Devanagari-
567 QChar::Script_Bengali, // Bengali-
568 QChar::Script_Gurmukhi, // Gurmukhi-
569 QChar::Script_Gujarati, // Gujarati-
570 QChar::Script_Oriya, // Oriya-
571 QChar::Script_Tamil, // Tamil-
572 QChar::Script_Telugu, // Telugu-
573 QChar::Script_Kannada, // Kannada-
574 QChar::Script_Malayalam, // Malayalam-
575 QChar::Script_Sinhala, // Sinhala-
576 QChar::Script_Thai, // Thai-
577 QChar::Script_Lao, // Lao-
578 QChar::Script_Tibetan, // Tibetan-
579 QChar::Script_Myanmar, // Myanmar-
580 QChar::Script_Georgian, // Georgian-
581 QChar::Script_Khmer, // Khmer-
582 QChar::Script_Han, // SimplifiedChinese-
583 QChar::Script_Han, // TraditionalChinese-
584 QChar::Script_Han, // Japanese-
585 QChar::Script_Hangul, // Korean-
586 QChar::Script_Latin, // Vietnamese-
587 QChar::Script_Common, // Symbol-
588 QChar::Script_Ogham, // Ogham-
589 QChar::Script_Runic, // Runic-
590 QChar::Script_Nko // Nko-
591};-
592-
593Q_STATIC_ASSERT(sizeof(scriptForWritingSystem) / sizeof(scriptForWritingSystem[0]) == QFontDatabase::WritingSystemsCount);-
594-
595Q_GUI_EXPORT int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)-
596{-
597 return scriptForWritingSystem[writingSystem];
never executed: return scriptForWritingSystem[writingSystem];
0
598}-
599-
600-
601-
602-
603/*!-
604 \internal-
605-
606 This makes sense of the font family name:-
607-
608 if the family name contains a '[' and a ']', then we take the text-
609 between the square brackets as the foundry, and the text before the-
610 square brackets as the family (ie. "Arial [Monotype]")-
611*/-
612static void parseFontName(const QString &name, QString &foundry, QString &family)-
613{-
614 int i = name.indexOf(QLatin1Char('['));-
615 int li = name.lastIndexOf(QLatin1Char(']'));-
616 if (i >= 0 && li >= 0 && i < li) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
li >= 0Description
TRUEnever evaluated
FALSEnever evaluated
i < liDescription
TRUEnever evaluated
FALSEnever evaluated
0
617 foundry = name.mid(i + 1, li - i - 1);-
618 if (i > 0 && name[i - 1] == QLatin1Char(' '))
i > 0Description
TRUEnever evaluated
FALSEnever evaluated
name[i - 1] ==...atin1Char(' ')Description
TRUEnever evaluated
FALSEnever evaluated
0
619 i--;
never executed: i--;
0
620 family = name.left(i);-
621 } else {
never executed: end of block
0
622 foundry.clear();-
623 family = name;-
624 }
never executed: end of block
0
625-
626 // capitalize the family/foundry names-
627 bool space = true;-
628 QChar *s = family.data();-
629 int len = family.length();-
630 while(len--) {
len--Description
TRUEnever evaluated
FALSEnever evaluated
0
631 if (space) *s = s->toUpper();
never executed: *s = s->toUpper();
spaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
632 space = s->isSpace();-
633 ++s;-
634 }
never executed: end of block
0
635-
636 space = true;-
637 s = foundry.data();-
638 len = foundry.length();-
639 while(len--) {
len--Description
TRUEnever evaluated
FALSEnever evaluated
0
640 if (space) *s = s->toUpper();
never executed: *s = s->toUpper();
spaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
641 space = s->isSpace();-
642 ++s;-
643 }
never executed: end of block
0
644}
never executed: end of block
0
645-
646-
647struct QtFontDesc-
648{-
649 inline QtFontDesc() : family(0), foundry(0), style(0), size(0) {}
never executed: end of block
0
650 QtFontFamily *family;-
651 QtFontFoundry *foundry;-
652 QtFontStyle *style;-
653 QtFontSize *size;-
654};-
655-
656static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi)-
657{-
658 fontDef->family = desc.family->name;-
659 if (! desc.foundry->name.isEmpty() && desc.family->count > 1) {
! desc.foundry->name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
desc.family->count > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
660 fontDef->family += QString::fromLatin1(" [");-
661 fontDef->family += desc.foundry->name;-
662 fontDef->family += QLatin1Char(']');-
663 }
never executed: end of block
0
664-
665 if (desc.style->smoothScalable
desc.style->smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
0
666 || QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable()
QGuiApplicatio...waysScalable()Description
TRUEnever evaluated
FALSEnever evaluated
0
667 || (desc.style->bitmapScalable && (request.styleStrategy & QFont::PreferMatch))) {
desc.style->bitmapScalableDescription
TRUEnever evaluated
FALSEnever evaluated
(request.style...::PreferMatch)Description
TRUEnever evaluated
FALSEnever evaluated
0
668 fontDef->pixelSize = request.pixelSize;-
669 } else {
never executed: end of block
0
670 fontDef->pixelSize = desc.size->pixelSize;-
671 }
never executed: end of block
0
672 fontDef->pointSize = request.pointSize;-
673-
674 fontDef->styleHint = request.styleHint;-
675 fontDef->styleStrategy = request.styleStrategy;-
676-
677 if (!multi)
!multiDescription
TRUEnever evaluated
FALSEnever evaluated
0
678 fontDef->weight = desc.style->key.weight;
never executed: fontDef->weight = desc.style->key.weight;
0
679 if (!multi)
!multiDescription
TRUEnever evaluated
FALSEnever evaluated
0
680 fontDef->style = desc.style->key.style;
never executed: fontDef->style = desc.style->key.style;
0
681 fontDef->fixedPitch = desc.family->fixedPitch;-
682 fontDef->stretch = desc.style->key.stretch;-
683 fontDef->ignorePitch = false;-
684}
never executed: end of block
0
685-
686static QStringList familyList(const QFontDef &req)-
687{-
688 // list of families to try-
689 QStringList family_list;-
690 if (req.family.isEmpty())
req.family.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
691 return family_list;
never executed: return family_list;
0
692-
693 QStringList list = req.family.split(QLatin1Char(','));-
694 const int numFamilies = list.size();-
695 family_list.reserve(numFamilies);-
696 for (int i = 0; i < numFamilies; ++i) {
i < numFamiliesDescription
TRUEnever evaluated
FALSEnever evaluated
0
697 QString str = list.at(i).trimmed();-
698 if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
str.startsWith...tin1Char('"'))Description
TRUEnever evaluated
FALSEnever evaluated
str.endsWith(QLatin1Char('"'))Description
TRUEnever evaluated
FALSEnever evaluated
0
699 || (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\''))))
str.startsWith...in1Char('\''))Description
TRUEnever evaluated
FALSEnever evaluated
str.endsWith(Q...in1Char('\''))Description
TRUEnever evaluated
FALSEnever evaluated
0
700 str = str.mid(1, str.length() - 2);
never executed: str = str.mid(1, str.length() - 2);
0
701 family_list << str;-
702 }
never executed: end of block
0
703-
704 // append the substitute list for each family in family_list-
705 QStringList subs_list;-
706 QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();-
707 for (; it != end; ++it)
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
708 subs_list += QFont::substitutes(*it);
never executed: subs_list += QFont::substitutes(*it);
0
709// qDebug() << "adding substs: " << subs_list;-
710-
711 family_list += subs_list;-
712-
713 return family_list;
never executed: return family_list;
0
714}-
715-
716Q_GLOBAL_STATIC(QFontDatabasePrivate, privateDb)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
717Q_GLOBAL_STATIC_WITH_ARGS(QMutex, fontDatabaseMutex, (QMutex::Recursive))
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
718-
719// used in qguiapplication.cpp-
720void qt_cleanupFontDatabase()-
721{-
722 QFontDatabasePrivate *db = privateDb();-
723 if (db) {
dbDescription
TRUEnever evaluated
FALSEnever evaluated
0
724 db->fallbacksCache.clear();-
725 db->free();-
726 }
never executed: end of block
0
727}
never executed: end of block
0
728-
729// used in qfontengine_x11.cpp-
730QMutex *qt_fontdatabase_mutex()-
731{-
732 return fontDatabaseMutex();
never executed: return fontDatabaseMutex();
0
733}-
734-
735-
736void qt_registerFont(const QString &familyName, const QString &stylename,-
737 const QString &foundryname, int weight,-
738 QFont::Style style, int stretch, bool antialiased,-
739 bool scalable, int pixelSize, bool fixedPitch,-
740 const QSupportedWritingSystems &writingSystems, void *handle)-
741{-
742 QFontDatabasePrivate *d = privateDb();-
743// qDebug() << "Adding font" << familyName << weight << style << pixelSize << antialiased;-
744 QtFontStyle::Key styleKey;-
745 styleKey.style = style;-
746 styleKey.weight = weight;-
747 styleKey.stretch = stretch;-
748 QtFontFamily *f = d->family(familyName, QFontDatabasePrivate::EnsureCreated);-
749 f->fixedPitch = fixedPitch;-
750-
751 for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
i < QFontDatab...ngSystemsCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
752 if (writingSystems.supported(QFontDatabase::WritingSystem(i)))
writingSystems...tingSystem(i))Description
TRUEnever evaluated
FALSEnever evaluated
0
753 f->writingSystems[i] = QtFontFamily::Supported;
never executed: f->writingSystems[i] = QtFontFamily::Supported;
0
754 }
never executed: end of block
0
755-
756 QtFontFoundry *foundry = f->foundry(foundryname, true);-
757 QtFontStyle *fontStyle = foundry->style(styleKey, stylename, true);-
758 fontStyle->smoothScalable = scalable;-
759 fontStyle->antialiased = antialiased;-
760 QtFontSize *size = fontStyle->pixelSize(pixelSize ? pixelSize : SMOOTH_SCALABLE, true);-
761 if (size->handle) {
size->handleDescription
TRUEnever evaluated
FALSEnever evaluated
0
762 QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration();-
763 if (integration)
integrationDescription
TRUEnever evaluated
FALSEnever evaluated
0
764 integration->fontDatabase()->releaseHandle(size->handle);
never executed: integration->fontDatabase()->releaseHandle(size->handle);
0
765 }
never executed: end of block
0
766 size->handle = handle;-
767 f->populated = true;-
768}
never executed: end of block
0
769-
770void qt_registerFontFamily(const QString &familyName)-
771{-
772 // Create uninitialized/unpopulated family-
773 privateDb()->family(familyName, QFontDatabasePrivate::EnsureCreated);-
774}
never executed: end of block
0
775-
776void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias)-
777{-
778 if (alias.isEmpty())
alias.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
779 return;
never executed: return;
0
780-
781 QFontDatabasePrivate *d = privateDb();-
782 QtFontFamily *f = d->family(familyName, QFontDatabasePrivate::RequestFamily);-
783 if (!f)
!fDescription
TRUEnever evaluated
FALSEnever evaluated
0
784 return;
never executed: return;
0
785-
786 if (f->aliases.contains(alias, Qt::CaseInsensitive))
f->aliases.con...seInsensitive)Description
TRUEnever evaluated
FALSEnever evaluated
0
787 return;
never executed: return;
0
788-
789 f->aliases.push_back(alias);-
790}
never executed: end of block
0
791-
792QString qt_resolveFontFamilyAlias(const QString &alias)-
793{-
794 if (!alias.isEmpty()) {
!alias.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
795 const QFontDatabasePrivate *d = privateDb();-
796 for (int i = 0; i < d->count; ++i)
i < d->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
797 if (d->families[i]->matchesFamilyName(alias))
d->families[i]...ilyName(alias)Description
TRUEnever evaluated
FALSEnever evaluated
0
798 return d->families[i]->name;
never executed: return d->families[i]->name;
0
799 }
never executed: end of block
0
800 return alias;
never executed: return alias;
0
801}-
802-
803QStringList QPlatformFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const-
804{-
805 Q_UNUSED(family);-
806 Q_UNUSED(styleHint);-
807-
808 QStringList preferredFallbacks;-
809 QStringList otherFallbacks;-
810-
811 size_t writingSystem = std::find(scriptForWritingSystem,-
812 scriptForWritingSystem + QFontDatabase::WritingSystemsCount,-
813 script) - scriptForWritingSystem;-
814 if (writingSystem >= QFontDatabase::WritingSystemsCount)
writingSystem ...ngSystemsCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
815 writingSystem = QFontDatabase::Any;
never executed: writingSystem = QFontDatabase::Any;
0
816-
817 QFontDatabasePrivate *db = privateDb();-
818 for (int i = 0; i < db->count; ++i) {
i < db->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
819 QtFontFamily *f = db->families[i];-
820-
821 f->ensurePopulated();-
822-
823 if (writingSystem > QFontDatabase::Any && f->writingSystems[writingSystem] != QtFontFamily::Supported)
writingSystem ...tDatabase::AnyDescription
TRUEnever evaluated
FALSEnever evaluated
f->writingSyst...ily::SupportedDescription
TRUEnever evaluated
FALSEnever evaluated
0
824 continue;
never executed: continue;
0
825-
826 for (int j = 0; j < f->count; ++j) {
j < f->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
827 QtFontFoundry *foundry = f->foundries[j];-
828-
829 for (int k = 0; k < foundry->count; ++k) {
k < foundry->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
830 QString name = foundry->name.isEmpty()
foundry->name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
831 ? f->name-
832 : f->name + QLatin1String(" [") + foundry->name + QLatin1Char(']');-
833 if (style == foundry->styles[k]->key.style)
style == found...[k]->key.styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
834 preferredFallbacks.append(name);
never executed: preferredFallbacks.append(name);
0
835 else-
836 otherFallbacks.append(name);
never executed: otherFallbacks.append(name);
0
837 }-
838 }
never executed: end of block
0
839 }
never executed: end of block
0
840-
841 return preferredFallbacks + otherFallbacks;
never executed: return preferredFallbacks + otherFallbacks;
0
842}-
843-
844static void initializeDb();-
845-
846static QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script)-
847{-
848 QFontDatabasePrivate *db = privateDb();-
849 if (!db->count)
!db->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
850 initializeDb();
never executed: initializeDb();
0
851-
852 const FallbacksCacheKey cacheKey = { family, style, styleHint, script };-
853-
854 if (const QStringList *fallbacks = db->fallbacksCache.object(cacheKey))
const QStringL...ject(cacheKey)Description
TRUEnever evaluated
FALSEnever evaluated
0
855 return *fallbacks;
never executed: return *fallbacks;
0
856-
857 // make sure that the db has all fallback families-
858 QStringList retList = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,styleHint,script);-
859-
860 QStringList::iterator i;-
861 for (i = retList.begin(); i != retList.end(); ++i) {
i != retList.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
862 bool contains = false;-
863 for (int j = 0; j < db->count; j++) {
j < db->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
864 if (db->families[j]->matchesFamilyName(*i)) {
db->families[j...FamilyName(*i)Description
TRUEnever evaluated
FALSEnever evaluated
0
865 contains = true;-
866 break;
never executed: break;
0
867 }-
868 }
never executed: end of block
0
869 if (!contains) {
!containsDescription
TRUEnever evaluated
FALSEnever evaluated
0
870 i = retList.erase(i);-
871 --i;-
872 }
never executed: end of block
0
873 }
never executed: end of block
0
874-
875 db->fallbacksCache.insert(cacheKey, new QStringList(retList));-
876-
877 return retList;
never executed: return retList;
0
878}-
879-
880QStringList qt_fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script)-
881{-
882 QMutexLocker locker(fontDatabaseMutex());-
883 return fallbacksForFamily(family, style, styleHint, script);
never executed: return fallbacksForFamily(family, style, styleHint, script);
0
884}-
885-
886static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt);-
887-
888static void initializeDb()-
889{-
890 QFontDatabasePrivate *db = privateDb();-
891-
892 // init by asking for the platformfontdb for the first time or after invalidation-
893 if (!db->count)
!db->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
894 QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
never executed: QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
0
895-
896 if (db->reregisterAppFonts) {
db->reregisterAppFontsDescription
TRUEnever evaluated
FALSEnever evaluated
0
897 for (int i = 0; i < db->applicationFonts.count(); i++) {
i < db->applic...nFonts.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
898 if (!db->applicationFonts.at(i).families.isEmpty())
!db->applicati...lies.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
899 registerFont(&db->applicationFonts[i]);
never executed: registerFont(&db->applicationFonts[i]);
0
900 }
never executed: end of block
0
901 db->reregisterAppFonts = false;-
902 }
never executed: end of block
0
903}
never executed: end of block
0
904-
905static inline void load(const QString & = QString(), int = -1)-
906{-
907 // Only initialize the database if it has been cleared or not initialized yet-
908 if (!privateDb()->count)
!privateDb()->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
909 initializeDb();
never executed: initializeDb();
0
910}
never executed: end of block
0
911-
912static-
913QFontEngine *loadSingleEngine(int script,-
914 const QFontDef &request,-
915 QtFontFamily *family, QtFontFoundry *foundry,-
916 QtFontStyle *style, QtFontSize *size)-
917{-
918 Q_UNUSED(foundry);-
919-
920 Q_ASSERT(size);-
921 QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();-
922 int pixelSize = size->pixelSize;-
923 if (!pixelSize || (style->smoothScalable && pixelSize == SMOOTH_SCALABLE)
!pixelSizeDescription
TRUEnever evaluated
FALSEnever evaluated
style->smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
pixelSize == 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
0
924 || pfdb->fontsAlwaysScalable()) {
pfdb->fontsAlwaysScalable()Description
TRUEnever evaluated
FALSEnever evaluated
0
925 pixelSize = request.pixelSize;-
926 }
never executed: end of block
0
927-
928 QFontDef def = request;-
929 def.pixelSize = pixelSize;-
930-
931 QFontCache *fontCache = QFontCache::instance();-
932-
933 QFontCache::Key key(def,script);-
934 QFontEngine *engine = fontCache->findEngine(key);-
935 if (!engine) {
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
936 const bool cacheForCommonScript = script != QChar::Script_Common
script != QChar::Script_CommonDescription
TRUEnever evaluated
FALSEnever evaluated
0
937 && (family->writingSystems[QFontDatabase::Latin] & QtFontFamily::Supported) != 0;
(family->writi...upported) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
938-
939 if (Q_LIKELY(cacheForCommonScript)) {
__builtin_expe...Script), true)Description
TRUEnever evaluated
FALSEnever evaluated
0
940 // fast path: check if engine was loaded for another script-
941 key.script = QChar::Script_Common;-
942 engine = fontCache->findEngine(key);-
943 key.script = script;-
944 if (engine) {
engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
945 // Also check for OpenType tables when using complex scripts-
946 if (Q_UNLIKELY(!engine->supportsScript(QChar::Script(script)))) {
__builtin_expe...ipt))), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
947 qWarning(" OpenType support missing for script %d", script);-
948 return 0;
never executed: return 0;
0
949 }-
950-
951 engine->isSmoothlyScalable = style->smoothScalable;-
952 fontCache->insertEngine(key, engine);-
953 return engine;
never executed: return engine;
0
954 }-
955 }
never executed: end of block
0
956-
957 // If the font data's native stretch matches the requested stretch we need to set stretch to 100-
958 // to avoid the fontengine synthesizing stretch. If they didn't match exactly we need to calculate-
959 // the new stretch factor. This only done if not matched by styleName.-
960 if (style->key.stretch != 0 && request.stretch != 0
style->key.stretch != 0Description
TRUEnever evaluated
FALSEnever evaluated
request.stretch != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
961 && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
request.styleName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
request.styleN...yle->styleNameDescription
TRUEnever evaluated
FALSEnever evaluated
0
962 def.stretch = (request.stretch * 100 + 50) / style->key.stretch;-
963 }
never executed: end of block
0
964-
965 engine = pfdb->fontEngine(def, size->handle);-
966 if (engine) {
engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
967 // Also check for OpenType tables when using complex scripts-
968 if (!engine->supportsScript(QChar::Script(script))) {
!engine->suppo...cript(script))Description
TRUEnever evaluated
FALSEnever evaluated
0
969 qWarning(" OpenType support missing for script %d", script);-
970 if (engine->ref.load() == 0)
engine->ref.load() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
971 delete engine;
never executed: delete engine;
0
972 return 0;
never executed: return 0;
0
973 }-
974-
975 engine->isSmoothlyScalable = style->smoothScalable;-
976 fontCache->insertEngine(key, engine);-
977-
978 if (Q_LIKELY(cacheForCommonScript && !engine->symbol)) {
__builtin_expe...symbol), true)Description
TRUEnever evaluated
FALSEnever evaluated
0
979 // cache engine for Common script as well-
980 key.script = QChar::Script_Common;-
981 if (!fontCache->findEngine(key))
!fontCache->findEngine(key)Description
TRUEnever evaluated
FALSEnever evaluated
0
982 fontCache->insertEngine(key, engine);
never executed: fontCache->insertEngine(key, engine);
0
983 }
never executed: end of block
0
984 }
never executed: end of block
0
985 }
never executed: end of block
0
986 return engine;
never executed: return engine;
0
987}-
988-
989static-
990QFontEngine *loadEngine(int script, const QFontDef &request,-
991 QtFontFamily *family, QtFontFoundry *foundry,-
992 QtFontStyle *style, QtFontSize *size)-
993{-
994 QFontEngine *engine = loadSingleEngine(script, request, family, foundry, style, size);-
995-
996 if (engine && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
engineDescription
TRUEnever evaluated
FALSEnever evaluated
!(request.styl...NoFontMerging)Description
TRUEnever evaluated
FALSEnever evaluated
!engine->symbolDescription
TRUEnever evaluated
FALSEnever evaluated
0
997 QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();-
998 QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QChar::Script(script));-
999 if (!request.fallBackFamilies.isEmpty()) {
!request.fallB...lies.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1000 QStringList fallbacks = request.fallBackFamilies;-
1001-
1002 QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);-
1003 if (styleHint == QFont::AnyStyle && request.fixedPitch)
styleHint == QFont::AnyStyleDescription
TRUEnever evaluated
FALSEnever evaluated
request.fixedPitchDescription
TRUEnever evaluated
FALSEnever evaluated
0
1004 styleHint = QFont::TypeWriter;
never executed: styleHint = QFont::TypeWriter;
0
1005-
1006 fallbacks += fallbacksForFamily(family->name, QFont::Style(style->key.style), styleHint, QChar::Script(script));-
1007-
1008 pfMultiEngine->setFallbackFamiliesList(fallbacks);-
1009 }
never executed: end of block
0
1010 engine = pfMultiEngine;-
1011-
1012 // Cache Multi font engine as well in case we got the single-
1013 // font engine when we are actually looking for a Multi one-
1014 QFontCache::Key key(request, script, 1);-
1015 QFontCache::instance()->insertEngine(key, engine);-
1016 }
never executed: end of block
0
1017-
1018 return engine;
never executed: return engine;
0
1019}-
1020-
1021static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)-
1022{-
1023 QFontDatabasePrivate *db = privateDb();-
1024-
1025 fnt->families = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->addApplicationFont(fnt->data,fnt->fileName);-
1026-
1027 db->reregisterAppFonts = true;-
1028}
never executed: end of block
0
1029-
1030static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &styleKey,-
1031 const QString &styleName = QString())-
1032{-
1033 int best = 0;-
1034 int dist = 0xffff;-
1035-
1036 for ( int i = 0; i < foundry->count; i++ ) {
i < foundry->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1037 QtFontStyle *style = foundry->styles[i];-
1038-
1039 if (!styleName.isEmpty() && styleName == style->styleName) {
!styleName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
styleName == style->styleNameDescription
TRUEnever evaluated
FALSEnever evaluated
0
1040 dist = 0;-
1041 best = i;-
1042 break;
never executed: break;
0
1043 }-
1044-
1045 int d = qAbs( styleKey.weight - style->key.weight );-
1046-
1047 if ( styleKey.stretch != 0 && style->key.stretch != 0 ) {
styleKey.stretch != 0Description
TRUEnever evaluated
FALSEnever evaluated
style->key.stretch != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1048 d += qAbs( styleKey.stretch - style->key.stretch );-
1049 }
never executed: end of block
0
1050-
1051 if (styleKey.style != style->key.style) {
styleKey.style...yle->key.styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1052 if (styleKey.style != QFont::StyleNormal && style->key.style != QFont::StyleNormal)
styleKey.style...t::StyleNormalDescription
TRUEnever evaluated
FALSEnever evaluated
style->key.sty...t::StyleNormalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1053 // one is italic, the other oblique-
1054 d += 0x0001;
never executed: d += 0x0001;
0
1055 else-
1056 d += 0x1000;
never executed: d += 0x1000;
0
1057 }-
1058-
1059 if ( d < dist ) {
d < distDescription
TRUEnever evaluated
FALSEnever evaluated
0
1060 best = i;-
1061 dist = d;-
1062 }
never executed: end of block
0
1063 }
never executed: end of block
0
1064-
1065 FM_DEBUG( " best style has distance 0x%x", dist );
dead code: QMessageLogger(__FILE__, 1065, __PRETTY_FUNCTION__).debug( " best style has distance 0x%x", dist );
-
1066 return foundry->styles[best];
never executed: return foundry->styles[best];
0
1067}-
1068-
1069-
1070static-
1071unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,-
1072 const QtFontFamily *family, const QString &foundry_name,-
1073 QtFontStyle::Key styleKey, int pixelSize, char pitch,-
1074 QtFontDesc *desc, const QString &styleName = QString())-
1075{-
1076 Q_UNUSED(script);-
1077 Q_UNUSED(pitch);-
1078-
1079 desc->foundry = 0;-
1080 desc->style = 0;-
1081 desc->size = 0;-
1082-
1083-
1084 FM_DEBUG(" REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count);
dead code: QMessageLogger(__FILE__, 1084, __PRETTY_FUNCTION__).debug(" REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count);
-
1085-
1086 for (int x = 0; x < family->count; ++x) {
x < family->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1087 QtFontFoundry *foundry = family->foundries[x];-
1088 if (!foundry_name.isEmpty() && foundry->name.compare(foundry_name, Qt::CaseInsensitive) != 0)
!foundry_name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
foundry->name....ensitive) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1089 continue;
never executed: continue;
0
1090-
1091 FM_DEBUG(" looking for matching style in foundry '%s' %d",
dead code: QMessageLogger(__FILE__, 1091, __PRETTY_FUNCTION__).debug(" looking for matching style in foundry '%s' %d", foundry->name.isEmpty() ? "-- none --" : foundry->name.toLatin1().constData(), foundry->count);
-
1092 foundry->name.isEmpty() ? "-- none --" : foundry->name.toLatin1().constData(), foundry->count);
dead code: QMessageLogger(__FILE__, 1091, __PRETTY_FUNCTION__).debug(" looking for matching style in foundry '%s' %d", foundry->name.isEmpty() ? "-- none --" : foundry->name.toLatin1().constData(), foundry->count);
-
1093-
1094 QtFontStyle *style = bestStyle(foundry, styleKey, styleName);-
1095-
1096 if (!style->smoothScalable && (styleStrategy & QFont::ForceOutline)) {
!style->smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
(styleStrategy...:ForceOutline)Description
TRUEnever evaluated
FALSEnever evaluated
0
1097 FM_DEBUG(" ForceOutline set, but not smoothly scalable");
dead code: QMessageLogger(__FILE__, 1097, __PRETTY_FUNCTION__).debug(" ForceOutline set, but not smoothly scalable");
-
1098 continue;
never executed: continue;
0
1099 }-
1100-
1101 int px = -1;-
1102 QtFontSize *size = 0;-
1103-
1104 // 1. see if we have an exact matching size-
1105 if (!(styleStrategy & QFont::ForceOutline)) {
!(styleStrateg...:ForceOutline)Description
TRUEnever evaluated
FALSEnever evaluated
0
1106 size = style->pixelSize(pixelSize);-
1107 if (size) {
sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1108 FM_DEBUG(" found exact size match (%d pixels)", size->pixelSize);
dead code: QMessageLogger(__FILE__, 1108, __PRETTY_FUNCTION__).debug(" found exact size match (%d pixels)", size->pixelSize);
-
1109 px = size->pixelSize;-
1110 }
never executed: end of block
0
1111 }
never executed: end of block
0
1112-
1113 // 2. see if we have a smoothly scalable font-
1114 if (!size && style->smoothScalable && ! (styleStrategy & QFont::PreferBitmap)) {
!sizeDescription
TRUEnever evaluated
FALSEnever evaluated
style->smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
! (styleStrate...:PreferBitmap)Description
TRUEnever evaluated
FALSEnever evaluated
0
1115 size = style->pixelSize(SMOOTH_SCALABLE);-
1116 if (size) {
sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1117 FM_DEBUG(" found smoothly scalable font (%d pixels)", pixelSize);
dead code: QMessageLogger(__FILE__, 1117, __PRETTY_FUNCTION__).debug(" found smoothly scalable font (%d pixels)", pixelSize);
-
1118 px = pixelSize;-
1119 }
never executed: end of block
0
1120 }
never executed: end of block
0
1121-
1122 // 3. see if we have a bitmap scalable font-
1123 if (!size && style->bitmapScalable && (styleStrategy & QFont::PreferMatch)) {
!sizeDescription
TRUEnever evaluated
FALSEnever evaluated
style->bitmapScalableDescription
TRUEnever evaluated
FALSEnever evaluated
(styleStrategy...::PreferMatch)Description
TRUEnever evaluated
FALSEnever evaluated
0
1124 size = style->pixelSize(0);-
1125 if (size) {
sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1126 FM_DEBUG(" found bitmap scalable font (%d pixels)", pixelSize);
dead code: QMessageLogger(__FILE__, 1126, __PRETTY_FUNCTION__).debug(" found bitmap scalable font (%d pixels)", pixelSize);
-
1127 px = pixelSize;-
1128 }
never executed: end of block
0
1129 }
never executed: end of block
0
1130-
1131-
1132 // 4. find closest size match-
1133 if (! size) {
! sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1134 unsigned int distance = ~0u;-
1135 for (int x = 0; x < style->count; ++x) {
x < style->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1136-
1137 unsigned int d;-
1138 if (style->pixelSizes[x].pixelSize < pixelSize) {
style->pixelSi...ze < pixelSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1139 // penalize sizes that are smaller than the-
1140 // requested size, due to truncation from floating-
1141 // point to integer conversions-
1142 d = pixelSize - style->pixelSizes[x].pixelSize + 1;-
1143 } else {
never executed: end of block
0
1144 d = style->pixelSizes[x].pixelSize - pixelSize;-
1145 }
never executed: end of block
0
1146-
1147 if (d < distance) {
d < distanceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1148 distance = d;-
1149 size = style->pixelSizes + x;-
1150 FM_DEBUG(" best size so far: %3d (%d)", size->pixelSize, pixelSize);
dead code: QMessageLogger(__FILE__, 1150, __PRETTY_FUNCTION__).debug(" best size so far: %3d (%d)", size->pixelSize, pixelSize);
-
1151 }
never executed: end of block
0
1152 }
never executed: end of block
0
1153-
1154 if (!size) {
!sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1155 FM_DEBUG(" no size supports the script we want");
dead code: QMessageLogger(__FILE__, 1155, __PRETTY_FUNCTION__).debug(" no size supports the script we want");
-
1156 continue;
never executed: continue;
0
1157 }-
1158-
1159 if (style->bitmapScalable && ! (styleStrategy & QFont::PreferQuality) &&
style->bitmapScalableDescription
TRUEnever evaluated
FALSEnever evaluated
! (styleStrate...PreferQuality)Description
TRUEnever evaluated
FALSEnever evaluated
0
1160 (distance * 10 / pixelSize) >= 2) {
(distance * 10...ixelSize) >= 2Description
TRUEnever evaluated
FALSEnever evaluated
0
1161 // the closest size is not close enough, go ahead and-
1162 // use a bitmap scaled font-
1163 size = style->pixelSize(0);-
1164 px = pixelSize;-
1165 } else {
never executed: end of block
0
1166 px = size->pixelSize;-
1167 }
never executed: end of block
0
1168 }-
1169-
1170-
1171 unsigned int this_score = 0x0000;-
1172 enum {-
1173 PitchMismatch = 0x4000,-
1174 StyleMismatch = 0x2000,-
1175 BitmapScaledPenalty = 0x1000-
1176 };-
1177 if (pitch != '*') {
pitch != '*'Description
TRUEnever evaluated
FALSEnever evaluated
0
1178 if ((pitch == 'm' && !family->fixedPitch)
pitch == 'm'Description
TRUEnever evaluated
FALSEnever evaluated
!family->fixedPitchDescription
TRUEnever evaluated
FALSEnever evaluated
0
1179 || (pitch == 'p' && family->fixedPitch))
pitch == 'p'Description
TRUEnever evaluated
FALSEnever evaluated
family->fixedPitchDescription
TRUEnever evaluated
FALSEnever evaluated
0
1180 this_score += PitchMismatch;
never executed: this_score += PitchMismatch;
0
1181 }
never executed: end of block
0
1182 if (styleKey != style->key)
styleKey != style->keyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1183 this_score += StyleMismatch;
never executed: this_score += StyleMismatch;
0
1184 if (!style->smoothScalable && px != size->pixelSize) // bitmap scaled
!style->smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
px != size->pixelSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1185 this_score += BitmapScaledPenalty;
never executed: this_score += BitmapScaledPenalty;
0
1186 if (px != pixelSize) // close, but not exact, size match
px != pixelSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1187 this_score += qAbs(px - pixelSize);
never executed: this_score += qAbs(px - pixelSize);
0
1188-
1189 if (this_score < score) {
this_score < scoreDescription
TRUEnever evaluated
FALSEnever evaluated
0
1190 FM_DEBUG(" found a match: score %x best score so far %x",
dead code: QMessageLogger(__FILE__, 1190, __PRETTY_FUNCTION__).debug(" found a match: score %x best score so far %x", this_score, score);
-
1191 this_score, score);
dead code: QMessageLogger(__FILE__, 1190, __PRETTY_FUNCTION__).debug(" found a match: score %x best score so far %x", this_score, score);
-
1192-
1193 score = this_score;-
1194 desc->foundry = foundry;-
1195 desc->style = style;-
1196 desc->size = size;-
1197 } else {
never executed: end of block
0
1198 FM_DEBUG(" score %x no better than best %x", this_score, score);
dead code: QMessageLogger(__FILE__, 1198, __PRETTY_FUNCTION__).debug(" score %x no better than best %x", this_score, score);
-
1199 }
never executed: end of block
0
1200 }-
1201-
1202 return score;
never executed: return score;
0
1203}-
1204-
1205static bool matchFamilyName(const QString &familyName, QtFontFamily *f)-
1206{-
1207 if (familyName.isEmpty())
familyName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1208 return true;
never executed: return true;
0
1209 return f->matchesFamilyName(familyName);
never executed: return f->matchesFamilyName(familyName);
0
1210}-
1211-
1212/*!-
1213 \internal-
1214-
1215 Tries to find the best match for a given request and family/foundry-
1216*/-
1217static int match(int script, const QFontDef &request,-
1218 const QString &family_name, const QString &foundry_name,-
1219 QtFontDesc *desc, const QList<int> &blacklistedFamilies)-
1220{-
1221 int result = -1;-
1222-
1223 QtFontStyle::Key styleKey;-
1224 styleKey.style = request.style;-
1225 styleKey.weight = request.weight;-
1226 styleKey.stretch = request.stretch;-
1227 char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p';
request.ignorePitchDescription
TRUEnever evaluated
FALSEnever evaluated
request.fixedPitchDescription
TRUEnever evaluated
FALSEnever evaluated
0
1228-
1229-
1230 FM_DEBUG("QFontDatabase::match\n"
dead code: QMessageLogger(__FILE__, 1230, __PRETTY_FUNCTION__).debug("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" " weight: %d, style: %d\n" " stretch: %d\n" " pixelSize: %g\n" " pitch: %c", family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(), foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
1231 " request:\n"
dead code: QMessageLogger(__FILE__, 1230, __PRETTY_FUNCTION__).debug("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" " weight: %d, style: %d\n" " stretch: %d\n" " pixelSize: %g\n" " pitch: %c", family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(), foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
1232 " family: %s [%s], script: %d\n"
dead code: QMessageLogger(__FILE__, 1230, __PRETTY_FUNCTION__).debug("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" " weight: %d, style: %d\n" " stretch: %d\n" " pixelSize: %g\n" " pitch: %c", family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(), foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
1233 " weight: %d, style: %d\n"
dead code: QMessageLogger(__FILE__, 1230, __PRETTY_FUNCTION__).debug("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" " weight: %d, style: %d\n" " stretch: %d\n" " pixelSize: %g\n" " pitch: %c", family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(), foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
1234 " stretch: %d\n"
dead code: QMessageLogger(__FILE__, 1230, __PRETTY_FUNCTION__).debug("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" " weight: %d, style: %d\n" " stretch: %d\n" " pixelSize: %g\n" " pitch: %c", family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(), foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
1235 " pixelSize: %g\n"
dead code: QMessageLogger(__FILE__, 1230, __PRETTY_FUNCTION__).debug("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" " weight: %d, style: %d\n" " stretch: %d\n" " pixelSize: %g\n" " pitch: %c", family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(), foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
1236 " pitch: %c",
dead code: QMessageLogger(__FILE__, 1230, __PRETTY_FUNCTION__).debug("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" " weight: %d, style: %d\n" " stretch: %d\n" " pixelSize: %g\n" " pitch: %c", family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(), foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
1237 family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(),
dead code: QMessageLogger(__FILE__, 1230, __PRETTY_FUNCTION__).debug("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" " weight: %d, style: %d\n" " stretch: %d\n" " pixelSize: %g\n" " pitch: %c", family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(), foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
1238 foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(),
dead code: QMessageLogger(__FILE__, 1230, __PRETTY_FUNCTION__).debug("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" " weight: %d, style: %d\n" " stretch: %d\n" " pixelSize: %g\n" " pitch: %c", family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(), foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
1239 script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
dead code: QMessageLogger(__FILE__, 1230, __PRETTY_FUNCTION__).debug("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" " weight: %d, style: %d\n" " stretch: %d\n" " pixelSize: %g\n" " pitch: %c", family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(), foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
1240-
1241 desc->family = 0;-
1242 desc->foundry = 0;-
1243 desc->style = 0;-
1244 desc->size = 0;-
1245-
1246 unsigned int score = ~0u;-
1247-
1248 load(family_name, script);-
1249-
1250 size_t writingSystem = std::find(scriptForWritingSystem, scriptForWritingSystem +-
1251 QFontDatabase::WritingSystemsCount, script) - scriptForWritingSystem;-
1252 if (writingSystem >= QFontDatabase::WritingSystemsCount)
writingSystem ...ngSystemsCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1253 writingSystem = QFontDatabase::Any;
never executed: writingSystem = QFontDatabase::Any;
0
1254-
1255 QFontDatabasePrivate *db = privateDb();-
1256 for (int x = 0; x < db->count; ++x) {
x < db->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1257 if (blacklistedFamilies.contains(x))
blacklistedFam...es.contains(x)Description
TRUEnever evaluated
FALSEnever evaluated
0
1258 continue;
never executed: continue;
0
1259 QtFontDesc test;-
1260 test.family = db->families[x];-
1261-
1262 if (!matchFamilyName(family_name, test.family))
!matchFamilyNa..., test.family)Description
TRUEnever evaluated
FALSEnever evaluated
0
1263 continue;
never executed: continue;
0
1264-
1265 test.family->ensurePopulated();-
1266-
1267 // Check if family is supported in the script we want-
1268 if (writingSystem != QFontDatabase::Any && !(test.family->writingSystems[writingSystem] & QtFontFamily::Supported))
writingSystem ...tDatabase::AnyDescription
TRUEnever evaluated
FALSEnever evaluated
!(test.family-...ly::Supported)Description
TRUEnever evaluated
FALSEnever evaluated
0
1269 continue;
never executed: continue;
0
1270-
1271 // as we know the script is supported, we can be sure-
1272 // to find a matching font here.-
1273 unsigned int newscore =-
1274 bestFoundry(script, score, request.styleStrategy,-
1275 test.family, foundry_name, styleKey, request.pixelSize, pitch,-
1276 &test, request.styleName);-
1277 if (test.foundry == 0 && !foundry_name.isEmpty()) {
test.foundry == 0Description
TRUEnever evaluated
FALSEnever evaluated
!foundry_name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1278 // the specific foundry was not found, so look for-
1279 // any foundry matching our requirements-
1280 newscore = bestFoundry(script, score, request.styleStrategy, test.family,-
1281 QString(), styleKey, request.pixelSize,-
1282 pitch, &test, request.styleName);-
1283 }
never executed: end of block
0
1284-
1285 if (newscore < score) {
newscore < scoreDescription
TRUEnever evaluated
FALSEnever evaluated
0
1286 result = x;-
1287 score = newscore;-
1288 *desc = test;-
1289 }
never executed: end of block
0
1290 if (newscore < 10) // xlfd instead of FT... just accept it
newscore < 10Description
TRUEnever evaluated
FALSEnever evaluated
0
1291 break;
never executed: break;
0
1292 }
never executed: end of block
0
1293 return result;
never executed: return result;
0
1294}-
1295-
1296static QString styleStringHelper(int weight, QFont::Style style)-
1297{-
1298 QString result;-
1299 if (weight > QFont::Normal) {
weight > QFont::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1300 if (weight >= QFont::Black)
weight >= QFont::BlackDescription
TRUEnever evaluated
FALSEnever evaluated
0
1301 result = QCoreApplication::translate("QFontDatabase", "Black");
never executed: result = QCoreApplication::translate("QFontDatabase", "Black");
0
1302 else if (weight >= QFont::ExtraBold)
weight >= QFont::ExtraBoldDescription
TRUEnever evaluated
FALSEnever evaluated
0
1303 result = QCoreApplication::translate("QFontDatabase", "Extra Bold");
never executed: result = QCoreApplication::translate("QFontDatabase", "Extra Bold");
0
1304 else if (weight >= QFont::Bold)
weight >= QFont::BoldDescription
TRUEnever evaluated
FALSEnever evaluated
0
1305 result = QCoreApplication::translate("QFontDatabase", "Bold");
never executed: result = QCoreApplication::translate("QFontDatabase", "Bold");
0
1306 else if (weight >= QFont::DemiBold)
weight >= QFont::DemiBoldDescription
TRUEnever evaluated
FALSEnever evaluated
0
1307 result = QCoreApplication::translate("QFontDatabase", "Demi Bold");
never executed: result = QCoreApplication::translate("QFontDatabase", "Demi Bold");
0
1308 else if (weight >= QFont::Medium)
weight >= QFont::MediumDescription
TRUEnever evaluated
FALSEnever evaluated
0
1309 result = QCoreApplication::translate("QFontDatabase", "Medium", "The Medium font weight");
never executed: result = QCoreApplication::translate("QFontDatabase", "Medium", "The Medium font weight");
0
1310 } else {
never executed: end of block
0
1311 if (weight <= QFont::Thin)
weight <= QFont::ThinDescription
TRUEnever evaluated
FALSEnever evaluated
0
1312 result = QCoreApplication::translate("QFontDatabase", "Thin");
never executed: result = QCoreApplication::translate("QFontDatabase", "Thin");
0
1313 else if (weight <= QFont::ExtraLight)
weight <= QFont::ExtraLightDescription
TRUEnever evaluated
FALSEnever evaluated
0
1314 result = QCoreApplication::translate("QFontDatabase", "Extra Light");
never executed: result = QCoreApplication::translate("QFontDatabase", "Extra Light");
0
1315 else if (weight <= QFont::Light)
weight <= QFont::LightDescription
TRUEnever evaluated
FALSEnever evaluated
0
1316 result = QCoreApplication::translate("QFontDatabase", "Light");
never executed: result = QCoreApplication::translate("QFontDatabase", "Light");
0
1317 }
never executed: end of block
0
1318-
1319 if (style == QFont::StyleItalic)
style == QFont::StyleItalicDescription
TRUEnever evaluated
FALSEnever evaluated
0
1320 result += QLatin1Char(' ') + QCoreApplication::translate("QFontDatabase", "Italic");
never executed: result += QLatin1Char(' ') + QCoreApplication::translate("QFontDatabase", "Italic");
0
1321 else if (style == QFont::StyleOblique)
style == QFont::StyleObliqueDescription
TRUEnever evaluated
FALSEnever evaluated
0
1322 result += QLatin1Char(' ') + QCoreApplication::translate("QFontDatabase", "Oblique");
never executed: result += QLatin1Char(' ') + QCoreApplication::translate("QFontDatabase", "Oblique");
0
1323-
1324 if (result.isEmpty())
result.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1325 result = QCoreApplication::translate("QFontDatabase", "Normal", "The Normal or Regular font weight");
never executed: result = QCoreApplication::translate("QFontDatabase", "Normal", "The Normal or Regular font weight");
0
1326-
1327 return result.simplified();
never executed: return result.simplified();
0
1328}-
1329-
1330/*!-
1331 Returns a string that describes the style of the \a font. For-
1332 example, "Bold Italic", "Bold", "Italic" or "Normal". An empty-
1333 string may be returned.-
1334*/-
1335QString QFontDatabase::styleString(const QFont &font)-
1336{-
1337 return font.styleName().isEmpty() ? styleStringHelper(font.weight(), font.style())
never executed: return font.styleName().isEmpty() ? styleStringHelper(font.weight(), font.style()) : font.styleName();
font.styleName().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1338 : font.styleName();
never executed: return font.styleName().isEmpty() ? styleStringHelper(font.weight(), font.style()) : font.styleName();
0
1339}-
1340-
1341/*!-
1342 Returns a string that describes the style of the \a fontInfo. For-
1343 example, "Bold Italic", "Bold", "Italic" or "Normal". An empty-
1344 string may be returned.-
1345*/-
1346QString QFontDatabase::styleString(const QFontInfo &fontInfo)-
1347{-
1348 return fontInfo.styleName().isEmpty() ? styleStringHelper(fontInfo.weight(), fontInfo.style())
never executed: return fontInfo.styleName().isEmpty() ? styleStringHelper(fontInfo.weight(), fontInfo.style()) : fontInfo.styleName();
fontInfo.styleName().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1349 : fontInfo.styleName();
never executed: return fontInfo.styleName().isEmpty() ? styleStringHelper(fontInfo.weight(), fontInfo.style()) : fontInfo.styleName();
0
1350}-
1351-
1352-
1353/*!-
1354 \class QFontDatabase-
1355 \threadsafe-
1356 \inmodule QtGui-
1357-
1358 \brief The QFontDatabase class provides information about the fonts available in the underlying window system.-
1359-
1360 \ingroup appearance-
1361-
1362 The most common uses of this class are to query the database for-
1363 the list of font families() and for the pointSizes() and styles()-
1364 that are available for each family. An alternative to pointSizes()-
1365 is smoothSizes() which returns the sizes at which a given family-
1366 and style will look attractive.-
1367-
1368 If the font family is available from two or more foundries the-
1369 foundry name is included in the family name; for example:-
1370 "Helvetica [Adobe]" and "Helvetica [Cronyx]". When you specify a-
1371 family, you can either use the old hyphenated "foundry-family"-
1372 format or the bracketed "family [foundry]" format; for example:-
1373 "Cronyx-Helvetica" or "Helvetica [Cronyx]". If the family has a-
1374 foundry it is always returned using the bracketed format, as is-
1375 the case with the value returned by families().-
1376-
1377 The font() function returns a QFont given a family, style and-
1378 point size.-
1379-
1380 A family and style combination can be checked to see if it is-
1381 italic() or bold(), and to retrieve its weight(). Similarly we can-
1382 call isBitmapScalable(), isSmoothlyScalable(), isScalable() and-
1383 isFixedPitch().-
1384-
1385 Use the styleString() to obtain a text version of a style.-
1386-
1387 The QFontDatabase class also supports some static functions, for-
1388 example, standardSizes(). You can retrieve the description of a-
1389 writing system using writingSystemName(), and a sample of-
1390 characters in a writing system with writingSystemSample().-
1391-
1392 Example:-
1393-
1394 \snippet qfontdatabase/main.cpp 0-
1395 \snippet qfontdatabase/main.cpp 1-
1396-
1397 This example gets the list of font families, the list of-
1398 styles for each family, and the point sizes that are available for-
1399 each combination of family and style, displaying this information-
1400 in a tree view.-
1401-
1402 \sa QFont, QFontInfo, QFontMetrics, {Character Map Example}-
1403*/-
1404-
1405/*!-
1406 Creates a font database object.-
1407*/-
1408QFontDatabase::QFontDatabase()-
1409{-
1410 if (!qApp || !QGuiApplicationPrivate::platformIntegration())
!(static_cast<...::instance()))Description
TRUEnever evaluated
FALSEnever evaluated
!QGuiApplicati...mIntegration()Description
TRUEnever evaluated
FALSEnever evaluated
0
1411 qFatal("QFontDatabase: Must construct a QGuiApplication before accessing QFontDatabase");
never executed: QMessageLogger(__FILE__, 1411, __PRETTY_FUNCTION__).fatal("QFontDatabase: Must construct a QGuiApplication before accessing QFontDatabase");
0
1412-
1413 QMutexLocker locker(fontDatabaseMutex());-
1414 createDatabase();-
1415 d = privateDb();-
1416}
never executed: end of block
0
1417-
1418/*!-
1419 \enum QFontDatabase::WritingSystem-
1420-
1421 \value Any-
1422 \value Latin-
1423 \value Greek-
1424 \value Cyrillic-
1425 \value Armenian-
1426 \value Hebrew-
1427 \value Arabic-
1428 \value Syriac-
1429 \value Thaana-
1430 \value Devanagari-
1431 \value Bengali-
1432 \value Gurmukhi-
1433 \value Gujarati-
1434 \value Oriya-
1435 \value Tamil-
1436 \value Telugu-
1437 \value Kannada-
1438 \value Malayalam-
1439 \value Sinhala-
1440 \value Thai-
1441 \value Lao-
1442 \value Tibetan-
1443 \value Myanmar-
1444 \value Georgian-
1445 \value Khmer-
1446 \value SimplifiedChinese-
1447 \value TraditionalChinese-
1448 \value Japanese-
1449 \value Korean-
1450 \value Vietnamese-
1451 \value Symbol-
1452 \value Other (the same as Symbol)-
1453 \value Ogham-
1454 \value Runic-
1455 \value Nko-
1456-
1457 \omitvalue WritingSystemsCount-
1458*/-
1459-
1460/*!-
1461 \enum QFontDatabase::SystemFont-
1462-
1463 \value GeneralFont The default system font.-
1464 \value FixedFont The fixed font that the system recommends.-
1465 \value TitleFont The system standard font for titles.-
1466 \value SmallestReadableFont The smallest readable system font.-
1467-
1468 \since 5.2-
1469*/-
1470-
1471/*!-
1472 Returns a sorted list of the available writing systems. This is-
1473 list generated from information about all installed fonts on the-
1474 system.-
1475-
1476 \sa families()-
1477*/-
1478QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems() const-
1479{-
1480 QMutexLocker locker(fontDatabaseMutex());-
1481-
1482 QT_PREPEND_NAMESPACE(load)();-
1483-
1484 quint64 writingSystemsFound = 0;-
1485 Q_STATIC_ASSERT(WritingSystemsCount < 64);-
1486-
1487 for (int i = 0; i < d->count; ++i) {
i < d->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1488 QtFontFamily *family = d->families[i];-
1489 family->ensurePopulated();-
1490-
1491 if (family->count == 0)
family->count == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1492 continue;
never executed: continue;
0
1493 for (uint x = Latin; x < uint(WritingSystemsCount); ++x) {
x < uint(WritingSystemsCount)Description
TRUEnever evaluated
FALSEnever evaluated
0
1494 if (family->writingSystems[x] & QtFontFamily::Supported)
family->writin...ily::SupportedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1495 writingSystemsFound |= quint64(1) << x;
never executed: writingSystemsFound |= quint64(1) << x;
0
1496 }
never executed: end of block
0
1497 }
never executed: end of block
0
1498-
1499 // mutex protection no longer needed - just working on local data now:-
1500 locker.unlock();-
1501-
1502 QList<WritingSystem> list;-
1503 list.reserve(qPopulationCount(writingSystemsFound));-
1504 for (uint x = Latin ; x < uint(WritingSystemsCount); ++x) {
x < uint(WritingSystemsCount)Description
TRUEnever evaluated
FALSEnever evaluated
0
1505 if (writingSystemsFound & (quint64(1) << x))
writingSystems...int64(1) << x)Description
TRUEnever evaluated
FALSEnever evaluated
0
1506 list.push_back(WritingSystem(x));
never executed: list.push_back(WritingSystem(x));
0
1507 }
never executed: end of block
0
1508 return list;
never executed: return list;
0
1509}-
1510-
1511-
1512/*!-
1513 Returns a sorted list of the writing systems supported by a given-
1514 font \a family.-
1515-
1516 \sa families()-
1517*/-
1518QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems(const QString &family) const-
1519{-
1520 QString familyName, foundryName;-
1521 parseFontName(family, foundryName, familyName);-
1522-
1523 QMutexLocker locker(fontDatabaseMutex());-
1524-
1525 QT_PREPEND_NAMESPACE(load)();-
1526-
1527 QList<WritingSystem> list;-
1528 QtFontFamily *f = d->family(familyName);-
1529 if (!f || f->count == 0)
!fDescription
TRUEnever evaluated
FALSEnever evaluated
f->count == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1530 return list;
never executed: return list;
0
1531-
1532 for (int x = Latin; x < WritingSystemsCount; ++x) {
x < WritingSystemsCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1533 const WritingSystem writingSystem = WritingSystem(x);-
1534 if (f->writingSystems[writingSystem] & QtFontFamily::Supported)
f->writingSyst...ily::SupportedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1535 list.append(writingSystem);
never executed: list.append(writingSystem);
0
1536 }
never executed: end of block
0
1537 return list;
never executed: return list;
0
1538}-
1539-
1540-
1541/*!-
1542 Returns a sorted list of the available font families which support-
1543 the \a writingSystem.-
1544-
1545 If a family exists in several foundries, the returned name for-
1546 that font is in the form "family [foundry]". Examples: "Times-
1547 [Adobe]", "Times [Cronyx]", "Palatino".-
1548-
1549 \sa writingSystems()-
1550*/-
1551QStringList QFontDatabase::families(WritingSystem writingSystem) const-
1552{-
1553 QMutexLocker locker(fontDatabaseMutex());-
1554-
1555 QT_PREPEND_NAMESPACE(load)();-
1556-
1557 QStringList flist;-
1558 for (int i = 0; i < d->count; i++) {
i < d->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1559 QtFontFamily *f = d->families[i];-
1560 if (f->populated && f->count == 0)
f->populatedDescription
TRUEnever evaluated
FALSEnever evaluated
f->count == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1561 continue;
never executed: continue;
0
1562 if (writingSystem != Any) {
writingSystem != AnyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1563 f->ensurePopulated();-
1564 if (f->writingSystems[writingSystem] != QtFontFamily::Supported)
f->writingSyst...ily::SupportedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1565 continue;
never executed: continue;
0
1566 }
never executed: end of block
0
1567 if (!f->populated || f->count == 1) {
!f->populatedDescription
TRUEnever evaluated
FALSEnever evaluated
f->count == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1568 flist.append(f->name);-
1569 } else {
never executed: end of block
0
1570 for (int j = 0; j < f->count; j++) {
j < f->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1571 QString str = f->name;-
1572 QString foundry = f->foundries[j]->name;-
1573 if (!foundry.isEmpty()) {
!foundry.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1574 str += QLatin1String(" [");-
1575 str += foundry;-
1576 str += QLatin1Char(']');-
1577 }
never executed: end of block
0
1578 flist.append(str);-
1579 }
never executed: end of block
0
1580 }
never executed: end of block
0
1581 }-
1582 return flist;
never executed: return flist;
0
1583}-
1584-
1585/*!-
1586 Returns a list of the styles available for the font family \a-
1587 family. Some example styles: "Light", "Light Italic", "Bold",-
1588 "Oblique", "Demi". The list may be empty.-
1589-
1590 \sa families()-
1591*/-
1592QStringList QFontDatabase::styles(const QString &family) const-
1593{-
1594 QString familyName, foundryName;-
1595 parseFontName(family, foundryName, familyName);-
1596-
1597 QMutexLocker locker(fontDatabaseMutex());-
1598-
1599 QT_PREPEND_NAMESPACE(load)(familyName);-
1600-
1601 QStringList l;-
1602 QtFontFamily *f = d->family(familyName);-
1603 if (!f)
!fDescription
TRUEnever evaluated
FALSEnever evaluated
0
1604 return l;
never executed: return l;
0
1605-
1606 QtFontFoundry allStyles(foundryName);-
1607 for (int j = 0; j < f->count; j++) {
j < f->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1608 QtFontFoundry *foundry = f->foundries[j];-
1609 if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
foundryName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
foundry->name....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1610 for (int k = 0; k < foundry->count; k++) {
k < foundry->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1611 QtFontStyle::Key ke(foundry->styles[k]->key);-
1612 ke.stretch = 0;-
1613 allStyles.style(ke, foundry->styles[k]->styleName, true);-
1614 }
never executed: end of block
0
1615 }
never executed: end of block
0
1616 }
never executed: end of block
0
1617-
1618 l.reserve(allStyles.count);-
1619 for (int i = 0; i < allStyles.count; i++) {
i < allStyles.countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1620 l.append(allStyles.styles[i]->styleName.isEmpty() ?-
1621 styleStringHelper(allStyles.styles[i]->key.weight,-
1622 (QFont::Style)allStyles.styles[i]->key.style) :-
1623 allStyles.styles[i]->styleName);-
1624 }
never executed: end of block
0
1625 return l;
never executed: return l;
0
1626}-
1627-
1628/*!-
1629 Returns \c true if the font that has family \a family and style \a-
1630 style is fixed pitch; otherwise returns \c false.-
1631*/-
1632-
1633bool QFontDatabase::isFixedPitch(const QString &family,-
1634 const QString &style) const-
1635{-
1636 Q_UNUSED(style);-
1637-
1638 QString familyName, foundryName;-
1639 parseFontName(family, foundryName, familyName);-
1640-
1641 QMutexLocker locker(fontDatabaseMutex());-
1642-
1643 QT_PREPEND_NAMESPACE(load)(familyName);-
1644-
1645 QtFontFamily *f = d->family(familyName);-
1646 return (f && f->fixedPitch);
never executed: return (f && f->fixedPitch);
fDescription
TRUEnever evaluated
FALSEnever evaluated
f->fixedPitchDescription
TRUEnever evaluated
FALSEnever evaluated
0
1647}-
1648-
1649/*!-
1650 Returns \c true if the font that has family \a family and style \a-
1651 style is a scalable bitmap font; otherwise returns \c false. Scaling-
1652 a bitmap font usually produces an unattractive hardly readable-
1653 result, because the pixels of the font are scaled. If you need to-
1654 scale a bitmap font it is better to scale it to one of the fixed-
1655 sizes returned by smoothSizes().-
1656-
1657 \sa isScalable(), isSmoothlyScalable()-
1658*/-
1659bool QFontDatabase::isBitmapScalable(const QString &family,-
1660 const QString &style) const-
1661{-
1662 bool bitmapScalable = false;-
1663 QString familyName, foundryName;-
1664 parseFontName(family, foundryName, familyName);-
1665-
1666 QMutexLocker locker(fontDatabaseMutex());-
1667-
1668 QT_PREPEND_NAMESPACE(load)(familyName);-
1669-
1670 QtFontFamily *f = d->family(familyName);-
1671 if (!f) return bitmapScalable;
never executed: return bitmapScalable;
!fDescription
TRUEnever evaluated
FALSEnever evaluated
0
1672-
1673 QtFontStyle::Key styleKey(style);-
1674 for (int j = 0; j < f->count; j++) {
j < f->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1675 QtFontFoundry *foundry = f->foundries[j];-
1676 if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
foundryName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
foundry->name....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1677 for (int k = 0; k < foundry->count; k++)
k < foundry->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1678 if ((style.isEmpty() ||
style.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1679 foundry->styles[k]->styleName == style ||
foundry->style...eName == styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1680 foundry->styles[k]->key == styleKey)
foundry->style...ey == styleKeyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1681 && foundry->styles[k]->bitmapScalable && !foundry->styles[k]->smoothScalable) {
foundry->style...bitmapScalableDescription
TRUEnever evaluated
FALSEnever evaluated
!foundry->styl...smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1682 bitmapScalable = true;-
1683 goto end;
never executed: goto end;
0
1684 }-
1685 }
never executed: end of block
0
1686 }
never executed: end of block
0
1687 end:
code before this statement never executed: end:
0
1688 return bitmapScalable;
never executed: return bitmapScalable;
0
1689}-
1690-
1691-
1692/*!-
1693 Returns \c true if the font that has family \a family and style \a-
1694 style is smoothly scalable; otherwise returns \c false. If this-
1695 function returns \c true, it's safe to scale this font to any size,-
1696 and the result will always look attractive.-
1697-
1698 \sa isScalable(), isBitmapScalable()-
1699*/-
1700bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &style) const-
1701{-
1702 bool smoothScalable = false;-
1703 QString familyName, foundryName;-
1704 parseFontName(family, foundryName, familyName);-
1705-
1706 QMutexLocker locker(fontDatabaseMutex());-
1707-
1708 QT_PREPEND_NAMESPACE(load)(familyName);-
1709-
1710 QtFontFamily *f = d->family(familyName);-
1711 if (!f) {
!fDescription
TRUEnever evaluated
FALSEnever evaluated
0
1712 for (int i = 0; i < d->count; i++) {
i < d->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1713 if (d->families[i]->matchesFamilyName(familyName)) {
d->families[i]...me(familyName)Description
TRUEnever evaluated
FALSEnever evaluated
0
1714 f = d->families[i];-
1715 f->ensurePopulated();-
1716 break;
never executed: break;
0
1717 }-
1718 }
never executed: end of block
0
1719 }
never executed: end of block
0
1720 if (!f) return smoothScalable;
never executed: return smoothScalable;
!fDescription
TRUEnever evaluated
FALSEnever evaluated
0
1721-
1722 QtFontStyle::Key styleKey(style);-
1723 for (int j = 0; j < f->count; j++) {
j < f->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1724 QtFontFoundry *foundry = f->foundries[j];-
1725 if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
foundryName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
foundry->name....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1726 for (int k = 0; k < foundry->count; k++)
k < foundry->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1727 if ((style.isEmpty() ||
style.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1728 foundry->styles[k]->styleName == style ||
foundry->style...eName == styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1729 foundry->styles[k]->key == styleKey) && foundry->styles[k]->smoothScalable) {
foundry->style...ey == styleKeyDescription
TRUEnever evaluated
FALSEnever evaluated
foundry->style...smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1730 smoothScalable = true;-
1731 goto end;
never executed: goto end;
0
1732 }-
1733 }
never executed: end of block
0
1734 }
never executed: end of block
0
1735 end:
code before this statement never executed: end:
0
1736 return smoothScalable;
never executed: return smoothScalable;
0
1737}-
1738-
1739/*!-
1740 Returns \c true if the font that has family \a family and style \a-
1741 style is scalable; otherwise returns \c false.-
1742-
1743 \sa isBitmapScalable(), isSmoothlyScalable()-
1744*/-
1745bool QFontDatabase::isScalable(const QString &family,-
1746 const QString &style) const-
1747{-
1748 QMutexLocker locker(fontDatabaseMutex());-
1749 if (isSmoothlyScalable(family, style))
isSmoothlyScal...family, style)Description
TRUEnever evaluated
FALSEnever evaluated
0
1750 return true;
never executed: return true;
0
1751 return isBitmapScalable(family, style);
never executed: return isBitmapScalable(family, style);
0
1752}-
1753-
1754-
1755/*!-
1756 Returns a list of the point sizes available for the font that has-
1757 family \a family and style \a styleName. The list may be empty.-
1758-
1759 \sa smoothSizes(), standardSizes()-
1760*/-
1761QList<int> QFontDatabase::pointSizes(const QString &family,-
1762 const QString &styleName)-
1763{-
1764 if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable())
QGuiApplicatio...waysScalable()Description
TRUEnever evaluated
FALSEnever evaluated
0
1765 return standardSizes();
never executed: return standardSizes();
0
1766-
1767 bool smoothScalable = false;-
1768 QString familyName, foundryName;-
1769 parseFontName(family, foundryName, familyName);-
1770-
1771 QMutexLocker locker(fontDatabaseMutex());-
1772-
1773 QT_PREPEND_NAMESPACE(load)(familyName);-
1774-
1775 QList<int> sizes;-
1776-
1777 QtFontFamily *fam = d->family(familyName);-
1778 if (!fam) return sizes;
never executed: return sizes;
!famDescription
TRUEnever evaluated
FALSEnever evaluated
0
1779-
1780-
1781 const int dpi = qt_defaultDpiY(); // embedded-
1782-
1783 QtFontStyle::Key styleKey(styleName);-
1784 for (int j = 0; j < fam->count; j++) {
j < fam->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1785 QtFontFoundry *foundry = fam->foundries[j];-
1786 if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
foundryName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
foundry->name....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1787 QtFontStyle *style = foundry->style(styleKey, styleName);-
1788 if (!style) continue;
never executed: continue;
!styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1789-
1790 if (style->smoothScalable) {
style->smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1791 smoothScalable = true;-
1792 goto end;
never executed: goto end;
0
1793 }-
1794 for (int l = 0; l < style->count; l++) {
l < style->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1795 const QtFontSize *size = style->pixelSizes + l;-
1796-
1797 if (size->pixelSize != 0 && size->pixelSize != SMOOTH_SCALABLE) {
size->pixelSize != 0Description
TRUEnever evaluated
FALSEnever evaluated
size->pixelSize != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
0
1798 const uint pointSize = qRound(size->pixelSize * 72.0 / dpi);-
1799 if (! sizes.contains(pointSize))
! sizes.contains(pointSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
1800 sizes.append(pointSize);
never executed: sizes.append(pointSize);
0
1801 }
never executed: end of block
0
1802 }
never executed: end of block
0
1803 }
never executed: end of block
0
1804 }
never executed: end of block
0
1805 end:
code before this statement never executed: end:
0
1806 if (smoothScalable)
smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1807 return standardSizes();
never executed: return standardSizes();
0
1808-
1809 std::sort(sizes.begin(), sizes.end());-
1810 return sizes;
never executed: return sizes;
0
1811}-
1812-
1813/*!-
1814 Returns a QFont object that has family \a family, style \a style-
1815 and point size \a pointSize. If no matching font could be created,-
1816 a QFont object that uses the application's default font is-
1817 returned.-
1818*/-
1819QFont QFontDatabase::font(const QString &family, const QString &style,-
1820 int pointSize) const-
1821{-
1822 QString familyName, foundryName;-
1823 parseFontName(family, foundryName, familyName);-
1824-
1825 QMutexLocker locker(fontDatabaseMutex());-
1826-
1827 QT_PREPEND_NAMESPACE(load)(familyName);-
1828-
1829 QtFontFoundry allStyles(foundryName);-
1830 QtFontFamily *f = d->family(familyName);-
1831 if (!f) return QGuiApplication::font();
never executed: return QGuiApplication::font();
!fDescription
TRUEnever evaluated
FALSEnever evaluated
0
1832-
1833 for (int j = 0; j < f->count; j++) {
j < f->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1834 QtFontFoundry *foundry = f->foundries[j];-
1835 if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
foundryName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
foundry->name....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1836 for (int k = 0; k < foundry->count; k++)
k < foundry->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1837 allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true);
never executed: allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true);
0
1838 }
never executed: end of block
0
1839 }
never executed: end of block
0
1840-
1841 QtFontStyle::Key styleKey(style);-
1842 QtFontStyle *s = bestStyle(&allStyles, styleKey, style);-
1843-
1844 if (!s) // no styles found?
!sDescription
TRUEnever evaluated
FALSEnever evaluated
0
1845 return QGuiApplication::font();
never executed: return QGuiApplication::font();
0
1846-
1847 QFont fnt(family, pointSize, s->key.weight);-
1848 fnt.setStyle((QFont::Style)s->key.style);-
1849 if (!s->styleName.isEmpty())
!s->styleName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1850 fnt.setStyleName(s->styleName);
never executed: fnt.setStyleName(s->styleName);
0
1851 return fnt;
never executed: return fnt;
0
1852}-
1853-
1854-
1855/*!-
1856 Returns the point sizes of a font that has family \a family and-
1857 style \a styleName that will look attractive. The list may be empty.-
1858 For non-scalable fonts and bitmap scalable fonts, this function-
1859 is equivalent to pointSizes().-
1860-
1861 \sa pointSizes(), standardSizes()-
1862*/-
1863QList<int> QFontDatabase::smoothSizes(const QString &family,-
1864 const QString &styleName)-
1865{-
1866 if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable())
QGuiApplicatio...waysScalable()Description
TRUEnever evaluated
FALSEnever evaluated
0
1867 return standardSizes();
never executed: return standardSizes();
0
1868-
1869 bool smoothScalable = false;-
1870 QString familyName, foundryName;-
1871 parseFontName(family, foundryName, familyName);-
1872-
1873 QMutexLocker locker(fontDatabaseMutex());-
1874-
1875 QT_PREPEND_NAMESPACE(load)(familyName);-
1876-
1877 QList<int> sizes;-
1878-
1879 QtFontFamily *fam = d->family(familyName);-
1880 if (!fam)
!famDescription
TRUEnever evaluated
FALSEnever evaluated
0
1881 return sizes;
never executed: return sizes;
0
1882-
1883 const int dpi = qt_defaultDpiY(); // embedded-
1884-
1885 QtFontStyle::Key styleKey(styleName);-
1886 for (int j = 0; j < fam->count; j++) {
j < fam->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1887 QtFontFoundry *foundry = fam->foundries[j];-
1888 if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
foundryName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
foundry->name....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1889 QtFontStyle *style = foundry->style(styleKey, styleName);-
1890 if (!style) continue;
never executed: continue;
!styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1891-
1892 if (style->smoothScalable) {
style->smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1893 smoothScalable = true;-
1894 goto end;
never executed: goto end;
0
1895 }-
1896 for (int l = 0; l < style->count; l++) {
l < style->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1897 const QtFontSize *size = style->pixelSizes + l;-
1898-
1899 if (size->pixelSize != 0 && size->pixelSize != SMOOTH_SCALABLE) {
size->pixelSize != 0Description
TRUEnever evaluated
FALSEnever evaluated
size->pixelSize != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
0
1900 const uint pointSize = qRound(size->pixelSize * 72.0 / dpi);-
1901 if (! sizes.contains(pointSize))
! sizes.contains(pointSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
1902 sizes.append(pointSize);
never executed: sizes.append(pointSize);
0
1903 }
never executed: end of block
0
1904 }
never executed: end of block
0
1905 }
never executed: end of block
0
1906 }
never executed: end of block
0
1907 end:
code before this statement never executed: end:
0
1908 if (smoothScalable)
smoothScalableDescription
TRUEnever evaluated
FALSEnever evaluated
0
1909 return QFontDatabase::standardSizes();
never executed: return QFontDatabase::standardSizes();
0
1910-
1911 std::sort(sizes.begin(), sizes.end());-
1912 return sizes;
never executed: return sizes;
0
1913}-
1914-
1915-
1916/*!-
1917 Returns a list of standard font sizes.-
1918-
1919 \sa smoothSizes(), pointSizes()-
1920*/-
1921QList<int> QFontDatabase::standardSizes()-
1922{-
1923 return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->standardSizes();
never executed: return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->standardSizes();
0
1924}-
1925-
1926-
1927/*!-
1928 Returns \c true if the font that has family \a family and style \a-
1929 style is italic; otherwise returns \c false.-
1930-
1931 \sa weight(), bold()-
1932*/-
1933bool QFontDatabase::italic(const QString &family, const QString &style) const-
1934{-
1935 QString familyName, foundryName;-
1936 parseFontName(family, foundryName, familyName);-
1937-
1938 QMutexLocker locker(fontDatabaseMutex());-
1939-
1940 QT_PREPEND_NAMESPACE(load)(familyName);-
1941-
1942 QtFontFoundry allStyles(foundryName);-
1943 QtFontFamily *f = d->family(familyName);-
1944 if (!f) return false;
never executed: return false;
!fDescription
TRUEnever evaluated
FALSEnever evaluated
0
1945-
1946 for (int j = 0; j < f->count; j++) {
j < f->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1947 QtFontFoundry *foundry = f->foundries[j];-
1948 if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
foundryName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
foundry->name....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1949 for (int k = 0; k < foundry->count; k++)
k < foundry->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1950 allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true);
never executed: allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true);
0
1951 }
never executed: end of block
0
1952 }
never executed: end of block
0
1953-
1954 QtFontStyle::Key styleKey(style);-
1955 QtFontStyle *s = allStyles.style(styleKey, style);-
1956 return s && s->key.style == QFont::StyleItalic;
never executed: return s && s->key.style == QFont::StyleItalic;
sDescription
TRUEnever evaluated
FALSEnever evaluated
s->key.style =...t::StyleItalicDescription
TRUEnever evaluated
FALSEnever evaluated
0
1957}-
1958-
1959-
1960/*!-
1961 Returns \c true if the font that has family \a family and style \a-
1962 style is bold; otherwise returns \c false.-
1963-
1964 \sa italic(), weight()-
1965*/-
1966bool QFontDatabase::bold(const QString &family,-
1967 const QString &style) const-
1968{-
1969 QString familyName, foundryName;-
1970 parseFontName(family, foundryName, familyName);-
1971-
1972 QMutexLocker locker(fontDatabaseMutex());-
1973-
1974 QT_PREPEND_NAMESPACE(load)(familyName);-
1975-
1976 QtFontFoundry allStyles(foundryName);-
1977 QtFontFamily *f = d->family(familyName);-
1978 if (!f) return false;
never executed: return false;
!fDescription
TRUEnever evaluated
FALSEnever evaluated
0
1979-
1980 for (int j = 0; j < f->count; j++) {
j < f->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1981 QtFontFoundry *foundry = f->foundries[j];-
1982 if (foundryName.isEmpty() ||
foundryName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1983 foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
foundry->name....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1984 for (int k = 0; k < foundry->count; k++)
k < foundry->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
1985 allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true);
never executed: allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true);
0
1986 }
never executed: end of block
0
1987 }
never executed: end of block
0
1988-
1989 QtFontStyle::Key styleKey(style);-
1990 QtFontStyle *s = allStyles.style(styleKey, style);-
1991 return s && s->key.weight >= QFont::Bold;
never executed: return s && s->key.weight >= QFont::Bold;
sDescription
TRUEnever evaluated
FALSEnever evaluated
s->key.weight >= QFont::BoldDescription
TRUEnever evaluated
FALSEnever evaluated
0
1992}-
1993-
1994-
1995/*!-
1996 Returns the weight of the font that has family \a family and style-
1997 \a style. If there is no such family and style combination,-
1998 returns -1.-
1999-
2000 \sa italic(), bold()-
2001*/-
2002int QFontDatabase::weight(const QString &family,-
2003 const QString &style) const-
2004{-
2005 QString familyName, foundryName;-
2006 parseFontName(family, foundryName, familyName);-
2007-
2008 QMutexLocker locker(fontDatabaseMutex());-
2009-
2010 QT_PREPEND_NAMESPACE(load)(familyName);-
2011-
2012 QtFontFoundry allStyles(foundryName);-
2013 QtFontFamily *f = d->family(familyName);-
2014 if (!f) return -1;
never executed: return -1;
!fDescription
TRUEnever evaluated
FALSEnever evaluated
0
2015-
2016 for (int j = 0; j < f->count; j++) {
j < f->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
2017 QtFontFoundry *foundry = f->foundries[j];-
2018 if (foundryName.isEmpty() ||
foundryName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2019 foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
foundry->name....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2020 for (int k = 0; k < foundry->count; k++)
k < foundry->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
2021 allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true);
never executed: allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true);
0
2022 }
never executed: end of block
0
2023 }
never executed: end of block
0
2024-
2025 QtFontStyle::Key styleKey(style);-
2026 QtFontStyle *s = allStyles.style(styleKey, style);-
2027 return s ? s->key.weight : -1;
never executed: return s ? s->key.weight : -1;
sDescription
TRUEnever evaluated
FALSEnever evaluated
0
2028}-
2029-
2030-
2031/*! \internal */-
2032bool QFontDatabase::hasFamily(const QString &family) const-
2033{-
2034 QString parsedFamily, foundry;-
2035 parseFontName(family, foundry, parsedFamily);-
2036 const QString familyAlias = resolveFontFamilyAlias(parsedFamily);-
2037 return families().contains(familyAlias, Qt::CaseInsensitive);
never executed: return families().contains(familyAlias, Qt::CaseInsensitive);
0
2038}-
2039-
2040-
2041/*!-
2042 \since 5.5-
2043-
2044 Returns \c true if and only if the \a family font family is private.-
2045-
2046 This happens, for instance, on \macos and iOS, where the system UI fonts are not-
2047 accessible to the user. For completeness, QFontDatabase::families() returns all-
2048 font families, including the private ones. You should use this function if you-
2049 are developing a font selection control in order to keep private fonts hidden.-
2050-
2051 \sa families()-
2052*/-
2053bool QFontDatabase::isPrivateFamily(const QString &family) const-
2054{-
2055 return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->isPrivateFontFamily(family);
never executed: return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->isPrivateFontFamily(family);
0
2056}-
2057-
2058-
2059/*!-
2060 Returns the names the \a writingSystem (e.g. for displaying to the-
2061 user in a dialog).-
2062*/-
2063QString QFontDatabase::writingSystemName(WritingSystem writingSystem)-
2064{-
2065 const char *name = 0;-
2066 switch (writingSystem) {-
2067 case Any:
never executed: case Any:
0
2068 name = QT_TRANSLATE_NOOP("QFontDatabase", "Any");-
2069 break;
never executed: break;
0
2070 case Latin:
never executed: case Latin:
0
2071 name = QT_TRANSLATE_NOOP("QFontDatabase", "Latin");-
2072 break;
never executed: break;
0
2073 case Greek:
never executed: case Greek:
0
2074 name = QT_TRANSLATE_NOOP("QFontDatabase", "Greek");-
2075 break;
never executed: break;
0
2076 case Cyrillic:
never executed: case Cyrillic:
0
2077 name = QT_TRANSLATE_NOOP("QFontDatabase", "Cyrillic");-
2078 break;
never executed: break;
0
2079 case Armenian:
never executed: case Armenian:
0
2080 name = QT_TRANSLATE_NOOP("QFontDatabase", "Armenian");-
2081 break;
never executed: break;
0
2082 case Hebrew:
never executed: case Hebrew:
0
2083 name = QT_TRANSLATE_NOOP("QFontDatabase", "Hebrew");-
2084 break;
never executed: break;
0
2085 case Arabic:
never executed: case Arabic:
0
2086 name = QT_TRANSLATE_NOOP("QFontDatabase", "Arabic");-
2087 break;
never executed: break;
0
2088 case Syriac:
never executed: case Syriac:
0
2089 name = QT_TRANSLATE_NOOP("QFontDatabase", "Syriac");-
2090 break;
never executed: break;
0
2091 case Thaana:
never executed: case Thaana:
0
2092 name = QT_TRANSLATE_NOOP("QFontDatabase", "Thaana");-
2093 break;
never executed: break;
0
2094 case Devanagari:
never executed: case Devanagari:
0
2095 name = QT_TRANSLATE_NOOP("QFontDatabase", "Devanagari");-
2096 break;
never executed: break;
0
2097 case Bengali:
never executed: case Bengali:
0
2098 name = QT_TRANSLATE_NOOP("QFontDatabase", "Bengali");-
2099 break;
never executed: break;
0
2100 case Gurmukhi:
never executed: case Gurmukhi:
0
2101 name = QT_TRANSLATE_NOOP("QFontDatabase", "Gurmukhi");-
2102 break;
never executed: break;
0
2103 case Gujarati:
never executed: case Gujarati:
0
2104 name = QT_TRANSLATE_NOOP("QFontDatabase", "Gujarati");-
2105 break;
never executed: break;
0
2106 case Oriya:
never executed: case Oriya:
0
2107 name = QT_TRANSLATE_NOOP("QFontDatabase", "Oriya");-
2108 break;
never executed: break;
0
2109 case Tamil:
never executed: case Tamil:
0
2110 name = QT_TRANSLATE_NOOP("QFontDatabase", "Tamil");-
2111 break;
never executed: break;
0
2112 case Telugu:
never executed: case Telugu:
0
2113 name = QT_TRANSLATE_NOOP("QFontDatabase", "Telugu");-
2114 break;
never executed: break;
0
2115 case Kannada:
never executed: case Kannada:
0
2116 name = QT_TRANSLATE_NOOP("QFontDatabase", "Kannada");-
2117 break;
never executed: break;
0
2118 case Malayalam:
never executed: case Malayalam:
0
2119 name = QT_TRANSLATE_NOOP("QFontDatabase", "Malayalam");-
2120 break;
never executed: break;
0
2121 case Sinhala:
never executed: case Sinhala:
0
2122 name = QT_TRANSLATE_NOOP("QFontDatabase", "Sinhala");-
2123 break;
never executed: break;
0
2124 case Thai:
never executed: case Thai:
0
2125 name = QT_TRANSLATE_NOOP("QFontDatabase", "Thai");-
2126 break;
never executed: break;
0
2127 case Lao:
never executed: case Lao:
0
2128 name = QT_TRANSLATE_NOOP("QFontDatabase", "Lao");-
2129 break;
never executed: break;
0
2130 case Tibetan:
never executed: case Tibetan:
0
2131 name = QT_TRANSLATE_NOOP("QFontDatabase", "Tibetan");-
2132 break;
never executed: break;
0
2133 case Myanmar:
never executed: case Myanmar:
0
2134 name = QT_TRANSLATE_NOOP("QFontDatabase", "Myanmar");-
2135 break;
never executed: break;
0
2136 case Georgian:
never executed: case Georgian:
0
2137 name = QT_TRANSLATE_NOOP("QFontDatabase", "Georgian");-
2138 break;
never executed: break;
0
2139 case Khmer:
never executed: case Khmer:
0
2140 name = QT_TRANSLATE_NOOP("QFontDatabase", "Khmer");-
2141 break;
never executed: break;
0
2142 case SimplifiedChinese:
never executed: case SimplifiedChinese:
0
2143 name = QT_TRANSLATE_NOOP("QFontDatabase", "Simplified Chinese");-
2144 break;
never executed: break;
0
2145 case TraditionalChinese:
never executed: case TraditionalChinese:
0
2146 name = QT_TRANSLATE_NOOP("QFontDatabase", "Traditional Chinese");-
2147 break;
never executed: break;
0
2148 case Japanese:
never executed: case Japanese:
0
2149 name = QT_TRANSLATE_NOOP("QFontDatabase", "Japanese");-
2150 break;
never executed: break;
0
2151 case Korean:
never executed: case Korean:
0
2152 name = QT_TRANSLATE_NOOP("QFontDatabase", "Korean");-
2153 break;
never executed: break;
0
2154 case Vietnamese:
never executed: case Vietnamese:
0
2155 name = QT_TRANSLATE_NOOP("QFontDatabase", "Vietnamese");-
2156 break;
never executed: break;
0
2157 case Symbol:
never executed: case Symbol:
0
2158 name = QT_TRANSLATE_NOOP("QFontDatabase", "Symbol");-
2159 break;
never executed: break;
0
2160 case Ogham:
never executed: case Ogham:
0
2161 name = QT_TRANSLATE_NOOP("QFontDatabase", "Ogham");-
2162 break;
never executed: break;
0
2163 case Runic:
never executed: case Runic:
0
2164 name = QT_TRANSLATE_NOOP("QFontDatabase", "Runic");-
2165 break;
never executed: break;
0
2166 case Nko:
never executed: case Nko:
0
2167 name = QT_TRANSLATE_NOOP("QFontDatabase", "N'Ko");-
2168 break;
never executed: break;
0
2169 default:
never executed: default:
0
2170 Q_ASSERT_X(false, "QFontDatabase::writingSystemName", "invalid 'writingSystem' parameter");-
2171 break;
never executed: break;
0
2172 }-
2173 return QCoreApplication::translate("QFontDatabase", name);
never executed: return QCoreApplication::translate("QFontDatabase", name);
0
2174}-
2175-
2176-
2177/*!-
2178 Returns a string with sample characters from \a writingSystem.-
2179*/-
2180QString QFontDatabase::writingSystemSample(WritingSystem writingSystem)-
2181{-
2182 QString sample;-
2183 switch (writingSystem) {-
2184 case Any:
never executed: case Any:
0
2185 case Symbol:
never executed: case Symbol:
0
2186 // show only ascii characters-
2187 sample += QLatin1String("AaBbzZ");-
2188 break;
never executed: break;
0
2189 case Latin:
never executed: case Latin:
0
2190 // This is cheating... we only show latin-1 characters so that we don't-
2191 // end up loading lots of fonts - at least on X11...-
2192 sample = QLatin1String("Aa");-
2193 sample += QChar(0x00C3);-
2194 sample += QChar(0x00E1);-
2195 sample += QLatin1String("Zz");-
2196 break;
never executed: break;
0
2197 case Greek:
never executed: case Greek:
0
2198 sample += QChar(0x0393);-
2199 sample += QChar(0x03B1);-
2200 sample += QChar(0x03A9);-
2201 sample += QChar(0x03C9);-
2202 break;
never executed: break;
0
2203 case Cyrillic:
never executed: case Cyrillic:
0
2204 sample += QChar(0x0414);-
2205 sample += QChar(0x0434);-
2206 sample += QChar(0x0436);-
2207 sample += QChar(0x044f);-
2208 break;
never executed: break;
0
2209 case Armenian:
never executed: case Armenian:
0
2210 sample += QChar(0x053f);-
2211 sample += QChar(0x054f);-
2212 sample += QChar(0x056f);-
2213 sample += QChar(0x057f);-
2214 break;
never executed: break;
0
2215 case Hebrew:
never executed: case Hebrew:
0
2216 sample += QChar(0x05D0);-
2217 sample += QChar(0x05D1);-
2218 sample += QChar(0x05D2);-
2219 sample += QChar(0x05D3);-
2220 break;
never executed: break;
0
2221 case Arabic:
never executed: case Arabic:
0
2222 sample += QChar(0x0628);-
2223 sample += QChar(0x0629);-
2224 sample += QChar(0x062A);-
2225 sample += QChar(0x063A);-
2226 break;
never executed: break;
0
2227 case Syriac:
never executed: case Syriac:
0
2228 sample += QChar(0x0715);-
2229 sample += QChar(0x0725);-
2230 sample += QChar(0x0716);-
2231 sample += QChar(0x0726);-
2232 break;
never executed: break;
0
2233 case Thaana:
never executed: case Thaana:
0
2234 sample += QChar(0x0784);-
2235 sample += QChar(0x0794);-
2236 sample += QChar(0x078c);-
2237 sample += QChar(0x078d);-
2238 break;
never executed: break;
0
2239 case Devanagari:
never executed: case Devanagari:
0
2240 sample += QChar(0x0905);-
2241 sample += QChar(0x0915);-
2242 sample += QChar(0x0925);-
2243 sample += QChar(0x0935);-
2244 break;
never executed: break;
0
2245 case Bengali:
never executed: case Bengali:
0
2246 sample += QChar(0x0986);-
2247 sample += QChar(0x0996);-
2248 sample += QChar(0x09a6);-
2249 sample += QChar(0x09b6);-
2250 break;
never executed: break;
0
2251 case Gurmukhi:
never executed: case Gurmukhi:
0
2252 sample += QChar(0x0a05);-
2253 sample += QChar(0x0a15);-
2254 sample += QChar(0x0a25);-
2255 sample += QChar(0x0a35);-
2256 break;
never executed: break;
0
2257 case Gujarati:
never executed: case Gujarati:
0
2258 sample += QChar(0x0a85);-
2259 sample += QChar(0x0a95);-
2260 sample += QChar(0x0aa5);-
2261 sample += QChar(0x0ab5);-
2262 break;
never executed: break;
0
2263 case Oriya:
never executed: case Oriya:
0
2264 sample += QChar(0x0b06);-
2265 sample += QChar(0x0b16);-
2266 sample += QChar(0x0b2b);-
2267 sample += QChar(0x0b36);-
2268 break;
never executed: break;
0
2269 case Tamil:
never executed: case Tamil:
0
2270 sample += QChar(0x0b89);-
2271 sample += QChar(0x0b99);-
2272 sample += QChar(0x0ba9);-
2273 sample += QChar(0x0bb9);-
2274 break;
never executed: break;
0
2275 case Telugu:
never executed: case Telugu:
0
2276 sample += QChar(0x0c05);-
2277 sample += QChar(0x0c15);-
2278 sample += QChar(0x0c25);-
2279 sample += QChar(0x0c35);-
2280 break;
never executed: break;
0
2281 case Kannada:
never executed: case Kannada:
0
2282 sample += QChar(0x0c85);-
2283 sample += QChar(0x0c95);-
2284 sample += QChar(0x0ca5);-
2285 sample += QChar(0x0cb5);-
2286 break;
never executed: break;
0
2287 case Malayalam:
never executed: case Malayalam:
0
2288 sample += QChar(0x0d05);-
2289 sample += QChar(0x0d15);-
2290 sample += QChar(0x0d25);-
2291 sample += QChar(0x0d35);-
2292 break;
never executed: break;
0
2293 case Sinhala:
never executed: case Sinhala:
0
2294 sample += QChar(0x0d90);-
2295 sample += QChar(0x0da0);-
2296 sample += QChar(0x0db0);-
2297 sample += QChar(0x0dc0);-
2298 break;
never executed: break;
0
2299 case Thai:
never executed: case Thai:
0
2300 sample += QChar(0x0e02);-
2301 sample += QChar(0x0e12);-
2302 sample += QChar(0x0e22);-
2303 sample += QChar(0x0e32);-
2304 break;
never executed: break;
0
2305 case Lao:
never executed: case Lao:
0
2306 sample += QChar(0x0e8d);-
2307 sample += QChar(0x0e9d);-
2308 sample += QChar(0x0ead);-
2309 sample += QChar(0x0ebd);-
2310 break;
never executed: break;
0
2311 case Tibetan:
never executed: case Tibetan:
0
2312 sample += QChar(0x0f00);-
2313 sample += QChar(0x0f01);-
2314 sample += QChar(0x0f02);-
2315 sample += QChar(0x0f03);-
2316 break;
never executed: break;
0
2317 case Myanmar:
never executed: case Myanmar:
0
2318 sample += QChar(0x1000);-
2319 sample += QChar(0x1001);-
2320 sample += QChar(0x1002);-
2321 sample += QChar(0x1003);-
2322 break;
never executed: break;
0
2323 case Georgian:
never executed: case Georgian:
0
2324 sample += QChar(0x10a0);-
2325 sample += QChar(0x10b0);-
2326 sample += QChar(0x10c0);-
2327 sample += QChar(0x10d0);-
2328 break;
never executed: break;
0
2329 case Khmer:
never executed: case Khmer:
0
2330 sample += QChar(0x1780);-
2331 sample += QChar(0x1790);-
2332 sample += QChar(0x17b0);-
2333 sample += QChar(0x17c0);-
2334 break;
never executed: break;
0
2335 case SimplifiedChinese:
never executed: case SimplifiedChinese:
0
2336 sample += QChar(0x4e2d);-
2337 sample += QChar(0x6587);-
2338 sample += QChar(0x8303);-
2339 sample += QChar(0x4f8b);-
2340 break;
never executed: break;
0
2341 case TraditionalChinese:
never executed: case TraditionalChinese:
0
2342 sample += QChar(0x4e2d);-
2343 sample += QChar(0x6587);-
2344 sample += QChar(0x7bc4);-
2345 sample += QChar(0x4f8b);-
2346 break;
never executed: break;
0
2347 case Japanese:
never executed: case Japanese:
0
2348 sample += QChar(0x30b5);-
2349 sample += QChar(0x30f3);-
2350 sample += QChar(0x30d7);-
2351 sample += QChar(0x30eb);-
2352 sample += QChar(0x3067);-
2353 sample += QChar(0x3059);-
2354 break;
never executed: break;
0
2355 case Korean:
never executed: case Korean:
0
2356 sample += QChar(0xac00);-
2357 sample += QChar(0xac11);-
2358 sample += QChar(0xac1a);-
2359 sample += QChar(0xac2f);-
2360 break;
never executed: break;
0
2361 case Vietnamese:
never executed: case Vietnamese:
0
2362 {-
2363 static const char vietnameseUtf8[] = {-
2364 char(0xef), char(0xbb), char(0xbf), char(0xe1), char(0xbb), char(0x97),-
2365 char(0xe1), char(0xbb), char(0x99),-
2366 char(0xe1), char(0xbb), char(0x91),-
2367 char(0xe1), char(0xbb), char(0x93),-
2368 };-
2369 sample += QString::fromUtf8(vietnameseUtf8, sizeof(vietnameseUtf8));-
2370 break;
never executed: break;
0
2371 }-
2372 case Ogham:
never executed: case Ogham:
0
2373 sample += QChar(0x1681);-
2374 sample += QChar(0x1682);-
2375 sample += QChar(0x1683);-
2376 sample += QChar(0x1684);-
2377 break;
never executed: break;
0
2378 case Runic:
never executed: case Runic:
0
2379 sample += QChar(0x16a0);-
2380 sample += QChar(0x16a1);-
2381 sample += QChar(0x16a2);-
2382 sample += QChar(0x16a3);-
2383 break;
never executed: break;
0
2384 case Nko:
never executed: case Nko:
0
2385 sample += QChar(0x7ca);-
2386 sample += QChar(0x7cb);-
2387 sample += QChar(0x7cc);-
2388 sample += QChar(0x7cd);-
2389 break;
never executed: break;
0
2390 default:
never executed: default:
0
2391 break;
never executed: break;
0
2392 }-
2393 return sample;
never executed: return sample;
0
2394}-
2395-
2396-
2397void QFontDatabase::parseFontName(const QString &name, QString &foundry, QString &family)-
2398{-
2399 QT_PREPEND_NAMESPACE(parseFontName)(name, foundry, family);-
2400}
never executed: end of block
0
2401-
2402void QFontDatabase::createDatabase()-
2403{
never executed: end of block
initializeDb(); }
never executed: end of block
0
2404-
2405// used from qfontengine_ft.cpp-
2406Q_GUI_EXPORT QByteArray qt_fontdata_from_index(int index)-
2407{-
2408 QMutexLocker locker(fontDatabaseMutex());-
2409 return privateDb()->applicationFonts.value(index).data;
never executed: return privateDb()->applicationFonts.value(index).data;
0
2410}-
2411-
2412int QFontDatabasePrivate::addAppFont(const QByteArray &fontData, const QString &fileName)-
2413{-
2414 QFontDatabasePrivate::ApplicationFont font;-
2415 font.data = fontData;-
2416 font.fileName = fileName;-
2417-
2418 int i;-
2419 for (i = 0; i < applicationFonts.count(); ++i)
i < applicationFonts.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2420 if (applicationFonts.at(i).families.isEmpty())
applicationFon...lies.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2421 break;
never executed: break;
0
2422 if (i >= applicationFonts.count()) {
i >= applicationFonts.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2423 applicationFonts.append(ApplicationFont());-
2424 i = applicationFonts.count() - 1;-
2425 }
never executed: end of block
0
2426-
2427 if (font.fileName.isEmpty() && !fontData.isEmpty())
font.fileName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!fontData.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2428 font.fileName = QString::fromLatin1(":qmemoryfonts/") + QString::number(i);
never executed: font.fileName = QString::fromLatin1(":qmemoryfonts/") + QString::number(i);
0
2429-
2430 registerFont(&font);-
2431 if (font.families.isEmpty())
font.families.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2432 return -1;
never executed: return -1;
0
2433-
2434 applicationFonts[i] = font;-
2435-
2436 invalidate();-
2437 return i;
never executed: return i;
0
2438}-
2439-
2440bool QFontDatabasePrivate::isApplicationFont(const QString &fileName)-
2441{-
2442 for (int i = 0; i < applicationFonts.count(); ++i)
i < applicationFonts.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2443 if (applicationFonts.at(i).fileName == fileName)
applicationFon...me == fileNameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2444 return true;
never executed: return true;
0
2445 return false;
never executed: return false;
0
2446}-
2447-
2448/*!-
2449 \since 4.2-
2450-
2451 Loads the font from the file specified by \a fileName and makes it available to-
2452 the application. An ID is returned that can be used to remove the font again-
2453 with removeApplicationFont() or to retrieve the list of family names contained-
2454 in the font.-
2455-
2456 The function returns -1 if the font could not be loaded.-
2457-
2458 Currently only TrueType fonts, TrueType font collections, and OpenType fonts are-
2459 supported.-
2460-
2461 \note Adding application fonts on Unix/X11 platforms without fontconfig is-
2462 currently not supported.-
2463-
2464 \sa addApplicationFontFromData(), applicationFontFamilies(), removeApplicationFont()-
2465*/-
2466int QFontDatabase::addApplicationFont(const QString &fileName)-
2467{-
2468 QByteArray data;-
2469 if (!QFileInfo(fileName).isNativePath()) {
!QFileInfo(fil...isNativePath()Description
TRUEnever evaluated
FALSEnever evaluated
0
2470 QFile f(fileName);-
2471 if (!f.open(QIODevice::ReadOnly))
!f.open(QIODevice::ReadOnly)Description
TRUEnever evaluated
FALSEnever evaluated
0
2472 return -1;
never executed: return -1;
0
2473 data = f.readAll();-
2474 }
never executed: end of block
0
2475 QMutexLocker locker(fontDatabaseMutex());-
2476 return privateDb()->addAppFont(data, fileName);
never executed: return privateDb()->addAppFont(data, fileName);
0
2477}-
2478-
2479/*!-
2480 \since 4.2-
2481-
2482 Loads the font from binary data specified by \a fontData and makes it available to-
2483 the application. An ID is returned that can be used to remove the font again-
2484 with removeApplicationFont() or to retrieve the list of family names contained-
2485 in the font.-
2486-
2487 The function returns -1 if the font could not be loaded.-
2488-
2489 Currently only TrueType fonts and TrueType font collections are supported.-
2490-
2491 \b{Note:} Adding application fonts on Unix/X11 platforms without fontconfig is-
2492 currently not supported.-
2493-
2494 \sa addApplicationFont(), applicationFontFamilies(), removeApplicationFont()-
2495*/-
2496int QFontDatabase::addApplicationFontFromData(const QByteArray &fontData)-
2497{-
2498 QMutexLocker locker(fontDatabaseMutex());-
2499 return privateDb()->addAppFont(fontData, QString() /* fileName */);
never executed: return privateDb()->addAppFont(fontData, QString() );
0
2500}-
2501-
2502/*!-
2503 \since 4.2-
2504-
2505 Returns a list of font families for the given application font identified by-
2506 \a id.-
2507-
2508 \sa addApplicationFont(), addApplicationFontFromData()-
2509*/-
2510QStringList QFontDatabase::applicationFontFamilies(int id)-
2511{-
2512 QMutexLocker locker(fontDatabaseMutex());-
2513 return privateDb()->applicationFonts.value(id).families;
never executed: return privateDb()->applicationFonts.value(id).families;
0
2514}-
2515-
2516/*!-
2517 \since 5.2-
2518-
2519 Returns the most adequate font for a given \a type case for proper integration-
2520 with the system's look and feel.-
2521-
2522 \sa QGuiApplication::font()-
2523*/-
2524-
2525QFont QFontDatabase::systemFont(QFontDatabase::SystemFont type)-
2526{-
2527 const QFont *font = 0;-
2528 if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
const QPlatfor...latformTheme()Description
TRUEnever evaluated
FALSEnever evaluated
0
2529 switch (type) {-
2530 case GeneralFont:
never executed: case GeneralFont:
0
2531 font = theme->font(QPlatformTheme::SystemFont);-
2532 break;
never executed: break;
0
2533 case FixedFont:
never executed: case FixedFont:
0
2534 font = theme->font(QPlatformTheme::FixedFont);-
2535 break;
never executed: break;
0
2536 case TitleFont:
never executed: case TitleFont:
0
2537 font = theme->font(QPlatformTheme::TitleBarFont);-
2538 break;
never executed: break;
0
2539 case SmallestReadableFont:
never executed: case SmallestReadableFont:
0
2540 font = theme->font(QPlatformTheme::MiniFont);-
2541 break;
never executed: break;
0
2542 }-
2543 }
never executed: end of block
0
2544-
2545 if (font)
fontDescription
TRUEnever evaluated
FALSEnever evaluated
0
2546 return *font;
never executed: return *font;
0
2547 else if (QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration())
QPlatformInteg...mIntegration()Description
TRUEnever evaluated
FALSEnever evaluated
0
2548 return integration->fontDatabase()->defaultFont();
never executed: return integration->fontDatabase()->defaultFont();
0
2549 else-
2550 return QFont();
never executed: return QFont();
0
2551}-
2552-
2553/*!-
2554 \fn bool QFontDatabase::removeApplicationFont(int id)-
2555 \since 4.2-
2556-
2557 Removes the previously loaded application font identified by \a-
2558 id. Returns \c true if unloading of the font succeeded; otherwise-
2559 returns \c false.-
2560-
2561 \sa removeAllApplicationFonts(), addApplicationFont(),-
2562 addApplicationFontFromData()-
2563*/-
2564bool QFontDatabase::removeApplicationFont(int handle)-
2565{-
2566 QMutexLocker locker(fontDatabaseMutex());-
2567-
2568 QFontDatabasePrivate *db = privateDb();-
2569 if (handle < 0 || handle >= db->applicationFonts.count())
handle < 0Description
TRUEnever evaluated
FALSEnever evaluated
handle >= db->...nFonts.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2570 return false;
never executed: return false;
0
2571-
2572 db->applicationFonts[handle] = QFontDatabasePrivate::ApplicationFont();-
2573-
2574 db->reregisterAppFonts = true;-
2575 db->invalidate();-
2576 return true;
never executed: return true;
0
2577}-
2578-
2579/*!-
2580 \fn bool QFontDatabase::removeAllApplicationFonts()-
2581 \since 4.2-
2582-
2583 Removes all application-local fonts previously added using addApplicationFont()-
2584 and addApplicationFontFromData().-
2585-
2586 Returns \c true if unloading of the fonts succeeded; otherwise-
2587 returns \c false.-
2588-
2589 \sa removeApplicationFont(), addApplicationFont(), addApplicationFontFromData()-
2590*/-
2591bool QFontDatabase::removeAllApplicationFonts()-
2592{-
2593 QMutexLocker locker(fontDatabaseMutex());-
2594-
2595 QFontDatabasePrivate *db = privateDb();-
2596 if (db->applicationFonts.isEmpty())
db->applicationFonts.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2597 return false;
never executed: return false;
0
2598-
2599 db->applicationFonts.clear();-
2600 db->invalidate();-
2601 return true;
never executed: return true;
0
2602}-
2603-
2604/*!-
2605 \fn bool QFontDatabase::supportsThreadedFontRendering()-
2606 \since 4.4-
2607 \deprecated-
2608-
2609 Returns \c true if font rendering is supported outside the GUI-
2610 thread, false otherwise. In other words, a return value of false-
2611 means that all QPainter::drawText() calls outside the GUI thread-
2612 will not produce readable output.-
2613-
2614 As of 5.0, always returns \c true.-
2615-
2616 \sa {Thread-Support in Qt Modules#Painting In Threads}{Painting In Threads}-
2617*/-
2618#if QT_DEPRECATED_SINCE(5, 2)-
2619bool QFontDatabase::supportsThreadedFontRendering()-
2620{-
2621 return true;
never executed: return true;
0
2622}-
2623#endif-
2624-
2625/*!-
2626 \internal-
2627*/-
2628QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)-
2629{-
2630 QMutexLocker locker(fontDatabaseMutex());-
2631-
2632 if (!privateDb()->count)
!privateDb()->countDescription
TRUEnever evaluated
FALSEnever evaluated
0
2633 initializeDb();
never executed: initializeDb();
0
2634-
2635 QFontEngine *engine;-
2636-
2637#if defined(QT_BUILD_INTERNAL)-
2638 // For testing purpose only, emulates an exact-matching monospace font-
2639 if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) {
qt_enable_test_fontDescription
TRUEnever evaluated
FALSEnever evaluated
request.family...ox__Engine__")Description
TRUEnever evaluated
FALSEnever evaluated
0
2640 engine = new QTestFontEngine(request.pixelSize);-
2641 engine->fontDef = request;-
2642 return engine;
never executed: return engine;
0
2643 }-
2644#endif-
2645-
2646 QFontCache *fontCache = QFontCache::instance();-
2647-
2648 // Until we specifically asked not to, try looking for Multi font engine-
2649 // first, the last '1' indicates that we want Multi font engine instead-
2650 // of single ones-
2651 bool multi = !(request.styleStrategy & QFont::NoFontMerging);-
2652 QFontCache::Key key(request, script, multi ? 1 : 0);-
2653 engine = fontCache->findEngine(key);-
2654 if (engine) {
engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2655 FM_DEBUG("Cache hit level 1");
dead code: QMessageLogger(__FILE__, 2655, __PRETTY_FUNCTION__).debug("Cache hit level 1");
-
2656 return engine;
never executed: return engine;
0
2657 }-
2658-
2659 QString family_name, foundry_name;-
2660-
2661 parseFontName(request.family, foundry_name, family_name);-
2662-
2663 QtFontDesc desc;-
2664 QList<int> blackListed;-
2665 int index = match(script, request, family_name, foundry_name, &desc, blackListed);-
2666 if (index >= 0) {
index >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2667 engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size);-
2668 if (engine)
engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2669 initFontDef(desc, request, &engine->fontDef, multi);
never executed: initFontDef(desc, request, &engine->fontDef, multi);
0
2670 else-
2671 blackListed.append(index);
never executed: blackListed.append(index);
0
2672 } else {-
2673 FM_DEBUG(" NO MATCH FOUND\n");
dead code: QMessageLogger(__FILE__, 2673, __PRETTY_FUNCTION__).debug(" NO MATCH FOUND\n");
-
2674 }
never executed: end of block
0
2675-
2676 if (!engine) {
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2677 if (!request.family.isEmpty()) {
!request.family.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2678 QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);-
2679 if (styleHint == QFont::AnyStyle && request.fixedPitch)
styleHint == QFont::AnyStyleDescription
TRUEnever evaluated
FALSEnever evaluated
request.fixedPitchDescription
TRUEnever evaluated
FALSEnever evaluated
0
2680 styleHint = QFont::TypeWriter;
never executed: styleHint = QFont::TypeWriter;
0
2681-
2682 QStringList fallbacks = request.fallBackFamilies-
2683 + fallbacksForFamily(request.family,-
2684 QFont::Style(request.style),-
2685 styleHint,-
2686 QChar::Script(script));-
2687 if (script > QChar::Script_Common)
script > QChar::Script_CommonDescription
TRUEnever evaluated
FALSEnever evaluated
0
2688 fallbacks += QString(); // Find the first font matching the specified script.
never executed: fallbacks += QString();
0
2689-
2690 for (int i = 0; !engine && i < fallbacks.size(); i++) {
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
i < fallbacks.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2691 QFontDef def = request;-
2692 def.family = fallbacks.at(i);-
2693 QFontCache::Key key(def, script, multi ? 1 : 0);-
2694 engine = fontCache->findEngine(key);-
2695 if (!engine) {
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2696 QtFontDesc desc;-
2697 do {-
2698 index = match(script, def, def.family, QLatin1String(""), &desc, blackListed);-
2699 if (index >= 0) {
index >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2700 QFontDef loadDef = def;-
2701 if (loadDef.family.isEmpty())
loadDef.family.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2702 loadDef.family = desc.family->name;
never executed: loadDef.family = desc.family->name;
0
2703 engine = loadEngine(script, loadDef, desc.family, desc.foundry, desc.style, desc.size);-
2704 if (engine)
engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2705 initFontDef(desc, loadDef, &engine->fontDef, multi);
never executed: initFontDef(desc, loadDef, &engine->fontDef, multi);
0
2706 else-
2707 blackListed.append(index);
never executed: blackListed.append(index);
0
2708 }-
2709 } while (index >= 0 && !engine);
never executed: end of block
index >= 0Description
TRUEnever evaluated
FALSEnever evaluated
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2710 }
never executed: end of block
0
2711 }
never executed: end of block
0
2712 }
never executed: end of block
0
2713-
2714 if (!engine)
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
2715 engine = new QFontEngineBox(request.pixelSize);
never executed: engine = new QFontEngineBox(request.pixelSize);
0
2716-
2717 FM_DEBUG("returning box engine");
dead code: QMessageLogger(__FILE__, 2717, __PRETTY_FUNCTION__).debug("returning box engine");
-
2718 }
never executed: end of block
0
2719-
2720 return engine;
never executed: return engine;
0
2721}-
2722-
2723void QFontDatabase::load(const QFontPrivate *d, int script)-
2724{-
2725 QFontDef req = d->request;-
2726-
2727 if (req.pixelSize == -1) {
req.pixelSize == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2728 req.pixelSize = std::floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100;-
2729 req.pixelSize = qRound(req.pixelSize);-
2730 }
never executed: end of block
0
2731 if (req.pointSize < 0)
req.pointSize < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2732 req.pointSize = req.pixelSize*72.0/d->dpi;
never executed: req.pointSize = req.pixelSize*72.0/d->dpi;
0
2733 if (req.stretch == 0)
req.stretch == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2734 req.stretch = 100;
never executed: req.stretch = 100;
0
2735-
2736 // respect the fallback families that might be passed through the request-
2737 const QStringList fallBackFamilies = familyList(req);-
2738-
2739 if (!d->engineData) {
!d->engineDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
2740 QFontCache *fontCache = QFontCache::instance();-
2741 // look for the requested font in the engine data cache-
2742 // note: fallBackFamilies are not respected in the EngineData cache key;-
2743 // join them with the primary selection family to avoid cache misses-
2744 req.family = fallBackFamilies.join(QLatin1Char(','));-
2745-
2746 d->engineData = fontCache->findEngineData(req);-
2747 if (!d->engineData) {
!d->engineDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
2748 // create a new one-
2749 d->engineData = new QFontEngineData;-
2750 fontCache->insertEngineData(req, d->engineData);-
2751 }
never executed: end of block
0
2752 d->engineData->ref.ref();-
2753 }
never executed: end of block
0
2754-
2755 // the cached engineData could have already loaded the engine we want-
2756 if (d->engineData->engines[script])
d->engineData->engines[script]Description
TRUEnever evaluated
FALSEnever evaluated
0
2757 return;
never executed: return;
0
2758-
2759 QFontEngine *fe = Q_NULLPTR;-
2760-
2761 req.fallBackFamilies = fallBackFamilies;-
2762 if (!req.fallBackFamilies.isEmpty())
!req.fallBackF...lies.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2763 req.family = req.fallBackFamilies.takeFirst();
never executed: req.family = req.fallBackFamilies.takeFirst();
0
2764-
2765 // list of families to try-
2766 QStringList family_list;-
2767-
2768 if (!req.family.isEmpty()) {
!req.family.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2769 // Add primary selection-
2770 family_list << req.family;-
2771-
2772 // add the default family-
2773 QString defaultFamily = QGuiApplication::font().family();-
2774 if (! family_list.contains(defaultFamily))
! family_list....defaultFamily)Description
TRUEnever evaluated
FALSEnever evaluated
0
2775 family_list << defaultFamily;
never executed: family_list << defaultFamily;
0
2776-
2777 }
never executed: end of block
0
2778-
2779 // null family means find the first font matching the specified script-
2780 family_list << QString();-
2781-
2782 QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();-
2783 for (; !fe && it != end; ++it) {
!feDescription
TRUEnever evaluated
FALSEnever evaluated
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
2784 req.family = *it;-
2785-
2786 fe = QFontDatabase::findFont(req, script);-
2787 if (fe) {
feDescription
TRUEnever evaluated
FALSEnever evaluated
0
2788 if (fe->type() == QFontEngine::Box && !req.family.isEmpty()) {
fe->type() == QFontEngine::BoxDescription
TRUEnever evaluated
FALSEnever evaluated
!req.family.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2789 if (fe->ref.load() == 0)
fe->ref.load() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2790 delete fe;
never executed: delete fe;
0
2791 fe = 0;-
2792 } else {
never executed: end of block
0
2793 if (d->dpi > 0)
d->dpi > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2794 fe->fontDef.pointSize = qreal(double((fe->fontDef.pixelSize * 72) / d->dpi));
never executed: fe->fontDef.pointSize = qreal(double((fe->fontDef.pixelSize * 72) / d->dpi));
0
2795 }
never executed: end of block
0
2796 }-
2797-
2798 // No need to check requested fallback families again-
2799 req.fallBackFamilies.clear();-
2800 }
never executed: end of block
0
2801-
2802 Q_ASSERT(fe);-
2803 if (fe->symbol || (d->request.styleStrategy & QFont::NoFontMerging)) {
fe->symbolDescription
TRUEnever evaluated
FALSEnever evaluated
(d->request.st...NoFontMerging)Description
TRUEnever evaluated
FALSEnever evaluated
0
2804 for (int i = 0; i < QChar::ScriptCount; ++i) {
i < QChar::ScriptCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
2805 if (!d->engineData->engines[i]) {
!d->engineData->engines[i]Description
TRUEnever evaluated
FALSEnever evaluated
0
2806 d->engineData->engines[i] = fe;-
2807 fe->ref.ref();-
2808 }
never executed: end of block
0
2809 }
never executed: end of block
0
2810 } else {
never executed: end of block
0
2811 d->engineData->engines[script] = fe;-
2812 fe->ref.ref();-
2813 }
never executed: end of block
0
2814}-
2815-
2816QString QFontDatabase::resolveFontFamilyAlias(const QString &family)-
2817{-
2818 return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->resolveFontFamilyAlias(family);
never executed: return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->resolveFontFamilyAlias(family);
0
2819}-
2820-
2821-
2822QT_END_NAMESPACE-
2823-
Source codeSwitch to Preprocessed file

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