343 |
343 |
344 struct Q_AUTOTEST_EXPORT QScriptItem |
344 struct Q_AUTOTEST_EXPORT QScriptItem |
345 { |
345 { |
346 inline QScriptItem() |
346 inline QScriptItem() |
347 : position(0), |
347 : position(0), |
348 num_glyphs(0), descent(-1), ascent(-1), width(-1), |
348 num_glyphs(0), descent(-1), ascent(-1), leading(-1), width(-1), |
349 glyph_data_offset(0) {} |
349 glyph_data_offset(0) {} |
350 inline QScriptItem(int p, const QScriptAnalysis &a) |
350 inline QScriptItem(int p, const QScriptAnalysis &a) |
351 : position(p), analysis(a), |
351 : position(p), analysis(a), |
352 num_glyphs(0), descent(-1), ascent(-1), width(-1), |
352 num_glyphs(0), descent(-1), ascent(-1), leading(-1), width(-1), |
353 glyph_data_offset(0) {} |
353 glyph_data_offset(0) {} |
354 |
354 |
355 int position; |
355 int position; |
356 QScriptAnalysis analysis; |
356 QScriptAnalysis analysis; |
357 unsigned short num_glyphs; |
357 unsigned short num_glyphs; |
358 QFixed descent; |
358 QFixed descent; |
359 QFixed ascent; |
359 QFixed ascent; |
|
360 QFixed leading; |
360 QFixed width; |
361 QFixed width; |
361 int glyph_data_offset; |
362 int glyph_data_offset; |
362 QFixed height() const { return ascent + descent + 1; } |
363 QFixed height() const { return ascent + descent + 1; } |
363 }; |
364 }; |
364 |
365 |
371 { |
372 { |
372 // created and filled in QTextLine::layout_helper |
373 // created and filled in QTextLine::layout_helper |
373 QScriptLine() |
374 QScriptLine() |
374 : from(0), length(0), |
375 : from(0), length(0), |
375 justified(0), gridfitted(0), |
376 justified(0), gridfitted(0), |
376 hasTrailingSpaces(0) {} |
377 hasTrailingSpaces(0), leadingIncluded(0) {} |
377 QFixed descent; |
378 QFixed descent; |
378 QFixed ascent; |
379 QFixed ascent; |
|
380 QFixed leading; |
379 QFixed x; |
381 QFixed x; |
380 QFixed y; |
382 QFixed y; |
381 QFixed width; |
383 QFixed width; |
382 QFixed textWidth; |
384 QFixed textWidth; |
383 int from; |
385 int from; |
384 signed int length : 29; |
386 signed int length : 29; |
385 mutable uint justified : 1; |
387 mutable uint justified : 1; |
386 mutable uint gridfitted : 1; |
388 mutable uint gridfitted : 1; |
387 uint hasTrailingSpaces : 1; |
389 uint hasTrailingSpaces : 1; |
388 QFixed height() const { return ascent + descent + 1; } |
390 uint leadingIncluded : 1; |
|
391 QFixed height() const { return ascent + descent + 1 |
|
392 + (leadingIncluded? qMax(QFixed(),leading) : QFixed()); } |
|
393 QFixed base() const { return ascent |
|
394 + (leadingIncluded ? qMax(QFixed(),leading) : QFixed()); } |
389 void setDefaultHeight(QTextEngine *eng); |
395 void setDefaultHeight(QTextEngine *eng); |
390 void operator+=(const QScriptLine &other); |
396 void operator+=(const QScriptLine &other); |
391 }; |
397 }; |
392 Q_DECLARE_TYPEINFO(QScriptLine, Q_PRIMITIVE_TYPE); |
398 Q_DECLARE_TYPEINFO(QScriptLine, Q_PRIMITIVE_TYPE); |
393 |
399 |
394 |
400 |
395 inline void QScriptLine::operator+=(const QScriptLine &other) |
401 inline void QScriptLine::operator+=(const QScriptLine &other) |
396 { |
402 { |
|
403 leading= qMax(leading + ascent, other.leading + other.ascent) - qMax(ascent, other.ascent); |
397 descent = qMax(descent, other.descent); |
404 descent = qMax(descent, other.descent); |
398 ascent = qMax(ascent, other.ascent); |
405 ascent = qMax(ascent, other.ascent); |
399 textWidth += other.textWidth; |
406 textWidth += other.textWidth; |
400 length += other.length; |
407 length += other.length; |
401 } |
408 } |
474 else |
481 else |
475 end = layoutData->string.length(); |
482 end = layoutData->string.length(); |
476 return end - si->position; |
483 return end - si->position; |
477 } |
484 } |
478 |
485 |
479 QFontEngine *fontEngine(const QScriptItem &si, QFixed *ascent = 0, QFixed *descent = 0) const; |
486 QFontEngine *fontEngine(const QScriptItem &si, QFixed *ascent = 0, QFixed *descent = 0, QFixed *leading = 0) const; |
480 QFont font(const QScriptItem &si) const; |
487 QFont font(const QScriptItem &si) const; |
481 inline QFont font() const { return fnt; } |
488 inline QFont font() const { return fnt; } |
482 |
489 |
483 /** |
490 /** |
484 * Returns a pointer to an array of log clusters, offset at the script item. |
491 * Returns a pointer to an array of log clusters, offset at the script item. |