mirror of https://github.com/qt/qtbase.git
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. Fixes: QTBUG-122139 Fixes: QTBUG-122167 Change-Id: Ic28da6b3235d7af0452bdcb836e037594f8a20ba Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> (cherry picked from commitde3d5dd73b
) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit90963387e4
) (cherry picked from commit1d244eb910
)
This commit is contained in:
parent
2880f8b2f6
commit
875f8a795f
|
@ -466,7 +466,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);
|
||||
|
||||
|
@ -478,11 +478,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…
Reference in New Issue