Fix design metrics for text on Windows

The trick to get design metrics on Windows is to request the
font with the design size, however we were passing the em square
size in as the cell height instead of the em square size (aka
character height in Windows docs). This would give us hinted metrics
and thus the design metrics would differ from other platforms.

[ChangeLog][Windows][Text] Fixed design metrics for text

Task-number: QTBUG-44501
Change-Id: I4cffc3b86359cfdaf2ece07e1259f6fa862132bc
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
bb10
Eskil Abrahamsen Blomfeldt 2015-03-04 13:03:20 +01:00
parent 3e6a14168b
commit ac3502345f
1 changed files with 3 additions and 3 deletions

View File

@ -194,10 +194,10 @@ void QWindowsFontEngine::getCMap()
_faceId.index = 0;
if(cmap) {
OUTLINETEXTMETRIC *otm = getOutlineTextMetric(hdc);
designToDevice = QFixed((int)otm->otmEMSquare)/int(otm->otmTextMetrics.tmHeight);
designToDevice = QFixed((int)otm->otmEMSquare)/QFixed::fromReal(fontDef.pixelSize);
unitsPerEm = otm->otmEMSquare;
x_height = (int)otm->otmsXHeight;
loadKerningPairs(designToDevice);
loadKerningPairs(QFixed((int)otm->otmEMSquare)/int(otm->otmTextMetrics.tmHeight));
_faceId.filename = QFile::encodeName(QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFullName)));
lineWidth = otm->otmsUnderscoreSize;
fsType = otm->otmfsType;
@ -361,7 +361,7 @@ glyph_t QWindowsFontEngine::glyphIndex(uint ucs4) const
HGDIOBJ QWindowsFontEngine::selectDesignFont() const
{
LOGFONT f = m_logfont;
f.lfHeight = unitsPerEm;
f.lfHeight = -unitsPerEm;
f.lfWidth = 0;
HFONT designFont = CreateFontIndirect(&f);
return SelectObject(m_fontEngineData->hdc, designFont);