Fix drawing color fonts with shear and perspective transforms

Fixes the fallback painting used with complex transforms to be able to
handle color bitmap fonts which can't be converted to a path.

Change-Id: Id2851607f673b8fc1aea63f92043d0cdebc0fb9d
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2017-11-24 15:52:09 +01:00
parent ca181d3740
commit d6473eb186

View File

@ -751,11 +751,29 @@ void QPaintEngine::drawPath(const QPainterPath &)
void QPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
{
const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
if (ti.glyphs.numGlyphs == 0)
return;
if (ti.fontEngine->glyphFormat == QFontEngine::Format_ARGB) {
QVarLengthArray<QFixedPoint> positions;
QVarLengthArray<glyph_t> glyphs;
QTransform matrix = QTransform::fromTranslate(p.x(), p.y() - ti.fontEngine->ascent().toReal());
ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
painter()->save();
painter()->setRenderHint(QPainter::SmoothPixmapTransform,
bool((painter()->renderHints() & QPainter::TextAntialiasing)
&& !(painter()->font().styleStrategy() & QFont::NoAntialias)));
for (int i = 0; i < ti.glyphs.numGlyphs; ++i) {
QImage glyph = ti.fontEngine->bitmapForGlyph(glyphs[i], QFixed(), QTransform());
painter()->drawImage(positions[i].x.toReal(), positions[i].y.toReal(), glyph);
}
painter()->restore();
return;
}
QPainterPath path;
path.setFillRule(Qt::WindingFill);
if (ti.glyphs.numGlyphs)
ti.fontEngine->addOutlineToPath(0, 0, ti.glyphs, &path, ti.flags);
ti.fontEngine->addOutlineToPath(0, 0, ti.glyphs, &path, ti.flags);
if (!path.isEmpty()) {
painter()->save();
painter()->setRenderHint(QPainter::Antialiasing,