pen.setWidthF(fe->lineThickness().toReal());
pen.setCapStyle(Qt::FlatCap);
- QLineF line(pos.x(), pos.y(), pos.x() + qFloor(width), pos.y());
-
const qreal underlineOffset = fe->underlinePosition().toReal();
// deliberately ceil the offset to avoid the underline coming too close to
// the text above it.
painter->fillRect(pos.x(), 0, qCeil(width), qMin(wave.height(), descent), wave);
painter->restore();
} else if (underlineStyle != QTextCharFormat::NoUnderline) {
- QLineF underLine(line.x1(), underlinePos, line.x2(), underlinePos);
+ QLineF underLine(pos.x(), underlinePos, pos.x() + qFloor(width), underlinePos);
QColor uc = charFormat.underlineColor();
if (uc.isValid())
painter->setPen(pen);
painter->drawLine(underLine);
}
-
- pen.setStyle(Qt::SolidLine);
- pen.setColor(oldPen.color());
-
- if (flags & QTextItem::StrikeOut) {
- QLineF strikeOutLine = line;
- strikeOutLine.translate(0., - fe->ascent().toReal() / 3.);
- painter->setPen(pen);
- painter->drawLine(strikeOutLine);
- }
-
- if (flags & QTextItem::Overline) {
- QLineF overLine = line;
- overLine.translate(0., - fe->ascent().toReal());
- painter->setPen(pen);
- painter->drawLine(overLine);
- }
-
- painter->setPen(oldPen);
- painter->setBrush(oldBrush);
}
void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti)
engine->stringToCMap(text.unicode(), nglyphs, &glyphs, &nglyphs, shaperflags);
engine->addOutlineToPath(point.x(), point.y(), glyphs, this);
}
+
+ const QFontMetricsF fontmetrics(f);
+ const qreal linewidth = fontmetrics.lineWidth();
+ const qreal textwidth = (fontmetrics.width('x') * text.size());
+#if 0
+ if (f.underline()) {
+ addRect(point.x(), point.y() + fontmetrics.underlinePos(), textwidth, linewidth);
+ }
+#endif
+ if (f.overline()) {
+ addRect(point.x(), point.y() - fontmetrics.overlinePos(), textwidth, linewidth);
+ }
+ if (f.strikeOut()) {
+ addRect(point.x(), point.y() - fontmetrics.strikeOutPos(), textwidth, linewidth);
+ }
}
/*!
QPainterPath path;
path.setFillRule(Qt::WindingFill);
- if (gf.glyphs.numGlyphs)
- gf.fontEngine->addOutlineToPath(pos.x(), pos.y(), gf.glyphs, &path);
- if (gf.flags) {
- const QFontEngine *fe = gf.fontEngine;
- const qreal lw = fe->lineThickness().toReal();
- if (gf.flags & QTextItem::Underline) {
- qreal offs = fe->underlinePosition().toReal();
- path.addRect(pos.x(), pos.y() + offs, gf.width.toReal(), lw);
- }
- if (gf.flags & QTextItem::Overline) {
- qreal offs = fe->ascent().toReal() + 1;
- path.addRect(pos.x(), pos.y() - offs, gf.width.toReal(), lw);
- }
- if (gf.flags & QTextItem::StrikeOut) {
- qreal offs = fe->ascent().toReal() / 3;
- path.addRect(pos.x(), pos.y() - offs, gf.width.toReal(), lw);
- }
- }
+ path.addText(pos, f, gf.text());
p->save();
//Currently QPen with a Qt::NoPen style still returns a default