Differ between vertical and no hinting on Windows

Symmetric text rendering seems to be the equivalent to no hinting
at all since it does subpixel antialiasing in both horizontal and vertical
directions. Let people select non-symmetric, natural rendering as well,
by setting vertical hinting on the font. This is the mode used for many
UI elements in newer versions of Windows (like the title bar of windows
etc.)

[ChangeLog][Windows] Added differentiation between vertical hinting and
no hinting in DirectWrite font engine.

Task-number: QTBUG-48546
Change-Id: I2f75ae2d16fdf26706587d92da43daf29afbbcf2
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2015-11-19 17:49:46 +01:00
parent 96cc7fe5c2
commit a2ef3479b8
3 changed files with 15 additions and 5 deletions

View File

@ -1239,11 +1239,13 @@ QT_WARNING_POP
fontFile->Release();
fontEngine = new QWindowsFontEngineDirectWrite(directWriteFontFace, pixelSize,
fontEngine = new QWindowsFontEngineDirectWrite(directWriteFontFace,
pixelSize,
fontEngineData);
// Get font family from font data
fontEngine->fontDef.family = font.familyName();
fontEngine->fontDef.hintingPreference = hintingPreference;
directWriteFontFace->Release();
}

View File

@ -1362,6 +1362,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
if (fontEngine->fontDef.style > QFont::StyleNormal)
fedw->fontDef.style = fontEngine->fontDef.style;
fedw->fontDef.family = fam;
fedw->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
return fedw;
} else {
qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__);
@ -1379,6 +1380,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
if (fontEngine->fontDef.style > QFont::StyleNormal)
fe->fontDef.style = fontEngine->fontDef.style;
fe->fontDef.family = fam;
fe->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
return fe;
}

View File

@ -196,8 +196,8 @@ namespace {
*/
QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite(IDWriteFontFace *directWriteFontFace,
qreal pixelSize,
const QSharedPointer<QWindowsFontEngineData> &d)
qreal pixelSize,
const QSharedPointer<QWindowsFontEngineData> &d)
: QFontEngine(DirectWrite)
, m_fontEngineData(d)
, m_directWriteFontFace(directWriteFontFace)
@ -547,12 +547,17 @@ QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t,
transform.m21 = xform.m21();
transform.m22 = xform.m22();
DWRITE_RENDERING_MODE renderMode =
fontDef.hintingPreference == QFont::PreferNoHinting
? DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC
: DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
IDWriteGlyphRunAnalysis *glyphAnalysis = NULL;
HRESULT hr = m_fontEngineData->directWriteFactory->CreateGlyphRunAnalysis(
&glyphRun,
1.0f,
&transform,
DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC,
renderMode,
DWRITE_MEASURING_MODE_NATURAL,
0.0, 0.0,
&glyphAnalysis
@ -626,7 +631,8 @@ QImage QWindowsFontEngineDirectWrite::alphaRGBMapForGlyph(glyph_t t,
QFontEngine *QWindowsFontEngineDirectWrite::cloneWithSize(qreal pixelSize) const
{
QFontEngine *fontEngine = new QWindowsFontEngineDirectWrite(m_directWriteFontFace,
pixelSize, m_fontEngineData);
pixelSize,
m_fontEngineData);
fontEngine->fontDef = fontDef;
fontEngine->fontDef.pixelSize = pixelSize;