Qt 4.8
Classes | Functions
qdeclarativetextlayout.cpp File Reference
#include "qdeclarativetextlayout_p.h"
#include <private/qstatictext_p.h>
#include <private/qfontengine_p.h>
#include <private/qtextengine_p.h>
#include <private/qpainter_p.h>
#include <private/qpaintengineex_p.h>

Go to the source code of this file.

Classes

class  QDeclarativeTextLayoutPrivate
 

Functions

 Q_GLOBAL_STATIC (InertTextPainter, inertTextPainter)
 
Q_GUI_EXPORT void qt_draw_decoration_for_glyphs (QPainter *painter, const glyph_t *glyphArray, const QFixedPoint *positions, int glyphCount, QFontEngine *fontEngine, const QFont &font, const QTextCharFormat &charFormat)
 

Function Documentation

◆ Q_GLOBAL_STATIC()

Q_GLOBAL_STATIC ( InertTextPainter  ,
inertTextPainter   
)

◆ qt_draw_decoration_for_glyphs()

Q_GUI_EXPORT void qt_draw_decoration_for_glyphs ( QPainter painter,
const glyph_t glyphArray,
const QFixedPoint positions,
int  glyphCount,
QFontEngine fontEngine,
const QFont font,
const QTextCharFormat charFormat 
)

Definition at line 6820 of file qpainter.cpp.

Referenced by QDeclarativeTextLayout::draw(), QPainter::drawStaticText(), and QDeclarativeTextLayout::prepare().

6824 {
6825  if (!(font.underline() || font.strikeOut() || font.overline()))
6826  return;
6827 
6828  QFixed leftMost;
6829  QFixed rightMost;
6830  QFixed baseLine;
6831  for (int i=0; i<glyphCount; ++i) {
6832  glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]);
6833  if (i == 0 || leftMost > positions[i].x)
6834  leftMost = positions[i].x;
6835 
6836  // We don't support glyphs that do not share a common baseline. If this turns out to
6837  // be a relevant use case, then we need to find clusters of glyphs that share a baseline
6838  // and do a drawTextItemDecorations call per cluster.
6839  if (i == 0 || baseLine < positions[i].y)
6840  baseLine = positions[i].y;
6841 
6842  // We use the advance rather than the actual bounds to match the algorithm in drawText()
6843  if (i == 0 || rightMost < positions[i].x + gm.xoff)
6844  rightMost = positions[i].x + gm.xoff;
6845  }
6846 
6847  QFixed width = rightMost - leftMost;
6848  QTextItem::RenderFlags flags = 0;
6849 
6850  if (font.underline())
6851  flags |= QTextItem::Underline;
6852  if (font.overline())
6853  flags |= QTextItem::Overline;
6854  if (font.strikeOut())
6855  flags |= QTextItem::StrikeOut;
6856 
6857  drawTextItemDecoration(painter, QPointF(leftMost.toReal(), baseLine.toReal()),
6858  fontEngine,
6861  width.toReal(), charFormat);
6862 }
bool underline() const
Returns true if underline has been set; otherwise returns false.
Definition: qfont.cpp:1320
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QFixed y
Definition: qfixed_p.h:191
bool overline() const
Returns true if overline has been set; otherwise returns false.
Definition: qfont.cpp:1344
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
QFixed x
Definition: qfixed_p.h:190
qreal toReal() const
Definition: qfixed_p.h:77
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
Definition: qfont.cpp:1367
static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe, QTextCharFormat::UnderlineStyle underlineStyle, QTextItem::RenderFlags flags, qreal width, const QTextCharFormat &charFormat)
Definition: qpainter.cpp:6738