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
parent
3e6a14168b
commit
ac3502345f
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue