Windows: Fix arbitrary outline on emojis
Emojis would sometimes get an outline in a seemingly random color. This was because the color run is not initialized to the first layer. MoveNext() should be called on the initially to move it to the first layer, so the first layer we rendered would end up being a monochrome version of the glyph with a random palette index. [ChangeLog][Windows] Fixed an issue where emojis would sometimes get an outline. Pick-to: 6.5 Fixes: QTBUG-131587 Change-Id: I42c2828d66c6149cdb62c2b6271dfd49ca002db0 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 51b584e6062e83e24950d5eccd826ea5a5b8af6f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
2e3439dc94
commit
992f81931e
@ -832,64 +832,65 @@ QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t,
|
||||
image.fill(0xffffffff);
|
||||
}
|
||||
|
||||
BOOL ok = true;
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
BOOL ok = true;
|
||||
while (SUCCEEDED(hr) && ok) {
|
||||
const DWRITE_COLOR_GLYPH_RUN *colorGlyphRun = 0;
|
||||
hr = enumerator->GetCurrentRun(&colorGlyphRun);
|
||||
if (FAILED(hr)) { // No colored runs, only outline
|
||||
qErrnoWarning(hr, "%s: IDWriteColorGlyphRunEnumerator::GetCurrentRun failed", __FUNCTION__);
|
||||
break;
|
||||
}
|
||||
|
||||
IDWriteGlyphRunAnalysis *colorGlyphsAnalysis = NULL;
|
||||
hr = factory2->CreateGlyphRunAnalysis(
|
||||
&colorGlyphRun->glyphRun,
|
||||
&transform,
|
||||
renderMode,
|
||||
measureMode,
|
||||
gridFitMode,
|
||||
DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE,
|
||||
0.0, 0.0,
|
||||
&colorGlyphsAnalysis
|
||||
);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
qErrnoWarning(hr, "%s: CreateGlyphRunAnalysis failed for color run", __FUNCTION__);
|
||||
break;
|
||||
}
|
||||
|
||||
float r, g, b, a;
|
||||
if (colorGlyphRun->paletteIndex == 0xFFFF) {
|
||||
r = float(color.redF());
|
||||
g = float(color.greenF());
|
||||
b = float(color.blueF());
|
||||
a = float(color.alphaF());
|
||||
} else {
|
||||
r = qBound(0.0f, colorGlyphRun->runColor.r, 1.0f);
|
||||
g = qBound(0.0f, colorGlyphRun->runColor.g, 1.0f);
|
||||
b = qBound(0.0f, colorGlyphRun->runColor.b, 1.0f);
|
||||
a = qBound(0.0f, colorGlyphRun->runColor.a, 1.0f);
|
||||
}
|
||||
|
||||
if (!qFuzzyIsNull(a)) {
|
||||
renderGlyphRun(&image,
|
||||
r,
|
||||
g,
|
||||
b,
|
||||
a,
|
||||
colorGlyphsAnalysis,
|
||||
boundingRect,
|
||||
renderMode);
|
||||
}
|
||||
colorGlyphsAnalysis->Release();
|
||||
|
||||
hr = enumerator->MoveNext(&ok);
|
||||
if (FAILED(hr)) {
|
||||
qErrnoWarning(hr, "%s: IDWriteColorGlyphRunEnumerator::MoveNext failed", __FUNCTION__);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
const DWRITE_COLOR_GLYPH_RUN *colorGlyphRun = 0;
|
||||
hr = enumerator->GetCurrentRun(&colorGlyphRun);
|
||||
if (FAILED(hr)) { // No colored runs, only outline
|
||||
qErrnoWarning(hr, "%s: IDWriteColorGlyphRunEnumerator::GetCurrentRun failed", __FUNCTION__);
|
||||
break;
|
||||
}
|
||||
|
||||
IDWriteGlyphRunAnalysis *colorGlyphsAnalysis = NULL;
|
||||
hr = factory2->CreateGlyphRunAnalysis(
|
||||
&colorGlyphRun->glyphRun,
|
||||
&transform,
|
||||
renderMode,
|
||||
measureMode,
|
||||
gridFitMode,
|
||||
DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE,
|
||||
0.0, 0.0,
|
||||
&colorGlyphsAnalysis
|
||||
);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
qErrnoWarning(hr, "%s: CreateGlyphRunAnalysis failed for color run", __FUNCTION__);
|
||||
break;
|
||||
}
|
||||
|
||||
float r, g, b, a;
|
||||
if (colorGlyphRun->paletteIndex == 0xFFFF) {
|
||||
r = float(color.redF());
|
||||
g = float(color.greenF());
|
||||
b = float(color.blueF());
|
||||
a = 1.0;
|
||||
} else {
|
||||
r = qBound(0.0f, colorGlyphRun->runColor.r, 1.0f);
|
||||
g = qBound(0.0f, colorGlyphRun->runColor.g, 1.0f);
|
||||
b = qBound(0.0f, colorGlyphRun->runColor.b, 1.0f);
|
||||
a = qBound(0.0f, colorGlyphRun->runColor.a, 1.0f);
|
||||
}
|
||||
|
||||
if (!qFuzzyIsNull(a)) {
|
||||
renderGlyphRun(&image,
|
||||
r,
|
||||
g,
|
||||
b,
|
||||
a,
|
||||
colorGlyphsAnalysis,
|
||||
boundingRect,
|
||||
renderMode);
|
||||
}
|
||||
colorGlyphsAnalysis->Release();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
float r, g, b, a;
|
||||
|
Loading…
x
Reference in New Issue
Block a user