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:
parent
96cc7fe5c2
commit
a2ef3479b8
@ -1239,11 +1239,13 @@ QT_WARNING_POP
|
|||||||
|
|
||||||
fontFile->Release();
|
fontFile->Release();
|
||||||
|
|
||||||
fontEngine = new QWindowsFontEngineDirectWrite(directWriteFontFace, pixelSize,
|
fontEngine = new QWindowsFontEngineDirectWrite(directWriteFontFace,
|
||||||
|
pixelSize,
|
||||||
fontEngineData);
|
fontEngineData);
|
||||||
|
|
||||||
// Get font family from font data
|
// Get font family from font data
|
||||||
fontEngine->fontDef.family = font.familyName();
|
fontEngine->fontDef.family = font.familyName();
|
||||||
|
fontEngine->fontDef.hintingPreference = hintingPreference;
|
||||||
|
|
||||||
directWriteFontFace->Release();
|
directWriteFontFace->Release();
|
||||||
}
|
}
|
||||||
|
@ -1362,6 +1362,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
|
|||||||
if (fontEngine->fontDef.style > QFont::StyleNormal)
|
if (fontEngine->fontDef.style > QFont::StyleNormal)
|
||||||
fedw->fontDef.style = fontEngine->fontDef.style;
|
fedw->fontDef.style = fontEngine->fontDef.style;
|
||||||
fedw->fontDef.family = fam;
|
fedw->fontDef.family = fam;
|
||||||
|
fedw->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
|
||||||
return fedw;
|
return fedw;
|
||||||
} else {
|
} else {
|
||||||
qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__);
|
qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__);
|
||||||
@ -1379,6 +1380,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
|
|||||||
if (fontEngine->fontDef.style > QFont::StyleNormal)
|
if (fontEngine->fontDef.style > QFont::StyleNormal)
|
||||||
fe->fontDef.style = fontEngine->fontDef.style;
|
fe->fontDef.style = fontEngine->fontDef.style;
|
||||||
fe->fontDef.family = fam;
|
fe->fontDef.family = fam;
|
||||||
|
fe->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
|
||||||
return fe;
|
return fe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,8 +196,8 @@ namespace {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite(IDWriteFontFace *directWriteFontFace,
|
QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite(IDWriteFontFace *directWriteFontFace,
|
||||||
qreal pixelSize,
|
qreal pixelSize,
|
||||||
const QSharedPointer<QWindowsFontEngineData> &d)
|
const QSharedPointer<QWindowsFontEngineData> &d)
|
||||||
: QFontEngine(DirectWrite)
|
: QFontEngine(DirectWrite)
|
||||||
, m_fontEngineData(d)
|
, m_fontEngineData(d)
|
||||||
, m_directWriteFontFace(directWriteFontFace)
|
, m_directWriteFontFace(directWriteFontFace)
|
||||||
@ -547,12 +547,17 @@ QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t,
|
|||||||
transform.m21 = xform.m21();
|
transform.m21 = xform.m21();
|
||||||
transform.m22 = xform.m22();
|
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;
|
IDWriteGlyphRunAnalysis *glyphAnalysis = NULL;
|
||||||
HRESULT hr = m_fontEngineData->directWriteFactory->CreateGlyphRunAnalysis(
|
HRESULT hr = m_fontEngineData->directWriteFactory->CreateGlyphRunAnalysis(
|
||||||
&glyphRun,
|
&glyphRun,
|
||||||
1.0f,
|
1.0f,
|
||||||
&transform,
|
&transform,
|
||||||
DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC,
|
renderMode,
|
||||||
DWRITE_MEASURING_MODE_NATURAL,
|
DWRITE_MEASURING_MODE_NATURAL,
|
||||||
0.0, 0.0,
|
0.0, 0.0,
|
||||||
&glyphAnalysis
|
&glyphAnalysis
|
||||||
@ -626,7 +631,8 @@ QImage QWindowsFontEngineDirectWrite::alphaRGBMapForGlyph(glyph_t t,
|
|||||||
QFontEngine *QWindowsFontEngineDirectWrite::cloneWithSize(qreal pixelSize) const
|
QFontEngine *QWindowsFontEngineDirectWrite::cloneWithSize(qreal pixelSize) const
|
||||||
{
|
{
|
||||||
QFontEngine *fontEngine = new QWindowsFontEngineDirectWrite(m_directWriteFontFace,
|
QFontEngine *fontEngine = new QWindowsFontEngineDirectWrite(m_directWriteFontFace,
|
||||||
pixelSize, m_fontEngineData);
|
pixelSize,
|
||||||
|
m_fontEngineData);
|
||||||
|
|
||||||
fontEngine->fontDef = fontDef;
|
fontEngine->fontDef = fontDef;
|
||||||
fontEngine->fontDef.pixelSize = pixelSize;
|
fontEngine->fontDef.pixelSize = pixelSize;
|
||||||
|
Loading…
Reference in New Issue
Block a user