Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qfontmetrics.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | extern void qt_format_text(const QFont& font, const QRectF &_r, | - | ||||||||||||
7 | int tf, const QString &text, QRectF *brect, | - | ||||||||||||
8 | int tabStops, int *tabArray, int tabArrayLen, | - | ||||||||||||
9 | QPainter *painter); | - | ||||||||||||
10 | QFontMetrics::QFontMetrics(const QFont &font) | - | ||||||||||||
11 | : d(font.d.data()) | - | ||||||||||||
12 | { | - | ||||||||||||
13 | } never executed: end of block | 0 | ||||||||||||
14 | QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice) | - | ||||||||||||
15 | { | - | ||||||||||||
16 | int dpi = paintdevice
| 0 | ||||||||||||
17 | const int screen = 0; | - | ||||||||||||
18 | if (font.d->dpi != dpi
| 0 | ||||||||||||
19 | d = new QFontPrivate(*font.d); | - | ||||||||||||
20 | d->dpi = dpi; | - | ||||||||||||
21 | d->screen = screen; | - | ||||||||||||
22 | } never executed: else {end of block | 0 | ||||||||||||
23 | d = font.d.data(); | - | ||||||||||||
24 | } never executed: end of block | 0 | ||||||||||||
25 | - | |||||||||||||
26 | } | - | ||||||||||||
27 | - | |||||||||||||
28 | - | |||||||||||||
29 | - | |||||||||||||
30 | - | |||||||||||||
31 | QFontMetrics::QFontMetrics(const QFontMetrics &fm) | - | ||||||||||||
32 | : d(fm.d.data()) | - | ||||||||||||
33 | { | - | ||||||||||||
34 | } never executed: end of block | 0 | ||||||||||||
35 | - | |||||||||||||
36 | - | |||||||||||||
37 | - | |||||||||||||
38 | - | |||||||||||||
39 | - | |||||||||||||
40 | QFontMetrics::~QFontMetrics() | - | ||||||||||||
41 | { | - | ||||||||||||
42 | } | - | ||||||||||||
43 | - | |||||||||||||
44 | - | |||||||||||||
45 | - | |||||||||||||
46 | - | |||||||||||||
47 | QFontMetrics &QFontMetrics::operator=(const QFontMetrics &fm) | - | ||||||||||||
48 | { | - | ||||||||||||
49 | d = fm.d.data(); | - | ||||||||||||
50 | return never executed: *this;return *this; never executed: return *this; | 0 | ||||||||||||
51 | } | - | ||||||||||||
52 | bool QFontMetrics::operator ==(const QFontMetrics &other) const | - | ||||||||||||
53 | { | - | ||||||||||||
54 | return never executed: d == other.d;return d == other.d; never executed: return d == other.d; | 0 | ||||||||||||
55 | } | - | ||||||||||||
56 | int QFontMetrics::ascent() const | - | ||||||||||||
57 | { | - | ||||||||||||
58 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
59 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,267) : qt_noop()); | - | ||||||||||||
60 | return never executed: qRound(engine->ascent());return qRound(engine->ascent()); never executed: return qRound(engine->ascent()); | 0 | ||||||||||||
61 | } | - | ||||||||||||
62 | int QFontMetrics::descent() const | - | ||||||||||||
63 | { | - | ||||||||||||
64 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
65 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,285) : qt_noop()); | - | ||||||||||||
66 | return never executed: qRound(engine->descent());return qRound(engine->descent()); never executed: return qRound(engine->descent()); | 0 | ||||||||||||
67 | } | - | ||||||||||||
68 | int QFontMetrics::height() const | - | ||||||||||||
69 | { | - | ||||||||||||
70 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
71 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,299) : qt_noop()); | - | ||||||||||||
72 | return never executed: qRound(engine->ascent()) + qRound(engine->descent());return qRound(engine->ascent()) + qRound(engine->descent()); never executed: return qRound(engine->ascent()) + qRound(engine->descent()); | 0 | ||||||||||||
73 | } | - | ||||||||||||
74 | int QFontMetrics::leading() const | - | ||||||||||||
75 | { | - | ||||||||||||
76 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
77 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,313) : qt_noop()); | - | ||||||||||||
78 | return never executed: qRound(engine->leading());return qRound(engine->leading()); never executed: return qRound(engine->leading()); | 0 | ||||||||||||
79 | } | - | ||||||||||||
80 | int QFontMetrics::lineSpacing() const | - | ||||||||||||
81 | { | - | ||||||||||||
82 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
83 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,327) : qt_noop()); | - | ||||||||||||
84 | return never executed: qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent());return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent()); never executed: return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent()); | 0 | ||||||||||||
85 | } | - | ||||||||||||
86 | int QFontMetrics::minLeftBearing() const | - | ||||||||||||
87 | { | - | ||||||||||||
88 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
89 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,344) : qt_noop()); | - | ||||||||||||
90 | return never executed: qRound(engine->minLeftBearing());return qRound(engine->minLeftBearing()); never executed: return qRound(engine->minLeftBearing()); | 0 | ||||||||||||
91 | } | - | ||||||||||||
92 | int QFontMetrics::minRightBearing() const | - | ||||||||||||
93 | { | - | ||||||||||||
94 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
95 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,361) : qt_noop()); | - | ||||||||||||
96 | return never executed: qRound(engine->minRightBearing());return qRound(engine->minRightBearing()); never executed: return qRound(engine->minRightBearing()); | 0 | ||||||||||||
97 | } | - | ||||||||||||
98 | - | |||||||||||||
99 | - | |||||||||||||
100 | - | |||||||||||||
101 | - | |||||||||||||
102 | int QFontMetrics::maxWidth() const | - | ||||||||||||
103 | { | - | ||||||||||||
104 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
105 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,371) : qt_noop()); | - | ||||||||||||
106 | return never executed: qRound(engine->maxCharWidth());return qRound(engine->maxCharWidth()); never executed: return qRound(engine->maxCharWidth()); | 0 | ||||||||||||
107 | } | - | ||||||||||||
108 | - | |||||||||||||
109 | - | |||||||||||||
110 | - | |||||||||||||
111 | - | |||||||||||||
112 | - | |||||||||||||
113 | int QFontMetrics::xHeight() const | - | ||||||||||||
114 | { | - | ||||||||||||
115 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
116 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,382) : qt_noop()); | - | ||||||||||||
117 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
118 | return never executed: qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent());return qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent()); never executed: return qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent()); | 0 | ||||||||||||
119 | return never executed: qRound(engine->xHeight());return qRound(engine->xHeight()); never executed: return qRound(engine->xHeight()); | 0 | ||||||||||||
120 | } | - | ||||||||||||
121 | - | |||||||||||||
122 | - | |||||||||||||
123 | - | |||||||||||||
124 | - | |||||||||||||
125 | - | |||||||||||||
126 | - | |||||||||||||
127 | int QFontMetrics::averageCharWidth() const | - | ||||||||||||
128 | { | - | ||||||||||||
129 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
130 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,396) : qt_noop()); | - | ||||||||||||
131 | return never executed: qRound(engine->averageCharWidth());return qRound(engine->averageCharWidth()); never executed: return qRound(engine->averageCharWidth()); | 0 | ||||||||||||
132 | } | - | ||||||||||||
133 | - | |||||||||||||
134 | - | |||||||||||||
135 | - | |||||||||||||
136 | - | |||||||||||||
137 | - | |||||||||||||
138 | bool QFontMetrics::inFont(QChar ch) const | - | ||||||||||||
139 | { | - | ||||||||||||
140 | return never executed: inFontUcs4(ch.unicode());return inFontUcs4(ch.unicode()); never executed: return inFontUcs4(ch.unicode()); | 0 | ||||||||||||
141 | } | - | ||||||||||||
142 | - | |||||||||||||
143 | - | |||||||||||||
144 | - | |||||||||||||
145 | - | |||||||||||||
146 | - | |||||||||||||
147 | bool QFontMetrics::inFontUcs4(uint ucs4) const | - | ||||||||||||
148 | { | - | ||||||||||||
149 | const int script = QChar::script(ucs4); | - | ||||||||||||
150 | QFontEngine *engine = d->engineForScript(script); | - | ||||||||||||
151 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,417) : qt_noop()); | - | ||||||||||||
152 | if (engine->type() == QFontEngine::Box
| 0 | ||||||||||||
153 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
154 | return never executed: engine->canRender(ucs4);return engine->canRender(ucs4); never executed: return engine->canRender(ucs4); | 0 | ||||||||||||
155 | } | - | ||||||||||||
156 | int QFontMetrics::leftBearing(QChar ch) const | - | ||||||||||||
157 | { | - | ||||||||||||
158 | const int script = ch.script(); | - | ||||||||||||
159 | QFontEngine *engine; | - | ||||||||||||
160 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
161 | engine = d->smallCapsFontPrivate()->engineForScript(script); never executed: engine = d->smallCapsFontPrivate()->engineForScript(script); | 0 | ||||||||||||
162 | else | - | ||||||||||||
163 | engine = d->engineForScript(script); never executed: engine = d->engineForScript(script); | 0 | ||||||||||||
164 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,443) : qt_noop()); | - | ||||||||||||
165 | if (engine->type() == QFontEngine::Box
| 0 | ||||||||||||
166 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
167 | - | |||||||||||||
168 | d->alterCharForCapitalization(ch); | - | ||||||||||||
169 | - | |||||||||||||
170 | glyph_t glyph = engine->glyphIndex(ch.unicode()); | - | ||||||||||||
171 | - | |||||||||||||
172 | qreal lb; | - | ||||||||||||
173 | engine->getGlyphBearings(glyph, &lb); | - | ||||||||||||
174 | return never executed: qRound(lb);return qRound(lb); never executed: return qRound(lb); | 0 | ||||||||||||
175 | } | - | ||||||||||||
176 | int QFontMetrics::rightBearing(QChar ch) const | - | ||||||||||||
177 | { | - | ||||||||||||
178 | const int script = ch.script(); | - | ||||||||||||
179 | QFontEngine *engine; | - | ||||||||||||
180 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
181 | engine = d->smallCapsFontPrivate()->engineForScript(script); never executed: engine = d->smallCapsFontPrivate()->engineForScript(script); | 0 | ||||||||||||
182 | else | - | ||||||||||||
183 | engine = d->engineForScript(script); never executed: engine = d->engineForScript(script); | 0 | ||||||||||||
184 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,476) : qt_noop()); | - | ||||||||||||
185 | if (engine->type() == QFontEngine::Box
| 0 | ||||||||||||
186 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
187 | - | |||||||||||||
188 | d->alterCharForCapitalization(ch); | - | ||||||||||||
189 | - | |||||||||||||
190 | glyph_t glyph = engine->glyphIndex(ch.unicode()); | - | ||||||||||||
191 | - | |||||||||||||
192 | qreal rb; | - | ||||||||||||
193 | engine->getGlyphBearings(glyph, 0, &rb); | - | ||||||||||||
194 | return never executed: qRound(rb);return qRound(rb); never executed: return qRound(rb); | 0 | ||||||||||||
195 | } | - | ||||||||||||
196 | int QFontMetrics::width(const QString &text, int len) const | - | ||||||||||||
197 | { | - | ||||||||||||
198 | return never executed: width(text, len, 0);return width(text, len, 0); never executed: return width(text, len, 0); | 0 | ||||||||||||
199 | } | - | ||||||||||||
200 | - | |||||||||||||
201 | - | |||||||||||||
202 | - | |||||||||||||
203 | - | |||||||||||||
204 | int QFontMetrics::width(const QString &text, int len, int flags) const | - | ||||||||||||
205 | { | - | ||||||||||||
206 | int pos = text.indexOf(QLatin1Char('\x9c')); | - | ||||||||||||
207 | if (pos != -1
| 0 | ||||||||||||
208 | len = (
| 0 | ||||||||||||
209 | } never executed: else if (len < 0end of block
| 0 | ||||||||||||
210 | len = text.length(); | - | ||||||||||||
211 | } never executed: end of block | 0 | ||||||||||||
212 | if (len == 0
| 0 | ||||||||||||
213 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
214 | - | |||||||||||||
215 | if (flags & Qt::TextBypassShaping
| 0 | ||||||||||||
216 | - | |||||||||||||
217 | int numGlyphs = len; | - | ||||||||||||
218 | QVarLengthGlyphLayoutArray glyphs(numGlyphs); | - | ||||||||||||
219 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
220 | if (!engine->stringToCMap(text.data(), len, &glyphs, &numGlyphs, 0)
| 0 | ||||||||||||
221 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,526) : qt_noop()); __builtin_unreachable(); } never executed: while (0);end of block | 0 | ||||||||||||
222 | - | |||||||||||||
223 | QFixed width; | - | ||||||||||||
224 | for (int i = 0; i < numGlyphs
| 0 | ||||||||||||
225 | width += glyphs.advances[i]; never executed: width += glyphs.advances[i]; | 0 | ||||||||||||
226 | return never executed: qRound(width);return qRound(width); never executed: return qRound(width); | 0 | ||||||||||||
227 | } | - | ||||||||||||
228 | - | |||||||||||||
229 | QStackTextEngine layout(text, QFont(d.data())); | - | ||||||||||||
230 | return never executed: qRound(layout.width(0, len));return qRound(layout.width(0, len)); never executed: return qRound(layout.width(0, len)); | 0 | ||||||||||||
231 | } | - | ||||||||||||
232 | int QFontMetrics::width(QChar ch) const | - | ||||||||||||
233 | { | - | ||||||||||||
234 | if (QChar::category(ch.unicode()) == QChar::Mark_NonSpacing
| 0 | ||||||||||||
235 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
236 | - | |||||||||||||
237 | const int script = ch.script(); | - | ||||||||||||
238 | QFontEngine *engine; | - | ||||||||||||
239 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
240 | engine = d->smallCapsFontPrivate()->engineForScript(script); never executed: engine = d->smallCapsFontPrivate()->engineForScript(script); | 0 | ||||||||||||
241 | else | - | ||||||||||||
242 | engine = d->engineForScript(script); never executed: engine = d->engineForScript(script); | 0 | ||||||||||||
243 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,573) : qt_noop()); | - | ||||||||||||
244 | - | |||||||||||||
245 | d->alterCharForCapitalization(ch); | - | ||||||||||||
246 | - | |||||||||||||
247 | glyph_t glyph = engine->glyphIndex(ch.unicode()); | - | ||||||||||||
248 | QFixed advance; | - | ||||||||||||
249 | - | |||||||||||||
250 | QGlyphLayout glyphs; | - | ||||||||||||
251 | glyphs.numGlyphs = 1; | - | ||||||||||||
252 | glyphs.glyphs = &glyph; | - | ||||||||||||
253 | glyphs.advances = &advance; | - | ||||||||||||
254 | engine->recalcAdvances(&glyphs, 0); | - | ||||||||||||
255 | - | |||||||||||||
256 | return never executed: qRound(advance);return qRound(advance); never executed: return qRound(advance); | 0 | ||||||||||||
257 | } | - | ||||||||||||
258 | int QFontMetrics::charWidth(const QString &text, int pos) const | - | ||||||||||||
259 | { | - | ||||||||||||
260 | int width = 0; | - | ||||||||||||
261 | if (pos < 0
| 0 | ||||||||||||
262 | return never executed: width;return width; never executed: return width; | 0 | ||||||||||||
263 | - | |||||||||||||
264 | QChar ch = text.at(pos); | - | ||||||||||||
265 | const int script = ch.script(); | - | ||||||||||||
266 | if (script != QChar::Script_Common
| 0 | ||||||||||||
267 | - | |||||||||||||
268 | int from = qMax(0, pos - 8); | - | ||||||||||||
269 | int to = qMin(text.length(), pos + 8); | - | ||||||||||||
270 | QString cstr = QString::fromRawData(text.unicode() + from, to - from); | - | ||||||||||||
271 | QStackTextEngine layout(cstr, QFont(d.data())); | - | ||||||||||||
272 | layout.ignoreBidi = true; | - | ||||||||||||
273 | layout.itemize(); | - | ||||||||||||
274 | width = qRound(layout.width(pos-from, 1)); | - | ||||||||||||
275 | } never executed: else if (ch.category() != QChar::Mark_NonSpacingend of block
| 0 | ||||||||||||
276 | QFontEngine *engine; | - | ||||||||||||
277 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
278 | engine = d->smallCapsFontPrivate()->engineForScript(script); never executed: engine = d->smallCapsFontPrivate()->engineForScript(script); | 0 | ||||||||||||
279 | else | - | ||||||||||||
280 | engine = d->engineForScript(script); never executed: engine = d->engineForScript(script); | 0 | ||||||||||||
281 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,625) : qt_noop()); | - | ||||||||||||
282 | - | |||||||||||||
283 | d->alterCharForCapitalization(ch); | - | ||||||||||||
284 | - | |||||||||||||
285 | glyph_t glyph = engine->glyphIndex(ch.unicode()); | - | ||||||||||||
286 | QFixed advance; | - | ||||||||||||
287 | - | |||||||||||||
288 | QGlyphLayout glyphs; | - | ||||||||||||
289 | glyphs.numGlyphs = 1; | - | ||||||||||||
290 | glyphs.glyphs = &glyph; | - | ||||||||||||
291 | glyphs.advances = &advance; | - | ||||||||||||
292 | engine->recalcAdvances(&glyphs, 0); | - | ||||||||||||
293 | - | |||||||||||||
294 | width = qRound(advance); | - | ||||||||||||
295 | } never executed: end of block | 0 | ||||||||||||
296 | return never executed: width;return width; never executed: return width; | 0 | ||||||||||||
297 | } | - | ||||||||||||
298 | QRect QFontMetrics::boundingRect(const QString &text) const | - | ||||||||||||
299 | { | - | ||||||||||||
300 | if (text.length() == 0
| 0 | ||||||||||||
301 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||
302 | - | |||||||||||||
303 | QStackTextEngine layout(text, QFont(d.data())); | - | ||||||||||||
304 | layout.itemize(); | - | ||||||||||||
305 | glyph_metrics_t gm = layout.boundingBox(0, text.length()); | - | ||||||||||||
306 | return never executed: QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); never executed: return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); | 0 | ||||||||||||
307 | } | - | ||||||||||||
308 | QRect QFontMetrics::boundingRect(QChar ch) const | - | ||||||||||||
309 | { | - | ||||||||||||
310 | const int script = ch.script(); | - | ||||||||||||
311 | QFontEngine *engine; | - | ||||||||||||
312 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
313 | engine = d->smallCapsFontPrivate()->engineForScript(script); never executed: engine = d->smallCapsFontPrivate()->engineForScript(script); | 0 | ||||||||||||
314 | else | - | ||||||||||||
315 | engine = d->engineForScript(script); never executed: engine = d->engineForScript(script); | 0 | ||||||||||||
316 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,700) : qt_noop()); | - | ||||||||||||
317 | - | |||||||||||||
318 | d->alterCharForCapitalization(ch); | - | ||||||||||||
319 | - | |||||||||||||
320 | glyph_t glyph = engine->glyphIndex(ch.unicode()); | - | ||||||||||||
321 | - | |||||||||||||
322 | glyph_metrics_t gm = engine->boundingBox(glyph); | - | ||||||||||||
323 | return never executed: QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); never executed: return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); | 0 | ||||||||||||
324 | } | - | ||||||||||||
325 | QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &text, int tabStops, | - | ||||||||||||
326 | int *tabArray) const | - | ||||||||||||
327 | { | - | ||||||||||||
328 | int tabArrayLen = 0; | - | ||||||||||||
329 | if (tabArray
| 0 | ||||||||||||
330 | while (tabArray[tabArrayLen]
| 0 | ||||||||||||
331 | tabArrayLen++; never executed: tabArrayLen++; | 0 | ||||||||||||
332 | - | |||||||||||||
333 | QRectF rb; | - | ||||||||||||
334 | QRectF rr(rect); | - | ||||||||||||
335 | qt_format_text(QFont(d.data()), rr, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, | - | ||||||||||||
336 | tabArrayLen, 0); | - | ||||||||||||
337 | - | |||||||||||||
338 | return never executed: rb.toAlignedRect();return rb.toAlignedRect(); never executed: return rb.toAlignedRect(); | 0 | ||||||||||||
339 | } | - | ||||||||||||
340 | QSize QFontMetrics::size(int flags, const QString &text, int tabStops, int *tabArray) const | - | ||||||||||||
341 | { | - | ||||||||||||
342 | return never executed: boundingRect(QRect(0,0,0,0), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size();return boundingRect(QRect(0,0,0,0), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size(); never executed: return boundingRect(QRect(0,0,0,0), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size(); | 0 | ||||||||||||
343 | } | - | ||||||||||||
344 | QRect QFontMetrics::tightBoundingRect(const QString &text) const | - | ||||||||||||
345 | { | - | ||||||||||||
346 | if (text.length() == 0
| 0 | ||||||||||||
347 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||
348 | - | |||||||||||||
349 | QStackTextEngine layout(text, QFont(d.data())); | - | ||||||||||||
350 | layout.itemize(); | - | ||||||||||||
351 | glyph_metrics_t gm = layout.tightBoundingBox(0, text.length()); | - | ||||||||||||
352 | return never executed: QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); never executed: return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); | 0 | ||||||||||||
353 | } | - | ||||||||||||
354 | QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags) const | - | ||||||||||||
355 | { | - | ||||||||||||
356 | QString _text = text; | - | ||||||||||||
357 | if (!(flags & Qt::TextLongestVariant)
| 0 | ||||||||||||
358 | int posA = 0; | - | ||||||||||||
359 | int posB = _text.indexOf(QLatin1Char('\x9c')); | - | ||||||||||||
360 | while (posB >= 0
| 0 | ||||||||||||
361 | QString portion = _text.mid(posA, posB - posA); | - | ||||||||||||
362 | if (size(flags, portion).width() <= width
| 0 | ||||||||||||
363 | return never executed: portion;return portion; never executed: return portion; | 0 | ||||||||||||
364 | posA = posB + 1; | - | ||||||||||||
365 | posB = _text.indexOf(QLatin1Char('\x9c'), posA); | - | ||||||||||||
366 | } never executed: end of block | 0 | ||||||||||||
367 | _text = _text.mid(posA); | - | ||||||||||||
368 | } never executed: end of block | 0 | ||||||||||||
369 | QStackTextEngine engine(_text, QFont(d.data())); | - | ||||||||||||
370 | return never executed: engine.elidedText(mode, width, flags);return engine.elidedText(mode, width, flags); never executed: return engine.elidedText(mode, width, flags); | 0 | ||||||||||||
371 | } | - | ||||||||||||
372 | - | |||||||||||||
373 | - | |||||||||||||
374 | - | |||||||||||||
375 | - | |||||||||||||
376 | - | |||||||||||||
377 | - | |||||||||||||
378 | - | |||||||||||||
379 | int QFontMetrics::underlinePos() const | - | ||||||||||||
380 | { | - | ||||||||||||
381 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
382 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,894) : qt_noop()); | - | ||||||||||||
383 | return never executed: qRound(engine->underlinePosition());return qRound(engine->underlinePosition()); never executed: return qRound(engine->underlinePosition()); | 0 | ||||||||||||
384 | } | - | ||||||||||||
385 | - | |||||||||||||
386 | - | |||||||||||||
387 | - | |||||||||||||
388 | - | |||||||||||||
389 | - | |||||||||||||
390 | - | |||||||||||||
391 | - | |||||||||||||
392 | int QFontMetrics::overlinePos() const | - | ||||||||||||
393 | { | - | ||||||||||||
394 | return never executed: ascent() + 1;return ascent() + 1; never executed: return ascent() + 1; | 0 | ||||||||||||
395 | } | - | ||||||||||||
396 | - | |||||||||||||
397 | - | |||||||||||||
398 | - | |||||||||||||
399 | - | |||||||||||||
400 | - | |||||||||||||
401 | - | |||||||||||||
402 | - | |||||||||||||
403 | int QFontMetrics::strikeOutPos() const | - | ||||||||||||
404 | { | - | ||||||||||||
405 | int pos = ascent() / 3; | - | ||||||||||||
406 | return never executed: pos > 0return pos > 0 ? pos : 1;
never executed: return pos > 0 ? pos : 1; | 0 | ||||||||||||
407 | } | - | ||||||||||||
408 | - | |||||||||||||
409 | - | |||||||||||||
410 | - | |||||||||||||
411 | - | |||||||||||||
412 | - | |||||||||||||
413 | - | |||||||||||||
414 | - | |||||||||||||
415 | int QFontMetrics::lineWidth() const | - | ||||||||||||
416 | { | - | ||||||||||||
417 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
418 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,930) : qt_noop()); | - | ||||||||||||
419 | return never executed: qRound(engine->lineThickness());return qRound(engine->lineThickness()); never executed: return qRound(engine->lineThickness()); | 0 | ||||||||||||
420 | } | - | ||||||||||||
421 | QFontMetricsF::QFontMetricsF(const QFontMetrics &fontMetrics) | - | ||||||||||||
422 | : d(fontMetrics.d.data()) | - | ||||||||||||
423 | { | - | ||||||||||||
424 | } never executed: end of block | 0 | ||||||||||||
425 | - | |||||||||||||
426 | - | |||||||||||||
427 | - | |||||||||||||
428 | - | |||||||||||||
429 | - | |||||||||||||
430 | - | |||||||||||||
431 | QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other) | - | ||||||||||||
432 | { | - | ||||||||||||
433 | d = other.d.data(); | - | ||||||||||||
434 | return never executed: *this;return *this; never executed: return *this; | 0 | ||||||||||||
435 | } | - | ||||||||||||
436 | QFontMetricsF::QFontMetricsF(const QFont &font) | - | ||||||||||||
437 | : d(font.d.data()) | - | ||||||||||||
438 | { | - | ||||||||||||
439 | } never executed: end of block | 0 | ||||||||||||
440 | QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice) | - | ||||||||||||
441 | { | - | ||||||||||||
442 | int dpi = paintdevice
| 0 | ||||||||||||
443 | const int screen = 0; | - | ||||||||||||
444 | if (font.d->dpi != dpi
| 0 | ||||||||||||
445 | d = new QFontPrivate(*font.d); | - | ||||||||||||
446 | d->dpi = dpi; | - | ||||||||||||
447 | d->screen = screen; | - | ||||||||||||
448 | } never executed: else {end of block | 0 | ||||||||||||
449 | d = font.d.data(); | - | ||||||||||||
450 | } never executed: end of block | 0 | ||||||||||||
451 | - | |||||||||||||
452 | } | - | ||||||||||||
453 | - | |||||||||||||
454 | - | |||||||||||||
455 | - | |||||||||||||
456 | - | |||||||||||||
457 | QFontMetricsF::QFontMetricsF(const QFontMetricsF &fm) | - | ||||||||||||
458 | : d(fm.d.data()) | - | ||||||||||||
459 | { | - | ||||||||||||
460 | } never executed: end of block | 0 | ||||||||||||
461 | - | |||||||||||||
462 | - | |||||||||||||
463 | - | |||||||||||||
464 | - | |||||||||||||
465 | - | |||||||||||||
466 | QFontMetricsF::~QFontMetricsF() | - | ||||||||||||
467 | { | - | ||||||||||||
468 | } | - | ||||||||||||
469 | - | |||||||||||||
470 | - | |||||||||||||
471 | - | |||||||||||||
472 | - | |||||||||||||
473 | QFontMetricsF &QFontMetricsF::operator=(const QFontMetricsF &fm) | - | ||||||||||||
474 | { | - | ||||||||||||
475 | d = fm.d.data(); | - | ||||||||||||
476 | return never executed: *this;return *this; never executed: return *this; | 0 | ||||||||||||
477 | } | - | ||||||||||||
478 | bool QFontMetricsF::operator ==(const QFontMetricsF &other) const | - | ||||||||||||
479 | { | - | ||||||||||||
480 | return never executed: d == other.d;return d == other.d; never executed: return d == other.d; | 0 | ||||||||||||
481 | } | - | ||||||||||||
482 | qreal QFontMetricsF::ascent() const | - | ||||||||||||
483 | { | - | ||||||||||||
484 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
485 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1128) : qt_noop()); | - | ||||||||||||
486 | return never executed: engine->ascent().toReal();return engine->ascent().toReal(); never executed: return engine->ascent().toReal(); | 0 | ||||||||||||
487 | } | - | ||||||||||||
488 | qreal QFontMetricsF::descent() const | - | ||||||||||||
489 | { | - | ||||||||||||
490 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
491 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1147) : qt_noop()); | - | ||||||||||||
492 | return never executed: engine->descent().toReal();return engine->descent().toReal(); never executed: return engine->descent().toReal(); | 0 | ||||||||||||
493 | } | - | ||||||||||||
494 | qreal QFontMetricsF::height() const | - | ||||||||||||
495 | { | - | ||||||||||||
496 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
497 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1161) : qt_noop()); | - | ||||||||||||
498 | - | |||||||||||||
499 | return never executed: (engine->ascent() + engine->descent()).toReal();return (engine->ascent() + engine->descent()).toReal(); never executed: return (engine->ascent() + engine->descent()).toReal(); | 0 | ||||||||||||
500 | } | - | ||||||||||||
501 | qreal QFontMetricsF::leading() const | - | ||||||||||||
502 | { | - | ||||||||||||
503 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
504 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1176) : qt_noop()); | - | ||||||||||||
505 | return never executed: engine->leading().toReal();return engine->leading().toReal(); never executed: return engine->leading().toReal(); | 0 | ||||||||||||
506 | } | - | ||||||||||||
507 | qreal QFontMetricsF::lineSpacing() const | - | ||||||||||||
508 | { | - | ||||||||||||
509 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
510 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1190) : qt_noop()); | - | ||||||||||||
511 | return never executed: (engine->leading() + engine->ascent() + engine->descent()).toReal();return (engine->leading() + engine->ascent() + engine->descent()).toReal(); never executed: return (engine->leading() + engine->ascent() + engine->descent()).toReal(); | 0 | ||||||||||||
512 | } | - | ||||||||||||
513 | qreal QFontMetricsF::minLeftBearing() const | - | ||||||||||||
514 | { | - | ||||||||||||
515 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
516 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1207) : qt_noop()); | - | ||||||||||||
517 | return never executed: engine->minLeftBearing();return engine->minLeftBearing(); never executed: return engine->minLeftBearing(); | 0 | ||||||||||||
518 | } | - | ||||||||||||
519 | qreal QFontMetricsF::minRightBearing() const | - | ||||||||||||
520 | { | - | ||||||||||||
521 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
522 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1224) : qt_noop()); | - | ||||||||||||
523 | return never executed: engine->minRightBearing();return engine->minRightBearing(); never executed: return engine->minRightBearing(); | 0 | ||||||||||||
524 | } | - | ||||||||||||
525 | - | |||||||||||||
526 | - | |||||||||||||
527 | - | |||||||||||||
528 | - | |||||||||||||
529 | qreal QFontMetricsF::maxWidth() const | - | ||||||||||||
530 | { | - | ||||||||||||
531 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
532 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1234) : qt_noop()); | - | ||||||||||||
533 | return never executed: engine->maxCharWidth();return engine->maxCharWidth(); never executed: return engine->maxCharWidth(); | 0 | ||||||||||||
534 | } | - | ||||||||||||
535 | - | |||||||||||||
536 | - | |||||||||||||
537 | - | |||||||||||||
538 | - | |||||||||||||
539 | - | |||||||||||||
540 | qreal QFontMetricsF::xHeight() const | - | ||||||||||||
541 | { | - | ||||||||||||
542 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
543 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1245) : qt_noop()); | - | ||||||||||||
544 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
545 | return never executed: d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal();return d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal(); never executed: return d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal(); | 0 | ||||||||||||
546 | return never executed: engine->xHeight().toReal();return engine->xHeight().toReal(); never executed: return engine->xHeight().toReal(); | 0 | ||||||||||||
547 | } | - | ||||||||||||
548 | - | |||||||||||||
549 | - | |||||||||||||
550 | - | |||||||||||||
551 | - | |||||||||||||
552 | - | |||||||||||||
553 | - | |||||||||||||
554 | qreal QFontMetricsF::averageCharWidth() const | - | ||||||||||||
555 | { | - | ||||||||||||
556 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
557 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1259) : qt_noop()); | - | ||||||||||||
558 | return never executed: engine->averageCharWidth().toReal();return engine->averageCharWidth().toReal(); never executed: return engine->averageCharWidth().toReal(); | 0 | ||||||||||||
559 | } | - | ||||||||||||
560 | - | |||||||||||||
561 | - | |||||||||||||
562 | - | |||||||||||||
563 | - | |||||||||||||
564 | - | |||||||||||||
565 | bool QFontMetricsF::inFont(QChar ch) const | - | ||||||||||||
566 | { | - | ||||||||||||
567 | return never executed: inFontUcs4(ch.unicode());return inFontUcs4(ch.unicode()); never executed: return inFontUcs4(ch.unicode()); | 0 | ||||||||||||
568 | } | - | ||||||||||||
569 | - | |||||||||||||
570 | - | |||||||||||||
571 | - | |||||||||||||
572 | - | |||||||||||||
573 | - | |||||||||||||
574 | - | |||||||||||||
575 | - | |||||||||||||
576 | bool QFontMetricsF::inFontUcs4(uint ucs4) const | - | ||||||||||||
577 | { | - | ||||||||||||
578 | const int script = QChar::script(ucs4); | - | ||||||||||||
579 | QFontEngine *engine = d->engineForScript(script); | - | ||||||||||||
580 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1282) : qt_noop()); | - | ||||||||||||
581 | if (engine->type() == QFontEngine::Box
| 0 | ||||||||||||
582 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
583 | return never executed: engine->canRender(ucs4);return engine->canRender(ucs4); never executed: return engine->canRender(ucs4); | 0 | ||||||||||||
584 | } | - | ||||||||||||
585 | qreal QFontMetricsF::leftBearing(QChar ch) const | - | ||||||||||||
586 | { | - | ||||||||||||
587 | const int script = ch.script(); | - | ||||||||||||
588 | QFontEngine *engine; | - | ||||||||||||
589 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
590 | engine = d->smallCapsFontPrivate()->engineForScript(script); never executed: engine = d->smallCapsFontPrivate()->engineForScript(script); | 0 | ||||||||||||
591 | else | - | ||||||||||||
592 | engine = d->engineForScript(script); never executed: engine = d->engineForScript(script); | 0 | ||||||||||||
593 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1308) : qt_noop()); | - | ||||||||||||
594 | if (engine->type() == QFontEngine::Box
| 0 | ||||||||||||
595 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
596 | - | |||||||||||||
597 | d->alterCharForCapitalization(ch); | - | ||||||||||||
598 | - | |||||||||||||
599 | glyph_t glyph = engine->glyphIndex(ch.unicode()); | - | ||||||||||||
600 | - | |||||||||||||
601 | qreal lb; | - | ||||||||||||
602 | engine->getGlyphBearings(glyph, &lb); | - | ||||||||||||
603 | return never executed: lb;return lb; never executed: return lb; | 0 | ||||||||||||
604 | } | - | ||||||||||||
605 | qreal QFontMetricsF::rightBearing(QChar ch) const | - | ||||||||||||
606 | { | - | ||||||||||||
607 | const int script = ch.script(); | - | ||||||||||||
608 | QFontEngine *engine; | - | ||||||||||||
609 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
610 | engine = d->smallCapsFontPrivate()->engineForScript(script); never executed: engine = d->smallCapsFontPrivate()->engineForScript(script); | 0 | ||||||||||||
611 | else | - | ||||||||||||
612 | engine = d->engineForScript(script); never executed: engine = d->engineForScript(script); | 0 | ||||||||||||
613 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1341) : qt_noop()); | - | ||||||||||||
614 | if (engine->type() == QFontEngine::Box
| 0 | ||||||||||||
615 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
616 | - | |||||||||||||
617 | d->alterCharForCapitalization(ch); | - | ||||||||||||
618 | - | |||||||||||||
619 | glyph_t glyph = engine->glyphIndex(ch.unicode()); | - | ||||||||||||
620 | - | |||||||||||||
621 | qreal rb; | - | ||||||||||||
622 | engine->getGlyphBearings(glyph, 0, &rb); | - | ||||||||||||
623 | return never executed: rb;return rb; never executed: return rb; | 0 | ||||||||||||
624 | - | |||||||||||||
625 | } | - | ||||||||||||
626 | qreal QFontMetricsF::width(const QString &text) const | - | ||||||||||||
627 | { | - | ||||||||||||
628 | int pos = text.indexOf(QLatin1Char('\x9c')); | - | ||||||||||||
629 | int len = (
| 0 | ||||||||||||
630 | - | |||||||||||||
631 | QStackTextEngine layout(text, QFont(d.data())); | - | ||||||||||||
632 | layout.itemize(); | - | ||||||||||||
633 | return never executed: layout.width(0, len).toReal();return layout.width(0, len).toReal(); never executed: return layout.width(0, len).toReal(); | 0 | ||||||||||||
634 | } | - | ||||||||||||
635 | qreal QFontMetricsF::width(QChar ch) const | - | ||||||||||||
636 | { | - | ||||||||||||
637 | if (ch.category() == QChar::Mark_NonSpacing
| 0 | ||||||||||||
638 | return never executed: 0.;return 0.; never executed: return 0.; | 0 | ||||||||||||
639 | - | |||||||||||||
640 | const int script = ch.script(); | - | ||||||||||||
641 | QFontEngine *engine; | - | ||||||||||||
642 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
643 | engine = d->smallCapsFontPrivate()->engineForScript(script); never executed: engine = d->smallCapsFontPrivate()->engineForScript(script); | 0 | ||||||||||||
644 | else | - | ||||||||||||
645 | engine = d->engineForScript(script); never executed: engine = d->engineForScript(script); | 0 | ||||||||||||
646 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1410) : qt_noop()); | - | ||||||||||||
647 | - | |||||||||||||
648 | d->alterCharForCapitalization(ch); | - | ||||||||||||
649 | - | |||||||||||||
650 | glyph_t glyph = engine->glyphIndex(ch.unicode()); | - | ||||||||||||
651 | QFixed advance; | - | ||||||||||||
652 | - | |||||||||||||
653 | QGlyphLayout glyphs; | - | ||||||||||||
654 | glyphs.numGlyphs = 1; | - | ||||||||||||
655 | glyphs.glyphs = &glyph; | - | ||||||||||||
656 | glyphs.advances = &advance; | - | ||||||||||||
657 | engine->recalcAdvances(&glyphs, 0); | - | ||||||||||||
658 | - | |||||||||||||
659 | return never executed: advance.toReal();return advance.toReal(); never executed: return advance.toReal(); | 0 | ||||||||||||
660 | } | - | ||||||||||||
661 | QRectF QFontMetricsF::boundingRect(const QString &text) const | - | ||||||||||||
662 | { | - | ||||||||||||
663 | int len = text.length(); | - | ||||||||||||
664 | if (len == 0
| 0 | ||||||||||||
665 | return never executed: QRectF();return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||
666 | - | |||||||||||||
667 | QStackTextEngine layout(text, QFont(d.data())); | - | ||||||||||||
668 | layout.itemize(); | - | ||||||||||||
669 | glyph_metrics_t gm = layout.boundingBox(0, len); | - | ||||||||||||
670 | return never executed: QRectF(gm.x.toReal(), gm.y.toReal(),return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); | 0 | ||||||||||||
671 | gm.width.toReal(), gm.height.toReal()); never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); | 0 | ||||||||||||
672 | } | - | ||||||||||||
673 | QRectF QFontMetricsF::boundingRect(QChar ch) const | - | ||||||||||||
674 | { | - | ||||||||||||
675 | const int script = ch.script(); | - | ||||||||||||
676 | QFontEngine *engine; | - | ||||||||||||
677 | if (d->capital == QFont::SmallCaps
| 0 | ||||||||||||
678 | engine = d->smallCapsFontPrivate()->engineForScript(script); never executed: engine = d->smallCapsFontPrivate()->engineForScript(script); | 0 | ||||||||||||
679 | else | - | ||||||||||||
680 | engine = d->engineForScript(script); never executed: engine = d->engineForScript(script); | 0 | ||||||||||||
681 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1480) : qt_noop()); | - | ||||||||||||
682 | - | |||||||||||||
683 | d->alterCharForCapitalization(ch); | - | ||||||||||||
684 | - | |||||||||||||
685 | glyph_t glyph = engine->glyphIndex(ch.unicode()); | - | ||||||||||||
686 | - | |||||||||||||
687 | glyph_metrics_t gm = engine->boundingBox(glyph); | - | ||||||||||||
688 | return never executed: QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); | 0 | ||||||||||||
689 | } | - | ||||||||||||
690 | QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString& text, | - | ||||||||||||
691 | int tabStops, int *tabArray) const | - | ||||||||||||
692 | { | - | ||||||||||||
693 | int tabArrayLen = 0; | - | ||||||||||||
694 | if (tabArray
| 0 | ||||||||||||
695 | while (tabArray[tabArrayLen]
| 0 | ||||||||||||
696 | tabArrayLen++; never executed: tabArrayLen++; | 0 | ||||||||||||
697 | - | |||||||||||||
698 | QRectF rb; | - | ||||||||||||
699 | qt_format_text(QFont(d.data()), rect, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, | - | ||||||||||||
700 | tabArrayLen, 0); | - | ||||||||||||
701 | return never executed: rb;return rb; never executed: return rb; | 0 | ||||||||||||
702 | } | - | ||||||||||||
703 | QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *tabArray) const | - | ||||||||||||
704 | { | - | ||||||||||||
705 | return never executed: boundingRect(QRectF(), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size();return boundingRect(QRectF(), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size(); never executed: return boundingRect(QRectF(), flags | Qt::TextLongestVariant, text, tabStops, tabArray).size(); | 0 | ||||||||||||
706 | } | - | ||||||||||||
707 | QRectF QFontMetricsF::tightBoundingRect(const QString &text) const | - | ||||||||||||
708 | { | - | ||||||||||||
709 | if (text.length() == 0
| 0 | ||||||||||||
710 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||
711 | - | |||||||||||||
712 | QStackTextEngine layout(text, QFont(d.data())); | - | ||||||||||||
713 | layout.itemize(); | - | ||||||||||||
714 | glyph_metrics_t gm = layout.tightBoundingBox(0, text.length()); | - | ||||||||||||
715 | return never executed: QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); never executed: return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); | 0 | ||||||||||||
716 | } | - | ||||||||||||
717 | QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags) const | - | ||||||||||||
718 | { | - | ||||||||||||
719 | QString _text = text; | - | ||||||||||||
720 | if (!(flags & Qt::TextLongestVariant)
| 0 | ||||||||||||
721 | int posA = 0; | - | ||||||||||||
722 | int posB = _text.indexOf(QLatin1Char('\x9c')); | - | ||||||||||||
723 | while (posB >= 0
| 0 | ||||||||||||
724 | QString portion = _text.mid(posA, posB - posA); | - | ||||||||||||
725 | if (size(flags, portion).width() <= width
| 0 | ||||||||||||
726 | return never executed: portion;return portion; never executed: return portion; | 0 | ||||||||||||
727 | posA = posB + 1; | - | ||||||||||||
728 | posB = _text.indexOf(QLatin1Char('\x9c'), posA); | - | ||||||||||||
729 | } never executed: end of block | 0 | ||||||||||||
730 | _text = _text.mid(posA); | - | ||||||||||||
731 | } never executed: end of block | 0 | ||||||||||||
732 | QStackTextEngine engine(_text, QFont(d.data())); | - | ||||||||||||
733 | return never executed: engine.elidedText(mode, QFixed::fromReal(width), flags);return engine.elidedText(mode, QFixed::fromReal(width), flags); never executed: return engine.elidedText(mode, QFixed::fromReal(width), flags); | 0 | ||||||||||||
734 | } | - | ||||||||||||
735 | - | |||||||||||||
736 | - | |||||||||||||
737 | - | |||||||||||||
738 | - | |||||||||||||
739 | - | |||||||||||||
740 | - | |||||||||||||
741 | - | |||||||||||||
742 | qreal QFontMetricsF::underlinePos() const | - | ||||||||||||
743 | { | - | ||||||||||||
744 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
745 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1678) : qt_noop()); | - | ||||||||||||
746 | return never executed: engine->underlinePosition().toReal();return engine->underlinePosition().toReal(); never executed: return engine->underlinePosition().toReal(); | 0 | ||||||||||||
747 | } | - | ||||||||||||
748 | - | |||||||||||||
749 | - | |||||||||||||
750 | - | |||||||||||||
751 | - | |||||||||||||
752 | - | |||||||||||||
753 | - | |||||||||||||
754 | - | |||||||||||||
755 | qreal QFontMetricsF::overlinePos() const | - | ||||||||||||
756 | { | - | ||||||||||||
757 | return never executed: ascent() + 1;return ascent() + 1; never executed: return ascent() + 1; | 0 | ||||||||||||
758 | } | - | ||||||||||||
759 | - | |||||||||||||
760 | - | |||||||||||||
761 | - | |||||||||||||
762 | - | |||||||||||||
763 | - | |||||||||||||
764 | - | |||||||||||||
765 | - | |||||||||||||
766 | qreal QFontMetricsF::strikeOutPos() const | - | ||||||||||||
767 | { | - | ||||||||||||
768 | return never executed: ascent() / 3.;return ascent() / 3.; never executed: return ascent() / 3.; | 0 | ||||||||||||
769 | } | - | ||||||||||||
770 | - | |||||||||||||
771 | - | |||||||||||||
772 | - | |||||||||||||
773 | - | |||||||||||||
774 | - | |||||||||||||
775 | - | |||||||||||||
776 | - | |||||||||||||
777 | qreal QFontMetricsF::lineWidth() const | - | ||||||||||||
778 | { | - | ||||||||||||
779 | QFontEngine *engine = d->engineForScript(QChar::Script_Common); | - | ||||||||||||
780 | ((!(engine != 0)) ? qt_assert("engine != 0",__FILE__,1713) : qt_noop()); | - | ||||||||||||
781 | return never executed: engine->lineThickness().toReal();return engine->lineThickness().toReal(); never executed: return engine->lineThickness().toReal(); | 0 | ||||||||||||
782 | } | - | ||||||||||||
783 | - | |||||||||||||
784 | - | |||||||||||||
Switch to Source code | Preprocessed file |