qfont.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qfont.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11bool QFontDef::exactMatch(const QFontDef &other) const-
12{-
13 if (pixelSize != -1
pixelSize != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& other.pixelSize != -1
other.pixelSize != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
14 if (pixelSize != other.pixelSize
pixelSize != other.pixelSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
15 return
never executed: return false;
false;
never executed: return false;
0
16 }
never executed: end of block
else if (pointSize != -1
pointSize != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& other.pointSize != -1
other.pointSize != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
17 if (pointSize != other.pointSize
pointSize != other.pointSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
18 return
never executed: return false;
false;
never executed: return false;
0
19 }
never executed: end of block
else {
0
20 return
never executed: return false;
false;
never executed: return false;
0
21 }-
22-
23 if (!ignorePitch
!ignorePitchDescription
TRUEnever evaluated
FALSEnever evaluated
&& !other.ignorePitch
!other.ignorePitchDescription
TRUEnever evaluated
FALSEnever evaluated
&& fixedPitch != other.fixedPitch
fixedPitch != other.fixedPitchDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
24 return
never executed: return false;
false;
never executed: return false;
0
25-
26 if (stretch != 0
stretch != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& other.stretch != 0
other.stretch != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& stretch != other.stretch
stretch != other.stretchDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
27 return
never executed: return false;
false;
never executed: return false;
0
28-
29 QString this_family, this_foundry, other_family, other_foundry;-
30 QFontDatabase::parseFontName(family, this_foundry, this_family);-
31 QFontDatabase::parseFontName(other.family, other_foundry, other_family);-
32-
33 this_family = QFontDatabase::resolveFontFamilyAlias(this_family);0
other_family = QFontDatabase::resolveFontFamilyAlias(other_family);return
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
(styleHint == other.styleHint
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
34 && styleStrategy == other.styleStrategy
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
0
35 && weight == other.weight
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
0
36 && style == other.style
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
0
37 && this_family == other_family
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
0
38 && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName)
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
0
39 && (this_foundry.isEmpty()
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
0
40 || other_foundry.isEmpty()
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
0
41 || this_foundry == other_foundry)
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
0
42 );
never executed: return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight && style == other.style && this_family == other_family && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName) && (this_foundry.isEmpty() || other_foundry.isEmpty() || this_foundry == other_foundry) );
0
43}-
44-
45extern bool qt_is_gui_used;-
46-
47__attribute__((visibility("default"))) int qt_defaultDpiX()-
48{-
49 if (QCoreApplication::instance()->testAttribute(Qt::AA_Use96Dpi))-
50 return 96;-
51-
52 if (!qt_is_gui_used)-
53 return 75;-
54-
55 if (const QScreen *screen = QGuiApplication::primaryScreen())-
56 return qRound(screen->logicalDotsPerInchX());-
57-
58-
59 return 100;-
60}-
61-
62__attribute__((visibility("default"))) int qt_defaultDpiY()-
63{-
64 if (QCoreApplication::instance()->testAttribute(Qt::AA_Use96Dpi))-
65 return 96;-
66-
67 if (!qt_is_gui_used)-
68 return 75;-
69-
70 if (const QScreen *screen = QGuiApplication::primaryScreen())-
71 return qRound(screen->logicalDotsPerInchY());-
72-
73-
74 return 100;-
75}-
76-
77__attribute__((visibility("default"))) int qt_defaultDpi()-
78{-
79 return qt_defaultDpiY();-
80}-
81-
82QFontPrivate::QFontPrivate()-
83 : engineData(0), dpi(qt_defaultDpi()), screen(0),-
84 underline(false), overline(false), strikeOut(false), kerning(true),-
85 capital(0), letterSpacingIsAbsolute(false), scFont(0)-
86{-
87}-
88-
89QFontPrivate::QFontPrivate(const QFontPrivate &other)-
90 : request(other.request), engineData(0), dpi(other.dpi), screen(other.screen),-
91 underline(other.underline), overline(other.overline),-
92 strikeOut(other.strikeOut), kerning(other.kerning),-
93 capital(other.capital), letterSpacingIsAbsolute(other.letterSpacingIsAbsolute),-
94 letterSpacing(other.letterSpacing), wordSpacing(other.wordSpacing),-
95 scFont(other.scFont)-
96{-
97 if (scFont && scFont != this)-
98 scFont->ref.ref();-
99}-
100-
101QFontPrivate::~QFontPrivate()-
102{-
103 if (engineData && !engineData->ref.deref())-
104 delete engineData;-
105 engineData = 0;-
106 if (scFont && scFont != this)-
107 scFont->ref.deref();-
108 scFont = 0;-
109}-
110-
111extern QMutex *qt_fontdatabase_mutex();-
112-
113-
114-
115QFontEngine *QFontPrivate::engineForScript(int script) const-
116{-
117 QMutexLocker locker(qt_fontdatabase_mutex());-
118 if (script <= QChar::Script_Latin)-
119 script = QChar::Script_Common;-
120 if (engineData && engineData->fontCacheId != QFontCache::instance()->id()) {-
121-
122 if (!engineData->ref.deref())-
123 delete engineData;-
124 engineData = 0;-
125 }-
126 if (!engineData || !engineData->engines[script])-
127 QFontDatabase::load(this, script);-
128 return engineData->engines[script];-
129}-
130-
131void QFontPrivate::alterCharForCapitalization(QChar &c) const {-
132 switch (capital) {-
133 case QFont::AllUppercase:-
134 case QFont::SmallCaps:-
135 c = c.toUpper();-
136 break;-
137 case QFont::AllLowercase:-
138 c = c.toLower();-
139 break;-
140 case QFont::MixedCase:-
141 break;-
142 }-
143}-
144-
145QFontPrivate *QFontPrivate::smallCapsFontPrivate() const-
146{-
147 if (scFont)-
148 return scFont;-
149 QFont font(const_cast<QFontPrivate *>(this));-
150 qreal pointSize = font.pointSizeF();-
151 if (pointSize > 0)-
152 font.setPointSizeF(pointSize * .7);-
153 else-
154 font.setPixelSize((font.pixelSize() * 7 + 5) / 10);-
155 scFont = font.d.data();-
156 if (scFont != this)-
157 scFont->ref.ref();-
158 return scFont;-
159}-
160-
161-
162void QFontPrivate::resolve(uint mask, const QFontPrivate *other)-
163{-
164 ((!(other != 0)) ? qt_assert("other != 0",__FILE__,251254) : qt_noop());-
165-
166 dpi = other->dpi;-
167-
168 if ((mask & QFont::AllPropertiesResolved) == QFont::AllPropertiesResolved) return;-
169-
170-
171 if (! (mask & QFont::FamilyResolved))-
172 request.family = other->request.family;-
173-
174 if (! (mask & QFont::StyleNameResolved))-
175 request.styleName = other->request.styleName;-
176-
177 if (! (mask & QFont::SizeResolved)) {-
178 request.pointSize = other->request.pointSize;-
179 request.pixelSize = other->request.pixelSize;-
180 }-
181-
182 if (! (mask & QFont::StyleHintResolved))-
183 request.styleHint = other->request.styleHint;-
184-
185 if (! (mask & QFont::StyleStrategyResolved))-
186 request.styleStrategy = other->request.styleStrategy;-
187-
188 if (! (mask & QFont::WeightResolved))-
189 request.weight = other->request.weight;-
190-
191 if (! (mask & QFont::StyleResolved))-
192 request.style = other->request.style;-
193-
194 if (! (mask & QFont::FixedPitchResolved))-
195 request.fixedPitch = other->request.fixedPitch;-
196-
197 if (! (mask & QFont::StretchResolved))-
198 request.stretch = other->request.stretch;-
199-
200 if (! (mask & QFont::HintingPreferenceResolved))-
201 request.hintingPreference = other->request.hintingPreference;-
202-
203 if (! (mask & QFont::UnderlineResolved))-
204 underline = other->underline;-
205-
206 if (! (mask & QFont::OverlineResolved))-
207 overline = other->overline;-
208-
209 if (! (mask & QFont::StrikeOutResolved))-
210 strikeOut = other->strikeOut;-
211-
212 if (! (mask & QFont::KerningResolved))-
213 kerning = other->kerning;-
214-
215 if (! (mask & QFont::LetterSpacingResolved)) {-
216 letterSpacing = other->letterSpacing;-
217 letterSpacingIsAbsolute = other->letterSpacingIsAbsolute;-
218 }-
219 if (! (mask & QFont::WordSpacingResolved))-
220 wordSpacing = other->wordSpacing;-
221 if (! (mask & QFont::CapitalizationResolved))-
222 capital = other->capital;-
223}-
224-
225-
226-
227-
228QFontEngineData::QFontEngineData()-
229 : ref(0), fontCacheId(QFontCache::instance()->id())-
230{-
231 memset(engines, 0, QChar::ScriptCount * sizeof(QFontEngine *));-
232}-
233-
234QFontEngineData::~QFontEngineData()-
235{-
236 ((!(ref.load() == 0)) ? qt_assert("ref.load() == 0",__FILE__,323326) : qt_noop());-
237 for (int i = 0; i < QChar::ScriptCount; ++i) {-
238 if (engines[i]) {-
239 if (!engines[i]->ref.deref())-
240 delete engines[i];-
241 engines[i] = 0;-
242 }-
243 }-
244}-
245QFont::QFont(const QFont &font, QPaintDevice *pd)-
246 : resolve_mask(font.resolve_mask)-
247{-
248 ((!(pd != 0)) ? qt_assert("pd != 0",__FILE__,546549) : qt_noop());-
249 int dpi = pd->logicalDpiY();-
250 const int screen = 0;-
251 if (font.d->dpi != dpi
font.d->dpi != dpiDescription
TRUEnever evaluated
FALSEnever evaluated
|| font.d->screen != screen
font.d->screen != screenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
252 d = new QFontPrivate(*font.d);-
253 d->dpi = dpi;-
254 d->screen = screen;-
255 }
never executed: end of block
else {
0
256 d = font.d.data();;-
257 }
never executed: end of block
0
258}-
259-
260-
261-
262-
263QFont::QFont(QFontPrivate *data)-
264 : d(data), resolve_mask(QFont::AllPropertiesResolved)-
265{-
266}-
267-
268-
269-
270-
271void QFont::detach()-
272{-
273 if (d->ref.load() == 1) {-
274 if (d->engineData && !d->engineData->ref.deref())-
275 delete d->engineData;-
276 d->engineData = 0;-
277 if (d->scFont && d->scFont != d.data())-
278 d->scFont->ref.deref();-
279 d->scFont = 0;-
280 return;-
281 }-
282-
283 d.detach();-
284}-
285-
286-
287-
288-
289-
290-
291-
292void QFontPrivate::detachButKeepEngineData(QFont *font)-
293{-
294 if (font->d->ref.load() == 1)-
295 return;-
296-
297 QFontEngineData *engineData = font->d->engineData;-
298 if (engineData)-
299 engineData->ref.ref();-
300 font->d.detach();-
301 font->d->engineData = engineData;-
302}-
303-
304-
305-
306-
307-
308-
309QFont::QFont()-
310 : d(QGuiApplicationPrivate::instance() ? QGuiApplication::font().d.data() : new QFontPrivate()), resolve_mask(0)-
311{-
312}-
313QFont::QFont(const QString &family, int pointSize, int weight, bool italic)-
314 : d(new QFontPrivate()), resolve_mask(QFont::FamilyResolved)-
315{-
316 if (pointSize <= 0) {-
317 pointSize = 12;-
318 } else {-
319 resolve_mask |= QFont::SizeResolved;-
320 }-
321-
322 if (weight < 0) {-
323 weight = Normal;-
324 } else {-
325 resolve_mask |= QFont::WeightResolved | QFont::StyleResolved;-
326 }-
327-
328 if (italic)-
329 resolve_mask |= QFont::StyleResolved;-
330-
331 d->request.family = family;-
332 d->request.pointSize = qreal(pointSize);-
333 d->request.pixelSize = -1;-
334 d->request.weight = weight;-
335 d->request.style = italic ? QFont::StyleItalic : QFont::StyleNormal;-
336}-
337-
338-
339-
340-
341QFont::QFont(const QFont &font)-
342 : d(font.d.data()),), resolve_mask(font.resolve_mask)-
343{-
344}
never executed: end of block
0
345-
346-
347-
348-
349QFont::~QFont()-
350{-
351}-
352-
353-
354-
355-
356QFont &QFont::operator=(const QFont &font)-
357{-
358 d = font.d.data();;-
359 resolve_mask = font.resolve_mask;-
360 return
never executed: return *this;
*this;
never executed: return *this;
0
361}-
362QString QFont::family() const-
363{-
364 return d->request.family;-
365}-
366void QFont::setFamily(const QString &family)-
367{-
368 if ((resolve_mask & QFont::FamilyResolved) && d->request.family == family)-
369 return;-
370-
371 detach();-
372-
373 d->request.family = family;-
374-
375 resolve_mask |= QFont::FamilyResolved;-
376}-
377QString QFont::styleName() const-
378{-
379 return d->request.styleName;-
380}-
381void QFont::setStyleName(const QString &styleName)-
382{-
383 if ((resolve_mask & QFont::StyleNameResolved) && d->request.styleName == styleName)-
384 return;-
385-
386 detach();-
387-
388 d->request.styleName = styleName;-
389 resolve_mask |= QFont::StyleNameResolved;-
390}-
391-
392-
393-
394-
395-
396-
397-
398int QFont::pointSize() const-
399{-
400 return qRound(d->request.pointSize);-
401}-
402void QFont::setHintingPreference(HintingPreference hintingPreference)-
403{-
404 if ((resolve_mask & QFont::HintingPreferenceResolved) && d->request.hintingPreference == hintingPreference)-
405 return;-
406-
407 detach();-
408-
409 d->request.hintingPreference = hintingPreference;-
410-
411 resolve_mask |= QFont::HintingPreferenceResolved;-
412}-
413-
414-
415-
416-
417-
418-
419QFont::HintingPreference QFont::hintingPreference() const-
420{-
421 return QFont::HintingPreference(d->request.hintingPreference);-
422}-
423-
424-
425-
426-
427-
428-
429-
430void QFont::setPointSize(int pointSize)-
431{-
432 if (pointSize <= 0) {-
433 QMessageLogger(__FILE__, 881884, __PRETTY_FUNCTION__).warning("QFont::setPointSize: Point size <= 0 (%d), must be greater than 0", pointSize);-
434 return;-
435 }-
436-
437 if ((resolve_mask & QFont::SizeResolved) && d->request.pointSize == qreal(pointSize))-
438 return;-
439-
440 detach();-
441-
442 d->request.pointSize = qreal(pointSize);-
443 d->request.pixelSize = -1;-
444-
445 resolve_mask |= QFont::SizeResolved;-
446}-
447void QFont::setPointSizeF(qreal pointSize)-
448{-
449 if (pointSize <= 0) {-
450 QMessageLogger(__FILE__, 906909, __PRETTY_FUNCTION__).warning("QFont::setPointSizeF: Point size <= 0 (%f), must be greater than 0", pointSize);-
451 return;-
452 }-
453-
454 if ((resolve_mask & QFont::SizeResolved) && d->request.pointSize == pointSize)-
455 return;-
456-
457 detach();-
458-
459 d->request.pointSize = pointSize;-
460 d->request.pixelSize = -1;-
461-
462 resolve_mask |= QFont::SizeResolved;-
463}-
464-
465-
466-
467-
468-
469-
470-
471qreal QFont::pointSizeF() const-
472{-
473 return d->request.pointSize;-
474}-
475void QFont::setPixelSize(int pixelSize)-
476{-
477 if (pixelSize <= 0) {-
478 QMessageLogger(__FILE__, 944947, __PRETTY_FUNCTION__).warning("QFont::setPixelSize: Pixel size <= 0 (%d)", pixelSize);-
479 return;-
480 }-
481-
482 if ((resolve_mask & QFont::SizeResolved) && d->request.pixelSize == qreal(pixelSize))-
483 return;-
484-
485 detach();-
486-
487 d->request.pixelSize = pixelSize;-
488 d->request.pointSize = -1;-
489-
490 resolve_mask |= QFont::SizeResolved;-
491}-
492int QFont::pixelSize() const-
493{-
494 return d->request.pixelSize;-
495}-
496QFont::Style QFont::style() const-
497{-
498 return (QFont::Style)d->request.style;-
499}-
500-
501-
502-
503-
504-
505-
506-
507void QFont::setStyle(Style style)-
508{-
509 if ((resolve_mask & QFont::StyleResolved) && d->request.style == style)-
510 return;-
511-
512 detach();-
513-
514 d->request.style = style;-
515 resolve_mask |= QFont::StyleResolved;-
516}-
517-
518-
519-
520-
521-
522-
523-
524int QFont::weight() const-
525{-
526 return d->request.weight;-
527}-
528void QFont::setWeight(int weight)-
529{-
530 ((!(weight >= 0 && weight <= 99)) ? qt_assert_x("QFont::setWeight", "Weight must be between 0 and 99",__FILE__,10541057) : qt_noop());-
531-
532 if ((resolve_mask & QFont::WeightResolved) && d->request.weight == weight)-
533 return;-
534-
535 detach();-
536-
537 d->request.weight = weight;-
538 resolve_mask |= QFont::WeightResolved;-
539}-
540bool QFont::underline() const-
541{-
542 return d->underline;-
543}-
544-
545-
546-
547-
548-
549-
550-
551void QFont::setUnderline(bool enable)-
552{-
553 if ((resolve_mask & QFont::UnderlineResolved) && d->underline == enable)-
554 return;-
555-
556 QFontPrivate::detachButKeepEngineData(this);-
557-
558 d->underline = enable;-
559 resolve_mask |= QFont::UnderlineResolved;-
560}-
561-
562-
563-
564-
565-
566-
567bool QFont::overline() const-
568{-
569 return d->overline;-
570}-
571-
572-
573-
574-
575-
576-
577void QFont::setOverline(bool enable)-
578{-
579 if ((resolve_mask & QFont::OverlineResolved) && d->overline == enable)-
580 return;-
581-
582 QFontPrivate::detachButKeepEngineData(this);-
583-
584 d->overline = enable;-
585 resolve_mask |= QFont::OverlineResolved;-
586}-
587-
588-
589-
590-
591-
592-
593bool QFont::strikeOut() const-
594{-
595 return d->strikeOut;-
596}-
597-
598-
599-
600-
601-
602-
603-
604void QFont::setStrikeOut(bool enable)-
605{-
606 if ((resolve_mask & QFont::StrikeOutResolved) && d->strikeOut == enable)-
607 return;-
608-
609 QFontPrivate::detachButKeepEngineData(this);-
610-
611 d->strikeOut = enable;-
612 resolve_mask |= QFont::StrikeOutResolved;-
613}-
614-
615-
616-
617-
618-
619-
620bool QFont::fixedPitch() const-
621{-
622 return d->request.fixedPitch;-
623}-
624-
625-
626-
627-
628-
629-
630-
631void QFont::setFixedPitch(bool enable)-
632{-
633 if ((resolve_mask & QFont::FixedPitchResolved) && d->request.fixedPitch == enable)-
634 return;-
635-
636 detach();-
637-
638 d->request.fixedPitch = enable;-
639 d->request.ignorePitch = false;-
640 resolve_mask |= QFont::FixedPitchResolved;-
641}-
642-
643-
644-
645-
646-
647-
648bool QFont::kerning() const-
649{-
650 return d->kerning;-
651}-
652void QFont::setKerning(bool enable)-
653{-
654 if ((resolve_mask & QFont::KerningResolved) && d->kerning == enable)-
655 return;-
656-
657 QFontPrivate::detachButKeepEngineData(this);-
658-
659 d->kerning = enable;-
660 resolve_mask |= QFont::KerningResolved;-
661}-
662QFont::StyleStrategy QFont::styleStrategy() const-
663{-
664 return (StyleStrategy) d->request.styleStrategy;-
665}-
666QFont::StyleHint QFont::styleHint() const-
667{-
668 return (StyleHint) d->request.styleHint;-
669}-
670void QFont::setStyleHint(StyleHint hint, StyleStrategy strategy)-
671{-
672 if ((resolve_mask & (QFont::StyleHintResolved | QFont::StyleStrategyResolved)) &&-
673 (StyleHint) d->request.styleHint == hint &&-
674 (StyleStrategy) d->request.styleStrategy == strategy)-
675 return;-
676-
677 detach();-
678-
679 d->request.styleHint = hint;-
680 d->request.styleStrategy = strategy;-
681 resolve_mask |= QFont::StyleHintResolved;-
682 resolve_mask |= QFont::StyleStrategyResolved;-
683-
684}-
685-
686-
687-
688-
689-
690-
691void QFont::setStyleStrategy(StyleStrategy s)-
692{-
693 if ((resolve_mask & QFont::StyleStrategyResolved) &&-
694 s == (StyleStrategy)d->request.styleStrategy)-
695 return;-
696-
697 detach();-
698-
699 d->request.styleStrategy = s;-
700 resolve_mask |= QFont::StyleStrategyResolved;-
701}-
702int QFont::stretch() const-
703{-
704 return d->request.stretch;-
705}-
706void QFont::setStretch(int factor)-
707{-
708 if (factor < 1 || factor > 4000) {-
709 QMessageLogger(__FILE__, 14161419, __PRETTY_FUNCTION__).warning("QFont::setStretch: Parameter '%d' out of range", factor);-
710 return;-
711 }-
712-
713 if ((resolve_mask & QFont::StretchResolved) &&-
714 d->request.stretch == (uint)factor)-
715 return;-
716-
717 detach();-
718-
719 d->request.stretch = (uint)factor;-
720 resolve_mask |= QFont::StretchResolved;-
721}-
722qreal QFont::letterSpacing() const-
723{-
724 return d->letterSpacing.toReal();-
725}-
726void QFont::setLetterSpacing(SpacingType type, qreal spacing)-
727{-
728 const QFixed newSpacing = QFixed::fromReal(spacing);-
729 const bool absoluteSpacing = type == AbsoluteSpacing;-
730 if ((resolve_mask & QFont::LetterSpacingResolved) &&-
731 d->letterSpacingIsAbsolute == absoluteSpacing &&-
732 d->letterSpacing == newSpacing)-
733 return;-
734-
735 QFontPrivate::detachButKeepEngineData(this);-
736-
737 d->letterSpacing = newSpacing;-
738 d->letterSpacingIsAbsolute = absoluteSpacing;-
739 resolve_mask |= QFont::LetterSpacingResolved;-
740}-
741-
742-
743-
744-
745-
746-
747-
748QFont::SpacingType QFont::letterSpacingType() const-
749{-
750 return d->letterSpacingIsAbsolute ? AbsoluteSpacing : PercentageSpacing;-
751}-
752-
753-
754-
755-
756-
757-
758-
759qreal QFont::wordSpacing() const-
760{-
761 return d->wordSpacing.toReal();-
762}-
763void QFont::setWordSpacing(qreal spacing)-
764{-
765 const QFixed newSpacing = QFixed::fromReal(spacing);-
766 if ((resolve_mask & QFont::WordSpacingResolved) &&-
767 d->wordSpacing == newSpacing)-
768 return;-
769-
770 QFontPrivate::detachButKeepEngineData(this);-
771-
772 d->wordSpacing = newSpacing;-
773 resolve_mask |= QFont::WordSpacingResolved;-
774}-
775void QFont::setCapitalization(Capitalization caps)-
776{-
777 if ((resolve_mask & QFont::CapitalizationResolved) &&-
778 capitalization() == caps)-
779 return;-
780-
781 QFontPrivate::detachButKeepEngineData(this);-
782-
783 d->capital = caps;-
784 resolve_mask |= QFont::CapitalizationResolved;-
785}-
786-
787-
788-
789-
790-
791-
792-
793QFont::Capitalization QFont::capitalization() const-
794{-
795 return static_cast<QFont::Capitalization> (d->capital);-
796}-
797void QFont::setRawMode(bool)-
798{-
799}-
800bool QFont::exactMatch() const-
801{-
802 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
803 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,16071610) : qt_noop());-
804 return d->request.exactMatch(engine->fontDef);-
805}-
806bool QFont::operator==(const QFont &f) const-
807{-
808 return (f.d == d-
809 || (f.d->request == d->request-
810 && f.d->request.pointSize == d->request.pointSize-
811 && f.d->underline == d->underline-
812 && f.d->overline == d->overline-
813 && f.d->strikeOut == d->strikeOut-
814 && f.d->kerning == d->kerning-
815 && f.d->capital == d->capital-
816 && f.d->letterSpacingIsAbsolute == d->letterSpacingIsAbsolute-
817 && f.d->letterSpacing == d->letterSpacing-
818 && f.d->wordSpacing == d->wordSpacing-
819 ));-
820}-
821bool QFont::operator<(const QFont &f) const-
822{-
823 if (f.d == d
f.d == dDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return false;
false;
never executed: return false;
0
824-
825 const QFontDef &r1 = f.d->request;-
826 const QFontDef &r2 = d->request;-
827 if (r1.pointSize != r2.pointSize
r1.pointSize != r2.pointSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return r1.pointSize < r2.pointSize;
r1.pointSize < r2.pointSize;
never executed: return r1.pointSize < r2.pointSize;
0
828 if (r1.pixelSize != r2.pixelSize
r1.pixelSize != r2.pixelSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return r1.pixelSize < r2.pixelSize;
r1.pixelSize < r2.pixelSize;
never executed: return r1.pixelSize < r2.pixelSize;
0
829 if (r1.weight != r2.weight
r1.weight != r2.weightDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return r1.weight < r2.weight;
r1.weight < r2.weight;
never executed: return r1.weight < r2.weight;
0
830 if (r1.style != r2.style
r1.style != r2.styleDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return r1.style < r2.style;
r1.style < r2.style;
never executed: return r1.style < r2.style;
0
831 if (r1.stretch != r2.stretch
r1.stretch != r2.stretchDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return r1.stretch < r2.stretch;
r1.stretch < r2.stretch;
never executed: return r1.stretch < r2.stretch;
0
832 if (r1.styleHint != r2.styleHint
r1.styleHint != r2.styleHintDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return r1.styleHint < r2.styleHint;
r1.styleHint < r2.styleHint;
never executed: return r1.styleHint < r2.styleHint;
0
833 if (r1.styleStrategy != r2.styleStrategy
r1.styleStrate....styleStrategyDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return r1.styleStrategy < r2.styleStrategy;
r1.styleStrategy < r2.styleStrategy;
never executed: return r1.styleStrategy < r2.styleStrategy;
0
834 if (r1.family != r2.family
r1.family != r2.familyDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return r1.family < r2.family;
r1.family < r2.family;
never executed: return r1.family < r2.family;
0
835 if (f.d->capital != d->capital
f.d->capital != d->capitalDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return f.d->capital < d->capital;
f.d->capital < d->capital;
never executed: return f.d->capital < d->capital;
0
836-
837 if (f.d->letterSpacingIsAbsolute != d->letterSpacingIsAbsolute
f.d->letterSpa...cingIsAbsoluteDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return f.d->letterSpacingIsAbsolute < d->letterSpacingIsAbsolute;
f.d->letterSpacingIsAbsolute < d->letterSpacingIsAbsolute;
never executed: return f.d->letterSpacingIsAbsolute < d->letterSpacingIsAbsolute;
0
838 if (f.d->letterSpacing != d->letterSpacing
f.d->letterSpa...>letterSpacingDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return f.d->letterSpacing < d->letterSpacing;
f.d->letterSpacing < d->letterSpacing;
never executed: return f.d->letterSpacing < d->letterSpacing;
0
839 if (f.d->wordSpacing != d->wordSpacing
f.d->wordSpaci...d->wordSpacingDescription
TRUEnever evaluated
FALSEnever evaluated
) return
never executed: return f.d->wordSpacing < d->wordSpacing;
f.d->wordSpacing < d->wordSpacing;
never executed: return f.d->wordSpacing < d->wordSpacing;
0
840-
841 int f1attrs = (f.d->underline << 3) + (f.d->overline << 2) + (f.d->strikeOut<<1) + f.d->kerning;-
842 int f2attrs = (d->underline << 3) + (d->overline << 2) + (d->strikeOut<<1) + d->kerning;-
843 return
never executed: return f1attrs < f2attrs;
f1attrs < f2attrs;
never executed: return f1attrs < f2attrs;
0
844}-
845bool QFont::operator!=(const QFont &f) const-
846{-
847 return !(operator==(f));-
848}-
849-
850-
851-
852-
853QFont::operator QVariant() const-
854{-
855 return QVariant(QVariant::Font, this);-
856}-
857bool QFont::isCopyOf(const QFont & f) const-
858{-
859 return d == f.d;-
860}-
861bool QFont::rawMode() const-
862{-
863 return false;-
864}-
865-
866-
867-
868-
869-
870-
871QFont QFont::resolve(const QFont &other) const-
872{-
873 if (resolve_mask == 0 || (resolve_mask == other.resolve_mask && *this == other)) {-
874 QFont o(other);-
875 o.resolve_mask = resolve_mask;-
876 return o;-
877 }-
878-
879 QFont font(*this);-
880 font.detach();-
881 font.d->resolve(resolve_mask, other.d.data());-
882-
883 return font;-
884}-
885typedef QHash<QString, QStringList> QFontSubst;-
886namespace { namespace Q_QGS_globalFontSubst { typedef QFontSubst Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QFontSubst, Q_QGS_globalFontSubst::innerFunction, Q_QGS_globalFontSubst::guard> globalFontSubst;-
887QString QFont::substitute(const QString &familyName)-
888{-
889 QFontSubst *fontSubst = globalFontSubst();-
890 ((!(fontSubst != 0)) ? qt_assert("fontSubst != 0",__FILE__,17741777) : qt_noop());-
891 QFontSubst::ConstIterator it = fontSubst->constFind(familyName.toLower());-
892 if (it != fontSubst->constEnd() && !(*it).isEmpty())-
893 return (*it).first();-
894-
895 return familyName;-
896}-
897QStringList QFont::substitutes(const QString &familyName)-
898{-
899 QFontSubst *fontSubst = globalFontSubst();-
900 ((!(fontSubst != 0)) ? qt_assert("fontSubst != 0",__FILE__,17951798) : qt_noop());-
901 return fontSubst->value(familyName.toLower(), QStringList());-
902}-
903void QFont::insertSubstitution(const QString &familyName,-
904 const QString &substituteName)-
905{-
906 QFontSubst *fontSubst = globalFontSubst();-
907 ((!(fontSubst != 0)) ? qt_assert("fontSubst != 0",__FILE__,18101813) : qt_noop());-
908 QStringList &list = (*fontSubst)[familyName.toLower()];-
909 QString s = substituteName.toLower();-
910 if (!list.contains(s))-
911 list.append(s);-
912}-
913void QFont::insertSubstitutions(const QString &familyName,-
914 const QStringList &substituteNames)-
915{-
916 QFontSubst *fontSubst = globalFontSubst();-
917 ((!(fontSubst != 0)) ? qt_assert("fontSubst != 0",__FILE__,18281831) : qt_noop());-
918 QStringList &list = (*fontSubst)[familyName.toLower()];-
919 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(substituteNames)>::type> _container_((substituteNames)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QString &substituteName = *_container_.i; _container_.control; _container_.control = 0: substituteNames) {-
920 const QString lowerSubstituteName = substituteName.toLower();-
921 if (!list.contains(lowerSubstituteName)
!list.contains...ubstituteName)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
922 list.append(lowerSubstituteName);
never executed: list.append(lowerSubstituteName);
0
923 }
never executed: end of block
0
924}
never executed: end of block
0
925-
926-
927-
928-
929-
930-
931-
932void QFont::removeSubstitutions(const QString &familyName)-
933{-
934 QFontSubst *fontSubst = globalFontSubst();-
935 ((!(fontSubst != 0)) ? qt_assert("fontSubst != 0",__FILE__,18461849) : qt_noop());-
936 fontSubst->remove(familyName.toLower());-
937}-
938QStringList QFont::substitutions()-
939{-
940 QFontSubst *fontSubst = globalFontSubst();-
941 ((!(fontSubst != 0)) ? qt_assert("fontSubst != 0",__FILE__,18661869) : qt_noop());-
942 QStringList ret = fontSubst->keys();-
943-
944 ret.sort();-
945 return ret;-
946}-
947-
948-
949-
950-
951-
952-
953static quint8 get_font_bits(int version, const QFontPrivate *f)-
954{-
955 ((!(f != 0)) ? qt_assert("f != 0",__FILE__,18801883) : qt_noop());-
956 quint8 bits = 0;-
957 if (f->request.style)-
958 bits |= 0x01;-
959 if (f->underline)-
960 bits |= 0x02;-
961 if (f->overline)-
962 bits |= 0x40;-
963 if (f->strikeOut)-
964 bits |= 0x04;-
965 if (f->request.fixedPitch)-
966 bits |= 0x08;-
967-
968-
969 if (version >= QDataStream::Qt_4_0) {-
970 if (f->kerning)-
971 bits |= 0x10;-
972 }-
973 if (f->request.style == QFont::StyleOblique)-
974 bits |= 0x80;-
975 return bits;-
976}-
977-
978static quint8 get_extended_font_bits(const QFontPrivate *f)-
979{-
980 ((!(f != 0)) ? qt_assert("f != 0",__FILE__,19051908) : qt_noop());-
981 quint8 bits = 0;-
982 if (f->request.ignorePitch)-
983 bits |= 0x01;-
984 if (f->letterSpacingIsAbsolute)-
985 bits |= 0x02;-
986 return bits;-
987}-
988-
989-
990-
991-
992-
993static void set_font_bits(int version, quint8 bits, QFontPrivate *f)-
994{-
995 ((!(f != 0)) ? qt_assert("f != 0",__FILE__,19201923) : qt_noop());-
996 f->request.style = (bits & 0x01) != 0 ? QFont::StyleItalic : QFont::StyleNormal;-
997 f->underline = (bits & 0x02) != 0;-
998 f->overline = (bits & 0x40) != 0;-
999 f->strikeOut = (bits & 0x04) != 0;-
1000 f->request.fixedPitch = (bits & 0x08) != 0;-
1001-
1002 if (version >= QDataStream::Qt_4_0)-
1003 f->kerning = (bits & 0x10) != 0;-
1004 if ((bits & 0x80) != 0)-
1005 f->request.style = QFont::StyleOblique;-
1006}-
1007-
1008static void set_extended_font_bits(quint8 bits, QFontPrivate *f)-
1009{-
1010 ((!(f != 0)) ? qt_assert("f != 0",__FILE__,19351938) : qt_noop());-
1011 f->request.ignorePitch = (bits & 0x01) != 0;-
1012 f->letterSpacingIsAbsolute = (bits & 0x02) != 0;-
1013}-
1014QString QFont::rawName() const-
1015{-
1016 return QLatin1String("unknown");-
1017}-
1018void QFont::setRawName(const QString &)-
1019{-
1020}-
1021QString QFont::key() const-
1022{-
1023 return toString();-
1024}-
1025QString QFont::toString() const-
1026{-
1027 const QChar comma(QLatin1Char(','));-
1028 return family() + comma +-
1029 QString::number( pointSizeF()) + comma +-
1030 QString::number( pixelSize()) + comma +-
1031 QString::number((int) styleHint()) + comma +-
1032 QString::number( weight()) + comma +-
1033 QString::number((int) style()) + comma +-
1034 QString::number((int) underline()) + comma +-
1035 QString::number((int) strikeOut()) + comma +-
1036 QString::number((int)fixedPitch()) + comma +-
1037 QString::number((int) false);-
1038}-
1039uint qHash(const QFont &font, uint seed) noexcept-
1040{-
1041 return
never executed: return qHash(QFontPrivate::get(font)->request, seed);
qHash(QFontPrivate::get(font)->request, seed);
never executed: return qHash(QFontPrivate::get(font)->request, seed);
0
1042}-
1043bool QFont::fromString(const QString &descrip)-
1044{-
1045 QStringListconst auto l (= descrip.splitsplitRef(QLatin1Char(',')));));-
1046-
1047 int count = l.count();-
1048 if (!count
!countDescription
TRUEnever evaluated
FALSEnever evaluated
|| (count > 2
count > 2Description
TRUEnever evaluated
FALSEnever evaluated
&& count < 9
count < 9Description
TRUEnever evaluated
FALSEnever evaluated
) || count > 11
count > 11Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1049 QMessageLogger(__FILE__, 20392042, __PRETTY_FUNCTION__).warning("QFont::fromString: Invalid description '%s'",-
1050 descrip.isEmpty() ? "(empty)" : descrip.toLatin1().data());-
1051 return
never executed: return false;
false;
never executed: return false;
0
1052 }-
1053-
1054 setFamily(l[0]);].toString());-
1055 if (count > 1
count > 1Description
TRUEnever evaluated
FALSEnever evaluated
&& l[1].toDouble() > 0.0
l[1].toDouble() > 0.0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1056 setPointSizeF(l[1].toDouble());
never executed: setPointSizeF(l[1].toDouble());
0
1057 if (count == 9
count == 9Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1058 setStyleHint((StyleHint) l[2].toInt());-
1059 setWeight(qMax(qMin(99, l[3].toInt()), 0));-
1060 setItalic(l[4].toInt());-
1061 setUnderline(l[5].toInt());-
1062 setStrikeOut(l[6].toInt());-
1063 setFixedPitch(l[7].toInt());-
1064 }
never executed: end of block
else if (count == 10
count == 10Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1065 if (l[2].toInt() > 0
l[2].toInt() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1066 setPixelSize(l[2].toInt());
never executed: setPixelSize(l[2].toInt());
0
1067 setStyleHint((StyleHint) l[3].toInt());-
1068 setWeight(qMax(qMin(99, l[4].toInt()), 0));-
1069 setStyle((QFont::Style)l[5].toInt());-
1070 setUnderline(l[6].toInt());-
1071 setStrikeOut(l[7].toInt());-
1072 setFixedPitch(l[8].toInt());-
1073 }
never executed: end of block
0
1074 if (count >= 9
count >= 9Description
TRUEnever evaluated
FALSEnever evaluated
&& !d->request.fixedPitch
!d->request.fixedPitchDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1075 d->request.ignorePitch = true;
never executed: d->request.ignorePitch = true;
0
1076-
1077 return
never executed: return true;
true;
never executed: return true;
0
1078}-
1079void QFont::initialize()-
1080{-
1081}-
1082-
1083-
1084-
1085-
1086-
1087-
1088void QFont::cleanup()-
1089{-
1090 QFontCache::cleanup();-
1091}-
1092-
1093-
1094-
1095-
1096-
1097void QFont::cacheStatistics()-
1098{-
1099}-
1100QString QFont::lastResortFamily() const-
1101{-
1102 return QString::fromLatin1("helvetica");-
1103}-
1104-
1105extern QStringList qt_fallbacksForFamily(const QString &family, QFont::Style style,-
1106 QFont::StyleHint styleHint, QChar::Script script);-
1107QString QFont::defaultFamily() const-
1108{-
1109 const QStringList fallbacks = qt_fallbacksForFamily(QString(), QFont::StyleNormal-
1110 , QFont::StyleHint(d->request.styleHint), QChar::Script_Common);-
1111 if (!fallbacks.isEmpty())-
1112 return fallbacks.first();-
1113 return QString();-
1114}-
1115QString QFont::lastResortFont() const-
1116{-
1117 QMessageLogger(__FILE__, 21582161, __PRETTY_FUNCTION__).fatal("QFont::lastResortFont: Cannot find any reasonable font");-
1118-
1119 return QString();-
1120}-
1121QDataStream &operator<<(QDataStream &s, const QFont &font)-
1122{-
1123 if (s.version() == 1) {-
1124 s << font.d->request.family.toLatin1();-
1125 } else {-
1126 s << font.d->request.family;-
1127 if (s.version() >= QDataStream::Qt_5_4)-
1128 s << font.d->request.styleName;-
1129 }-
1130-
1131 if (s.version() >= QDataStream::Qt_4_0) {-
1132-
1133 double pointSize = font.d->request.pointSize;-
1134 qint32 pixelSize = font.d->request.pixelSize;-
1135 s << pointSize;-
1136 s << pixelSize;-
1137 } else if (s.version() <= 3) {-
1138 qint16 pointSize = (qint16) (font.d->request.pointSize * 10);-
1139 if (pointSize < 0) {-
1140 pointSize = (qint16)QFontInfo(font).pointSize() * 10;-
1141 }-
1142 s << pointSize;-
1143 } else {-
1144 s << (qint16) (font.d->request.pointSize * 10);-
1145 s << (qint16) font.d->request.pixelSize;-
1146 }-
1147-
1148 s << (quint8) font.d->request.styleHint;-
1149 if (s.version() >= QDataStream::Qt_3_1) {-
1150-
1151-
1152 if (s.version() >= QDataStream::Qt_5_4)-
1153 s << (quint16) font.d->request.styleStrategy;-
1154 else-
1155 s << (quint8) font.d->request.styleStrategy;-
1156 }-
1157 s << (quint8) 0-
1158 << (quint8) font.d->request.weight-
1159 << get_font_bits(s.version(), font.d.data());-
1160 if (s.version() >= QDataStream::Qt_4_3)-
1161 s << (quint16)font.d->request.stretch;-
1162 if (s.version() >= QDataStream::Qt_4_4)-
1163 s << get_extended_font_bits(font.d.data());-
1164 if (s.version() >= QDataStream::Qt_4_5) {-
1165 s << font.d->letterSpacing.value();-
1166 s << font.d->wordSpacing.value();-
1167 }-
1168 if (s.version() >= QDataStream::Qt_5_4)-
1169 s << (quint8)font.d->request.hintingPreference;-
1170 if (s.version() >= QDataStream::Qt_5_6)-
1171 s << (quint8)font.d->capital;-
1172 return s;-
1173}-
1174QDataStream &operator>>(QDataStream &s, QFont &font)-
1175{-
1176 font.d = new QFontPrivate;-
1177 font.resolve_mask = QFont::AllPropertiesResolved;-
1178-
1179 quint8 styleHint, charSet, weight, bits;-
1180 quint16 styleStrategy = QFont::PreferDefault;-
1181-
1182 if (s.version() == 1) {-
1183 QByteArray fam;-
1184 s >> fam;-
1185 font.d->request.family = QString::fromLatin1(fam);-
1186 } else {-
1187 s >> font.d->request.family;-
1188 if (s.version() >= QDataStream::Qt_5_4)-
1189 s >> font.d->request.styleName;-
1190 }-
1191-
1192 if (s.version() >= QDataStream::Qt_4_0) {-
1193-
1194 double pointSize;-
1195 qint32 pixelSize;-
1196 s >> pointSize;-
1197 s >> pixelSize;-
1198 font.d->request.pointSize = qreal(pointSize);-
1199 font.d->request.pixelSize = pixelSize;-
1200 } else {-
1201 qint16 pointSize, pixelSize = -1;-
1202 s >> pointSize;-
1203 if (s.version() >= 4)-
1204 s >> pixelSize;-
1205 font.d->request.pointSize = qreal(pointSize / 10.);-
1206 font.d->request.pixelSize = pixelSize;-
1207 }-
1208 s >> styleHint;-
1209 if (s.version() >= QDataStream::Qt_3_1) {-
1210 if (s.version() >= QDataStream::Qt_5_4) {-
1211 s >> styleStrategy;-
1212 } else {-
1213 quint8 tempStyleStrategy;-
1214 s >> tempStyleStrategy;-
1215 styleStrategy = tempStyleStrategy;-
1216 }-
1217 }-
1218-
1219 s >> charSet;-
1220 s >> weight;-
1221 s >> bits;-
1222-
1223 font.d->request.styleHint = styleHint;-
1224 font.d->request.styleStrategy = styleStrategy;-
1225 font.d->request.weight = weight;-
1226-
1227 set_font_bits(s.version(), bits, font.d.data());-
1228-
1229 if (s.version() >= QDataStream::Qt_4_3) {-
1230 quint16 stretch;-
1231 s >> stretch;-
1232 font.d->request.stretch = stretch;-
1233 }-
1234-
1235 if (s.version() >= QDataStream::Qt_4_4) {-
1236 quint8 extendedBits;-
1237 s >> extendedBits;-
1238 set_extended_font_bits(extendedBits, font.d.data());-
1239 }-
1240 if (s.version() >= QDataStream::Qt_4_5) {-
1241 int value;-
1242 s >> value;-
1243 font.d->letterSpacing.setValue(value);-
1244 s >> value;-
1245 font.d->wordSpacing.setValue(value);-
1246 }-
1247 if (s.version() >= QDataStream::Qt_5_4) {-
1248 quint8 value;-
1249 s >> value;-
1250 font.d->request.hintingPreference = QFont::HintingPreference(value);-
1251 }-
1252 if (s.version() >= QDataStream::Qt_5_6) {-
1253 quint8 value;-
1254 s >> value;-
1255 font.d->capital = QFont::Capitalization(value);-
1256 }-
1257 return s;-
1258}-
1259QFontInfo::QFontInfo(const QFont &font)-
1260 : d(font.d.data()))-
1261{-
1262}
never executed: end of block
0
1263-
1264-
1265-
1266-
1267QFontInfo::QFontInfo(const QFontInfo &fi)-
1268 : d(fi.d.data()))-
1269{-
1270}
never executed: end of block
0
1271-
1272-
1273-
1274-
1275QFontInfo::~QFontInfo()-
1276{-
1277}-
1278-
1279-
1280-
1281-
1282QFontInfo &QFontInfo::operator=(const QFontInfo &fi)-
1283{-
1284 d = fi.d.data();;-
1285 return
never executed: return *this;
*this;
never executed: return *this;
0
1286}-
1287QString QFontInfo::family() const-
1288{-
1289 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1290 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,24372440) : qt_noop());-
1291 return engine->fontDef.family;-
1292}-
1293QString QFontInfo::styleName() const-
1294{-
1295 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1296 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,24522455) : qt_noop());-
1297 return engine->fontDef.styleName;-
1298}-
1299-
1300-
1301-
1302-
1303-
1304-
1305int QFontInfo::pointSize() const-
1306{-
1307 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1308 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,24642467) : qt_noop());-
1309 return qRound(engine->fontDef.pointSize);-
1310}-
1311-
1312-
1313-
1314-
1315-
1316-
1317qreal QFontInfo::pointSizeF() const-
1318{-
1319 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1320 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,24762479) : qt_noop());-
1321 return engine->fontDef.pointSize;-
1322}-
1323-
1324-
1325-
1326-
1327-
1328-
1329int QFontInfo::pixelSize() const-
1330{-
1331 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1332 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,24882491) : qt_noop());-
1333 return engine->fontDef.pixelSize;-
1334}-
1335-
1336-
1337-
1338-
1339-
1340-
1341bool QFontInfo::italic() const-
1342{-
1343 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1344 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,25002503) : qt_noop());-
1345 return engine->fontDef.style != QFont::StyleNormal;-
1346}-
1347-
1348-
1349-
1350-
1351-
1352-
1353QFont::Style QFontInfo::style() const-
1354{-
1355 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1356 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,25122515) : qt_noop());-
1357 return (QFont::Style)engine->fontDef.style;-
1358}-
1359-
1360-
1361-
1362-
1363-
1364-
1365int QFontInfo::weight() const-
1366{-
1367 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1368 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,25242527) : qt_noop());-
1369 return engine->fontDef.weight;-
1370-
1371}-
1372bool QFontInfo::underline() const-
1373{-
1374 return d->underline;-
1375}-
1376bool QFontInfo::overline() const-
1377{-
1378 return d->overline;-
1379}-
1380bool QFontInfo::strikeOut() const-
1381{-
1382 return d->strikeOut;-
1383}-
1384-
1385-
1386-
1387-
1388-
1389-
1390bool QFontInfo::fixedPitch() const-
1391{-
1392 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1393 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,25892592) : qt_noop());-
1394 return engine->fontDef.fixedPitch;-
1395}-
1396QFont::StyleHint QFontInfo::styleHint() const-
1397{-
1398 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1399 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,26152618) : qt_noop());-
1400 return (QFont::StyleHint) engine->fontDef.styleHint;-
1401}-
1402bool QFontInfo::rawMode() const-
1403{-
1404 return false;-
1405}-
1406bool QFontInfo::exactMatch() const-
1407{-
1408 QFontEngine *engine = d->engineForScript(QChar::Script_Common);-
1409 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,26472650) : qt_noop());-
1410 return d->request.exactMatch(engine->fontDef);-
1411}-
1412static const int fast_timeout = 10000;-
1413static const int slow_timeout = 300000;-
1414-
1415-
1416const uint QFontCache::min_cost = 4*1024;-
1417namespace { namespace Q_QGS_theFontCache { typedef QThreadStorage<QFontCache *> Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QThreadStorage<QFontCache *>, Q_QGS_theFontCache::innerFunction, Q_QGS_theFontCache::guard> theFontCache;-
1418-
1419QFontCache *QFontCache::instance()-
1420{-
1421 QFontCache *&fontCache = theFontCache()->localData();-
1422 if (!fontCache)-
1423 fontCache = new QFontCache;-
1424 return fontCache;-
1425}-
1426-
1427void QFontCache::cleanup()-
1428{-
1429 QThreadStorage<QFontCache *> *cache = 0;-
1430 if (true) {-
1431 cache = theFontCache();-
1432 } else {
dead code: { }
-
1433-
1434 }
dead code: { }
-
1435 if (cache && cache->hasLocalData())-
1436 cache->setLocalData(0);-
1437}-
1438-
1439-
1440QBasicAtomicInt font_cache_id = { 1 };-
1441-
1442QFontCache::QFontCache()-
1443 : QObject(), total_cost(0), max_cost(min_cost),-
1444 current_timestamp(0), fast(false), timer_id(-1),-
1445 m_id(font_cache_id.fetchAndAddRelaxed(1))-
1446{-
1447}-
1448-
1449QFontCache::~QFontCache()-
1450{-
1451 clear();-
1452}-
1453-
1454void QFontCache::clear()-
1455{-
1456 {-
1457 EngineDataCache::Iterator it = engineDataCache.begin(),-
1458 end = engineDataCache.end();-
1459 while (it != end) {-
1460 QFontEngineData *data = it.value();-
1461 for (int i = 0; i < QChar::ScriptCount; ++i) {-
1462 if (data->engines[i]) {-
1463 if (!data->engines[i]->ref.deref()) {-
1464 ((!(engineCacheCount.value(data->engines[i]) == 0)) ? qt_assert("engineCacheCount.value(data->engines[i]) == 0",__FILE__,27282731) : qt_noop());-
1465 delete data->engines[i];-
1466 }-
1467 data->engines[i] = 0;-
1468 }-
1469 }-
1470 if (!data->ref.deref()) {-
1471 delete data;-
1472 } else {-
1473 if (false) QMessageLogger(__FILE__, 27372740, __PRETTY_FUNCTION__).debug("QFontCache::clear: engineData %p still has refcount %d",
dead code: QMessageLogger(__FILE__, 2740, __PRETTY_FUNCTION__).debug("QFontCache::clear: engineData %p still has refcount %d", data, data->ref.load());
-
1474 data, data->ref.load());
dead code: QMessageLogger(__FILE__, 2740, __PRETTY_FUNCTION__).debug("QFontCache::clear: engineData %p still has refcount %d", data, data->ref.load());
-
1475 }-
1476 ++it;-
1477 }-
1478 }-
1479-
1480 engineDataCache.clear();-
1481-
1482-
1483 bool mightHaveEnginesLeftForCleanup;-
1484 do {-
1485 mightHaveEnginesLeftForCleanup = false;-
1486 for (EngineCache::Iterator it = engineCache.begin(), end = engineCache.end();-
1487 it != end; ++it) {-
1488 QFontEngine *engine = it.value().data;-
1489 if (engine) {-
1490 const int cacheCount = --engineCacheCount[engine];-
1491 ((!(cacheCount >= 0)) ? qt_assert("cacheCount >= 0",__FILE__,27552758) : qt_noop());-
1492 if (!engine->ref.deref()) {-
1493 ((!(cacheCount == 0)) ? qt_assert("cacheCount == 0",__FILE__,27572760) : qt_noop());-
1494 mightHaveEnginesLeftForCleanup = engine->type() == QFontEngine::Multi;-
1495 delete engine;-
1496 } else if (cacheCount == 0) {-
1497 if (false) QMessageLogger(__FILE__, 27612764, __PRETTY_FUNCTION__).debug("QFontCache::clear: engine %p still has refcount %d",
dead code: QMessageLogger(__FILE__, 2764, __PRETTY_FUNCTION__).debug("QFontCache::clear: engine %p still has refcount %d", engine, engine->ref.load());
-
1498 engine, engine->ref.load());
dead code: QMessageLogger(__FILE__, 2764, __PRETTY_FUNCTION__).debug("QFontCache::clear: engine %p still has refcount %d", engine, engine->ref.load());
-
1499 }-
1500 it.value().data = 0;-
1501 }-
1502 }-
1503 } while (mightHaveEnginesLeftForCleanup);-
1504-
1505 engineCache.clear();-
1506 engineCacheCount.clear();-
1507-
1508-
1509 total_cost = 0;-
1510 max_cost = min_cost;-
1511}-
1512-
1513-
1514QFontEngineData *QFontCache::findEngineData(const QFontDef &def) const-
1515{-
1516 EngineDataCache::ConstIterator it = engineDataCache.constFind(def);-
1517 if (it == engineDataCache.constEnd())-
1518 return 0;-
1519-
1520-
1521 return it.value();-
1522}-
1523-
1524void QFontCache::insertEngineData(const QFontDef &def, QFontEngineData *engineData)-
1525{-
1526 ((!(!engineDataCache.contains(def))) ? qt_assert("!engineDataCache.contains(def)",__FILE__,27982801) : qt_noop());-
1527-
1528 engineData->ref.ref();-
1529-
1530 if (total_cost > min_cost * 2 && engineDataCache.size() >= 256)-
1531 decreaseCache();-
1532-
1533 engineDataCache.insert(def, engineData);-
1534 increaseCost(sizeof(QFontEngineData));-
1535}-
1536-
1537QFontEngine *QFontCache::findEngine(const Key &key)-
1538{-
1539 EngineCache::Iterator it = engineCache.find(key),-
1540 end = engineCache.end();-
1541 if (it == end) return 0;-
1542-
1543 ((!(it.value().data != nullptr)) ? qt_assert("it.value().data != Q_NULLPTR",__FILE__,28152818) : qt_noop());-
1544 ((!(key.multi == (it.value().data->type() == QFontEngine::Multi))) ? qt_assert("key.multi == (it.value().data->type() == QFontEngine::Multi)",__FILE__,28162819) : qt_noop());-
1545-
1546-
1547 updateHitCountAndTimeStamp(it.value());-
1548-
1549 return it.value().data;-
1550}-
1551-
1552void QFontCache::updateHitCountAndTimeStamp(Engine &value)-
1553{-
1554 value.hits++;-
1555 value.timestamp = ++current_timestamp;-
1556-
1557 if (false) QMessageLogger(__FILE__, 28292832, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n"
dead code: QMessageLogger(__FILE__, 2832, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", value.data, value.timestamp, value.hits, value.data->ref.load(), engineCacheCount.value(value.data), value.data->type());
-
1558 " %p: timestamp %4u hits %3u ref %2d/%2d, type %d",
dead code: QMessageLogger(__FILE__, 2832, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", value.data, value.timestamp, value.hits, value.data->ref.load(), engineCacheCount.value(value.data), value.data->type());
-
1559 value.data, value.timestamp, value.hits,
dead code: QMessageLogger(__FILE__, 2832, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", value.data, value.timestamp, value.hits, value.data->ref.load(), engineCacheCount.value(value.data), value.data->type());
-
1560 value.data->ref.load(), engineCacheCount.value(value.data),
dead code: QMessageLogger(__FILE__, 2832, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", value.data, value.timestamp, value.hits, value.data->ref.load(), engineCacheCount.value(value.data), value.data->type());
-
1561 value.data->type());
dead code: QMessageLogger(__FILE__, 2832, __PRETTY_FUNCTION__).debug("QFontCache: found font engine\n" " %p: timestamp %4u hits %3u ref %2d/%2d, type %d", value.data, value.timestamp, value.hits, value.data->ref.load(), engineCacheCount.value(value.data), value.data->type());
-
1562}-
1563-
1564void QFontCache::insertEngine(const Key &key, QFontEngine *engine, bool insertMulti)-
1565{-
1566 ((!(engine != nullptr)) ? qt_assert("engine != Q_NULLPTR",__FILE__,28382841) : qt_noop());-
1567 ((!(key.multi == (engine->type() == QFontEngine::Multi))) ? qt_assert("key.multi == (engine->type() == QFontEngine::Multi)",__FILE__,28392842) : qt_noop());-
1568 engine->ref.ref();-
1569-
1570 if (total_cost > min_cost * 2 && engineCache.size() >= 256)-
1571 decreaseCache();-
1572-
1573 Engine data(engine);-
1574 data.timestamp = ++current_timestamp;-
1575-
1576 if (insertMulti)-
1577 engineCache.insertMulti(key, data);-
1578 else-
1579 engineCache.insert(key, data);-
1580-
1581 if (++engineCacheCount[engine] == 1)-
1582 increaseCost(engine->cache_cost);-
1583}-
1584-
1585void QFontCache::increaseCost(uint cost)-
1586{-
1587 cost = (cost + 512) / 1024;-
1588 cost = cost > 0 ? cost : 1;-
1589 total_cost += cost;-
1590-
1591 if (false) QMessageLogger(__FILE__, 28722875, __PRETTY_FUNCTION__).debug(" COST: increased %u kb, total_cost %u kb, max_cost %u kb",
dead code: QMessageLogger(__FILE__, 2875, __PRETTY_FUNCTION__).debug(" COST: increased %u kb, total_cost %u kb, max_cost %u kb", cost, total_cost, max_cost);
-
1592 cost, total_cost, max_cost);
dead code: QMessageLogger(__FILE__, 2875, __PRETTY_FUNCTION__).debug(" COST: increased %u kb, total_cost %u kb, max_cost %u kb", cost, total_cost, max_cost);
-
1593-
1594 if (total_cost > max_cost) {-
1595 max_cost = total_cost;-
1596-
1597 if (timer_id == -1 || ! fast) {-
1598 if (false) QMessageLogger(__FILE__, 28792882, __PRETTY_FUNCTION__).debug(" TIMER: starting fast timer (%d ms)", fast_timeout);
dead code: QMessageLogger(__FILE__, 2882, __PRETTY_FUNCTION__).debug(" TIMER: starting fast timer (%d ms)", fast_timeout);
-
1599-
1600 if (timer_id != -1) killTimer(timer_id);-
1601 timer_id = startTimer(fast_timeout);-
1602 fast = true;-
1603 }-
1604 }-
1605}-
1606-
1607void QFontCache::decreaseCost(uint cost)-
1608{-
1609 cost = (cost + 512) / 1024;-
1610 cost = cost > 0 ? cost : 1;-
1611 ((!(cost <= total_cost)) ? qt_assert("cost <= total_cost",__FILE__,28922895) : qt_noop());-
1612 total_cost -= cost;-
1613-
1614 if (false) QMessageLogger(__FILE__, 28952898, __PRETTY_FUNCTION__).debug(" COST: decreased %u kb, total_cost %u kb, max_cost %u kb",
dead code: QMessageLogger(__FILE__, 2898, __PRETTY_FUNCTION__).debug(" COST: decreased %u kb, total_cost %u kb, max_cost %u kb", cost, total_cost, max_cost);
-
1615 cost, total_cost, max_cost);
dead code: QMessageLogger(__FILE__, 2898, __PRETTY_FUNCTION__).debug(" COST: decreased %u kb, total_cost %u kb, max_cost %u kb", cost, total_cost, max_cost);
-
1616}-
1617-
1618void QFontCache::timerEvent(QTimerEvent *)-
1619{-
1620 if (false) QMessageLogger(__FILE__, 29012904, __PRETTY_FUNCTION__).debug("QFontCache::timerEvent: performing cache maintenance (timestamp %u)",
dead code: QMessageLogger(__FILE__, 2904, __PRETTY_FUNCTION__).debug("QFontCache::timerEvent: performing cache maintenance (timestamp %u)", current_timestamp);
-
1621 current_timestamp);
dead code: QMessageLogger(__FILE__, 2904, __PRETTY_FUNCTION__).debug("QFontCache::timerEvent: performing cache maintenance (timestamp %u)", current_timestamp);
-
1622-
1623 if (total_cost <= max_cost && max_cost <= min_cost) {-
1624 if (false) QMessageLogger(__FILE__, 29052908, __PRETTY_FUNCTION__).debug(" cache redused sufficiently, stopping timer");
dead code: QMessageLogger(__FILE__, 2908, __PRETTY_FUNCTION__).debug(" cache redused sufficiently, stopping timer");
-
1625-
1626 killTimer(timer_id);-
1627 timer_id = -1;-
1628 fast = false;-
1629-
1630 return;-
1631 }-
1632 decreaseCache();-
1633}-
1634-
1635void QFontCache::decreaseCache()-
1636{-
1637-
1638 uint in_use_cost = 0;-
1639-
1640 {-
1641 if (false) QMessageLogger(__FILE__, 29222925, __PRETTY_FUNCTION__).debug(" SWEEP engine data:");
dead code: QMessageLogger(__FILE__, 2925, __PRETTY_FUNCTION__).debug(" SWEEP engine data:");
-
1642-
1643-
1644 const uint engine_data_cost =-
1645 sizeof(QFontEngineData) > 1024 ? sizeof(QFontEngineData) : 1024;-
1646-
1647 EngineDataCache::ConstIterator it = engineDataCache.constBegin(),-
1648 end = engineDataCache.constEnd();-
1649 for (; it != end; ++it) {-
1650 if (false) QMessageLogger(__FILE__, 29312934, __PRETTY_FUNCTION__).debug(" %p: ref %2d", it.value(), int(it.value()->ref.load()));
dead code: QMessageLogger(__FILE__, 2934, __PRETTY_FUNCTION__).debug(" %p: ref %2d", it.value(), int(it.value()->ref.load()));
-
1651-
1652 if (it.value()->ref.load() != 1)-
1653 in_use_cost += engine_data_cost;-
1654 }-
1655 }-
1656-
1657 {-
1658 if (false) QMessageLogger(__FILE__, 29392942, __PRETTY_FUNCTION__).debug(" SWEEP engine:");
dead code: QMessageLogger(__FILE__, 2942, __PRETTY_FUNCTION__).debug(" SWEEP engine:");
-
1659-
1660 EngineCache::ConstIterator it = engineCache.constBegin(),-
1661 end = engineCache.constEnd();-
1662 for (; it != end; ++it) {-
1663 if (false) QMessageLogger(__FILE__, 29442947, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes",
dead code: QMessageLogger(__FILE__, 2947, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->cache_cost);
-
1664 it.value().data, it.value().timestamp, it.value().hits,
dead code: QMessageLogger(__FILE__, 2947, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->cache_cost);
-
1665 it.value().data->ref.load(), engineCacheCount.value(it.value().data),
dead code: QMessageLogger(__FILE__, 2947, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->cache_cost);
-
1666 it.value().data->cache_cost);
dead code: QMessageLogger(__FILE__, 2947, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->cache_cost);
-
1667-
1668 if (it.value().data->ref.load() != 0)-
1669 in_use_cost += it.value().data->cache_cost / engineCacheCount.value(it.value().data);-
1670 }-
1671-
1672-
1673 in_use_cost += engineCache.size();-
1674 }-
1675-
1676 in_use_cost = (in_use_cost + 512) / 1024;-
1677 uint new_max_cost = qMax(qMax(max_cost / 2, in_use_cost), min_cost);-
1678-
1679 if (false) QMessageLogger(__FILE__, 29692972, __PRETTY_FUNCTION__).debug(" after sweep, in use %u kb, total %u kb, max %u kb, new max %u kb",
dead code: QMessageLogger(__FILE__, 2972, __PRETTY_FUNCTION__).debug(" after sweep, in use %u kb, total %u kb, max %u kb, new max %u kb", in_use_cost, total_cost, max_cost, new_max_cost);
-
1680 in_use_cost, total_cost, max_cost, new_max_cost);
dead code: QMessageLogger(__FILE__, 2972, __PRETTY_FUNCTION__).debug(" after sweep, in use %u kb, total %u kb, max %u kb, new max %u kb", in_use_cost, total_cost, max_cost, new_max_cost);
-
1681-
1682 if (new_max_cost == max_cost) {-
1683 if (fast) {-
1684 if (false) QMessageLogger(__FILE__, 29742977, __PRETTY_FUNCTION__).debug(" cannot shrink cache, slowing timer");
dead code: QMessageLogger(__FILE__, 2977, __PRETTY_FUNCTION__).debug(" cannot shrink cache, slowing timer");
-
1685-
1686 killTimer(timer_id);-
1687 timer_id = startTimer(slow_timeout);-
1688 fast = false;-
1689 }-
1690-
1691 return;-
1692 } else if (! fast) {-
1693 if (false) QMessageLogger(__FILE__, 29832986, __PRETTY_FUNCTION__).debug(" dropping into passing gear");
dead code: QMessageLogger(__FILE__, 2986, __PRETTY_FUNCTION__).debug(" dropping into passing gear");
-
1694-
1695 killTimer(timer_id);-
1696 timer_id = startTimer(fast_timeout);-
1697 fast = true;-
1698 }-
1699-
1700 max_cost = new_max_cost;-
1701-
1702 {-
1703 if (false) QMessageLogger(__FILE__, 29932996, __PRETTY_FUNCTION__).debug(" CLEAN engine data:");
dead code: QMessageLogger(__FILE__, 2996, __PRETTY_FUNCTION__).debug(" CLEAN engine data:");
-
1704-
1705-
1706 EngineDataCache::Iterator it = engineDataCache.begin();-
1707 while (it != engineDataCache.end()) {-
1708 if (it.value()->ref.load() == 1) {-
1709 if (false) QMessageLogger(__FILE__, 29993002, __PRETTY_FUNCTION__).debug(" %p", it.value());
dead code: QMessageLogger(__FILE__, 3002, __PRETTY_FUNCTION__).debug(" %p", it.value());
-
1710 decreaseCost(sizeof(QFontEngineData));-
1711 it.value()->ref.deref();-
1712 delete it.value();-
1713 it = engineDataCache.erase(it);-
1714 } else {-
1715 ++it;-
1716 }-
1717 }-
1718 }-
1719-
1720 if (false) QMessageLogger(__FILE__, 30103013, __PRETTY_FUNCTION__).debug(" CLEAN engine:");
dead code: QMessageLogger(__FILE__, 3013, __PRETTY_FUNCTION__).debug(" CLEAN engine:");
-
1721-
1722-
1723 bool cost_decreased;-
1724 do {-
1725 cost_decreased = false;-
1726-
1727 EngineCache::Iterator it = engineCache.begin(),-
1728 end = engineCache.end();-
1729-
1730 uint oldest = ~0u;-
1731 uint least_popular = ~0u;-
1732-
1733 EngineCache::Iterator jt = end;-
1734-
1735 for ( ; it != end; ++it) {-
1736 if (it.value().data->ref.load() != engineCacheCount.value(it.value().data))-
1737 continue;-
1738-
1739 if (it.value().timestamp < oldest && it.value().hits <= least_popular) {-
1740 oldest = it.value().timestamp;-
1741 least_popular = it.value().hits;-
1742 jt = it;-
1743 }-
1744 }-
1745-
1746 it = jt;-
1747 if (it != end) {-
1748 if (false) QMessageLogger(__FILE__, 30383041, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, type %d",
dead code: QMessageLogger(__FILE__, 3041, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, type %d", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->type());
-
1749 it.value().data, it.value().timestamp, it.value().hits,
dead code: QMessageLogger(__FILE__, 3041, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, type %d", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->type());
-
1750 it.value().data->ref.load(), engineCacheCount.value(it.value().data),
dead code: QMessageLogger(__FILE__, 3041, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, type %d", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->type());
-
1751 it.value().data->type());
dead code: QMessageLogger(__FILE__, 3041, __PRETTY_FUNCTION__).debug(" %p: timestamp %4u hits %2u ref %2d/%2d, type %d", it.value().data, it.value().timestamp, it.value().hits, it.value().data->ref.load(), engineCacheCount.value(it.value().data), it.value().data->type());
-
1752-
1753 QFontEngine *fontEngine = it.value().data;-
1754-
1755 it = engineCache.begin();-
1756 while (it != engineCache.end()) {-
1757 if (it.value().data == fontEngine) {-
1758 fontEngine->ref.deref();-
1759 it = engineCache.erase(it);-
1760 } else {-
1761 ++it;-
1762 }-
1763 }-
1764-
1765 ((!(fontEngine->ref.load() == 0)) ? qt_assert("fontEngine->ref.load() == 0",__FILE__,30553058) : qt_noop());-
1766 decreaseCost(fontEngine->cache_cost);-
1767 delete fontEngine;-
1768 engineCacheCount.remove(fontEngine);-
1769-
1770 cost_decreased = true;-
1771 }-
1772 } while (cost_decreased && total_cost > max_cost);-
1773}-
1774-
1775-
1776-
1777QDebug operator<<(QDebug stream, const QFont &font)-
1778{-
1779 return stream << "QFont(" << font.toString() << ')';-
1780}-
1781-
1782-
1783-
Switch to Source codePreprocessed file

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