Fix kerning errors when using DirectWrite backend
There were a couple of errors when calculating advances in the DirectWrite font engine: First of all, we would apply the CLEARTYPE_NATURAL glyph metrics when using GDI_CLASSIC rendering, causing text to look compressed in some places, because we always passed TRUE for the useGdiNatural parameter to GetGdiCompatibleGlyphMetrics(). In addition, we would pick the GDI-compatible metrics even when design metrics had explicitly been requested on the layout. This is the case for distance field rendered text, which always operates with design metrics and scalable layouts, so it was visible as kerning errors on some text there. Pick-to: 6.6 6.5 Fixes: QTBUG-122139 Fixes: QTBUG-122167 Change-Id: Ic28da6b3235d7af0452bdcb836e037594f8a20ba Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> (cherry picked from commit de3d5dd73b748bc1591447fe81dff6427a86f77b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
aea4e9788a
commit
90963387e4
@ -471,7 +471,7 @@ QFontEngine::FaceId QWindowsFontEngineDirectWrite::faceId() const
|
||||
return m_faceId;
|
||||
}
|
||||
|
||||
void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const
|
||||
void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags shaperFlags) const
|
||||
{
|
||||
QVarLengthArray<UINT16> glyphIndices(glyphs->numGlyphs);
|
||||
|
||||
@ -483,11 +483,13 @@ void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEn
|
||||
|
||||
HRESULT hr;
|
||||
DWRITE_RENDERING_MODE renderMode = hintingPreferenceToRenderingMode(fontDef);
|
||||
if (renderMode == DWRITE_RENDERING_MODE_GDI_CLASSIC || renderMode == DWRITE_RENDERING_MODE_GDI_NATURAL) {
|
||||
bool needsDesignMetrics = shaperFlags & QFontEngine::DesignMetrics;
|
||||
if (!needsDesignMetrics && (renderMode == DWRITE_RENDERING_MODE_GDI_CLASSIC
|
||||
|| renderMode == DWRITE_RENDERING_MODE_GDI_NATURAL)) {
|
||||
hr = m_directWriteFontFace->GetGdiCompatibleGlyphMetrics(float(fontDef.pixelSize),
|
||||
1.0f,
|
||||
NULL,
|
||||
TRUE,
|
||||
renderMode == DWRITE_RENDERING_MODE_GDI_NATURAL,
|
||||
glyphIndices.data(),
|
||||
glyphIndices.size(),
|
||||
glyphMetrics.data());
|
||||
|
Loading…
x
Reference in New Issue
Block a user