macOS: Only do gamma-corrected blending for subpixel-antialiased text

The grayscale font-smoothing doesn't expect to be linearly blended,
as first assumed.

Amended nativetext manual test to better diagnose the native Core
Text behavior. Non-linear blending will result in the magenta
text having a dark outline against the green background.

Change-Id: I24a5f04eb1bd66fb98d621078d80ee9b80800827
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tor Arne Vestbø 2018-12-18 22:20:57 +01:00
parent 5af60d3b37
commit 3306b16239
2 changed files with 3 additions and 3 deletions

View File

@ -736,7 +736,7 @@ bool QCoreTextFontEngine::shouldSmoothFont() const
bool QCoreTextFontEngine::expectsGammaCorrectedBlending() const
{
return shouldSmoothFont();
return shouldSmoothFont() && fontSmoothing() == Subpixel;
}
qreal QCoreTextFontEngine::fontSmoothingGamma()

View File

@ -101,7 +101,7 @@ public:
const int ascent = fontMetrics().ascent();
QPen metricsPen(Qt::magenta, 1.0);
QPen metricsPen(QColor(112, 216, 255), 1.0);
metricsPen.setCosmetic(true);
p.setPen(metricsPen);
p.drawLine(QPoint(0, ascent), QPoint(width(), ascent));
@ -201,7 +201,7 @@ public:
case 0: return qMakePair(QColor(), QColor());
case 1: return qMakePair(QColor(Qt::black), QColor(Qt::white));
case 2: return qMakePair(QColor(Qt::white), QColor(Qt::black));
case 3: return qMakePair(QColor(Qt::green), QColor(Qt::red));
case 3: return qMakePair(QColor(Qt::magenta), QColor(Qt::green));
case 4: return qMakePair(QColor(0, 0, 0, 128), QColor(Qt::white));
case 5: return qMakePair(QColor(255, 255, 255, 128), QColor(Qt::black));
default: return qMakePair(QColor(), QColor());