text/qrawfont.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7QRawFont::QRawFont() -
8 : d(new QRawFontPrivate) -
9{ -
10}
executed: }
Execution Count:203591
203591
11QRawFont::QRawFont(const QString &fileName, -
12 qreal pixelSize, -
13 QFont::HintingPreference hintingPreference) -
14 : d(new QRawFontPrivate) -
15{ -
16 loadFromFile(fileName, pixelSize, hintingPreference); -
17}
executed: }
Execution Count:1233
1233
18QRawFont::QRawFont(const QByteArray &fontData, -
19 qreal pixelSize, -
20 QFont::HintingPreference hintingPreference) -
21 : d(new QRawFontPrivate) -
22{ -
23 loadFromData(fontData, pixelSize, hintingPreference); -
24}
never executed: }
0
25 -
26 -
27 -
28 -
29QRawFont::QRawFont(const QRawFont &other) -
30{ -
31 d = other.d; -
32}
executed: }
Execution Count:70
70
33 -
34 -
35 -
36 -
37QRawFont::~QRawFont() -
38{ -
39} -
40 -
41 -
42 -
43 -
44QRawFont &QRawFont::operator=(const QRawFont &other) -
45{ -
46 d = other.d; -
47 return *this;
executed: return *this;
Execution Count:50
50
48} -
49bool QRawFont::isValid() const -
50{ -
51 return d->isValid();
executed: return d->isValid();
Execution Count:1292
1292
52} -
53void QRawFont::loadFromFile(const QString &fileName, -
54 qreal pixelSize, -
55 QFont::HintingPreference hintingPreference) -
56{ -
57 QFile file(fileName); -
58 if (file.open(QIODevice::ReadOnly))
partially evaluated: file.open(QIODevice::ReadOnly)
TRUEFALSE
yes
Evaluation Count:1245
no
Evaluation Count:0
0-1245
59 loadFromData(file.readAll(), pixelSize, hintingPreference);
executed: loadFromData(file.readAll(), pixelSize, hintingPreference);
Execution Count:1245
1245
60}
executed: }
Execution Count:1245
1245
61void QRawFont::loadFromData(const QByteArray &fontData, -
62 qreal pixelSize, -
63 QFont::HintingPreference hintingPreference) -
64{ -
65 d.detach(); -
66 d->cleanUp(); -
67 d->hintingPreference = hintingPreference; -
68 d->thread = QThread::currentThread(); -
69 d->platformLoadFromData(fontData, pixelSize, hintingPreference); -
70}
executed: }
Execution Count:1247
1247
71QImage QRawFont::alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialiasingType, -
72 const QTransform &transform) const -
73{ -
74 if (!d->isValid())
never evaluated: !d->isValid()
0
75 return QImage();
never executed: return QImage();
0
76 -
77 if (antialiasingType == SubPixelAntialiasing)
never evaluated: antialiasingType == SubPixelAntialiasing
0
78 return d->fontEngine->alphaRGBMapForGlyph(glyphIndex, QFixed(), transform);
never executed: return d->fontEngine->alphaRGBMapForGlyph(glyphIndex, QFixed(), transform);
0
79 -
80 return d->fontEngine->alphaMapForGlyph(glyphIndex, QFixed(), transform);
never executed: return d->fontEngine->alphaMapForGlyph(glyphIndex, QFixed(), transform);
0
81} -
82QPainterPath QRawFont::pathForGlyph(quint32 glyphIndex) const -
83{ -
84 if (!d->isValid())
never evaluated: !d->isValid()
0
85 return QPainterPath();
never executed: return QPainterPath();
0
86 -
87 QFixedPoint position; -
88 QPainterPath path; -
89 d->fontEngine->addGlyphsToPath(&glyphIndex, &position, 1, &path, 0); -
90 return path;
never executed: return path;
0
91} -
92 -
93 -
94 -
95 -
96bool QRawFont::operator==(const QRawFont &other) const -
97{ -
98 return d->fontEngine == other.d->fontEngine;
executed: return d->fontEngine == other.d->fontEngine;
Execution Count:7
7
99} -
100qreal QRawFont::ascent() const -
101{ -
102 return d->isValid() ? d->fontEngine->ascent().toReal() : 0.0;
executed: return d->isValid() ? d->fontEngine->ascent().toReal() : 0.0;
Execution Count:79
79
103} -
104 -
105 -
106 -
107 -
108 -
109 -
110qreal QRawFont::descent() const -
111{ -
112 return d->isValid() ? d->fontEngine->descent().toReal() : 0.0;
executed: return d->isValid() ? d->fontEngine->descent().toReal() : 0.0;
Execution Count:56
56
113} -
114 -
115 -
116 -
117 -
118 -
119 -
120qreal QRawFont::xHeight() const -
121{ -
122 return d->isValid() ? d->fontEngine->xHeight().toReal() : 0.0;
never executed: return d->isValid() ? d->fontEngine->xHeight().toReal() : 0.0;
0
123} -
124 -
125 -
126 -
127 -
128 -
129 -
130qreal QRawFont::leading() const -
131{ -
132 return d->isValid() ? d->fontEngine->leading().toReal() : 0.0;
never executed: return d->isValid() ? d->fontEngine->leading().toReal() : 0.0;
0
133} -
134 -
135 -
136 -
137 -
138 -
139 -
140qreal QRawFont::averageCharWidth() const -
141{ -
142 return d->isValid() ? d->fontEngine->averageCharWidth().toReal() : 0.0;
never executed: return d->isValid() ? d->fontEngine->averageCharWidth().toReal() : 0.0;
0
143} -
144 -
145 -
146 -
147 -
148 -
149 -
150qreal QRawFont::maxCharWidth() const -
151{ -
152 return d->isValid() ? d->fontEngine->maxCharWidth() : 0.0;
never executed: return d->isValid() ? d->fontEngine->maxCharWidth() : 0.0;
0
153} -
154qreal QRawFont::pixelSize() const -
155{ -
156 return d->isValid() ? d->fontEngine->fontDef.pixelSize : 0.0;
executed: return d->isValid() ? d->fontEngine->fontDef.pixelSize : 0.0;
Execution Count:79
79
157} -
158qreal QRawFont::unitsPerEm() const -
159{ -
160 return d->isValid() ? d->fontEngine->emSquareSize().toReal() : 0.0;
executed: return d->isValid() ? d->fontEngine->emSquareSize().toReal() : 0.0;
Execution Count:8
8
161} -
162 -
163 -
164 -
165 -
166 -
167qreal QRawFont::lineThickness() const -
168{ -
169 return d->isValid() ? d->fontEngine->lineThickness().toReal() : 0.0;
never executed: return d->isValid() ? d->fontEngine->lineThickness().toReal() : 0.0;
0
170} -
171 -
172 -
173 -
174 -
175 -
176qreal QRawFont::underlinePosition() const -
177{ -
178 return d->isValid() ? d->fontEngine->underlinePosition().toReal() : 0.0;
never executed: return d->isValid() ? d->fontEngine->underlinePosition().toReal() : 0.0;
0
179} -
180 -
181 -
182 -
183 -
184QString QRawFont::familyName() const -
185{ -
186 return d->isValid() ? d->fontEngine->fontDef.family : QString();
executed: return d->isValid() ? d->fontEngine->fontDef.family : QString();
Execution Count:84
84
187} -
188 -
189 -
190 -
191 -
192 -
193 -
194QString QRawFont::styleName() const -
195{ -
196 return d->isValid() ? d->fontEngine->fontDef.styleName : QString();
never executed: return d->isValid() ? d->fontEngine->fontDef.styleName : QString();
0
197} -
198 -
199 -
200 -
201 -
202 -
203 -
204QFont::Style QRawFont::style() const -
205{ -
206 return d->isValid() ? QFont::Style(d->fontEngine->fontDef.style) : QFont::StyleNormal;
executed: return d->isValid() ? QFont::Style(d->fontEngine->fontDef.style) : QFont::StyleNormal;
Execution Count:11
11
207} -
208 -
209 -
210 -
211 -
212 -
213 -
214int QRawFont::weight() const -
215{ -
216 return d->isValid() ? int(d->fontEngine->fontDef.weight) : -1;
executed: return d->isValid() ? int(d->fontEngine->fontDef.weight) : -1;
Execution Count:9
9
217} -
218QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const -
219{ -
220 QVector<quint32> glyphIndexes; -
221 if (!d->isValid() || text.isEmpty())
evaluated: !d->isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
evaluated: text.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-3
222 return glyphIndexes;
executed: return glyphIndexes;
Execution Count:2
2
223 -
224 int numGlyphs = text.size(); -
225 glyphIndexes.resize(numGlyphs); -
226 -
227 QGlyphLayout glyphs; -
228 glyphs.numGlyphs = numGlyphs; -
229 glyphs.glyphs = glyphIndexes.data(); -
230 if (!d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &numGlyphs, QFontEngine::GlyphIndicesOnly)) {
partially evaluated: !d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &numGlyphs, QFontEngine::GlyphIndicesOnly)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
231 glyphIndexes.resize(numGlyphs); -
232 -
233 glyphs.numGlyphs = numGlyphs; -
234 glyphs.glyphs = glyphIndexes.data(); -
235 if (!d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &numGlyphs, QFontEngine::GlyphIndicesOnly)) {
never evaluated: !d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &numGlyphs, QFontEngine::GlyphIndicesOnly)
0
236 qt_noop(); -
237 return QVector<quint32>();
never executed: return QVector<quint32>();
0
238 } -
239 }
never executed: }
0
240 -
241 glyphIndexes.resize(numGlyphs); -
242 return glyphIndexes;
executed: return glyphIndexes;
Execution Count:2
2
243} -
244bool QRawFont::glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const -
245{ -
246 qt_noop(); -
247 if (!d->isValid() || numChars <= 0) {
partially evaluated: !d->isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
evaluated: numChars <= 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
0-3
248 *numGlyphs = 0; -
249 return false;
executed: return false;
Execution Count:1
1
250 } -
251 -
252 if (*numGlyphs <= 0 || !glyphIndexes) {
evaluated: *numGlyphs <= 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
partially evaluated: !glyphIndexes
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
253 *numGlyphs = numChars; -
254 return false;
executed: return false;
Execution Count:1
1
255 } -
256 -
257 QGlyphLayout glyphs; -
258 glyphs.numGlyphs = *numGlyphs; -
259 glyphs.glyphs = glyphIndexes; -
260 return d->fontEngine->stringToCMap(chars, numChars, &glyphs, numGlyphs, QFontEngine::GlyphIndicesOnly);
executed: return d->fontEngine->stringToCMap(chars, numChars, &glyphs, numGlyphs, QFontEngine::GlyphIndicesOnly);
Execution Count:1
1
261} -
262bool QRawFont::advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const -
263{ -
264 qt_noop(); -
265 if (!d->isValid() || numGlyphs <= 0)
partially evaluated: !d->isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
evaluated: numGlyphs <= 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:9
0-17
266 return false;
executed: return false;
Execution Count:8
8
267 -
268 QGlyphLayout glyphs; -
269 glyphs.glyphs = const_cast<HB_Glyph *>(glyphIndexes); -
270 glyphs.numGlyphs = numGlyphs; -
271 QVarLengthArray<QFixed> advances_x(numGlyphs); -
272 QVarLengthArray<QFixed> advances_y(numGlyphs); -
273 glyphs.advances_x = advances_x.data(); -
274 glyphs.advances_y = advances_y.data(); -
275 -
276 d->fontEngine->recalcAdvances(&glyphs, 0); -
277 -
278 for (int i=0; i<numGlyphs; ++i)
evaluated: i<numGlyphs
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:9
9-53
279 advances[i] = QPointF(glyphs.advances_x[i].toReal(), glyphs.advances_y[i].toReal());
executed: advances[i] = QPointF(glyphs.advances_x[i].toReal(), glyphs.advances_y[i].toReal());
Execution Count:53
53
280 -
281 return true;
executed: return true;
Execution Count:9
9
282} -
283 -
284 -
285 -
286 -
287 -
288 -
289QFont::HintingPreference QRawFont::hintingPreference() const -
290{ -
291 return d->isValid() ? d->hintingPreference : QFont::PreferDefaultHinting;
executed: return d->isValid() ? d->hintingPreference : QFont::PreferDefaultHinting;
Execution Count:32
32
292} -
293 -
294 -
295 -
296 -
297 -
298 -
299 -
300QByteArray QRawFont::fontTable(const char *tagName) const -
301{ -
302 if (!d->isValid())
partially evaluated: !d->isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44
0-44
303 return QByteArray();
never executed: return QByteArray();
0
304 -
305 const quint32 *tagId = reinterpret_cast<const quint32 *>(tagName); -
306 return d->fontEngine->getSfntTable(qToBigEndian(*tagId));
executed: return d->fontEngine->getSfntTable(qToBigEndian(*tagId));
Execution Count:44
44
307} -
308 -
309 -
310extern QList<QFontDatabase::WritingSystem> qt_determine_writing_systems_from_truetype_bits(quint32 unicodeRange[4], quint32 codePageRange[2]); -
311QList<QFontDatabase::WritingSystem> QRawFont::supportedWritingSystems() const -
312{ -
313 if (d->isValid()) {
partially evaluated: d->isValid()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
314 QByteArray os2Table = fontTable("OS/2"); -
315 if (os2Table.size() > 86) {
partially evaluated: os2Table.size() > 86
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
316 char *data = os2Table.data(); -
317 quint32 *bigEndianUnicodeRanges = reinterpret_cast<quint32 *>(data + 42); -
318 quint32 *bigEndianCodepageRanges = reinterpret_cast<quint32 *>(data + 78); -
319 -
320 quint32 unicodeRanges[4]; -
321 quint32 codepageRanges[2]; -
322 -
323 for (int i=0; i<4; ++i) {
evaluated: i<4
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:8
8-32
324 if (i < 2)
evaluated: i < 2
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:16
16
325 codepageRanges[i] = qFromBigEndian(bigEndianCodepageRanges[i]);
executed: codepageRanges[i] = qFromBigEndian(bigEndianCodepageRanges[i]);
Execution Count:16
16
326 unicodeRanges[i] = qFromBigEndian(bigEndianUnicodeRanges[i]); -
327 }
executed: }
Execution Count:32
32
328 -
329 return qt_determine_writing_systems_from_truetype_bits(unicodeRanges, codepageRanges);
executed: return qt_determine_writing_systems_from_truetype_bits(unicodeRanges, codepageRanges);
Execution Count:8
8
330 } -
331 }
never executed: }
0
332 -
333 return QList<QFontDatabase::WritingSystem>();
never executed: return QList<QFontDatabase::WritingSystem>();
0
334} -
335 -
336 -
337 -
338 -
339 -
340 -
341bool QRawFont::supportsCharacter(QChar character) const -
342{ -
343 return d->isValid() && d->fontEngine->canRender(&character, 1);
executed: return d->isValid() && d->fontEngine->canRender(&character, 1);
Execution Count:976
976
344} -
345bool QRawFont::supportsCharacter(uint ucs4) const -
346{ -
347 return d->isValid() && d->fontEngine->canRender(ucs4);
executed: return d->isValid() && d->fontEngine->canRender(ucs4);
Execution Count:216
216
348} -
349 -
350 -
351extern int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem); -
352QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writingSystem) -
353{ -
354 QRawFont rawFont; -
355 QFontPrivate *font_d = QFontPrivate::get(font); -
356 int script = qt_script_for_writing_system(writingSystem); -
357 QFontEngine *fe = font_d->engineForScript(script); -
358 -
359 if (fe != 0 && fe->type() == QFontEngine::Multi) {
partially evaluated: fe != 0
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
partially evaluated: fe->type() == QFontEngine::Multi
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
360 QFontEngineMulti *multiEngine = static_cast<QFontEngineMulti *>(fe); -
361 fe = multiEngine->engine(0); -
362 if (fe == 0) {
partially evaluated: fe == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
363 multiEngine->loadEngine(0); -
364 fe = multiEngine->engine(0); -
365 }
never executed: }
0
366 }
executed: }
Execution Count:32
32
367 -
368 if (fe != 0) {
partially evaluated: fe != 0
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
369 rawFont.d.data()->fontEngine = fe; -
370 rawFont.d.data()->fontEngine->ref.ref(); -
371 rawFont.d.data()->hintingPreference = font.hintingPreference(); -
372 }
executed: }
Execution Count:32
32
373 return rawFont;
executed: return rawFont;
Execution Count:32
32
374} -
375 -
376 -
377 -
378 -
379void QRawFont::setPixelSize(qreal pixelSize) -
380{ -
381 if (d->fontEngine == 0 || qFuzzyCompare(d->fontEngine->fontDef.pixelSize, pixelSize))
partially evaluated: d->fontEngine == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
partially evaluated: qFuzzyCompare(d->fontEngine->fontDef.pixelSize, pixelSize)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
382 return;
never executed: return;
0
383 -
384 d.detach(); -
385 QFontEngine *oldFontEngine = d->fontEngine; -
386 -
387 d->fontEngine = d->fontEngine->cloneWithSize(pixelSize); -
388 if (d->fontEngine != 0)
partially evaluated: d->fontEngine != 0
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
389 d->fontEngine->ref.ref();
executed: d->fontEngine->ref.ref();
Execution Count:4
4
390 -
391 oldFontEngine->ref.deref(); -
392 if (oldFontEngine->cache_count == 0 && oldFontEngine->ref.load() == 0)
partially evaluated: oldFontEngine->cache_count == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
never evaluated: oldFontEngine->ref.load() == 0
0-4
393 delete oldFontEngine;
never executed: delete oldFontEngine;
0
394}
executed: }
Execution Count:4
4
395 -
396 -
397 -
398 -
399void QRawFontPrivate::cleanUp() -
400{ -
401 platformCleanUp(); -
402 if (fontEngine != 0) {
evaluated: fontEngine != 0
TRUEFALSE
yes
Evaluation Count:1318
yes
Evaluation Count:204750
1318-204750
403 fontEngine->ref.deref(); -
404 if (fontEngine->cache_count == 0 && fontEngine->ref.load() == 0)
evaluated: fontEngine->cache_count == 0
TRUEFALSE
yes
Evaluation Count:1263
yes
Evaluation Count:55
evaluated: fontEngine->ref.load() == 0
TRUEFALSE
yes
Evaluation Count:1251
yes
Evaluation Count:12
12-1263
405 delete fontEngine;
executed: delete fontEngine;
Execution Count:1251
1251
406 fontEngine = 0; -
407 }
executed: }
Execution Count:1318
1318
408 hintingPreference = QFont::PreferDefaultHinting; -
409}
executed: }
Execution Count:206068
206068
410 -
411 -
412 -
413 -
414 -
415 -
416QRectF QRawFont::boundingRect(quint32 glyphIndex) const -
417{ -
418 if (!isValid())
partially evaluated: !isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
419 return QRectF();
never executed: return QRectF();
0
420 -
421 glyph_metrics_t gm = d->fontEngine->boundingBox(glyphIndex); -
422 return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
Execution Count:10
10
423} -
424 -
425 -
426 -
427 -
428 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial