qfontengine_qpf2.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qfontengine_qpf2.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9static const QFontEngineQPF2::TagType tagTypes[QFontEngineQPF2::NumTags] = {-
10 QFontEngineQPF2::StringType,-
11 QFontEngineQPF2::StringType,-
12 QFontEngineQPF2::UInt32Type,-
13 QFontEngineQPF2::UInt32Type,-
14 QFontEngineQPF2::StringType,-
15 QFontEngineQPF2::FixedType,-
16 QFontEngineQPF2::FixedType,-
17 QFontEngineQPF2::FixedType,-
18 QFontEngineQPF2::FixedType,-
19 QFontEngineQPF2::FixedType,-
20 QFontEngineQPF2::FixedType,-
21 QFontEngineQPF2::FixedType,-
22 QFontEngineQPF2::FixedType,-
23 QFontEngineQPF2::FixedType,-
24 QFontEngineQPF2::FixedType,-
25 QFontEngineQPF2::UInt8Type,-
26 QFontEngineQPF2::UInt8Type,-
27 QFontEngineQPF2::UInt8Type,-
28 QFontEngineQPF2::UInt8Type,-
29 QFontEngineQPF2::StringType,-
30 QFontEngineQPF2::BitFieldType-
31};-
32template <typename T>-
33T readValue(const uchar *&data)-
34{-
35 T value = qFromBigEndian<T>(data);-
36 data += sizeof(T);-
37 return
never executed: return value;
value;
never executed: return value;
0
38}-
39static inline const uchar *verifyTag(const uchar *tagPtr, const uchar *endPtr)-
40{-
41 quint16 tag, length;-
42 if (tagPtr + sizeof(quint16) > endPtr
tagPtr + sizeo...nt16) > endPtrDescription
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 121, __PRETTY_FUNCTION__).debug() << "read verify failed in line" << 121;
dead code: QMessageLogger(__FILE__, 121, __PRETTY_FUNCTION__).debug() << "read verify failed in line" << 121;
return
never executed: return 0;
0;
never executed: return 0;
} tag = qFromBigEndian<quint16>(tagPtr); if (0) QMessageLogger(__FILE__, 121, __PRETTY_FUNCTION__).debug() << "read value" << tag << "of type " "quint16";
dead code: QMessageLogger(__FILE__, 121, __PRETTY_FUNCTION__).debug() << "read value" << tag << "of type " "quint16";
tagPtr += sizeof(quint16);
-
43 if (tagPtr + sizeof(quint16) > endPtr
tagPtr + sizeo...nt16) > endPtrDescription
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 122, __PRETTY_FUNCTION__).debug() << "read verify failed in line" << 122;
dead code: QMessageLogger(__FILE__, 122, __PRETTY_FUNCTION__).debug() << "read verify failed in line" << 122;
return
never executed: return 0;
0;
never executed: return 0;
} length = qFromBigEndian<quint16>(tagPtr); if (0) QMessageLogger(__FILE__, 122, __PRETTY_FUNCTION__).debug() << "read value" << length << "of type " "quint16";
dead code: QMessageLogger(__FILE__, 122, __PRETTY_FUNCTION__).debug() << "read value" << length << "of type " "quint16";
tagPtr += sizeof(quint16);
-
44 if (tag == QFontEngineQPF2::Tag_EndOfHeader
tag == QFontEn...ag_EndOfHeaderDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
45 return
never executed: return endPtr;
endPtr;
never executed: return endPtr;
0
46 if (tag < QFontEngineQPF2::NumTags
tag < QFontEngineQPF2::NumTagsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
47 switch (tagTypes[tag]) {-
48 case
never executed: case QFontEngineQPF2::BitFieldType:
QFontEngineQPF2::BitFieldType:
never executed: case QFontEngineQPF2::BitFieldType:
0
49 case
never executed: case QFontEngineQPF2::StringType:
QFontEngineQPF2::StringType:
never executed: case QFontEngineQPF2::StringType:
0
50-
51 break;
never executed: break;
0
52 case
never executed: case QFontEngineQPF2::UInt32Type:
QFontEngineQPF2::UInt32Type:
never executed: case QFontEngineQPF2::UInt32Type:
0
53 if (!(length == sizeof(quint32))
!(length == sizeof(quint32))Description
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 132, __PRETTY_FUNCTION__).debug() << "verifying tag condition " "length == sizeof(quint32)" " failed in line" << 132 << "with tag" << tag;
dead code: QMessageLogger(__FILE__, 132, __PRETTY_FUNCTION__).debug() << "verifying tag condition " "length == sizeof(quint32)" " failed in line" << 132 << "with tag" << tag;
return
never executed: return 0;
0;
never executed: return 0;
};
-
54 break;
never executed: break;
0
55 case
never executed: case QFontEngineQPF2::FixedType:
QFontEngineQPF2::FixedType:
never executed: case QFontEngineQPF2::FixedType:
0
56 if (!(length == sizeof(quint32))
!(length == sizeof(quint32))Description
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 135, __PRETTY_FUNCTION__).debug() << "verifying tag condition " "length == sizeof(quint32)" " failed in line" << 135 << "with tag" << tag;
dead code: QMessageLogger(__FILE__, 135, __PRETTY_FUNCTION__).debug() << "verifying tag condition " "length == sizeof(quint32)" " failed in line" << 135 << "with tag" << tag;
return
never executed: return 0;
0;
never executed: return 0;
};
-
57 break;
never executed: break;
0
58 case
never executed: case QFontEngineQPF2::UInt8Type:
QFontEngineQPF2::UInt8Type:
never executed: case QFontEngineQPF2::UInt8Type:
0
59 if (!(length == sizeof(quint8))
!(length == sizeof(quint8))Description
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 138, __PRETTY_FUNCTION__).debug() << "verifying tag condition " "length == sizeof(quint8)" " failed in line" << 138 << "with tag" << tag;
dead code: QMessageLogger(__FILE__, 138, __PRETTY_FUNCTION__).debug() << "verifying tag condition " "length == sizeof(quint8)" " failed in line" << 138 << "with tag" << tag;
return
never executed: return 0;
0;
never executed: return 0;
};
-
60 break;
never executed: break;
0
61 }-
62-
63-
64-
65-
66-
67-
68 }
never executed: end of block
0
69 return
never executed: return tagPtr + length;
tagPtr + length;
never executed: return tagPtr + length;
0
70}-
71-
72const QFontEngineQPF2::Glyph *QFontEngineQPF2::findGlyph(glyph_t g) const-
73{-
74 if (!g
!gDescription
TRUEnever evaluated
FALSEnever evaluated
|| g >= glyphMapEntries
g >= glyphMapEntriesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
75 return
never executed: return 0;
0;
never executed: return 0;
0
76 const quint32 *gmapPtr = reinterpret_cast<const quint32 *>(fontData + glyphMapOffset);-
77 quint32 glyphPos = qFromBigEndian<quint32>(gmapPtr[g]);-
78 if (glyphPos > glyphDataSize
glyphPos > glyphDataSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
79 if (glyphPos == 0xffffffff
glyphPos == 0xffffffffDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
80 return
never executed: return 0;
0;
never executed: return 0;
0
81-
82-
83-
84 if (glyphPos > glyphDataSize
glyphPos > glyphDataSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
85 return
never executed: return 0;
0;
never executed: return 0;
0
86 }
never executed: end of block
0
87 return
never executed: return reinterpret_cast<const Glyph *>(fontData + glyphDataOffset + glyphPos);
reinterpret_cast<const Glyph *>(fontData + glyphDataOffset + glyphPos);
never executed: return reinterpret_cast<const Glyph *>(fontData + glyphDataOffset + glyphPos);
0
88}-
89-
90bool QFontEngineQPF2::verifyHeader(const uchar *data, int size)-
91{-
92 if (!(quintptr(data) % alignof(Header) == 0)
!(quintptr(dat...(Header) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 171, __PRETTY_FUNCTION__).debug() << "condition " "quintptr(data) % Q_ALIGNOF(Header) == 0" " failed in line" << 171;
dead code: QMessageLogger(__FILE__, 171, __PRETTY_FUNCTION__).debug() << "condition " "quintptr(data) % Q_ALIGNOF(Header) == 0" " failed in line" << 171;
return
never executed: return 0;
0;
never executed: return 0;
};
-
93 if (!(size >= int(sizeof(Header)))
!(size >= int(sizeof(Header)))Description
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 172, __PRETTY_FUNCTION__).debug() << "condition " "size >= int(sizeof(Header))" " failed in line" << 172;
dead code: QMessageLogger(__FILE__, 172, __PRETTY_FUNCTION__).debug() << "condition " "size >= int(sizeof(Header))" " failed in line" << 172;
return
never executed: return 0;
0;
never executed: return 0;
};
-
94 const Header *header = reinterpret_cast<const Header *>(data);-
95 if (header->magic[0] != 'Q'
header->magic[0] != 'Q'Description
TRUEnever evaluated
FALSEnever evaluated
0
96 || header->magic[1] != 'P'
header->magic[1] != 'P'Description
TRUEnever evaluated
FALSEnever evaluated
0
97 || header->magic[2] != 'F'
header->magic[2] != 'F'Description
TRUEnever evaluated
FALSEnever evaluated
0
98 || header->magic[3] != '2'
header->magic[3] != '2'Description
TRUEnever evaluated
FALSEnever evaluated
)
0
99 return
never executed: return false;
false;
never executed: return false;
0
100-
101 if (!(header->majorVersion <= CurrentMajorVersion)
!(header->majo...tMajorVersion)Description
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 180, __PRETTY_FUNCTION__).debug() << "condition " "header->majorVersion <= CurrentMajorVersion" " failed in line" << 180;
dead code: QMessageLogger(__FILE__, 180, __PRETTY_FUNCTION__).debug() << "condition " "header->majorVersion <= CurrentMajorVersion" " failed in line" << 180;
return
never executed: return 0;
0;
never executed: return 0;
};
-
102 const quint16 dataSize = qFromBigEndian<quint16>(header->dataSize);-
103 if (!(size >= int(sizeof(Header)) + dataSize)
!(size >= int(...)) + dataSize)Description
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 182, __PRETTY_FUNCTION__).debug() << "condition " "size >= int(sizeof(Header)) + dataSize" " failed in line" << 182;
dead code: QMessageLogger(__FILE__, 182, __PRETTY_FUNCTION__).debug() << "condition " "size >= int(sizeof(Header)) + dataSize" " failed in line" << 182;
return
never executed: return 0;
0;
never executed: return 0;
};
-
104-
105 const uchar *tagPtr = data + sizeof(Header);-
106 const uchar *tagEndPtr = tagPtr + dataSize;-
107 while (tagPtr < tagEndPtr - 3
tagPtr < tagEndPtr - 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
108 tagPtr = verifyTag(tagPtr, tagEndPtr);-
109 if (!(tagPtr)
!(tagPtr)Description
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 188, __PRETTY_FUNCTION__).debug() << "condition " "tagPtr" " failed in line" << 188;
dead code: QMessageLogger(__FILE__, 188, __PRETTY_FUNCTION__).debug() << "condition " "tagPtr" " failed in line" << 188;
return
never executed: return 0;
0;
never executed: return 0;
};
-
110 }
never executed: end of block
0
111-
112 if (!(tagPtr <= tagEndPtr)
!(tagPtr <= tagEndPtr)Description
TRUEnever evaluated
FALSEnever evaluated
) { if (0) QMessageLogger(__FILE__, 191, __PRETTY_FUNCTION__).debug() << "condition " "tagPtr <= tagEndPtr" " failed in line" << 191;
dead code: QMessageLogger(__FILE__, 191, __PRETTY_FUNCTION__).debug() << "condition " "tagPtr <= tagEndPtr" " failed in line" << 191;
return
never executed: return 0;
0;
never executed: return 0;
};
-
113 return
never executed: return true;
true;
never executed: return true;
0
114}-
115-
116QVariant QFontEngineQPF2::extractHeaderField(const uchar *data, HeaderTag requestedTag)-
117{-
118 const Header *header = reinterpret_cast<const Header *>(data);-
119 const uchar *tagPtr = data + sizeof(Header);-
120 const uchar *endPtr = tagPtr + qFromBigEndian<quint16>(header->dataSize);-
121 while (tagPtr < endPtr - 3
tagPtr < endPtr - 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
122 quint16 tag = readValue<quint16>(tagPtr);-
123 quint16 length = readValue<quint16>(tagPtr);-
124 if (tag == requestedTag
tag == requestedTagDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
125 switch (tagTypes[requestedTag]) {-
126 case
never executed: case StringType:
StringType:
never executed: case StringType:
0
127 return
never executed: return QVariant(QString::fromUtf8(reinterpret_cast<const char *>(tagPtr), length));
QVariant(QString::fromUtf8(reinterpret_cast<const char *>(tagPtr), length));
never executed: return QVariant(QString::fromUtf8(reinterpret_cast<const char *>(tagPtr), length));
0
128 case
never executed: case UInt32Type:
UInt32Type:
never executed: case UInt32Type:
0
129 return
never executed: return QVariant(readValue<quint32>(tagPtr));
QVariant(readValue<quint32>(tagPtr));
never executed: return QVariant(readValue<quint32>(tagPtr));
0
130 case
never executed: case UInt8Type:
UInt8Type:
never executed: case UInt8Type:
0
131 return
never executed: return QVariant(uint(*tagPtr));
QVariant(uint(*tagPtr));
never executed: return QVariant(uint(*tagPtr));
0
132 case
never executed: case FixedType:
FixedType:
never executed: case FixedType:
0
133 return
never executed: return QVariant(QFixed::fromFixed(readValue<quint32>(tagPtr)).toReal());
QVariant(QFixed::fromFixed(readValue<quint32>(tagPtr)).toReal());
never executed: return QVariant(QFixed::fromFixed(readValue<quint32>(tagPtr)).toReal());
0
134 case
never executed: case BitFieldType:
BitFieldType:
never executed: case BitFieldType:
0
135 return
never executed: return QVariant(QByteArray(reinterpret_cast<const char *>(tagPtr), length));
QVariant(QByteArray(reinterpret_cast<const char *>(tagPtr), length));
never executed: return QVariant(QByteArray(reinterpret_cast<const char *>(tagPtr), length));
0
136 }-
137 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
138 } else if (tag == Tag_EndOfHeader
tag == Tag_EndOfHeaderDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
139 break;
never executed: break;
0
140 }-
141 tagPtr += length;-
142 }
never executed: end of block
0
143-
144 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
145}-
146-
147-
148QFontEngineQPF2::QFontEngineQPF2(const QFontDef &def, const QByteArray &data)-
149 : QFontEngine(QPF2),-
150 fontData(reinterpret_cast<const uchar *>(data.constData())), dataSize(data.size())-
151{-
152 fontDef = def;-
153 cache_cost = 100;-
154 cmap = 0;-
155 cmapOffset = 0;-
156 cmapSize = 0;-
157 glyphMapOffset = 0;-
158 glyphMapEntries = 0;-
159 glyphDataOffset = 0;-
160 glyphDataSize = 0;-
161 kerning_pairs_loaded = false;-
162 readOnly = true;-
163-
164-
165-
166-
167-
168 if (!verifyHeader(fontData, dataSize)
!verifyHeader(...ata, dataSize)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
169-
170-
171-
172 return;
never executed: return;
0
173 }-
174-
175 const Header *header = reinterpret_cast<const Header *>(fontData);-
176-
177 readOnly = (header->lock == 0xffffffff);-
178-
179 const uchar *imgData = fontData + sizeof(Header) + qFromBigEndian<quint16>(header->dataSize);-
180 const uchar *endPtr = fontData + dataSize;-
181 while (imgData <= endPtr - 8
imgData <= endPtr - 8Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
182 quint16 blockTag = readValue<quint16>(imgData);-
183 imgData += 2;-
184 quint32 blockSize = readValue<quint32>(imgData);-
185-
186 if (blockTag == CMapBlock
blockTag == CMapBlockDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
187 cmapOffset = imgData - fontData;-
188 cmapSize = blockSize;-
189 }
never executed: end of block
else if (blockTag == GMapBlock
blockTag == GMapBlockDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
190 glyphMapOffset = imgData - fontData;-
191 glyphMapEntries = blockSize / 4;-
192 }
never executed: end of block
else if (blockTag == GlyphBlock
blockTag == GlyphBlockDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
193 glyphDataOffset = imgData - fontData;-
194 glyphDataSize = blockSize;-
195 }
never executed: end of block
0
196-
197 imgData += blockSize;-
198 }
never executed: end of block
0
199-
200 face_id.filename = QFile::encodeName(extractHeaderField(fontData, Tag_FileName).toString());-
201 face_id.index = extractHeaderField(fontData, Tag_FileIndex).toInt();-
202-
203-
204 if (cmapOffset
cmapOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
205 cmap = QFontEngine::getCMap(fontData + cmapOffset, cmapSize, &symbol, &cmapSize);-
206 cmapOffset = cmap
cmapDescription
TRUEnever evaluated
FALSEnever evaluated
? cmap - fontData : 0;
0
207 }
never executed: end of block
0
208-
209-
210 if (glyphMapOffset
glyphMapOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
211 const quint32 *gmapPtr = reinterpret_cast<const quint32 *>(fontData + glyphMapOffset);-
212 for (uint i = 0; i < glyphMapEntries
i < glyphMapEntriesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
213 quint32 glyphDataPos = qFromBigEndian<quint32>(gmapPtr[i]);-
214 if (glyphDataPos == 0xffffffff
glyphDataPos == 0xffffffffDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
215 continue;
never executed: continue;
0
216 if (glyphDataPos >= glyphDataSize
glyphDataPos >= glyphDataSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
217-
218 glyphMapOffset = 0;-
219 glyphMapEntries = 0;-
220 break;
never executed: break;
0
221 }-
222 }
never executed: end of block
0
223 }
never executed: end of block
0
224}
never executed: end of block
0
225-
226QFontEngineQPF2::~QFontEngineQPF2()-
227{-
228}-
229-
230bool QFontEngineQPF2::getSfntTableData(uint tag, uchar *buffer, uint *length) const-
231{-
232 if (tag != ( (((quint32)('c')) << 24) | (((quint32)('m')) << 16) | (((quint32)('a')) << 8) | ((quint32)('p')) )
tag != ( (((qu...int32)('p')) )Description
TRUEnever evaluated
FALSEnever evaluated
|| !cmap
!cmapDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
233 return
never executed: return false;
false;
never executed: return false;
0
234-
235 if (buffer
bufferDescription
TRUEnever evaluated
FALSEnever evaluated
&& int(*length) >= cmapSize
int(*length) >= cmapSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
236 memcpy(buffer, cmap, cmapSize);
never executed: memcpy(buffer, cmap, cmapSize);
0
237 *length = cmapSize;-
238 ((!(int(*length) > 0)) ? qt_assert("int(*length) > 0",__FILE__,325) : qt_noop());-
239 return
never executed: return true;
true;
never executed: return true;
0
240}-
241-
242glyph_t QFontEngineQPF2::glyphIndex(uint ucs4) const-
243{-
244 glyph_t glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4);-
245 if (glyph == 0
glyph == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& symbol
symbolDescription
TRUEnever evaluated
FALSEnever evaluated
&& ucs4 < 0x100
ucs4 < 0x100Description
TRUEnever evaluated
FALSEnever evaluated
)
0
246 glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4 + 0xf000);
never executed: glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4 + 0xf000);
0
247 if (!findGlyph(glyph)
!findGlyph(glyph)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
248 glyph = 0;
never executed: glyph = 0;
0
249-
250 return
never executed: return glyph;
glyph;
never executed: return glyph;
0
251}-
252-
253bool QFontEngineQPF2::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const-
254{-
255 ((!(glyphs->numGlyphs >= *nglyphs)) ? qt_assert("glyphs->numGlyphs >= *nglyphs",__FILE__,342) : qt_noop());-
256 if (*
*nglyphs < lenDescription
TRUEnever evaluated
FALSEnever evaluated
nglyphs < len
*nglyphs < lenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
257 *nglyphs = len;-
258 return
never executed: return false;
false;
never executed: return false;
0
259 }-
260-
261-
262-
263-
264-
265 int glyph_pos = 0;-
266 if (symbol
symbolDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
267 QStringIterator it(str, str + len);-
268 while (it.hasNext()
it.hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
269 const uint uc = it.next();-
270 glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc);-
271 if(!glyphs->glyphs[glyph_pos]
!glyphs->glyphs[glyph_pos]Description
TRUEnever evaluated
FALSEnever evaluated
&& uc < 0x100
uc < 0x100Description
TRUEnever evaluated
FALSEnever evaluated
)
0
272 glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc + 0xf000);
never executed: glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc + 0xf000);
0
273 ++glyph_pos;-
274 }
never executed: end of block
0
275 }
never executed: end of block
else {
0
276 QStringIterator it(str, str + len);-
277 while (it.hasNext()
it.hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
278 const uint uc = it.next();-
279 glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, cmapSize, uc);-
280-
281-
282-
283-
284-
285-
286-
287 ++glyph_pos;-
288 }
never executed: end of block
0
289 }
never executed: end of block
0
290-
291 *nglyphs = glyph_pos;-
292 glyphs->numGlyphs = glyph_pos;-
293-
294 if (!(flags & GlyphIndicesOnly)
!(flags & GlyphIndicesOnly)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
295 recalcAdvances(glyphs, flags);
never executed: recalcAdvances(glyphs, flags);
0
296-
297 return
never executed: return true;
true;
never executed: return true;
0
298}-
299-
300void QFontEngineQPF2::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const-
301{-
302 for (int i = 0; i < glyphs->numGlyphs
i < glyphs->numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
303 const Glyph *g = findGlyph(glyphs->glyphs[i]);-
304 if (!g
!gDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
305 continue;
never executed: continue;
0
306 glyphs->advances[i] = g->advance;-
307 }
never executed: end of block
0
308}
never executed: end of block
0
309-
310QImage QFontEngineQPF2::alphaMapForGlyph(glyph_t g)-
311{-
312 const Glyph *glyph = findGlyph(g);-
313 if (!glyph
!glyphDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
314 return
never executed: return QImage();
QImage();
never executed: return QImage();
0
315-
316 const uchar *bits = ((const uchar *) glyph) + sizeof(Glyph);-
317-
318 QImage image(bits,glyph->width, glyph->height, glyph->bytesPerLine, QImage::Format_Alpha8);-
319-
320 return
never executed: return image;
image;
never executed: return image;
0
321}-
322-
323void QFontEngineQPF2::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags)-
324{-
325 addBitmapFontToPath(x, y, glyphs, path, flags);-
326}
never executed: end of block
0
327-
328glyph_metrics_t QFontEngineQPF2::boundingBox(const QGlyphLayout &glyphs)-
329{-
330 glyph_metrics_t overall;-
331-
332 overall.y = -ascent();-
333 overall.height = ascent() + descent() + 1;-
334-
335 QFixed ymax = 0;-
336 QFixed xmax = 0;-
337 for (int i = 0; i < glyphs.numGlyphs
i < glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
338 const Glyph *g = findGlyph(glyphs.glyphs[i]);-
339 if (!g
!gDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
340 continue;
never executed: continue;
0
341-
342 QFixed x = overall.xoff + glyphs.offsets[i].x + g->x;-
343 QFixed y = overall.yoff + glyphs.offsets[i].y + g->y;-
344 overall.x = qMin(overall.x, x);-
345 overall.y = qMin(overall.y, y);-
346 xmax = qMax(xmax, x + g->width);-
347 ymax = qMax(ymax, y + g->height);-
348 overall.xoff += g->advance;-
349 }
never executed: end of block
0
350 overall.height = qMax(overall.height, ymax - overall.y);-
351 overall.width = xmax - overall.x;-
352-
353 return
never executed: return overall;
overall;
never executed: return overall;
0
354}-
355-
356glyph_metrics_t QFontEngineQPF2::boundingBox(glyph_t glyph)-
357{-
358 glyph_metrics_t overall;-
359 const Glyph *g = findGlyph(glyph);-
360 if (!g
!gDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
361 return
never executed: return overall;
overall;
never executed: return overall;
0
362 overall.x = g->x;-
363 overall.y = g->y;-
364 overall.width = g->width;-
365 overall.height = g->height;-
366 overall.xoff = g->advance;-
367 return
never executed: return overall;
overall;
never executed: return overall;
0
368}-
369-
370QFixed QFontEngineQPF2::ascent() const-
371{-
372 return
never executed: return QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value<qreal>());
QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value<qreal>());
never executed: return QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value<qreal>());
0
373}-
374-
375QFixed QFontEngineQPF2::descent() const-
376{-
377 return
never executed: return QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value<qreal>());
QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value<qreal>());
never executed: return QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value<qreal>());
0
378}-
379-
380QFixed QFontEngineQPF2::leading() const-
381{-
382 return
never executed: return QFixed::fromReal(extractHeaderField(fontData, Tag_Leading).value<qreal>());
QFixed::fromReal(extractHeaderField(fontData, Tag_Leading).value<qreal>());
never executed: return QFixed::fromReal(extractHeaderField(fontData, Tag_Leading).value<qreal>());
0
383}-
384-
385qreal QFontEngineQPF2::maxCharWidth() const-
386{-
387 return
never executed: return extractHeaderField(fontData, Tag_MaxCharWidth).value<qreal>();
extractHeaderField(fontData, Tag_MaxCharWidth).value<qreal>();
never executed: return extractHeaderField(fontData, Tag_MaxCharWidth).value<qreal>();
0
388}-
389-
390qreal QFontEngineQPF2::minLeftBearing() const-
391{-
392 return
never executed: return extractHeaderField(fontData, Tag_MinLeftBearing).value<qreal>();
extractHeaderField(fontData, Tag_MinLeftBearing).value<qreal>();
never executed: return extractHeaderField(fontData, Tag_MinLeftBearing).value<qreal>();
0
393}-
394-
395qreal QFontEngineQPF2::minRightBearing() const-
396{-
397 return
never executed: return extractHeaderField(fontData, Tag_MinRightBearing).value<qreal>();
extractHeaderField(fontData, Tag_MinRightBearing).value<qreal>();
never executed: return extractHeaderField(fontData, Tag_MinRightBearing).value<qreal>();
0
398}-
399-
400QFixed QFontEngineQPF2::underlinePosition() const-
401{-
402 return
never executed: return QFixed::fromReal(extractHeaderField(fontData, Tag_UnderlinePosition).value<qreal>());
QFixed::fromReal(extractHeaderField(fontData, Tag_UnderlinePosition).value<qreal>());
never executed: return QFixed::fromReal(extractHeaderField(fontData, Tag_UnderlinePosition).value<qreal>());
0
403}-
404-
405QFixed QFontEngineQPF2::lineThickness() const-
406{-
407 return
never executed: return QFixed::fromReal(extractHeaderField(fontData, Tag_LineThickness).value<qreal>());
QFixed::fromReal(extractHeaderField(fontData, Tag_LineThickness).value<qreal>());
never executed: return QFixed::fromReal(extractHeaderField(fontData, Tag_LineThickness).value<qreal>());
0
408}-
409-
410bool QFontEngineQPF2::isValid() const-
411{-
412 return
never executed: return fontData && dataSize && cmapOffset && glyphMapOffset && glyphDataOffset && glyphDataSize > 0;
fontData && dataSize && cmapOffset
never executed: return fontData && dataSize && cmapOffset && glyphMapOffset && glyphDataOffset && glyphDataSize > 0;
0
413 && glyphMapOffset && glyphDataOffset && glyphDataSize > 0;
never executed: return fontData && dataSize && cmapOffset && glyphMapOffset && glyphDataOffset && glyphDataSize > 0;
0
414}-
415-
416void QPF2Generator::generate()-
417{-
418 writeHeader();-
419 writeGMap();-
420 writeBlock(QFontEngineQPF2::GlyphBlock, QByteArray());-
421-
422 dev->seek(4);-
423 writeUInt32(0);-
424}
never executed: end of block
0
425-
426void QPF2Generator::writeHeader()-
427{-
428 QFontEngineQPF2::Header header;-
429-
430 header.magic[0] = 'Q';-
431 header.magic[1] = 'P';-
432 header.magic[2] = 'F';-
433 header.magic[3] = '2';-
434 header.lock = 1;-
435 header.majorVersion = QFontEngineQPF2::CurrentMajorVersion;-
436 header.minorVersion = QFontEngineQPF2::CurrentMinorVersion;-
437 header.dataSize = 0;-
438 dev->write((const char *)&header, sizeof(header));-
439-
440 writeTaggedString(QFontEngineQPF2::Tag_FontName, fe->fontDef.family.toUtf8());-
441-
442 QFontEngine::FaceId face = fe->faceId();-
443 writeTaggedString(QFontEngineQPF2::Tag_FileName, face.filename);-
444 writeTaggedUInt32(QFontEngineQPF2::Tag_FileIndex, face.index);-
445-
446 {-
447 const QByteArray head = fe->getSfntTable(( (((quint32)('h')) << 24) | (((quint32)('e')) << 16) | (((quint32)('a')) << 8) | ((quint32)('d')) ));-
448 if (head.size() >= 4
head.size() >= 4Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
449 const quint32 revision = qFromBigEndian<quint32>(head.constData());-
450 writeTaggedUInt32(QFontEngineQPF2::Tag_FontRevision, revision);-
451 }
never executed: end of block
0
452 }-
453-
454 writeTaggedQFixed(QFontEngineQPF2::Tag_Ascent, fe->ascent());-
455 writeTaggedQFixed(QFontEngineQPF2::Tag_Descent, fe->descent());-
456 writeTaggedQFixed(QFontEngineQPF2::Tag_Leading, fe->leading());-
457 writeTaggedQFixed(QFontEngineQPF2::Tag_XHeight, fe->xHeight());-
458 writeTaggedQFixed(QFontEngineQPF2::Tag_AverageCharWidth, fe->averageCharWidth());-
459 writeTaggedQFixed(QFontEngineQPF2::Tag_MaxCharWidth, QFixed::fromReal(fe->maxCharWidth()));-
460 writeTaggedQFixed(QFontEngineQPF2::Tag_LineThickness, fe->lineThickness());-
461 writeTaggedQFixed(QFontEngineQPF2::Tag_MinLeftBearing, QFixed::fromReal(fe->minLeftBearing()));-
462 writeTaggedQFixed(QFontEngineQPF2::Tag_MinRightBearing, QFixed::fromReal(fe->minRightBearing()));-
463 writeTaggedQFixed(QFontEngineQPF2::Tag_UnderlinePosition, fe->underlinePosition());-
464 writeTaggedUInt8(QFontEngineQPF2::Tag_PixelSize, fe->fontDef.pixelSize);-
465 writeTaggedUInt8(QFontEngineQPF2::Tag_Weight, fe->fontDef.weight);-
466 writeTaggedUInt8(QFontEngineQPF2::Tag_Style, fe->fontDef.style);-
467-
468 writeTaggedUInt8(QFontEngineQPF2::Tag_GlyphFormat, QFontEngineQPF2::AlphamapGlyphs);-
469-
470 writeTaggedString(QFontEngineQPF2::Tag_EndOfHeader, QByteArray());-
471 align4();-
472-
473 const quint64 size = dev->pos();-
474 header.dataSize = qToBigEndian<quint16>(size - sizeof(header));-
475 dev->seek(0);-
476 dev->write((const char *)&header, sizeof(header));-
477 dev->seek(size);-
478}
never executed: end of block
0
479-
480void QPF2Generator::writeGMap()-
481{-
482 const quint16 glyphCount = fe->glyphCount();-
483-
484 writeUInt16(QFontEngineQPF2::GMapBlock);-
485 writeUInt16(0);-
486 writeUInt32(glyphCount * 4);-
487-
488 QByteArray &buffer = dev->buffer();-
489 const int numBytes = glyphCount * sizeof(quint32);-
490 qint64 pos = buffer.size();-
491 buffer.resize(pos + numBytes);-
492 memset(buffer.data() + pos, 0xff, numBytes);-
493 dev->seek(pos + numBytes);-
494}
never executed: end of block
0
495-
496void QPF2Generator::writeBlock(QFontEngineQPF2::BlockTag tag, const QByteArray &data)-
497{-
498 writeUInt16(tag);-
499 writeUInt16(0);-
500 const int padSize = ((data.size() + 3) / 4) * 4 - data.size();-
501 writeUInt32(data.size() + padSize);-
502 dev->write(data);-
503 for (int i = 0; i < padSize
i < padSizeDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
504 writeUInt8(0);
never executed: writeUInt8(0);
0
505}
never executed: end of block
0
506-
507void QPF2Generator::writeTaggedString(QFontEngineQPF2::HeaderTag tag, const QByteArray &string)-
508{-
509 writeUInt16(tag);-
510 writeUInt16(string.length());-
511 dev->write(string);-
512}
never executed: end of block
0
513-
514void QPF2Generator::writeTaggedUInt32(QFontEngineQPF2::HeaderTag tag, quint32 value)-
515{-
516 writeUInt16(tag);-
517 writeUInt16(sizeof(value));-
518 writeUInt32(value);-
519}
never executed: end of block
0
520-
521void QPF2Generator::writeTaggedUInt8(QFontEngineQPF2::HeaderTag tag, quint8 value)-
522{-
523 writeUInt16(tag);-
524 writeUInt16(sizeof(value));-
525 writeUInt8(value);-
526}
never executed: end of block
0
527-
528void QPF2Generator::writeTaggedQFixed(QFontEngineQPF2::HeaderTag tag, QFixed value)-
529{-
530 writeUInt16(tag);-
531 writeUInt16(sizeof(quint32));-
532 writeUInt32(value.value());-
533}
never executed: end of block
0
534-
535-
Switch to Source codePreprocessed file

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