qfontengine.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qfontengine.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11static inline bool qtransform_equals_no_translate(const QTransform &a, const QTransform &b)-
12{-
13 if (a.type() <= QTransform::TxTranslate
a.type() <= QT...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
&& b.type() <= QTransform::TxTranslate
b.type() <= QT...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
14 return
never executed: return true;
true;
never executed: return true;
0
15 } else {-
16-
17-
18 ((!(a.type() < QTransform::TxProject)) ? qt_assert("a.type() < QTransform::TxProject",__FILE__,74) : qt_noop());-
19 ((!(b.type() < QTransform::TxProject)) ? qt_assert("b.type() < QTransform::TxProject",__FILE__,75) : qt_noop());-
20-
21 return
never executed: return a.m11() == b.m11() && a.m12() == b.m12() && a.m21() == b.m21() && a.m22() == b.m22();
a.m11() == b.m11()
never executed: return a.m11() == b.m11() && a.m12() == b.m12() && a.m21() == b.m21() && a.m22() == b.m22();
0
22 && a.m12() == b.m12()
never executed: return a.m11() == b.m11() && a.m12() == b.m12() && a.m21() == b.m21() && a.m22() == b.m22();
0
23 && a.m21() == b.m21()
never executed: return a.m11() == b.m11() && a.m12() == b.m12() && a.m21() == b.m21() && a.m22() == b.m22();
0
24 && a.m22() == b.m22();
never executed: return a.m11() == b.m11() && a.m12() == b.m12() && a.m21() == b.m21() && a.m22() == b.m22();
0
25 }-
26}-
27-
28template<typename T>-
29static inline bool qSafeFromBigEndian(const uchar *source, const uchar *end, T *output)-
30{-
31 if (source + sizeof(T) > end
source + sizeof(T) > endDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
32 return
never executed: return false;
false;
never executed: return false;
0
33-
34 *output = qFromBigEndian<T>(source);-
35 return
never executed: return true;
true;
never executed: return true;
0
36}-
37-
38-
39-
40-
41namespace { namespace Q_QGS_useHarfbuzzNG { typedef bool Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
never executed: guard.store(QtGlobalStatic::Destroyed);
}
never executed: end of block
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type (qgetenv("QT_HARFBUZZ") != "old"))) : value (qgetenv("QT_HARFBUZZ") != "old") { guard.store(QtGlobalStatic::Initialized); } } holder; return
never executed: return &holder.value;
&holder.value;
never executed: return &holder.value;
} } } static QGlobalStatic<bool, Q_QGS_useHarfbuzzNG::innerFunction, Q_QGS_useHarfbuzzNG::guard> useHarfbuzzNG;
0
42-
43bool qt_useHarfbuzzNG()-
44{-
45 return
never executed: return *useHarfbuzzNG();
*useHarfbuzzNG();
never executed: return *useHarfbuzzNG();
0
46}-
47-
48-
49static_assert(bool(sizeof(HB_Glyph) == sizeof(glyph_t)), "sizeof(HB_Glyph) == sizeof(glyph_t)");-
50static_assert(bool(sizeof(HB_Fixed) == sizeof(QFixed)), "sizeof(HB_Fixed) == sizeof(QFixed)");-
51-
52static HB_Bool hb_stringToGlyphs(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft)-
53{-
54 QFontEngine *fe = (QFontEngine *)font->userData;-
55-
56 const QChar *str = reinterpret_cast<const QChar *>(string);-
57-
58 QGlyphLayout qglyphs;-
59 qglyphs.numGlyphs = *numGlyphs;-
60 qglyphs.glyphs = glyphs;-
61 int nGlyphs = *numGlyphs;-
62 bool result = fe->stringToCMap(str, length, &qglyphs, &nGlyphs, QFontEngine::GlyphIndicesOnly);-
63 *numGlyphs = nGlyphs;-
64-
65 if (rightToLeft
rightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
&& result
resultDescription
TRUEnever evaluated
FALSEnever evaluated
&& !fe->symbol
!fe->symbolDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
66 QStringIterator it(str, str + length);-
67 while (it.hasNext()
it.hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
68 const uint ucs4 = it.next();-
69 const uint mirrored = QChar::mirroredChar(ucs4);-
70 if (__builtin_expect(!!(mirrored != ucs4), false)
__builtin_expe... ucs4), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
71 *
never executed: *glyphs = fe->glyphIndex(mirrored);
glyphs = fe->glyphIndex(mirrored);
never executed: *glyphs = fe->glyphIndex(mirrored);
0
72 ++glyphs;-
73 }
never executed: end of block
0
74 }
never executed: end of block
0
75-
76 return
never executed: return result;
result;
never executed: return result;
0
77}-
78-
79static void hb_getAdvances(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs, HB_Fixed *advances, int flags)-
80{-
81 QFontEngine *fe = (QFontEngine *)font->userData;-
82-
83 QGlyphLayout qglyphs;-
84 qglyphs.numGlyphs = numGlyphs;-
85 qglyphs.glyphs = const_cast<glyph_t *>(glyphs);-
86 qglyphs.advances = reinterpret_cast<QFixed *>(advances);-
87-
88 fe->recalcAdvances(&qglyphs, (flags & HB_ShaperFlag_UseDesignMetrics) ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0));-
89}
never executed: end of block
0
90-
91static HB_Bool hb_canRender(HB_Font font, const HB_UChar16 *string, hb_uint32 length)-
92{-
93 QFontEngine *fe = (QFontEngine *)font->userData;-
94 return
never executed: return fe->canRender(reinterpret_cast<const QChar *>(string), length);
fe->canRender(reinterpret_cast<const QChar *>(string), length);
never executed: return fe->canRender(reinterpret_cast<const QChar *>(string), length);
0
95}-
96-
97static void hb_getGlyphMetrics(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics)-
98{-
99 QFontEngine *fe = (QFontEngine *)font->userData;-
100 glyph_metrics_t m = fe->boundingBox(glyph);-
101 metrics->x = m.x.value();-
102 metrics->y = m.y.value();-
103 metrics->width = m.width.value();-
104 metrics->height = m.height.value();-
105 metrics->xOffset = m.xoff.value();-
106 metrics->yOffset = m.yoff.value();-
107}
never executed: end of block
0
108-
109static HB_Fixed hb_getFontMetric(HB_Font font, HB_FontMetric metric)-
110{-
111 if (metric == HB_FontAscent
metric == HB_FontAscentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
112 QFontEngine *fe = (QFontEngine *)font->userData;-
113 return
never executed: return fe->ascent().value();
fe->ascent().value();
never executed: return fe->ascent().value();
0
114 }-
115 return
never executed: return 0;
0;
never executed: return 0;
0
116}-
117-
118int QFontEngine::getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints)-
119{-
120 (void)glyph;-
121 (void)flags;-
122 (void)point;-
123 (void)xpos;-
124 (void)ypos;-
125 (void)nPoints;-
126 return
never executed: return Err_Not_Covered;
Err_Not_Covered;
never executed: return Err_Not_Covered;
0
127}-
128-
129static HB_Error hb_getPointInOutline(HB_Font font, HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints)-
130{-
131 QFontEngine *fe = (QFontEngine *)font->userData;-
132 return
never executed: return (HB_Error)fe->getPointInOutline(glyph, flags, point, (QFixed *)xpos, (QFixed *)ypos, (quint32 *)nPoints);
(HB_Error)fe->getPointInOutline(glyph, flags, point, (QFixed *)xpos, (QFixed *)ypos, (quint32 *)nPoints);
never executed: return (HB_Error)fe->getPointInOutline(glyph, flags, point, (QFixed *)xpos, (QFixed *)ypos, (quint32 *)nPoints);
0
133}-
134-
135static const HB_FontClass hb_fontClass = {-
136 hb_stringToGlyphs, hb_getAdvances, hb_canRender, hb_getPointInOutline,-
137 hb_getGlyphMetrics, hb_getFontMetric-
138};-
139-
140static HB_Error hb_getSFntTable(void *font, HB_Tag tableTag, HB_Byte *buffer, HB_UInt *length)-
141{-
142 QFontEngine::FaceData *data = (QFontEngine::FaceData *)font;-
143 ((!(data)) ? qt_assert("data",__FILE__,199) : qt_noop());-
144-
145 qt_get_font_table_func_t get_font_table = data->get_font_table;-
146 ((!(get_font_table)) ? qt_assert("get_font_table",__FILE__,202) : qt_noop());-
147-
148 if (!get_font_table(data->user_data, tableTag, buffer, length)
!get_font_tabl...uffer, length)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
149 return
never executed: return HB_Err_Invalid_Argument;
HB_Err_Invalid_Argument;
never executed: return HB_Err_Invalid_Argument;
0
150 return
never executed: return HB_Err_Ok;
HB_Err_Ok;
never executed: return HB_Err_Ok;
0
151}-
152-
153static void hb_freeFace(void *face)-
154{-
155 qHBFreeFace((HB_Face)face);-
156}
never executed: end of block
0
157-
158-
159static bool qt_get_font_table_default(void *user_data, uint tag, uchar *buffer, uint *length)-
160{-
161 QFontEngine *fe = (QFontEngine *)user_data;-
162 return
never executed: return fe->getSfntTableData(tag, buffer, length);
fe->getSfntTableData(tag, buffer, length);
never executed: return fe->getSfntTableData(tag, buffer, length);
0
163}-
164-
165-
166-
167-
168static QList<QFontEngine *> *enginesCollector = 0;-
169-
170__attribute__((visibility("default"))) void QFontEngine_startCollectingEngines()-
171{-
172 delete enginesCollector;-
173 enginesCollector = new QList<QFontEngine *>();-
174}
never executed: end of block
0
175-
176__attribute__((visibility("default"))) QList<QFontEngine *> QFontEngine_stopCollectingEngines()-
177{-
178 ((!(enginesCollector)) ? qt_assert("enginesCollector",__FILE__,234) : qt_noop());-
179 QList<QFontEngine *> ret = *enginesCollector;-
180 delete enginesCollector;-
181 enginesCollector = 0;-
182 return
never executed: return ret;
ret;
never executed: return ret;
0
183}-
184-
185-
186-
187-
188-
189-
190-
191QFontEngine::QFontEngine(Type type)-
192 : m_type(type), ref(0),-
193 font_(),-
194 face_(),-
195 m_minLeftBearing(std::numeric_limits<qreal>::max()),-
196 m_minRightBearing(std::numeric_limits<qreal>::max())-
197{-
198 faceData.user_data = this;-
199 faceData.get_font_table = qt_get_font_table_default;-
200-
201 cache_cost = 0;-
202 fsType = 0;-
203 symbol = false;-
204 isSmoothlyScalable = false;-
205-
206 glyphFormat = Format_None;-
207 m_subPixelPositionCount = 0;-
208-
209-
210 if (enginesCollector
enginesCollectorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
211 enginesCollector->append(this);
never executed: enginesCollector->append(this);
0
212-
213}
never executed: end of block
0
214-
215QFontEngine::~QFontEngine()-
216{-
217-
218 if (enginesCollector
enginesCollectorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
219 enginesCollector->removeOne(this);
never executed: enginesCollector->removeOne(this);
0
220-
221}
never executed: end of block
0
222-
223QFixed QFontEngine::lineThickness() const-
224{-
225-
226 int score = fontDef.weight * fontDef.pixelSize;-
227 int lw = score / 700;-
228-
229-
230 if (lw < 2
lw < 2Description
TRUEnever evaluated
FALSEnever evaluated
&& score >= 1050
score >= 1050Description
TRUEnever evaluated
FALSEnever evaluated
) lw = 2;
never executed: lw = 2;
0
231 if (lw == 0
lw == 0Description
TRUEnever evaluated
FALSEnever evaluated
) lw = 1;
never executed: lw = 1;
0
232-
233 return
never executed: return lw;
lw;
never executed: return lw;
0
234}-
235-
236QFixed QFontEngine::underlinePosition() const-
237{-
238 return
never executed: return ((lineThickness() * 2) + 3) / 6;
((lineThickness() * 2) + 3) / 6;
never executed: return ((lineThickness() * 2) + 3) / 6;
0
239}-
240-
241void *QFontEngine::harfbuzzFont() const-
242{-
243 ((!(type() != QFontEngine::Multi)) ? qt_assert("type() != QFontEngine::Multi",__FILE__,299) : qt_noop());-
244-
245 if (qt_useHarfbuzzNG()
qt_useHarfbuzzNG()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
246 return
never executed: return hb_qt_font_get_for_engine(const_cast<QFontEngine *>(this));
hb_qt_font_get_for_engine(const_cast<QFontEngine *>(this));
never executed: return hb_qt_font_get_for_engine(const_cast<QFontEngine *>(this));
0
247-
248 if (!font_
!font_Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
249 HB_Face hbFace = (HB_Face)harfbuzzFace();-
250 if (hbFace->font_for_init
hbFace->font_for_initDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
251 void *data = hbFace->font_for_init;-
252 q_check_ptr(qHBLoadFace(hbFace));-
253 free(data);-
254 }
never executed: end of block
0
255-
256 HB_FontRec *hbFont = (HB_FontRec *) malloc(sizeof(HB_FontRec));-
257 do {if(!(hbFont)
!(hbFont)Description
TRUEnever evaluated
FALSEnever evaluated
)qt_check_pointer(__FILE__,313);
never executed: qt_check_pointer(__FILE__,313);
} while (0);
0
258 hbFont->klass = &hb_fontClass;-
259 hbFont->userData = const_cast<QFontEngine *>(this);-
260-
261 qint64 emSquare = emSquareSize().truncate();-
262 ((!(emSquare == emSquareSize().toInt())) ? qt_assert("emSquare == emSquareSize().toInt()",__FILE__,318) : qt_noop());-
263 if (emSquare == 0
emSquare == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
264 emSquare = 1000;
never executed: emSquare = 1000;
0
265 hbFont->y_ppem = fontDef.pixelSize;-
266 hbFont->x_ppem = fontDef.pixelSize * fontDef.stretch / 100;-
267-
268 hbFont->x_scale = (((qint64)hbFont->x_ppem << 6) * 0x10000L + (emSquare >> 1)) / emSquare;-
269 hbFont->y_scale = (((qint64)hbFont->y_ppem << 6) * 0x10000L + (emSquare >> 1)) / emSquare;-
270-
271 font_ = Holder(hbFont, free);-
272 }
never executed: end of block
0
273 return
never executed: return font_.get();
font_.get();
never executed: return font_.get();
0
274}-
275-
276void *QFontEngine::harfbuzzFace() const-
277{-
278 ((!(type() != QFontEngine::Multi)) ? qt_assert("type() != QFontEngine::Multi",__FILE__,334) : qt_noop());-
279-
280 if (qt_useHarfbuzzNG()
qt_useHarfbuzzNG()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
281 return
never executed: return hb_qt_face_get_for_engine(const_cast<QFontEngine *>(this));
hb_qt_face_get_for_engine(const_cast<QFontEngine *>(this));
never executed: return hb_qt_face_get_for_engine(const_cast<QFontEngine *>(this));
0
282-
283 if (!face_
!face_Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
284 QFontEngine::FaceData *data = (QFontEngine::FaceData *)malloc(sizeof(QFontEngine::FaceData));-
285 do {if(!(data)
!(data)Description
TRUEnever evaluated
FALSEnever evaluated
)qt_check_pointer(__FILE__,341);
never executed: qt_check_pointer(__FILE__,341);
} while (0);
0
286 data->user_data = faceData.user_data;-
287 data->get_font_table = faceData.get_font_table;-
288-
289 HB_Face hbFace = qHBNewFace(data, hb_getSFntTable);-
290 do {if(!(hbFace)
!(hbFace)Description
TRUEnever evaluated
FALSEnever evaluated
)qt_check_pointer(__FILE__,346);
never executed: qt_check_pointer(__FILE__,346);
} while (0);
0
291 hbFace->isSymbolFont = symbol;-
292-
293 face_ = Holder(hbFace, hb_freeFace);-
294 }
never executed: end of block
0
295 return
never executed: return face_.get();
face_.get();
never executed: return face_.get();
0
296}-
297-
298bool QFontEngine::supportsScript(QChar::Script script) const-
299{-
300 if (type() <= QFontEngine::Multi
type() <= QFontEngine::MultiDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
301 return
never executed: return true;
true;
never executed: return true;
0
302-
303-
304-
305-
306 if (!((script >= QChar::Script_Syriac
script >= QChar::Script_SyriacDescription
TRUEnever evaluated
FALSEnever evaluated
&& script <= QChar::Script_Sinhala
script <= QCha...Script_SinhalaDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
307 || script == QChar::Script_Khmer
script == QChar::Script_KhmerDescription
TRUEnever evaluated
FALSEnever evaluated
|| script == QChar::Script_Nko
script == QChar::Script_NkoDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
308 return
never executed: return true;
true;
never executed: return true;
0
309 }-
310-
311-
312 if (qt_useHarfbuzzNG()
qt_useHarfbuzzNG()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
313-
314-
315-
316-
317-
318-
319-
320 bool ret = false;-
321 if (hb_face_t *face = hb_qt_face_get_for_engine(const_cast<QFontEngine *>(this))
hb_face_t *fac...gine *>(this))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
322 hb_tag_t script_tag_1, script_tag_2;-
323 hb_ot_tags_from_script(hb_qt_script_to_script(script), &script_tag_1, &script_tag_2);-
324-
325 unsigned int script_index;-
326 ret = hb_ot_layout_table_find_script(face, ((hb_tag_t)((((uint8_t)('G'))<<24)|(((uint8_t)('S'))<<16)|(((uint8_t)('U'))<<8)|((uint8_t)('B')))), script_tag_1, &script_index);-
327 if (!ret
!retDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
328 ret = hb_ot_layout_table_find_script(face, ((hb_tag_t)((((uint8_t)('G'))<<24)|(((uint8_t)('S'))<<16)|(((uint8_t)('U'))<<8)|((uint8_t)('B')))), script_tag_2, &script_index);-
329 if (!ret
!retDescription
TRUEnever evaluated
FALSEnever evaluated
&& script_tag_2 != ((hb_tag_t)((((uint8_t)('D'))<<24)|(((uint8_t)('F'))<<16)|(((uint8_t)('L'))<<8)|((uint8_t)('T'))))
script_tag_2 !...nt8_t)('T'))))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
330 ret = hb_ot_layout_table_find_script(face, ((hb_tag_t)((((uint8_t)('G'))<<24)|(((uint8_t)('S'))<<16)|(((uint8_t)('U'))<<8)|((uint8_t)('B')))), ((hb_tag_t)((((uint8_t)('D'))<<24)|(((uint8_t)('F'))<<16)|(((uint8_t)('L'))<<8)|((uint8_t)('T')))), &script_index);
never executed: ret = hb_ot_layout_table_find_script(face, ((hb_tag_t)((((uint8_t)('G'))<<24)|(((uint8_t)('S'))<<16)|(((uint8_t)('U'))<<8)|((uint8_t)('B')))), ((hb_tag_t)((((uint8_t)('D'))<<24)|(((uint8_t)('F'))<<16)|(((uint8_t)('L'))<<8)|((uint8_t)('T')))), &script_index);
0
331 }
never executed: end of block
0
332 }
never executed: end of block
0
333 return
never executed: return ret;
ret;
never executed: return ret;
0
334 }-
335-
336 HB_Face hbFace = (HB_Face)harfbuzzFace();-
337 if (hbFace->font_for_init
hbFace->font_for_initDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
338 void *data = hbFace->font_for_init;-
339 q_check_ptr(qHBLoadFace(hbFace));-
340 free(data);-
341 }
never executed: end of block
0
342 return
never executed: return hbFace->supported_scripts[script_to_hbscript(script)];
hbFace->supported_scripts[script_to_hbscript(script)];
never executed: return hbFace->supported_scripts[script_to_hbscript(script)];
0
343}-
344-
345bool QFontEngine::canRender(const QChar *str, int len) const-
346{-
347 QStringIterator it(str, str + len);-
348 while (it.hasNext()
it.hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
349 if (glyphIndex(it.next()) == 0
glyphIndex(it.next()) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
350 return
never executed: return false;
false;
never executed: return false;
0
351 }
never executed: end of block
0
352-
353 return
never executed: return true;
true;
never executed: return true;
0
354}-
355-
356glyph_metrics_t QFontEngine::boundingBox(glyph_t glyph, const QTransform &matrix)-
357{-
358 glyph_metrics_t metrics = boundingBox(glyph);-
359-
360 if (matrix.type() > QTransform::TxTranslate
matrix.type() ...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
361 return
never executed: return metrics.transformed(matrix);
metrics.transformed(matrix);
never executed: return metrics.transformed(matrix);
0
362 }-
363 return
never executed: return metrics;
metrics;
never executed: return metrics;
0
364}-
365-
366QFixed QFontEngine::xHeight() const-
367{-
368 const glyph_t glyph = glyphIndex('x');-
369 glyph_metrics_t bb = const_cast<QFontEngine *>(this)->boundingBox(glyph);-
370 return
never executed: return bb.height;
bb.height;
never executed: return bb.height;
0
371}-
372-
373QFixed QFontEngine::averageCharWidth() const-
374{-
375 const glyph_t glyph = glyphIndex('x');-
376 glyph_metrics_t bb = const_cast<QFontEngine *>(this)->boundingBox(glyph);-
377 return
never executed: return bb.xoff;
bb.xoff;
never executed: return bb.xoff;
0
378}-
379-
380bool QFontEngine::supportsTransformation(const QTransform &transform) const-
381{-
382 return
never executed: return transform.type() < QTransform::TxProject;
transform.type() < QTransform::TxProject;
never executed: return transform.type() < QTransform::TxProject;
0
383}-
384-
385void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags,-
386 QVarLengthArray<glyph_t> &glyphs_out, QVarLengthArray<QFixedPoint> &positions)-
387{-
388 QFixed xpos;-
389 QFixed ypos;-
390-
391 const bool transform = matrix.m11() != 1.
matrix.m11() != 1.Description
TRUEnever evaluated
FALSEnever evaluated
0
392 || matrix.m12() != 0.
matrix.m12() != 0.Description
TRUEnever evaluated
FALSEnever evaluated
0
393 || matrix.m21() != 0.
matrix.m21() != 0.Description
TRUEnever evaluated
FALSEnever evaluated
0
394 || matrix.m22() != 1.
matrix.m22() != 1.Description
TRUEnever evaluated
FALSEnever evaluated
;
0
395 if (!transform
!transformDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
396 xpos = QFixed::fromReal(matrix.dx());-
397 ypos = QFixed::fromReal(matrix.dy());-
398 }
never executed: end of block
0
399-
400 int current = 0;-
401 if (flags & QTextItem::RightToLeft
flags & QTextItem::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
402 int i = glyphs.numGlyphs;-
403 int totalKashidas = 0;-
404 while(i--
i--Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
405 if (glyphs.attributes[i].dontPrint
glyphs.attributes[i].dontPrintDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
406 continue;
never executed: continue;
0
407 xpos += glyphs.advances[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6);-
408 totalKashidas += glyphs.justifications[i].nKashidas;-
409 }
never executed: end of block
0
410 positions.resize(glyphs.numGlyphs+totalKashidas);-
411 glyphs_out.resize(glyphs.numGlyphs+totalKashidas);-
412-
413 i = 0;-
414 while(i < glyphs.numGlyphs
i < glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
415 if (glyphs.attributes[i].dontPrint
glyphs.attributes[i].dontPrintDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
416 ++i;-
417 continue;
never executed: continue;
0
418 }-
419 xpos -= glyphs.advances[i];-
420-
421 QFixed gpos_x = xpos + glyphs.offsets[i].x;-
422 QFixed gpos_y = ypos + glyphs.offsets[i].y;-
423 if (transform
transformDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
424 QPointF gpos(gpos_x.toReal(), gpos_y.toReal());-
425 gpos = gpos * matrix;-
426 gpos_x = QFixed::fromReal(gpos.x());-
427 gpos_y = QFixed::fromReal(gpos.y());-
428 }
never executed: end of block
0
429 positions[current].x = gpos_x;-
430 positions[current].y = gpos_y;-
431 glyphs_out[current] = glyphs.glyphs[i];-
432 ++current;-
433 if (glyphs.justifications[i].nKashidas
glyphs.justifi...s[i].nKashidasDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
434 QChar ch(0x640);-
435-
436 glyph_t kashidaGlyph = glyphIndex(ch.unicode());-
437 QFixed kashidaWidth;-
438-
439 QGlyphLayout g;-
440 g.numGlyphs = 1;-
441 g.glyphs = &kashidaGlyph;-
442 g.advances = &kashidaWidth;-
443 recalcAdvances(&g, 0);-
444-
445 for (uint k = 0; k < glyphs.justifications[i].nKashidas
k < glyphs.jus...s[i].nKashidasDescription
TRUEnever evaluated
FALSEnever evaluated
; ++k) {
0
446 xpos -= kashidaWidth;-
447-
448 QFixed gpos_x = xpos + glyphs.offsets[i].x;-
449 QFixed gpos_y = ypos + glyphs.offsets[i].y;-
450 if (transform
transformDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
451 QPointF gpos(gpos_x.toReal(), gpos_y.toReal());-
452 gpos = gpos * matrix;-
453 gpos_x = QFixed::fromReal(gpos.x());-
454 gpos_y = QFixed::fromReal(gpos.y());-
455 }
never executed: end of block
0
456 positions[current].x = gpos_x;-
457 positions[current].y = gpos_y;-
458 glyphs_out[current] = kashidaGlyph;-
459 ++current;-
460 }
never executed: end of block
0
461 }
never executed: end of block
else {
0
462 xpos -= QFixed::fromFixed(glyphs.justifications[i].space_18d6);-
463 }
never executed: end of block
0
464 ++i;-
465 }
never executed: end of block
0
466 }
never executed: end of block
else {
0
467 positions.resize(glyphs.numGlyphs);-
468 glyphs_out.resize(glyphs.numGlyphs);-
469 int i = 0;-
470 if (!transform
!transformDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
471 while (i < glyphs.numGlyphs
i < glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
472 if (!glyphs.attributes[i].dontPrint
!glyphs.attrib...s[i].dontPrintDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
473 positions[current].x = xpos + glyphs.offsets[i].x;-
474 positions[current].y = ypos + glyphs.offsets[i].y;-
475 glyphs_out[current] = glyphs.glyphs[i];-
476 xpos += glyphs.advances[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6);-
477 ++current;-
478 }
never executed: end of block
0
479 ++i;-
480 }
never executed: end of block
0
481 }
never executed: end of block
else {
0
482 while (i < glyphs.numGlyphs
i < glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
483 if (!glyphs.attributes[i].dontPrint
!glyphs.attrib...s[i].dontPrintDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
484 QFixed gpos_x = xpos + glyphs.offsets[i].x;-
485 QFixed gpos_y = ypos + glyphs.offsets[i].y;-
486 QPointF gpos(gpos_x.toReal(), gpos_y.toReal());-
487 gpos = gpos * matrix;-
488 positions[current].x = QFixed::fromReal(gpos.x());-
489 positions[current].y = QFixed::fromReal(gpos.y());-
490 glyphs_out[current] = glyphs.glyphs[i];-
491 xpos += glyphs.advances[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6);-
492 ++current;-
493 }
never executed: end of block
0
494 ++i;-
495 }
never executed: end of block
0
496 }
never executed: end of block
0
497 }-
498 positions.resize(current);-
499 glyphs_out.resize(current);-
500 ((!(positions.size() == glyphs_out.size())) ? qt_assert("positions.size() == glyphs_out.size()",__FILE__,556) : qt_noop());-
501}
never executed: end of block
0
502-
503void QFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)-
504{-
505 glyph_metrics_t gi = boundingBox(glyph);-
506 if (leftBearing != 0
leftBearing != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
507 *
never executed: *leftBearing = gi.leftBearing().toReal();
leftBearing = gi.leftBearing().toReal();
never executed: *leftBearing = gi.leftBearing().toReal();
0
508 if (rightBearing != 0
rightBearing != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
509 *
never executed: *rightBearing = gi.rightBearing().toReal();
rightBearing = gi.rightBearing().toReal();
never executed: *rightBearing = gi.rightBearing().toReal();
0
510}
never executed: end of block
0
511-
512qreal QFontEngine::minLeftBearing() const-
513{-
514 if (m_minLeftBearing == std::numeric_limits<qreal>::max()
m_minLeftBeari...<qreal>::max()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
515 minRightBearing();
never executed: minRightBearing();
0
516-
517 return
never executed: return m_minLeftBearing;
m_minLeftBearing;
never executed: return m_minLeftBearing;
0
518}-
519-
520-
521-
522-
523-
524-
525qreal QFontEngine::minRightBearing() const-
526{-
527 if (m_minRightBearing == std::numeric_limits<qreal>::max()
m_minRightBear...<qreal>::max()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
528-
529-
530 QByteArray hheaTable = getSfntTable(( (((quint32)('h')) << 24) | (((quint32)('h')) << 16) | (((quint32)('e')) << 8) | ((quint32)('a')) ));-
531 if (hheaTable.size() >= int(14 + sizeof(qint16))
hheaTable.size...izeof(qint16))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
532 const uchar *tableData = reinterpret_cast<const uchar *>(hheaTable.constData());-
533 ((!(((qFromBigEndian<quint32>(tableData)) / 65536.0) == 1.0)) ? qt_assert("q16Dot16ToFloat(qFromBigEndian<quint32>(tableData)) == 1.0",__FILE__,589) : qt_noop());-
534-
535 qint16 minLeftSideBearing = qFromBigEndian<qint16>(tableData + 12);-
536 qint16 minRightSideBearing = qFromBigEndian<qint16>(tableData + 14);-
537-
538-
539-
540-
541 int unitsPerEm = emSquareSize().toInt();-
542 qreal funitToPixelFactor = fontDef.pixelSize / unitsPerEm;-
543-
544-
545-
546-
547-
548 static const int largestValidBearing = 4 * unitsPerEm;-
549-
550 if (qAbs(minLeftSideBearing) < largestValidBearing
qAbs(minLeftSi...stValidBearingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
551 m_minLeftBearing = minLeftSideBearing * funitToPixelFactor;
never executed: m_minLeftBearing = minLeftSideBearing * funitToPixelFactor;
0
552 if (qAbs(minRightSideBearing) < largestValidBearing
qAbs(minRightS...stValidBearingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
553 m_minRightBearing = minRightSideBearing * funitToPixelFactor;
never executed: m_minRightBearing = minRightSideBearing * funitToPixelFactor;
0
554 }
never executed: end of block
0
555-
556-
557 if (m_minLeftBearing == std::numeric_limits<qreal>::max()
m_minLeftBeari...<qreal>::max()Description
TRUEnever evaluated
FALSEnever evaluated
|| m_minRightBearing == std::numeric_limits<qreal>::max()
m_minRightBear...<qreal>::max()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
558-
559-
560-
561-
562 static const ushort characterSubset[] = {-
563 '(', 'C', 'F', 'K', 'V', 'X', 'Y', ']', '_', 'f', 'r', '|',-
564 127, 205, 645, 884, 922, 1070, 12386-
565 };-
566-
567-
568 m_minLeftBearing = m_minRightBearing = std::numeric_limits<qreal>::max();-
569-
570 for (uint i = 0; i < (sizeof(characterSubset) / sizeof(ushort))
i < (sizeof(ch...izeof(ushort))Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
571 const glyph_t glyph = glyphIndex(characterSubset[i]);-
572 if (!glyph
!glyphDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
573 continue;
never executed: continue;
0
574-
575 glyph_metrics_t glyphMetrics = const_cast<QFontEngine *>(this)->boundingBox(glyph);-
576-
577-
578 if (!glyphMetrics.width
!glyphMetrics.widthDescription
TRUEnever evaluated
FALSEnever evaluated
|| !glyphMetrics.height
!glyphMetrics.heightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
579 continue;
never executed: continue;
0
580-
581 m_minLeftBearing = qMin(m_minLeftBearing, glyphMetrics.leftBearing().toReal());-
582 m_minRightBearing = qMin(m_minRightBearing, glyphMetrics.rightBearing().toReal());-
583 }
never executed: end of block
0
584 }
never executed: end of block
0
585-
586 if (m_minLeftBearing == std::numeric_limits<qreal>::max()
m_minLeftBeari...<qreal>::max()Description
TRUEnever evaluated
FALSEnever evaluated
|| m_minRightBearing == std::numeric_limits<qreal>::max()
m_minRightBear...<qreal>::max()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
587 QMessageLogger(__FILE__, 643, __PRETTY_FUNCTION__).warning() << "Failed to compute left/right minimum bearings for" << fontDef.family;
never executed: QMessageLogger(__FILE__, 643, __PRETTY_FUNCTION__).warning() << "Failed to compute left/right minimum bearings for" << fontDef.family;
0
588 }
never executed: end of block
0
589-
590 return
never executed: return m_minRightBearing;
m_minRightBearing;
never executed: return m_minRightBearing;
0
591}-
592-
593glyph_metrics_t QFontEngine::tightBoundingBox(const QGlyphLayout &glyphs)-
594{-
595 glyph_metrics_t overall;-
596-
597 QFixed ymax = 0;-
598 QFixed xmax = 0;-
599 for (int i = 0; i < glyphs.numGlyphs
i < glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
600 glyph_metrics_t bb = boundingBox(glyphs.glyphs[i]);-
601 QFixed x = overall.xoff + glyphs.offsets[i].x + bb.x;-
602 QFixed y = overall.yoff + glyphs.offsets[i].y + bb.y;-
603 overall.x = qMin(overall.x, x);-
604 overall.y = qMin(overall.y, y);-
605 xmax = qMax(xmax, x + bb.width);-
606 ymax = qMax(ymax, y + bb.height);-
607 overall.xoff += bb.xoff;-
608 overall.yoff += bb.yoff;-
609 }
never executed: end of block
0
610 overall.height = qMax(overall.height, ymax - overall.y);-
611 overall.width = xmax - overall.x;-
612-
613 return
never executed: return overall;
overall;
never executed: return overall;
0
614}-
615-
616-
617void QFontEngine::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path,-
618 QTextItem::RenderFlags flags)-
619{-
620 if (!glyphs.numGlyphs
!glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
621 return;
never executed: return;
0
622-
623 QVarLengthArray<QFixedPoint> positions;-
624 QVarLengthArray<glyph_t> positioned_glyphs;-
625 QTransform matrix = QTransform::fromTranslate(x, y);-
626 getGlyphPositions(glyphs, matrix, flags, positioned_glyphs, positions);-
627 addGlyphsToPath(positioned_glyphs.data(), positions.data(), positioned_glyphs.size(), path, flags);-
628}
never executed: end of block
0
629-
630-
631-
632-
633enum { EdgeRight = 0x1,-
634 EdgeDown = 0x2,-
635 EdgeLeft = 0x4,-
636 EdgeUp = 0x8-
637};-
638-
639static void collectSingleContour(qreal x0, qreal y0, uint *grid, int x, int y, int w, int h, QPainterPath *path)-
640{-
641 (void)h;;-
642-
643 path->moveTo(x + x0, y + y0);-
644 while (grid[(y)*(w+1) + (x)]
grid[(y)*(w+1) + (x)]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
645 if (grid[(y)*(w+1) + (x)] & EdgeRight
grid[(y)*(w+1)...)] & EdgeRightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
646 while (grid[(y)*(w+1) + (x)] & EdgeRight
grid[(y)*(w+1)...)] & EdgeRightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
647 grid[(y)*(w+1) + (x)] &= ~EdgeRight;-
648 ++x;-
649 }
never executed: end of block
0
650 ((!(x <= w)) ? qt_assert("x <= w",__FILE__,706) : qt_noop());-
651 path->lineTo(x + x0, y + y0);-
652 continue;
never executed: continue;
0
653 }-
654 if (grid[(y)*(w+1) + (x)] & EdgeDown
grid[(y)*(w+1)...x)] & EdgeDownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
655 while (grid[(y)*(w+1) + (x)] & EdgeDown
grid[(y)*(w+1)...x)] & EdgeDownDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
656 grid[(y)*(w+1) + (x)] &= ~EdgeDown;-
657 ++y;-
658 }
never executed: end of block
0
659 ((!(y <= h)) ? qt_assert("y <= h",__FILE__,715) : qt_noop());-
660 path->lineTo(x + x0, y + y0);-
661 continue;
never executed: continue;
0
662 }-
663 if (grid[(y)*(w+1) + (x)] & EdgeLeft
grid[(y)*(w+1)...x)] & EdgeLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
664 while (grid[(y)*(w+1) + (x)] & EdgeLeft
grid[(y)*(w+1)...x)] & EdgeLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
665 grid[(y)*(w+1) + (x)] &= ~EdgeLeft;-
666 --x;-
667 }
never executed: end of block
0
668 ((!(x >= 0)) ? qt_assert("x >= 0",__FILE__,724) : qt_noop());-
669 path->lineTo(x + x0, y + y0);-
670 continue;
never executed: continue;
0
671 }-
672 if (grid[(y)*(w+1) + (x)] & EdgeUp
grid[(y)*(w+1) + (x)] & EdgeUpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
673 while (grid[(y)*(w+1) + (x)] & EdgeUp
grid[(y)*(w+1) + (x)] & EdgeUpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
674 grid[(y)*(w+1) + (x)] &= ~EdgeUp;-
675 --y;-
676 }
never executed: end of block
0
677 ((!(y >= 0)) ? qt_assert("y >= 0",__FILE__,733) : qt_noop());-
678 path->lineTo(x + x0, y + y0);-
679 continue;
never executed: continue;
0
680 }-
681 }
never executed: end of block
0
682 path->closeSubpath();-
683}
never executed: end of block
0
684-
685__attribute__((visibility("default"))) void qt_addBitmapToPath(qreal x0, qreal y0, const uchar *image_data, int bpl, int w, int h, QPainterPath *path)-
686{-
687 uint *grid = new uint[(w+1)*(h+1)];-
688-
689 for (int y = 0; y <= h
y <= hDescription
TRUEnever evaluated
FALSEnever evaluated
; ++y) {
0
690 for (int x = 0; x <= w
x <= wDescription
TRUEnever evaluated
FALSEnever evaluated
; ++x) {
0
691 bool topLeft = (
(x == 0)|(y == 0)Description
TRUEnever evaluated
FALSEnever evaluated
x == 0)|(y == 0)
(x == 0)|(y == 0)Description
TRUEnever evaluated
FALSEnever evaluated
? false : (*(image_data + (y - 1)*bpl + ((x - 1) >> 3)) & (0x80 >> ((x - 1) & 7)));
0
692 bool topRight = (
(x == w)|(y == 0)Description
TRUEnever evaluated
FALSEnever evaluated
x == w)|(y == 0)
(x == w)|(y == 0)Description
TRUEnever evaluated
FALSEnever evaluated
? false : (*(image_data + (y - 1)*bpl + ((x) >> 3)) & (0x80 >> ((x) & 7)));
0
693 bool bottomLeft = (
(x == 0)|(y == h)Description
TRUEnever evaluated
FALSEnever evaluated
x == 0)|(y == h)
(x == 0)|(y == h)Description
TRUEnever evaluated
FALSEnever evaluated
? false : (*(image_data + (y)*bpl + ((x - 1) >> 3)) & (0x80 >> ((x - 1) & 7)));
0
694 bool bottomRight = (
(x == w)|(y == h)Description
TRUEnever evaluated
FALSEnever evaluated
x == w)|(y == h)
(x == w)|(y == h)Description
TRUEnever evaluated
FALSEnever evaluated
? false : (*(image_data + (y)*bpl + ((x) >> 3)) & (0x80 >> ((x) & 7)));
0
695-
696 grid[(y)*(w+1) + (x)] = 0;-
697 if ((
(!topRight) & bottomRightDescription
TRUEnever evaluated
FALSEnever evaluated
!topRight) & bottomRight
(!topRight) & bottomRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
698 grid[(y)*(w+1) + (x)] |= EdgeRight;
never executed: grid[(y)*(w+1) + (x)] |= EdgeRight;
0
699 if ((
(!bottomRight) & bottomLeftDescription
TRUEnever evaluated
FALSEnever evaluated
!bottomRight) & bottomLeft
(!bottomRight) & bottomLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
700 grid[(y)*(w+1) + (x)] |= EdgeDown;
never executed: grid[(y)*(w+1) + (x)] |= EdgeDown;
0
701 if ((
(!bottomLeft) & topLeftDescription
TRUEnever evaluated
FALSEnever evaluated
!bottomLeft) & topLeft
(!bottomLeft) & topLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
702 grid[(y)*(w+1) + (x)] |= EdgeLeft;
never executed: grid[(y)*(w+1) + (x)] |= EdgeLeft;
0
703 if ((
(!topLeft) & topRightDescription
TRUEnever evaluated
FALSEnever evaluated
!topLeft) & topRight
(!topLeft) & topRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
704 grid[(y)*(w+1) + (x)] |= EdgeUp;
never executed: grid[(y)*(w+1) + (x)] |= EdgeUp;
0
705 }
never executed: end of block
0
706 }
never executed: end of block
0
707-
708-
709 for (int y = 0; y < h
y < hDescription
TRUEnever evaluated
FALSEnever evaluated
; ++y) {
0
710 for (int x = 0; x < w
x < wDescription
TRUEnever evaluated
FALSEnever evaluated
; ++x) {
0
711 if (!grid[(y)*(w+1) + (x)]
!grid[(y)*(w+1) + (x)]Description
TRUEnever evaluated
FALSEnever evaluated
)
0
712 continue;
never executed: continue;
0
713-
714 collectSingleContour(x0, y0, grid, x, y, w, h, path);-
715 }
never executed: end of block
0
716 }
never executed: end of block
0
717 delete [] grid;-
718}
never executed: end of block
0
719-
720-
721-
722-
723-
724void QFontEngine::addBitmapFontToPath(qreal x, qreal y, const QGlyphLayout &glyphs,-
725 QPainterPath *path, QTextItem::RenderFlags flags)-
726{-
727-
728 (void)flags;;-
729 QFixed advanceX = QFixed::fromReal(x);-
730 QFixed advanceY = QFixed::fromReal(y);-
731 for (int i=0; i < glyphs.numGlyphs
i < glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
732 glyph_metrics_t metrics = boundingBox(glyphs.glyphs[i]);-
733 if (metrics.width.value() == 0
metrics.width.value() == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| metrics.height.value() == 0
metrics.height.value() == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
734 advanceX += glyphs.advances[i];-
735 continue;
never executed: continue;
0
736 }-
737 const QImage alphaMask = alphaMapForGlyph(glyphs.glyphs[i]);-
738-
739 const int w = alphaMask.width();-
740 const int h = alphaMask.height();-
741 const int srcBpl = alphaMask.bytesPerLine();-
742 QImage bitmap;-
743 if (alphaMask.depth() == 1
alphaMask.depth() == 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
744 bitmap = alphaMask;-
745 }
never executed: end of block
else {
0
746 bitmap = QImage(w, h, QImage::Format_Mono);-
747 const uchar *imageData = alphaMask.bits();-
748 const int destBpl = bitmap.bytesPerLine();-
749 uchar *bitmapData = bitmap.bits();-
750-
751 for (int yi = 0; yi < h
yi < hDescription
TRUEnever evaluated
FALSEnever evaluated
; ++yi) {
0
752 const uchar *src = imageData + yi*srcBpl;-
753 uchar *dst = bitmapData + yi*destBpl;-
754 for (int xi = 0; xi < w
xi < wDescription
TRUEnever evaluated
FALSEnever evaluated
; ++xi) {
0
755 const int byte = xi / 8;-
756 const int bit = xi % 8;-
757 if (bit == 0
bit == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
758 dst[byte] = 0;
never executed: dst[byte] = 0;
0
759 if (src[xi]
src[xi]Description
TRUEnever evaluated
FALSEnever evaluated
)
0
760 dst[byte] |= 128 >> bit;
never executed: dst[byte] |= 128 >> bit;
0
761 }
never executed: end of block
0
762 }
never executed: end of block
0
763 }
never executed: end of block
0
764 const uchar *bitmap_data = bitmap.constBits();-
765 QFixedPoint offset = glyphs.offsets[i];-
766 advanceX += offset.x;-
767 advanceY += offset.y;-
768 qt_addBitmapToPath((advanceX + metrics.x).toReal(), (advanceY + metrics.y).toReal(), bitmap_data, bitmap.bytesPerLine(), w, h, path);-
769 advanceX += glyphs.advances[i];-
770 }
never executed: end of block
0
771}
never executed: end of block
0
772-
773void QFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nGlyphs,-
774 QPainterPath *path, QTextItem::RenderFlags flags)-
775{-
776 qreal x = positions[0].x.toReal();-
777 qreal y = positions[0].y.toReal();-
778 QVarLengthGlyphLayoutArray g(nGlyphs);-
779-
780 for (int i = 0; i < nGlyphs - 1
i < nGlyphs - 1Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
781 g.glyphs[i] = glyphs[i];-
782 g.advances[i] = positions[i + 1].x - positions[i].x;-
783 }
never executed: end of block
0
784 g.glyphs[nGlyphs - 1] = glyphs[nGlyphs - 1];-
785 g.advances[nGlyphs - 1] = QFixed::fromReal(maxCharWidth());-
786-
787 addBitmapFontToPath(x, y, g, path, flags);-
788}
never executed: end of block
0
789-
790QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed )-
791{-
792-
793 return
never executed: return alphaMapForGlyph(glyph);
alphaMapForGlyph(glyph);
never executed: return alphaMapForGlyph(glyph);
0
794}-
795-
796QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &t)-
797{-
798 QImage i = alphaMapForGlyph(glyph);-
799 if (t.type() > QTransform::TxTranslate
t.type() > QTr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
800 i = i.transformed(t).convertToFormat(QImage::Format_Alpha8);
never executed: i = i.transformed(t).convertToFormat(QImage::Format_Alpha8);
0
801 ((!(i.depth() <= 8)) ? qt_assert("i.depth() <= 8",__FILE__,857) : qt_noop());-
802-
803 return
never executed: return i;
i;
never executed: return i;
0
804}-
805-
806QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)-
807{-
808 if (! supportsSubPixelPositions()
! supportsSubPixelPositions()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
809 return
never executed: return alphaMapForGlyph(glyph, t);
alphaMapForGlyph(glyph, t);
never executed: return alphaMapForGlyph(glyph, t);
0
810-
811 QImage i = alphaMapForGlyph(glyph, subPixelPosition);-
812 if (t.type() > QTransform::TxTranslate
t.type() > QTr...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
813 i = i.transformed(t).convertToFormat(QImage::Format_Alpha8);
never executed: i = i.transformed(t).convertToFormat(QImage::Format_Alpha8);
0
814 ((!(i.depth() <= 8)) ? qt_assert("i.depth() <= 8",__FILE__,870) : qt_noop());-
815-
816 return
never executed: return i;
i;
never executed: return i;
0
817}-
818-
819QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed , const QTransform &t)-
820{-
821 const QImage alphaMask = alphaMapForGlyph(glyph, t);-
822 QImage rgbMask(alphaMask.width(), alphaMask.height(), QImage::Format_RGB32);-
823-
824 for (int y=0; y<alphaMask.height()
y<alphaMask.height()Description
TRUEnever evaluated
FALSEnever evaluated
; ++y) {
0
825 uint *dst = (uint *) rgbMask.scanLine(y);-
826 const uchar *src = alphaMask.constScanLine(y);-
827 for (int x=0; x<alphaMask.width()
x<alphaMask.width()Description
TRUEnever evaluated
FALSEnever evaluated
; ++x) {
0
828 int val = src[x];-
829 dst[x] = qRgb(val, val, val);-
830 }
never executed: end of block
0
831 }
never executed: end of block
0
832-
833 return
never executed: return rgbMask;
rgbMask;
never executed: return rgbMask;
0
834}-
835-
836QImage QFontEngine::bitmapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform&)-
837{-
838 (void)subPixelPosition;;-
839-
840 return
never executed: return QImage();
QImage();
never executed: return QImage();
0
841}-
842-
843QFixed QFontEngine::subPixelPositionForX(QFixed x) const-
844{-
845 if (m_subPixelPositionCount <= 1
m_subPixelPositionCount <= 1Description
TRUEnever evaluated
FALSEnever evaluated
|| !supportsSubPixelPositions()
!supportsSubPixelPositions()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
846 return
never executed: return QFixed();
QFixed();
never executed: return QFixed();
0
847-
848 QFixed subPixelPosition;-
849 if (x != 0
x != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
850 subPixelPosition = x - x.floor();-
851 QFixed fraction = (subPixelPosition / QFixed::fromReal(1.0 / m_subPixelPositionCount)).floor();-
852-
853-
854-
855 subPixelPosition = fraction / QFixed(m_subPixelPositionCount) + QFixed::fromReal(0.015625);-
856 }
never executed: end of block
0
857 return
never executed: return subPixelPosition;
subPixelPosition;
never executed: return subPixelPosition;
0
858}-
859-
860QImage *QFontEngine::lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition,-
861 QFontEngine::GlyphFormat neededFormat,-
862 const QTransform &t, QPoint *offset)-
863{-
864 ((!(currentlyLockedAlphaMap.isNull())) ? qt_assert("currentlyLockedAlphaMap.isNull()",__FILE__,920) : qt_noop());-
865 if (neededFormat == Format_None
neededFormat == Format_NoneDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
866 neededFormat = Format_A32;
never executed: neededFormat = Format_A32;
0
867-
868 if (neededFormat != Format_A32
neededFormat != Format_A32Description
TRUEnever evaluated
FALSEnever evaluated
)
0
869 currentlyLockedAlphaMap = alphaMapForGlyph(glyph, subPixelPosition, t);
never executed: currentlyLockedAlphaMap = alphaMapForGlyph(glyph, subPixelPosition, t);
0
870 else-
871 currentlyLockedAlphaMap = alphaRGBMapForGlyph(glyph, subPixelPosition, t);
never executed: currentlyLockedAlphaMap = alphaRGBMapForGlyph(glyph, subPixelPosition, t);
0
872-
873 if (offset != 0
offset != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
874 *
never executed: *offset = QPoint(0, 0);
offset = QPoint(0, 0);
never executed: *offset = QPoint(0, 0);
0
875-
876 return
never executed: return &currentlyLockedAlphaMap;
&currentlyLockedAlphaMap;
never executed: return &currentlyLockedAlphaMap;
0
877}-
878-
879void QFontEngine::unlockAlphaMapForGlyph()-
880{-
881 ((!(!currentlyLockedAlphaMap.isNull())) ? qt_assert("!currentlyLockedAlphaMap.isNull()",__FILE__,937) : qt_noop());-
882 currentlyLockedAlphaMap = QImage();-
883}
never executed: end of block
0
884-
885QImage QFontEngine::alphaMapForGlyph(glyph_t glyph)-
886{-
887 glyph_metrics_t gm = boundingBox(glyph);-
888 int glyph_x = qFloor(gm.x.toReal());-
889 int glyph_y = qFloor(gm.y.toReal());-
890 int glyph_width = qCeil((gm.x + gm.width).toReal()) - glyph_x;-
891 int glyph_height = qCeil((gm.y + gm.height).toReal()) - glyph_y;-
892-
893 if (glyph_width <= 0
glyph_width <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| glyph_height <= 0
glyph_height <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
894 return
never executed: return QImage();
QImage();
never executed: return QImage();
0
895 QFixedPoint pt;-
896 pt.x = -glyph_x;-
897 pt.y = -glyph_y;-
898 QPainterPath path;-
899 path.setFillRule(Qt::WindingFill);-
900 QImage im(glyph_width, glyph_height, QImage::Format_ARGB32_Premultiplied);-
901 im.fill(Qt::transparent);-
902 QPainter p(&im);-
903 p.setRenderHint(QPainter::Antialiasing);-
904 addGlyphsToPath(&glyph, &pt, 1, &path, 0);-
905 p.setPen(Qt::NoPen);-
906 p.setBrush(Qt::black);-
907 p.drawPath(path);-
908 p.end();-
909-
910 QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8);-
911-
912 for (int y=0; y<im.height()
y<im.height()Description
TRUEnever evaluated
FALSEnever evaluated
; ++y) {
0
913 uchar *dst = (uchar *) alphaMap.scanLine(y);-
914 const uint *src = reinterpret_cast<const uint *>(im.constScanLine(y));-
915 for (int x=0; x<im.width()
x<im.width()Description
TRUEnever evaluated
FALSEnever evaluated
; ++x)
0
916 dst[x] = qAlpha(src[x]);
never executed: dst[x] = qAlpha(src[x]);
0
917 }
never executed: end of block
0
918-
919 return
never executed: return alphaMap;
alphaMap;
never executed: return alphaMap;
0
920}-
921-
922void QFontEngine::removeGlyphFromCache(glyph_t)-
923{-
924}-
925-
926QFontEngine::Properties QFontEngine::properties() const-
927{-
928 Properties p;-
929 QByteArray psname = QFontEngine::convertToPostscriptFontFamilyName(fontDef.family.toUtf8());-
930 psname += '-';-
931 psname += QByteArray::number(fontDef.style);-
932 psname += '-';-
933 psname += QByteArray::number(fontDef.weight);-
934-
935 p.postscriptName = psname;-
936 p.ascent = ascent();-
937 p.descent = descent();-
938 p.leading = leading();-
939 p.emSquare = p.ascent;-
940 p.boundingBox = QRectF(0, -p.ascent.toReal(), maxCharWidth(), (p.ascent + p.descent).toReal());-
941 p.italicAngle = 0;-
942 p.capHeight = p.ascent;-
943 p.lineWidth = lineThickness();-
944 return
never executed: return p;
p;
never executed: return p;
0
945}-
946-
947void QFontEngine::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)-
948{-
949 *metrics = boundingBox(glyph);-
950 QFixedPoint p;-
951 p.x = 0;-
952 p.y = 0;-
953 addGlyphsToPath(&glyph, &p, 1, path, QFlag(0));-
954}
never executed: end of block
0
955bool QFontEngine::getSfntTableData(uint tag, uchar *buffer, uint *length) const-
956{-
957 (void)tag;-
958 (void)buffer;-
959 (void)length;-
960 return
never executed: return false;
false;
never executed: return false;
0
961}-
962-
963QByteArray QFontEngine::getSfntTable(uint tag) const-
964{-
965 QByteArray table;-
966 uint len = 0;-
967 if (!getSfntTableData(tag, 0, &len)
!getSfntTableD...(tag, 0, &len)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
968 return
never executed: return table;
table;
never executed: return table;
0
969 table.resize(len);-
970 if (!getSfntTableData(tag, reinterpret_cast<uchar *>(table.data()), &len)
!getSfntTableD...data()), &len)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
971 return
never executed: return QByteArray();
QByteArray();
never executed: return QByteArray();
0
972 return
never executed: return table;
table;
never executed: return table;
0
973}-
974-
975void QFontEngine::clearGlyphCache(const void *context)-
976{-
977 m_glyphCaches.remove(context);-
978}
never executed: end of block
0
979-
980void QFontEngine::setGlyphCache(const void *context, QFontEngineGlyphCache *cache)-
981{-
982 ((!(cache)) ? qt_assert("cache",__FILE__,1050) : qt_noop());-
983-
984 GlyphCaches &caches = m_glyphCaches[context];-
985 for (GlyphCaches::const_iterator it = caches.constBegin(), end = caches.constEnd(); it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
986 if (cache == it->cache.data()
cache == it->cache.data()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
987 return;
never executed: return;
0
988 }
never executed: end of block
0
989-
990-
991-
992 if (caches.size() == 4
caches.size() == 4Description
TRUEnever evaluated
FALSEnever evaluated
)
0
993 caches.removeLast();
never executed: caches.removeLast();
0
994-
995 GlyphCacheEntry entry;-
996 entry.cache = cache;-
997 caches.push_front(entry);-
998-
999}
never executed: end of block
0
1000-
1001QFontEngineGlyphCache *QFontEngine::glyphCache(const void *context, GlyphFormat format, const QTransform &transform) const-
1002{-
1003 const QHash<const void*, GlyphCaches>::const_iterator caches = m_glyphCaches.constFind(context);-
1004 if (caches == m_glyphCaches.cend()
caches == m_glyphCaches.cend()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1005 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
1006-
1007 for (GlyphCaches::const_iterator it = caches->begin(), end = caches->end(); it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
1008 QFontEngineGlyphCache *cache = it->cache.data();-
1009 if (format == cache->glyphFormat()
format == cache->glyphFormat()Description
TRUEnever evaluated
FALSEnever evaluated
&& qtransform_equals_no_translate(cache->m_transform, transform)
qtransform_equ...rm, transform)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1010 return
never executed: return cache;
cache;
never executed: return cache;
0
1011 }
never executed: end of block
0
1012-
1013 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
1014}-
1015-
1016static inline QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs)-
1017{-
1018 uint left_right = (left << 16) + right;-
1019-
1020 left = 0, right = numPairs - 1;-
1021 while (left <= right
left <= rightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1022 int middle = left + ( ( right - left ) >> 1 );-
1023-
1024 if(pairs[middle].left_right == left_right
pairs[middle].... == left_rightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1025 return
never executed: return pairs[middle].adjust;
pairs[middle].adjust;
never executed: return pairs[middle].adjust;
0
1026-
1027 if (pairs[middle].left_right < left_right
pairs[middle]....t < left_rightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1028 left = middle + 1;
never executed: left = middle + 1;
0
1029 else-
1030 right = middle - 1;
never executed: right = middle - 1;
0
1031 }-
1032 return
never executed: return 0;
0;
never executed: return 0;
0
1033}-
1034-
1035void QFontEngine::doKerning(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const-
1036{-
1037 int numPairs = kerning_pairs.size();-
1038 if(!numPairs
!numPairsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1039 return;
never executed: return;
0
1040-
1041 const KernPair *pairs = kerning_pairs.constData();-
1042-
1043 if (flags & DesignMetrics
flags & DesignMetricsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1044 for(int i = 0; i < glyphs->numGlyphs - 1
i < glyphs->numGlyphs - 1Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1045 glyphs->advances[i] += kerning(glyphs->glyphs[i], glyphs->glyphs[i+1] , pairs, numPairs);
never executed: glyphs->advances[i] += kerning(glyphs->glyphs[i], glyphs->glyphs[i+1] , pairs, numPairs);
0
1046 }
never executed: end of block
else {
0
1047 for(int i = 0; i < glyphs->numGlyphs - 1
i < glyphs->numGlyphs - 1Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1048 glyphs->advances[i] += qRound(kerning(glyphs->glyphs[i], glyphs->glyphs[i+1] , pairs, numPairs));
never executed: glyphs->advances[i] += qRound(kerning(glyphs->glyphs[i], glyphs->glyphs[i+1] , pairs, numPairs));
0
1049 }
never executed: end of block
0
1050}-
1051-
1052void QFontEngine::loadKerningPairs(QFixed scalingFactor)-
1053{-
1054 kerning_pairs.clear();-
1055-
1056 QByteArray tab = getSfntTable(( (((quint32)('k')) << 24) | (((quint32)('e')) << 16) | (((quint32)('r')) << 8) | ((quint32)('n')) ));-
1057 if (tab.isEmpty()
tab.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1058 return;
never executed: return;
0
1059-
1060 const uchar *table = reinterpret_cast<const uchar *>(tab.constData());-
1061 const uchar *end = table + tab.size();-
1062-
1063 quint16 version;-
1064 if (!qSafeFromBigEndian(table, end, &version)
!qSafeFromBigE...end, &version)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1065 return;
never executed: return;
0
1066-
1067 if (version != 0
version != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1068-
1069 return;
never executed: return;
0
1070 }-
1071-
1072 quint16 numTables;-
1073 if (!qSafeFromBigEndian(table + 2, end, &numTables)
!qSafeFromBigE...d, &numTables)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1074 return;
never executed: return;
0
1075-
1076 {-
1077 int offset = 4;-
1078 for(int i = 0; i < numTables
i < numTablesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1079 const uchar *header = table + offset;-
1080-
1081 quint16 version;-
1082 if (!qSafeFromBigEndian(header, end, &version)
!qSafeFromBigE...end, &version)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1083 goto
never executed: goto end;
end;
never executed: goto end;
0
1084-
1085 quint16 length;-
1086 if (!qSafeFromBigEndian(header + 2, end, &length)
!qSafeFromBigE... end, &length)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1087 goto
never executed: goto end;
end;
never executed: goto end;
0
1088-
1089 quint16 coverage;-
1090 if (!qSafeFromBigEndian(header + 4, end, &coverage)
!qSafeFromBigE...nd, &coverage)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1091 goto
never executed: goto end;
end;
never executed: goto end;
0
1092-
1093-
1094 if(version == 0
version == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& coverage == 0x0001
coverage == 0x0001Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1095 if (offset + length > tab.size()
offset + length > tab.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1096-
1097 goto
never executed: goto end;
end;
never executed: goto end;
0
1098 }-
1099 const uchar *data = table + offset + 6;-
1100-
1101 quint16 nPairs;-
1102 if (!qSafeFromBigEndian(data, end, &nPairs)
!qSafeFromBigE... end, &nPairs)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1103 goto
never executed: goto end;
end;
never executed: goto end;
0
1104-
1105 if(nPairs * 6 + 8 > length - 6
nPairs * 6 + 8 > length - 6Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1106-
1107-
1108 goto
never executed: goto end;
end;
never executed: goto end;
0
1109 }-
1110-
1111 int off = 8;-
1112 for(int i = 0; i < nPairs
i < nPairsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1113 QFontEngine::KernPair p;-
1114-
1115 quint16 tmp;-
1116 if (!qSafeFromBigEndian(data + off, end, &tmp)
!qSafeFromBigE...ff, end, &tmp)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1117 goto
never executed: goto end;
end;
never executed: goto end;
0
1118-
1119 p.left_right = uint(tmp) << 16;-
1120 if (!qSafeFromBigEndian(data + off + 2, end, &tmp)
!qSafeFromBigE... 2, end, &tmp)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1121 goto
never executed: goto end;
end;
never executed: goto end;
0
1122-
1123 p.left_right |= tmp;-
1124-
1125 if (!qSafeFromBigEndian(data + off + 4, end, &tmp)
!qSafeFromBigE... 4, end, &tmp)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1126 goto
never executed: goto end;
end;
never executed: goto end;
0
1127-
1128 p.adjust = QFixed(int(short(tmp))) / scalingFactor;-
1129 kerning_pairs.append(p);-
1130 off += 6;-
1131 }
never executed: end of block
0
1132 }
never executed: end of block
0
1133 offset += length;-
1134 }
never executed: end of block
0
1135 }-
1136end:
code before this statement never executed: end:
0
1137 std::sort(kerning_pairs.begin(), kerning_pairs.end());-
1138-
1139-
1140}
never executed: end of block
0
1141-
1142-
1143int QFontEngine::glyphCount() const-
1144{-
1145 QByteArray maxpTable = getSfntTable(( (((quint32)('m')) << 24) | (((quint32)('a')) << 16) | (((quint32)('x')) << 8) | ((quint32)('p')) ));-
1146 if (maxpTable.size() < 6
maxpTable.size() < 6Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1147 return
never executed: return 0;
0;
never executed: return 0;
0
1148-
1149 const uchar *source = reinterpret_cast<const uchar *>(maxpTable.constData() + 4);-
1150 const uchar *end = source + maxpTable.size();-
1151-
1152 quint16 count = 0;-
1153 qSafeFromBigEndian(source, end, &count);-
1154 return
never executed: return count;
count;
never executed: return count;
0
1155}-
1156-
1157Qt::HANDLE QFontEngine::handle() const-
1158{-
1159 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
1160}-
1161-
1162const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize)-
1163{-
1164 const uchar *header = table;-
1165 const uchar *endPtr = table + tableSize;-
1166-
1167-
1168 quint16 version;-
1169 if (!qSafeFromBigEndian(header, endPtr, &version)
!qSafeFromBigE...Ptr, &version)Description
TRUEnever evaluated
FALSEnever evaluated
|| version != 0
version != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1170 return
never executed: return 0;
0;
never executed: return 0;
0
1171-
1172 quint16 numTables;-
1173 if (!qSafeFromBigEndian(header + 2, endPtr, &numTables)
!qSafeFromBigE...r, &numTables)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1174 return
never executed: return 0;
0;
never executed: return 0;
0
1175-
1176 const uchar *maps = table + 4;-
1177-
1178 enum {-
1179 Invalid,-
1180 AppleRoman,-
1181 Symbol,-
1182 Unicode11,-
1183 Unicode,-
1184 MicrosoftUnicode,-
1185 MicrosoftUnicodeExtended-
1186 };-
1187-
1188 int symbolTable = -1;-
1189 int tableToUse = -1;-
1190 int score = Invalid;-
1191 for (int n = 0; n < numTables
n < numTablesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++n) {
0
1192 quint16 platformId;-
1193 if (!qSafeFromBigEndian(maps + 8 * n, endPtr, &platformId)
!qSafeFromBigE..., &platformId)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1194 return
never executed: return 0;
0;
never executed: return 0;
0
1195-
1196 quint16 platformSpecificId;-
1197 if (!qSafeFromBigEndian(maps + 8 * n + 2, endPtr, &platformSpecificId)
!qSafeFromBigE...ormSpecificId)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1198 return
never executed: return 0;
0;
never executed: return 0;
0
1199-
1200 switch (platformId) {-
1201 case
never executed: case 0:
0:
never executed: case 0:
0
1202 if (score < Unicode
score < UnicodeDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
1203 (platformSpecificId == 0
platformSpecificId == 0Description
TRUEnever evaluated
FALSEnever evaluated
||
0
1204 platformSpecificId == 2
platformSpecificId == 2Description
TRUEnever evaluated
FALSEnever evaluated
||
0
1205 platformSpecificId == 3
platformSpecificId == 3Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
1206 tableToUse = n;-
1207 score = Unicode;-
1208 }
never executed: end of block
else if (score < Unicode11
score < Unicode11Description
TRUEnever evaluated
FALSEnever evaluated
&& platformSpecificId == 1
platformSpecificId == 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1209 tableToUse = n;-
1210 score = Unicode11;-
1211 }
never executed: end of block
0
1212 break;
never executed: break;
0
1213 case
never executed: case 1:
1:
never executed: case 1:
0
1214 if (score < AppleRoman
score < AppleRomanDescription
TRUEnever evaluated
FALSEnever evaluated
&& platformSpecificId == 0
platformSpecificId == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1215 tableToUse = n;-
1216 score = AppleRoman;-
1217 }
never executed: end of block
0
1218 break;
never executed: break;
0
1219 case
never executed: case 3:
3:
never executed: case 3:
0
1220 switch (platformSpecificId) {-
1221 case
never executed: case 0:
0:
never executed: case 0:
0
1222 symbolTable = n;-
1223 if (score < Symbol
score < SymbolDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1224 tableToUse = n;-
1225 score = Symbol;-
1226 }
never executed: end of block
0
1227 break;
never executed: break;
0
1228 case
never executed: case 1:
1:
never executed: case 1:
0
1229 if (score < MicrosoftUnicode
score < MicrosoftUnicodeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1230 tableToUse = n;-
1231 score = MicrosoftUnicode;-
1232 }
never executed: end of block
0
1233 break;
never executed: break;
0
1234 case
never executed: case 0xa:
0xa:
never executed: case 0xa:
0
1235 if (score < MicrosoftUnicodeExtended
score < Micros...nicodeExtendedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1236 tableToUse = n;-
1237 score = MicrosoftUnicodeExtended;-
1238 }
never executed: end of block
0
1239 break;
never executed: break;
0
1240 default
never executed: default:
:
never executed: default:
0
1241 break;
never executed: break;
0
1242 }-
1243 default
never executed: default:
:
never executed: default:
code before this statement never executed: default:
0
1244 break;
never executed: break;
0
1245 }-
1246 }-
1247 if(tableToUse < 0
tableToUse < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1248 return
never executed: return 0;
0;
never executed: return 0;
0
1249-
1250resolveTable:
code before this statement never executed: resolveTable:
0
1251 *isSymbolFont = (symbolTable > -1);-
1252-
1253 quint32 unicode_table;-
1254 if (!qSafeFromBigEndian(maps + 8 * tableToUse + 4, endPtr, &unicode_table)
!qSafeFromBigE...unicode_table)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1255 return
never executed: return 0;
0;
never executed: return 0;
0
1256-
1257 if (!unicode_table
!unicode_tableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1258 return
never executed: return 0;
0;
never executed: return 0;
0
1259-
1260-
1261 header = table + unicode_table;-
1262-
1263 quint16 format;-
1264 if (!qSafeFromBigEndian(header, endPtr, &format)
!qSafeFromBigE...dPtr, &format)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1265 return
never executed: return 0;
0;
never executed: return 0;
0
1266-
1267 quint32 length;-
1268 if (format < 8
format < 8Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1269 quint16 tmp;-
1270 if (!qSafeFromBigEndian(header + 2, endPtr, &tmp)
!qSafeFromBigE... endPtr, &tmp)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1271 return
never executed: return 0;
0;
never executed: return 0;
0
1272 length = tmp;-
1273 }
never executed: end of block
else {
0
1274 if (!qSafeFromBigEndian(header + 4, endPtr, &length)
!qSafeFromBigE...dPtr, &length)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1275 return
never executed: return 0;
0;
never executed: return 0;
0
1276 }
never executed: end of block
0
1277-
1278 if (table + unicode_table + length > endPtr
table + unicod...ength > endPtrDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1279 return
never executed: return 0;
0;
never executed: return 0;
0
1280 *cmapSize = length;-
1281-
1282-
1283-
1284-
1285 if (symbolTable > -1
symbolTable > -1Description
TRUEnever evaluated
FALSEnever evaluated
&& ((
(score == Unicode)Description
TRUEnever evaluated
FALSEnever evaluated
score == Unicode)
(score == Unicode)Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(score == Unicode11)Description
TRUEnever evaluated
FALSEnever evaluated
score == Unicode11)
(score == Unicode11)Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
1286 const uchar *selectedTable = table + unicode_table;-
1287-
1288-
1289 bool unicodeTableHasLatin1 = false;-
1290 for (int uc=0x00; uc<0x100
uc<0x100Description
TRUEnever evaluated
FALSEnever evaluated
; ++uc) {
0
1291 if (getTrueTypeGlyphIndex(selectedTable, length, uc) != 0
getTrueTypeGly...ngth, uc) != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1292 unicodeTableHasLatin1 = true;-
1293 break;
never executed: break;
0
1294 }-
1295 }
never executed: end of block
0
1296-
1297-
1298 bool unicodeTableHasSymbols = false;-
1299 if (!unicodeTableHasLatin1
!unicodeTableHasLatin1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1300 for (int uc=0xf000; uc<0xf100
uc<0xf100Description
TRUEnever evaluated
FALSEnever evaluated
; ++uc) {
0
1301 if (getTrueTypeGlyphIndex(selectedTable, length, uc) != 0
getTrueTypeGly...ngth, uc) != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1302 unicodeTableHasSymbols = true;-
1303 break;
never executed: break;
0
1304 }-
1305 }
never executed: end of block
0
1306 }
never executed: end of block
0
1307-
1308-
1309 if (!unicodeTableHasLatin1
!unicodeTableHasLatin1Description
TRUEnever evaluated
FALSEnever evaluated
&& unicodeTableHasSymbols
unicodeTableHasSymbolsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1310 tableToUse = symbolTable;-
1311 score = Symbol;-
1312 goto
never executed: goto resolveTable;
resolveTable;
never executed: goto resolveTable;
0
1313 }-
1314 }
never executed: end of block
0
1315-
1316 return
never executed: return table + unicode_table;
table + unicode_table;
never executed: return table + unicode_table;
0
1317}-
1318-
1319quint32 QFontEngine::getTrueTypeGlyphIndex(const uchar *cmap, int cmapSize, uint unicode)-
1320{-
1321 const uchar *end = cmap + cmapSize;-
1322 quint16 format;-
1323 if (!qSafeFromBigEndian(cmap, end, &format)
!qSafeFromBigE... end, &format)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1324 return
never executed: return 0;
0;
never executed: return 0;
0
1325-
1326 if (format == 0
format == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1327 const uchar *ptr = cmap + 6 + unicode;-
1328 if (unicode < 256
unicode < 256Description
TRUEnever evaluated
FALSEnever evaluated
&& ptr < end
ptr < endDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1329 return
never executed: return quint32(*ptr);
quint32(*ptr);
never executed: return quint32(*ptr);
0
1330 }
never executed: end of block
else if (format == 4
format == 4Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1331-
1332-
1333-
1334-
1335-
1336 if(unicode >= 0xffff
unicode >= 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1337 return
never executed: return 0;
0;
never executed: return 0;
0
1338-
1339 quint16 segCountX2;-
1340 if (!qSafeFromBigEndian(cmap + 6, end, &segCountX2)
!qSafeFromBigE..., &segCountX2)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1341 return
never executed: return 0;
0;
never executed: return 0;
0
1342-
1343 const unsigned char *ends = cmap + 14;-
1344-
1345 int i = 0;-
1346 for (; i < segCountX2/2
i < segCountX2/2Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1347 quint16 codePoint;-
1348 if (!qSafeFromBigEndian(ends + 2 * i, end, &codePoint)
!qSafeFromBigE...d, &codePoint)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1349 return
never executed: return 0;
0;
never executed: return 0;
0
1350 if (codePoint >= unicode
codePoint >= unicodeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1351 break;
never executed: break;
0
1352 }
never executed: end of block
0
1353-
1354 const unsigned char *idx = ends + segCountX2 + 2 + 2*i;-
1355-
1356 quint16 startIndex;-
1357 if (!qSafeFromBigEndian(idx, end, &startIndex)
!qSafeFromBigE..., &startIndex)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1358 return
never executed: return 0;
0;
never executed: return 0;
0
1359 if (startIndex > unicode
startIndex > unicodeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1360 return
never executed: return 0;
0;
never executed: return 0;
0
1361-
1362 idx += segCountX2;-
1363-
1364 quint16 tmp;-
1365 if (!qSafeFromBigEndian(idx, end, &tmp)
!qSafeFromBigE...dx, end, &tmp)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1366 return
never executed: return 0;
0;
never executed: return 0;
0
1367 qint16 idDelta = qint16(tmp);-
1368-
1369 idx += segCountX2;-
1370-
1371 quint16 idRangeoffset_t;-
1372 if (!qSafeFromBigEndian(idx, end, &idRangeoffset_t)
!qSafeFromBigE...Rangeoffset_t)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1373 return
never executed: return 0;
0;
never executed: return 0;
0
1374-
1375 quint16 glyphIndex;-
1376 if (idRangeoffset_t
idRangeoffset_tDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1377 quint16 id;-
1378 if (!qSafeFromBigEndian(idRangeoffset_t + 2 * (unicode - startIndex) + idx, end, &id)
!qSafeFromBigE...idx, end, &id)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1379 return
never executed: return 0;
0;
never executed: return 0;
0
1380-
1381 if (id
idDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1382 glyphIndex = (idDelta + id) % 0x10000;
never executed: glyphIndex = (idDelta + id) % 0x10000;
0
1383 else-
1384 glyphIndex = 0;
never executed: glyphIndex = 0;
0
1385 } else {-
1386 glyphIndex = (idDelta + unicode) % 0x10000;-
1387 }
never executed: end of block
0
1388 return
never executed: return glyphIndex;
glyphIndex;
never executed: return glyphIndex;
0
1389 } else if (format == 6
format == 6Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1390 quint16 tableSize;-
1391 if (!qSafeFromBigEndian(cmap + 2, end, &tableSize)
!qSafeFromBigE...d, &tableSize)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1392 return
never executed: return 0;
0;
never executed: return 0;
0
1393-
1394 quint16 firstCode6;-
1395 if (!qSafeFromBigEndian(cmap + 6, end, &firstCode6)
!qSafeFromBigE..., &firstCode6)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1396 return
never executed: return 0;
0;
never executed: return 0;
0
1397 if (unicode < firstCode6
unicode < firstCode6Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1398 return
never executed: return 0;
0;
never executed: return 0;
0
1399-
1400 quint16 entryCount6;-
1401 if (!qSafeFromBigEndian(cmap + 8, end, &entryCount6)
!qSafeFromBigE... &entryCount6)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1402 return
never executed: return 0;
0;
never executed: return 0;
0
1403 if (entryCount6 * 2 + 10 > tableSize
entryCount6 * ...10 > tableSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1404 return
never executed: return 0;
0;
never executed: return 0;
0
1405-
1406 quint16 sentinel6 = firstCode6 + entryCount6;-
1407 if (unicode >= sentinel6
unicode >= sentinel6Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1408 return
never executed: return 0;
0;
never executed: return 0;
0
1409-
1410 quint16 entryIndex6 = unicode - firstCode6;-
1411-
1412 quint16 index = 0;-
1413 qSafeFromBigEndian(cmap + 10 + (entryIndex6 * 2), end, &index);-
1414 return
never executed: return index;
index;
never executed: return index;
0
1415 } else if (format == 12
format == 12Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1416 quint32 nGroups;-
1417 if (!qSafeFromBigEndian(cmap + 12, end, &nGroups)
!qSafeFromBigE...end, &nGroups)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1418 return
never executed: return 0;
0;
never executed: return 0;
0
1419-
1420 cmap += 16;-
1421-
1422 int left = 0, right = nGroups - 1;-
1423 while (left <= right
left <= rightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1424 int middle = left + ( ( right - left ) >> 1 );-
1425-
1426 quint32 startCharCode;-
1427 if (!qSafeFromBigEndian(cmap + 12 * middle, end, &startCharCode)
!qSafeFromBigE...startCharCode)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1428 return
never executed: return 0;
0;
never executed: return 0;
0
1429-
1430 if(unicode < startCharCode
unicode < startCharCodeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1431 right = middle - 1;
never executed: right = middle - 1;
0
1432 else {-
1433 quint32 endCharCode;-
1434 if (!qSafeFromBigEndian(cmap + 12 * middle + 4, end, &endCharCode)
!qSafeFromBigE... &endCharCode)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1435 return
never executed: return 0;
0;
never executed: return 0;
0
1436-
1437 if (unicode <= endCharCode
unicode <= endCharCodeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1438 quint32 index;-
1439 if (!qSafeFromBigEndian(cmap + 12 * middle + 8, end, &index)
!qSafeFromBigE..., end, &index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1440 return
never executed: return 0;
0;
never executed: return 0;
0
1441-
1442 return
never executed: return index + unicode - startCharCode;
index + unicode - startCharCode;
never executed: return index + unicode - startCharCode;
0
1443 }-
1444 left = middle + 1;-
1445 }
never executed: end of block
0
1446 }-
1447 }
never executed: end of block
else {
0
1448 QMessageLogger(__FILE__, 1516, __PRETTY_FUNCTION__).debug("cmap table of format %d not implemented", format);-
1449 }
never executed: end of block
0
1450-
1451 return
never executed: return 0;
0;
never executed: return 0;
0
1452}-
1453-
1454QByteArray QFontEngine::convertToPostscriptFontFamilyName(const QByteArray &family)-
1455{-
1456 QByteArray f = family;-
1457 f.replace(' ', "");-
1458 f.replace('(', "");-
1459 f.replace(')', "");-
1460 f.replace('<', "");-
1461 f.replace('>', "");-
1462 f.replace('[', "");-
1463 f.replace(']', "");-
1464 f.replace('{', "");-
1465 f.replace('}', "");-
1466 f.replace('/', "");-
1467 f.replace('%', "");-
1468 return
never executed: return f;
f;
never executed: return f;
0
1469}-
1470-
1471-
1472-
1473-
1474bool QFontEngine::hasUnreliableGlyphOutline() const-
1475{-
1476-
1477 return
never executed: return glyphFormat == QFontEngine::Format_ARGB;
glyphFormat == QFontEngine::Format_ARGB;
never executed: return glyphFormat == QFontEngine::Format_ARGB;
0
1478}-
1479-
1480QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round)-
1481{-
1482 if (glyphs.numGlyphs >= 1
glyphs.numGlyphs >= 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1483 glyph_t glyph = glyphs.glyphs[glyphs.numGlyphs - 1];-
1484 glyph_metrics_t gi = boundingBox(glyph);-
1485 if (gi.isValid()
gi.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1486 return
never executed: return round ? qRound(gi.rightBearing()) : gi.rightBearing();
round ? qRound(gi.rightBearing()) : gi.rightBearing();
never executed: return round ? qRound(gi.rightBearing()) : gi.rightBearing();
0
1487 }
never executed: end of block
0
1488 return
never executed: return 0;
0;
never executed: return 0;
0
1489}-
1490-
1491-
1492QFontEngine::GlyphCacheEntry::GlyphCacheEntry()-
1493{-
1494}-
1495-
1496QFontEngine::GlyphCacheEntry::GlyphCacheEntry(const GlyphCacheEntry &o)-
1497 : cache(o.cache)-
1498{-
1499}
never executed: end of block
0
1500-
1501QFontEngine::GlyphCacheEntry::~GlyphCacheEntry()-
1502{-
1503}-
1504-
1505QFontEngine::GlyphCacheEntry &QFontEngine::GlyphCacheEntry::operator=(const GlyphCacheEntry &o)-
1506{-
1507 cache = o.cache;-
1508 return
never executed: return *this;
*this;
never executed: return *this;
0
1509}-
1510-
1511-
1512-
1513-
1514-
1515QFontEngineBox::QFontEngineBox(int size)-
1516 : QFontEngine(Box),-
1517 _size(size)-
1518{-
1519 cache_cost = sizeof(QFontEngineBox);-
1520}
never executed: end of block
0
1521-
1522QFontEngineBox::QFontEngineBox(Type type, int size)-
1523 : QFontEngine(type),-
1524 _size(size)-
1525{-
1526 cache_cost = sizeof(QFontEngineBox);-
1527}
never executed: end of block
0
1528-
1529QFontEngineBox::~QFontEngineBox()-
1530{-
1531}-
1532-
1533glyph_t QFontEngineBox::glyphIndex(uint ucs4) const-
1534{-
1535 (void)ucs4;-
1536 return
never executed: return 0;
0;
never executed: return 0;
0
1537}-
1538-
1539bool QFontEngineBox::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const-
1540{-
1541 ((!(glyphs->numGlyphs >= *nglyphs)) ? qt_assert("glyphs->numGlyphs >= *nglyphs",__FILE__,1609) : qt_noop());-
1542 if (*
*nglyphs < lenDescription
TRUEnever evaluated
FALSEnever evaluated
nglyphs < len
*nglyphs < lenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1543 *nglyphs = len;-
1544 return
never executed: return false;
false;
never executed: return false;
0
1545 }-
1546-
1547 int ucs4Length = 0;-
1548 QStringIterator it(str, str + len);-
1549 while (it.hasNext()
it.hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1550 it.advance();-
1551 glyphs->glyphs[ucs4Length++] = 0;-
1552 }
never executed: end of block
0
1553-
1554 *nglyphs = ucs4Length;-
1555 glyphs->numGlyphs = ucs4Length;-
1556-
1557 if (!(flags & GlyphIndicesOnly)
!(flags & GlyphIndicesOnly)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1558 recalcAdvances(glyphs, flags);
never executed: recalcAdvances(glyphs, flags);
0
1559-
1560 return
never executed: return true;
true;
never executed: return true;
0
1561}-
1562-
1563void QFontEngineBox::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const-
1564{-
1565 for (int i = 0; i < glyphs->numGlyphs
i < glyphs->numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
1566 glyphs->advances[i] = _size;
never executed: glyphs->advances[i] = _size;
0
1567}
never executed: end of block
0
1568-
1569void QFontEngineBox::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags)-
1570{-
1571 if (!glyphs.numGlyphs
!glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1572 return;
never executed: return;
0
1573-
1574 QVarLengthArray<QFixedPoint> positions;-
1575 QVarLengthArray<glyph_t> positioned_glyphs;-
1576 QTransform matrix = QTransform::fromTranslate(x, y - _size);-
1577 getGlyphPositions(glyphs, matrix, flags, positioned_glyphs, positions);-
1578-
1579 QSize s(_size - 3, _size - 3);-
1580 for (int k = 0; k < positions.size()
k < positions.size()Description
TRUEnever evaluated
FALSEnever evaluated
; k++)
0
1581 path->addRect(QRectF(positions[k].toPointF(), s));
never executed: path->addRect(QRectF(positions[k].toPointF(), s));
0
1582}
never executed: end of block
0
1583-
1584glyph_metrics_t QFontEngineBox::boundingBox(const QGlyphLayout &glyphs)-
1585{-
1586 glyph_metrics_t overall;-
1587 overall.width = _size*glyphs.numGlyphs;-
1588 overall.height = _size;-
1589 overall.xoff = overall.width;-
1590 return
never executed: return overall;
overall;
never executed: return overall;
0
1591}-
1592-
1593void QFontEngineBox::draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &ti)-
1594{-
1595 if (!ti.glyphs.numGlyphs
!ti.glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1596 return;
never executed: return;
0
1597-
1598-
1599 QSize s(_size - 3, _size - 3);-
1600-
1601 QVarLengthArray<QFixedPoint> positions;-
1602 QVarLengthArray<glyph_t> glyphs;-
1603 QTransform matrix = QTransform::fromTranslate(x, y - _size);-
1604 ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);-
1605 if (glyphs.size() == 0
glyphs.size() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1606 return;
never executed: return;
0
1607-
1608-
1609 QPainter *painter = p->painter();-
1610 painter->save();-
1611 painter->setBrush(Qt::NoBrush);-
1612 QPen pen = painter->pen();-
1613 pen.setWidthF(lineThickness().toReal());-
1614 painter->setPen(pen);-
1615 for (int k = 0; k < positions.size()
k < positions.size()Description
TRUEnever evaluated
FALSEnever evaluated
; k++)
0
1616 painter->drawRect(QRectF(positions[k].toPointF(), s));
never executed: painter->drawRect(QRectF(positions[k].toPointF(), s));
0
1617 painter->restore();-
1618}
never executed: end of block
0
1619-
1620glyph_metrics_t QFontEngineBox::boundingBox(glyph_t)-
1621{-
1622 return
never executed: return glyph_metrics_t(0, -_size, _size, _size, _size, 0);
glyph_metrics_t(0, -_size, _size, _size, _size, 0);
never executed: return glyph_metrics_t(0, -_size, _size, _size, _size, 0);
0
1623}-
1624-
1625QFontEngine *QFontEngineBox::cloneWithSize(qreal pixelSize) const-
1626{-
1627 QFontEngineBox *fe = new QFontEngineBox(pixelSize);-
1628 return
never executed: return fe;
fe;
never executed: return fe;
0
1629}-
1630-
1631QFixed QFontEngineBox::ascent() const-
1632{-
1633 return
never executed: return _size;
_size;
never executed: return _size;
0
1634}-
1635-
1636QFixed QFontEngineBox::descent() const-
1637{-
1638 return
never executed: return 0;
0;
never executed: return 0;
0
1639}-
1640-
1641QFixed QFontEngineBox::leading() const-
1642{-
1643 QFixed l = _size * QFixed::fromReal(qreal(0.15));-
1644 return
never executed: return l.ceil();
l.ceil();
never executed: return l.ceil();
0
1645}-
1646-
1647qreal QFontEngineBox::maxCharWidth() const-
1648{-
1649 return
never executed: return _size;
_size;
never executed: return _size;
0
1650}-
1651-
1652bool QFontEngineBox::canRender(const QChar *, int) const-
1653{-
1654 return
never executed: return true;
true;
never executed: return true;
0
1655}-
1656-
1657QImage QFontEngineBox::alphaMapForGlyph(glyph_t)-
1658{-
1659 QImage image(_size, _size, QImage::Format_Alpha8);-
1660 image.fill(0);-
1661-
1662-
1663 for (int i=2; i <= _size-3
i <= _size-3Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1664 image.setPixel(i, 2, 255);-
1665 image.setPixel(i, _size-3, 255);-
1666 image.setPixel(2, i, 255);-
1667 image.setPixel(_size-3, i, 255);-
1668 }
never executed: end of block
0
1669 return
never executed: return image;
image;
never executed: return image;
0
1670}-
1671-
1672-
1673-
1674-
1675-
1676static inline uchar highByte(glyph_t glyph)-
1677{ return
never executed: return glyph >> 24;
glyph >> 24;
never executed: return glyph >> 24;
}
0
1678-
1679-
1680static inline glyph_t stripped(glyph_t glyph)-
1681{ return
never executed: return glyph & 0x00ffffff;
glyph & 0x00ffffff;
never executed: return glyph & 0x00ffffff;
}
0
1682-
1683QFontEngineMulti::QFontEngineMulti(QFontEngine *engine, int script, const QStringList &fallbackFamilies)-
1684 : QFontEngine(Multi),-
1685 m_fallbackFamilies(fallbackFamilies),-
1686 m_script(script),-
1687 m_fallbackFamiliesQueried(!m_fallbackFamilies.isEmpty())-
1688{-
1689 ((!(engine && engine->type() != QFontEngine::Multi)) ? qt_assert("engine && engine->type() != QFontEngine::Multi",__FILE__,1757) : qt_noop());-
1690-
1691 if (m_fallbackFamilies.isEmpty()
m_fallbackFamilies.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1692-
1693 m_fallbackFamilies << QString();-
1694 }
never executed: end of block
0
1695-
1696 m_engines.resize(m_fallbackFamilies.size() + 1);-
1697-
1698 engine->ref.ref();-
1699 m_engines[0] = engine;-
1700-
1701 fontDef = engine->fontDef;-
1702 cache_cost = engine->cache_cost;-
1703}
never executed: end of block
0
1704-
1705QFontEngineMulti::~QFontEngineMulti()-
1706{-
1707 for (int i = 0; i < m_engines.size()
i < m_engines.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1708 QFontEngine *fontEngine = m_engines.at(i);-
1709 if (fontEngine
fontEngineDescription
TRUEnever evaluated
FALSEnever evaluated
&& !fontEngine->ref.deref()
!fontEngine->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1710 delete fontEngine;
never executed: delete fontEngine;
0
1711 }
never executed: end of block
0
1712}
never executed: end of block
0
1713-
1714QStringList qt_fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script);-
1715-
1716void QFontEngineMulti::ensureFallbackFamiliesQueried()-
1717{-
1718 QFont::StyleHint styleHint = QFont::StyleHint(fontDef.styleHint);-
1719 if (styleHint == QFont::AnyStyle
styleHint == QFont::AnyStyleDescription
TRUEnever evaluated
FALSEnever evaluated
&& fontDef.fixedPitch
fontDef.fixedPitchDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1720 styleHint = QFont::TypeWriter;
never executed: styleHint = QFont::TypeWriter;
0
1721-
1722 setFallbackFamiliesList(qt_fallbacksForFamily(fontDef.family, QFont::Style(fontDef.style), styleHint, QChar::Script(m_script)));-
1723}
never executed: end of block
0
1724-
1725void QFontEngineMulti::setFallbackFamiliesList(const QStringList &fallbackFamilies)-
1726{-
1727 ((!(!m_fallbackFamiliesQueried)) ? qt_assert("!m_fallbackFamiliesQueried",__FILE__,1795) : qt_noop());-
1728-
1729 m_fallbackFamilies = fallbackFamilies;-
1730 if (m_fallbackFamilies.isEmpty()
m_fallbackFamilies.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1731-
1732 ((!(m_engines.size() == 2)) ? qt_assert("m_engines.size() == 2",__FILE__,1800) : qt_noop());-
1733 QFontEngine *engine = m_engines.at(0);-
1734 engine->ref.ref();-
1735 m_engines[1] = engine;-
1736 m_fallbackFamilies << fontDef.family;-
1737 }
never executed: end of block
else {
0
1738 m_engines.resize(m_fallbackFamilies.size() + 1);-
1739 }
never executed: end of block
0
1740-
1741 m_fallbackFamiliesQueried = true;-
1742}
never executed: end of block
0
1743-
1744void QFontEngineMulti::ensureEngineAt(int at)-
1745{-
1746 if (!m_fallbackFamiliesQueried
!m_fallbackFamiliesQueriedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1747 ensureFallbackFamiliesQueried();
never executed: ensureFallbackFamiliesQueried();
0
1748 ((!(at < m_engines.size())) ? qt_assert("at < m_engines.size()",__FILE__,1816) : qt_noop());-
1749 if (!m_engines.at(at)
!m_engines.at(at)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1750 QFontEngine *engine = loadEngine(at);-
1751 if (!engine
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1752 engine = new QFontEngineBox(fontDef.pixelSize);
never executed: engine = new QFontEngineBox(fontDef.pixelSize);
0
1753 ((!(engine && engine->type() != QFontEngine::Multi)) ? qt_assert("engine && engine->type() != QFontEngine::Multi",__FILE__,1821) : qt_noop());-
1754 engine->ref.ref();-
1755 m_engines[at] = engine;-
1756 }
never executed: end of block
0
1757}
never executed: end of block
0
1758-
1759QFontEngine *QFontEngineMulti::loadEngine(int at)-
1760{-
1761 QFontDef request(fontDef);-
1762 request.styleStrategy |= QFont::NoFontMerging;-
1763 request.family = fallbackFamilyAt(at - 1);-
1764-
1765 if (QFontEngine *engine = QFontDatabase::findFont(request, m_script)
QFontEngine *e...est, m_script)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1766 engine->fontDef.weight = request.weight;-
1767 if (request.style > QFont::StyleNormal
request.style ...t::StyleNormalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1768 engine->fontDef.style = request.style;
never executed: engine->fontDef.style = request.style;
0
1769 return
never executed: return engine;
engine;
never executed: return engine;
0
1770 }-
1771-
1772 return
never executed: return 0;
0;
never executed: return 0;
0
1773}-
1774-
1775glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const-
1776{-
1777 glyph_t glyph = engine(0)->glyphIndex(ucs4);-
1778 if (glyph == 0
glyph == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& ucs4 != QChar::LineSeparator
ucs4 != QChar::LineSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1779 if (!m_fallbackFamiliesQueried
!m_fallbackFamiliesQueriedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1780 const_cast<
never executed: const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
never executed: const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
0
1781 for (int x = 1, n = qMin(m_engines.size(), 256); x < n
x < nDescription
TRUEnever evaluated
FALSEnever evaluated
; ++x) {
0
1782 QFontEngine *engine = m_engines.at(x);-
1783 if (!engine
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1784 if (!shouldLoadFontEngineForCharacter(x, ucs4)
!shouldLoadFon...acter(x, ucs4)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1785 continue;
never executed: continue;
0
1786 const_cast<QFontEngineMulti *>(this)->ensureEngineAt(x);-
1787 engine = m_engines.at(x);-
1788 }
never executed: end of block
0
1789 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1857) : qt_noop());-
1790 if (engine->type() == Box
engine->type() == BoxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1791 continue;
never executed: continue;
0
1792-
1793 glyph = engine->glyphIndex(ucs4);-
1794 if (glyph != 0
glyph != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1795-
1796 glyph |= (x << 24);-
1797 break;
never executed: break;
0
1798 }-
1799 }
never executed: end of block
0
1800 }
never executed: end of block
0
1801-
1802 return
never executed: return glyph;
glyph;
never executed: return glyph;
0
1803}-
1804-
1805bool QFontEngineMulti::stringToCMap(const QChar *str, int len,-
1806 QGlyphLayout *glyphs, int *nglyphs,-
1807 QFontEngine::ShaperFlags flags) const-
1808{-
1809 if (!engine(0)->stringToCMap(str, len, glyphs, nglyphs, flags)
!engine(0)->st...glyphs, flags)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1810 return
never executed: return false;
false;
never executed: return false;
0
1811-
1812 int glyph_pos = 0;-
1813 QStringIterator it(str, str + len);-
1814 while (it.hasNext()
it.hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1815 const uint ucs4 = it.peekNext();-
1816 if (glyphs->glyphs[glyph_pos] == 0
glyphs->glyphs[glyph_pos] == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& ucs4 != QChar::LineSeparator
ucs4 != QChar::LineSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1817 if (!m_fallbackFamiliesQueried
!m_fallbackFamiliesQueriedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1818 const_cast<
never executed: const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
never executed: const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
0
1819 for (int x = 1, n = qMin(m_engines.size(), 256); x < n
x < nDescription
TRUEnever evaluated
FALSEnever evaluated
; ++x) {
0
1820 QFontEngine *engine = m_engines.at(x);-
1821 if (!engine
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1822 if (!shouldLoadFontEngineForCharacter(x, ucs4)
!shouldLoadFon...acter(x, ucs4)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1823 continue;
never executed: continue;
0
1824 const_cast<QFontEngineMulti *>(this)->ensureEngineAt(x);-
1825 engine = m_engines.at(x);-
1826 if (!engine
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1827 continue;
never executed: continue;
0
1828 }
never executed: end of block
0
1829 ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1897) : qt_noop());-
1830 if (engine->type() == Box
engine->type() == BoxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1831 continue;
never executed: continue;
0
1832-
1833 glyph_t glyph = engine->glyphIndex(ucs4);-
1834 if (glyph != 0
glyph != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1835 glyphs->glyphs[glyph_pos] = glyph;-
1836 if (!(flags & GlyphIndicesOnly)
!(flags & GlyphIndicesOnly)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1837 QGlyphLayout g = glyphs->mid(glyph_pos, 1);-
1838 engine->recalcAdvances(&g, flags);-
1839 }
never executed: end of block
0
1840-
1841 glyphs->glyphs[glyph_pos] |= (x << 24);-
1842 break;
never executed: break;
0
1843 }-
1844 }
never executed: end of block
0
1845 }
never executed: end of block
0
1846-
1847 it.advance();-
1848 ++glyph_pos;-
1849 }
never executed: end of block
0
1850-
1851 *nglyphs = glyph_pos;-
1852 glyphs->numGlyphs = glyph_pos;-
1853-
1854 return
never executed: return true;
true;
never executed: return true;
0
1855}-
1856-
1857bool QFontEngineMulti::shouldLoadFontEngineForCharacter(int at, uint ucs4) const-
1858{-
1859 (void)at;;-
1860 (void)ucs4;;-
1861 return
never executed: return true;
true;
never executed: return true;
0
1862}-
1863-
1864glyph_metrics_t QFontEngineMulti::boundingBox(const QGlyphLayout &glyphs)-
1865{-
1866 if (glyphs.numGlyphs <= 0
glyphs.numGlyphs <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1867 return
never executed: return glyph_metrics_t();
glyph_metrics_t();
never executed: return glyph_metrics_t();
0
1868-
1869 glyph_metrics_t overall;-
1870-
1871 int which = highByte(glyphs.glyphs[0]);-
1872 int start = 0;-
1873 int end, i;-
1874 for (end = 0; end < glyphs.numGlyphs
end < glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++end) {
0
1875 const int e = highByte(glyphs.glyphs[end]);-
1876 if (e == which
e == whichDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1877 continue;
never executed: continue;
0
1878-
1879-
1880 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1881 glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
never executed: glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
0
1882-
1883-
1884 const glyph_metrics_t gm = engine(which)->boundingBox(glyphs.mid(start, end - start));-
1885-
1886 overall.x = qMin(overall.x, gm.x);-
1887 overall.y = qMin(overall.y, gm.y);-
1888 overall.width = overall.xoff + gm.width;-
1889 overall.height = qMax(overall.height + overall.y, gm.height + gm.y) --
1890 qMin(overall.y, gm.y);-
1891 overall.xoff += gm.xoff;-
1892 overall.yoff += gm.yoff;-
1893-
1894-
1895 const int hi = which << 24;-
1896 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1897 glyphs.glyphs[i] = hi | glyphs.glyphs[i];
never executed: glyphs.glyphs[i] = hi | glyphs.glyphs[i];
0
1898-
1899-
1900 start = end;-
1901 which = e;-
1902 }
never executed: end of block
0
1903-
1904-
1905 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1906 glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
never executed: glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
0
1907-
1908-
1909 const glyph_metrics_t gm = engine(which)->boundingBox(glyphs.mid(start, end - start));-
1910-
1911 overall.x = qMin(overall.x, gm.x);-
1912 overall.y = qMin(overall.y, gm.y);-
1913 overall.width = overall.xoff + gm.width;-
1914 overall.height = qMax(overall.height + overall.y, gm.height + gm.y) --
1915 qMin(overall.y, gm.y);-
1916 overall.xoff += gm.xoff;-
1917 overall.yoff += gm.yoff;-
1918-
1919-
1920 const int hi = which << 24;-
1921 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1922 glyphs.glyphs[i] = hi | glyphs.glyphs[i];
never executed: glyphs.glyphs[i] = hi | glyphs.glyphs[i];
0
1923-
1924 return
never executed: return overall;
overall;
never executed: return overall;
0
1925}-
1926-
1927void QFontEngineMulti::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)-
1928{-
1929 int which = highByte(glyph);-
1930 ensureEngineAt(which);-
1931 engine(which)->getGlyphBearings(stripped(glyph), leftBearing, rightBearing);-
1932}
never executed: end of block
0
1933-
1934void QFontEngineMulti::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs,-
1935 QPainterPath *path, QTextItem::RenderFlags flags)-
1936{-
1937 if (glyphs.numGlyphs <= 0
glyphs.numGlyphs <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1938 return;
never executed: return;
0
1939-
1940 int which = highByte(glyphs.glyphs[0]);-
1941 int start = 0;-
1942 int end, i;-
1943 if (flags & QTextItem::RightToLeft
flags & QTextItem::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1944 for (int gl = 0; gl < glyphs.numGlyphs
gl < glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; gl++)
0
1945 x += glyphs.advances[gl].toReal();
never executed: x += glyphs.advances[gl].toReal();
0
1946 }
never executed: end of block
0
1947 for (end = 0; end < glyphs.numGlyphs
end < glyphs.numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++end) {
0
1948 const int e = highByte(glyphs.glyphs[end]);-
1949 if (e == which
e == whichDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1950 continue;
never executed: continue;
0
1951-
1952 if (flags & QTextItem::RightToLeft
flags & QTextItem::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1953 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1954 x -= glyphs.advances[i].toReal();
never executed: x -= glyphs.advances[i].toReal();
0
1955 }
never executed: end of block
0
1956-
1957-
1958 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1959 glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
never executed: glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
0
1960 engine(which)->addOutlineToPath(x, y, glyphs.mid(start, end - start), path, flags);-
1961-
1962 const int hi = which << 24;-
1963 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1964 glyphs.glyphs[i] = hi | glyphs.glyphs[i];
never executed: glyphs.glyphs[i] = hi | glyphs.glyphs[i];
0
1965-
1966 if (!(flags & QTextItem::RightToLeft)
!(flags & QTex...::RightToLeft)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1967 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1968 x += glyphs.advances[i].toReal();
never executed: x += glyphs.advances[i].toReal();
0
1969 }
never executed: end of block
0
1970-
1971-
1972 start = end;-
1973 which = e;-
1974 }
never executed: end of block
0
1975-
1976 if (flags & QTextItem::RightToLeft
flags & QTextItem::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1977 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1978 x -= glyphs.advances[i].toReal();
never executed: x -= glyphs.advances[i].toReal();
0
1979 }
never executed: end of block
0
1980-
1981-
1982 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1983 glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
never executed: glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
0
1984-
1985 engine(which)->addOutlineToPath(x, y, glyphs.mid(start, end - start), path, flags);-
1986-
1987-
1988 const int hi = which << 24;-
1989 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
1990 glyphs.glyphs[i] = hi | glyphs.glyphs[i];
never executed: glyphs.glyphs[i] = hi | glyphs.glyphs[i];
0
1991}
never executed: end of block
0
1992-
1993void QFontEngineMulti::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const-
1994{-
1995 if (glyphs->numGlyphs <= 0
glyphs->numGlyphs <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1996 return;
never executed: return;
0
1997-
1998 int which = highByte(glyphs->glyphs[0]);-
1999 int start = 0;-
2000 int end, i;-
2001 for (end = 0; end < glyphs->numGlyphs
end < glyphs->numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++end) {
0
2002 const int e = highByte(glyphs->glyphs[end]);-
2003 if (e == which
e == whichDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2004 continue;
never executed: continue;
0
2005-
2006-
2007 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
2008 glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
never executed: glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
0
2009-
2010 QGlyphLayout offs = glyphs->mid(start, end - start);-
2011 engine(which)->recalcAdvances(&offs, flags);-
2012-
2013-
2014 const int hi = which << 24;-
2015 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
2016 glyphs->glyphs[i] = hi | glyphs->glyphs[i];
never executed: glyphs->glyphs[i] = hi | glyphs->glyphs[i];
0
2017-
2018-
2019 start = end;-
2020 which = e;-
2021 }
never executed: end of block
0
2022-
2023-
2024 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
2025 glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
never executed: glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
0
2026-
2027 QGlyphLayout offs = glyphs->mid(start, end - start);-
2028 engine(which)->recalcAdvances(&offs, flags);-
2029-
2030-
2031 const int hi = which << 24;-
2032 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
2033 glyphs->glyphs[i] = hi | glyphs->glyphs[i];
never executed: glyphs->glyphs[i] = hi | glyphs->glyphs[i];
0
2034}
never executed: end of block
0
2035-
2036void QFontEngineMulti::doKerning(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const-
2037{-
2038 if (glyphs->numGlyphs <= 0
glyphs->numGlyphs <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2039 return;
never executed: return;
0
2040-
2041 int which = highByte(glyphs->glyphs[0]);-
2042 int start = 0;-
2043 int end, i;-
2044 for (end = 0; end < glyphs->numGlyphs
end < glyphs->numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++end) {
0
2045 const int e = highByte(glyphs->glyphs[end]);-
2046 if (e == which
e == whichDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2047 continue;
never executed: continue;
0
2048-
2049-
2050 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
2051 glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
never executed: glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
0
2052-
2053 QGlyphLayout offs = glyphs->mid(start, end - start);-
2054 engine(which)->doKerning(&offs, flags);-
2055-
2056-
2057 const int hi = which << 24;-
2058 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
2059 glyphs->glyphs[i] = hi | glyphs->glyphs[i];
never executed: glyphs->glyphs[i] = hi | glyphs->glyphs[i];
0
2060-
2061-
2062 start = end;-
2063 which = e;-
2064 }
never executed: end of block
0
2065-
2066-
2067 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
2068 glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
never executed: glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
0
2069-
2070 QGlyphLayout offs = glyphs->mid(start, end - start);-
2071 engine(which)->doKerning(&offs, flags);-
2072-
2073-
2074 const int hi = which << 24;-
2075 for (i = start; i < end
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
2076 glyphs->glyphs[i] = hi | glyphs->glyphs[i];
never executed: glyphs->glyphs[i] = hi | glyphs->glyphs[i];
0
2077}
never executed: end of block
0
2078-
2079glyph_metrics_t QFontEngineMulti::boundingBox(glyph_t glyph)-
2080{-
2081 const int which = highByte(glyph);-
2082 return
never executed: return engine(which)->boundingBox(stripped(glyph));
engine(which)->boundingBox(stripped(glyph));
never executed: return engine(which)->boundingBox(stripped(glyph));
0
2083}-
2084-
2085QFixed QFontEngineMulti::ascent() const-
2086{ return
never executed: return engine(0)->ascent();
engine(0)->ascent();
never executed: return engine(0)->ascent();
}
0
2087-
2088QFixed QFontEngineMulti::descent() const-
2089{ return
never executed: return engine(0)->descent();
engine(0)->descent();
never executed: return engine(0)->descent();
}
0
2090-
2091QFixed QFontEngineMulti::leading() const-
2092{-
2093 return
never executed: return engine(0)->leading();
engine(0)->leading();
never executed: return engine(0)->leading();
0
2094}-
2095-
2096QFixed QFontEngineMulti::xHeight() const-
2097{-
2098 return
never executed: return engine(0)->xHeight();
engine(0)->xHeight();
never executed: return engine(0)->xHeight();
0
2099}-
2100-
2101QFixed QFontEngineMulti::averageCharWidth() const-
2102{-
2103 return
never executed: return engine(0)->averageCharWidth();
engine(0)->averageCharWidth();
never executed: return engine(0)->averageCharWidth();
0
2104}-
2105-
2106QFixed QFontEngineMulti::lineThickness() const-
2107{-
2108 return
never executed: return engine(0)->lineThickness();
engine(0)->lineThickness();
never executed: return engine(0)->lineThickness();
0
2109}-
2110-
2111QFixed QFontEngineMulti::underlinePosition() const-
2112{-
2113 return
never executed: return engine(0)->underlinePosition();
engine(0)->underlinePosition();
never executed: return engine(0)->underlinePosition();
0
2114}-
2115-
2116qreal QFontEngineMulti::maxCharWidth() const-
2117{-
2118 return
never executed: return engine(0)->maxCharWidth();
engine(0)->maxCharWidth();
never executed: return engine(0)->maxCharWidth();
0
2119}-
2120-
2121qreal QFontEngineMulti::minLeftBearing() const-
2122{-
2123 return
never executed: return engine(0)->minLeftBearing();
engine(0)->minLeftBearing();
never executed: return engine(0)->minLeftBearing();
0
2124}-
2125-
2126qreal QFontEngineMulti::minRightBearing() const-
2127{-
2128 return
never executed: return engine(0)->minRightBearing();
engine(0)->minRightBearing();
never executed: return engine(0)->minRightBearing();
0
2129}-
2130-
2131bool QFontEngineMulti::canRender(const QChar *string, int len) const-
2132{-
2133 if (engine(0)->canRender(string, len)
engine(0)->can...r(string, len)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2134 return
never executed: return true;
true;
never executed: return true;
0
2135-
2136 int nglyphs = len;-
2137-
2138 QVarLengthArray<glyph_t> glyphs(nglyphs);-
2139-
2140 QGlyphLayout g;-
2141 g.numGlyphs = nglyphs;-
2142 g.glyphs = glyphs.data();-
2143 if (!stringToCMap(string, len, &g, &nglyphs, GlyphIndicesOnly)
!stringToCMap(...phIndicesOnly)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2144 do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,2212) : qt_noop()); __builtin_unreachable(); }
never executed: end of block
while (0);
0
2145-
2146 for (int i = 0; i < nglyphs
i < nglyphsDescription
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
2147 if (glyphs[i] == 0
glyphs[i] == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2148 return
never executed: return false;
false;
never executed: return false;
0
2149 }
never executed: end of block
0
2150-
2151 return
never executed: return true;
true;
never executed: return true;
0
2152}-
2153-
2154-
2155-
2156-
2157QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph)-
2158{-
2159 const int which = highByte(glyph);-
2160 return
never executed: return engine(which)->alphaMapForGlyph(stripped(glyph));
engine(which)->alphaMapForGlyph(stripped(glyph));
never executed: return engine(which)->alphaMapForGlyph(stripped(glyph));
0
2161}-
2162-
2163QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition)-
2164{-
2165 const int which = highByte(glyph);-
2166 return
never executed: return engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition);
engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition);
never executed: return engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition);
0
2167}-
2168-
2169QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph, const QTransform &t)-
2170{-
2171 const int which = highByte(glyph);-
2172 return
never executed: return engine(which)->alphaMapForGlyph(stripped(glyph), t);
engine(which)->alphaMapForGlyph(stripped(glyph), t);
never executed: return engine(which)->alphaMapForGlyph(stripped(glyph), t);
0
2173}-
2174-
2175QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)-
2176{-
2177 const int which = highByte(glyph);-
2178 return
never executed: return engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition, t);
engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition, t);
never executed: return engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition, t);
0
2179}-
2180-
2181QImage QFontEngineMulti::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)-
2182{-
2183 const int which = highByte(glyph);-
2184 return
never executed: return engine(which)->alphaRGBMapForGlyph(stripped(glyph), subPixelPosition, t);
engine(which)->alphaRGBMapForGlyph(stripped(glyph), subPixelPosition, t);
never executed: return engine(which)->alphaRGBMapForGlyph(stripped(glyph), subPixelPosition, t);
0
2185}-
2186QFontEngine *QFontEngineMulti::createMultiFontEngine(QFontEngine *fe, int script)-
2187{-
2188 QFontEngine *engine = 0;-
2189 QFontCache::Key key(fe->fontDef, script, true);-
2190 QFontCache *fc = QFontCache::instance();-
2191-
2192-
2193-
2194-
2195-
2196 const bool faceIsLocal = !fe->faceId().filename.isEmpty();-
2197 QFontCache::EngineCache::Iterator it = fc->engineCache.find(key),-
2198 end = fc->engineCache.end();-
2199 while (it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
&& it.key() == key
it.key() == keyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2200 ((!(it.value().data->type() == QFontEngine::Multi)) ? qt_assert("it.value().data->type() == QFontEngine::Multi",__FILE__,2277) : qt_noop());-
2201 QFontEngineMulti *cachedEngine = static_cast<QFontEngineMulti *>(it.value().data);-
2202 if (fe == cachedEngine->engine(0)
fe == cachedEngine->engine(0)Description
TRUEnever evaluated
FALSEnever evaluated
|| (faceIsLocal
faceIsLocalDescription
TRUEnever evaluated
FALSEnever evaluated
&& fe->faceId().filename == cachedEngine->engine(0)->faceId().filename
fe->faceId().f...eId().filenameDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
2203 engine = cachedEngine;-
2204 fc->updateHitCountAndTimeStamp(it.value());-
2205 break;
never executed: break;
0
2206 }-
2207 ++it;-
2208 }
never executed: end of block
0
2209 if (!engine
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2210 engine = QGuiApplicationPrivate::instance()->platformIntegration()->fontDatabase()->fontEngineMulti(fe, QChar::Script(script));-
2211 fc->insertEngine(key, engine, !faceIsLocal);-
2212 }
never executed: end of block
0
2213 ((!(engine)) ? qt_assert("engine",__FILE__,2290) : qt_noop());-
2214 return
never executed: return engine;
engine;
never executed: return engine;
0
2215}-
2216-
2217QTestFontEngine::QTestFontEngine(int size)-
2218 : QFontEngineBox(TestFontEngine, size)-
2219{}
never executed: end of block
0
2220-
2221-
Switch to Source codePreprocessed file

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