windows: Fix vertical metrics with GDI engine

In Qt 6 we consolidated vertical font metrics across all
platforms (see f761ad3cd9
and follow-ups). However, a couple mistakes were made.

First of all, when we use the winAscent/winDescent values
from the OS/2 table, we would also set the leading to the
line gap value from the HHEA table. However, the line gap
is actually built into the winAscent/winDescent, so we
ended up adding this twice to the line spacing, increasing
it with some older fonts. When using the Windows legacy
metrics, we now set the line gap to 0 instead to reflect
that this is baked into the height.

In addition, since we now calculate the values ourselves,
we would not round them to nearest integer like the GDI
engine does. We now round these values to make it clear that
the GDI engine does not support any fractional metrics.

[ChangeLog][Windows][Text] Fixed an issue where the line
gap of some fonts would be included twice in the font's
leading.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-109400
Change-Id: I02ab7447b5e82d9f4474f9bca581f82acee85ff3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2022-12-14 10:03:32 +01:00
parent bdee7becf6
commit 8892819d0c

View File

@ -416,6 +416,12 @@ void QFontEngine::initializeHeightMetrics() const
// Allow OS/2 metrics to override if present // Allow OS/2 metrics to override if present
processOS2Table(); processOS2Table();
if (!supportsSubPixelPositions()) {
m_ascent = m_ascent.round();
m_descent = m_descent.round();
m_leading = m_leading.round();
}
} }
m_heightMetricsQueried = true; m_heightMetricsQueried = true;
@ -448,6 +454,7 @@ bool QFontEngine::processOS2Table() const
return false; return false;
m_ascent = QFixed::fromReal(winAscent * fontDef.pixelSize) / unitsPerEm; m_ascent = QFixed::fromReal(winAscent * fontDef.pixelSize) / unitsPerEm;
m_descent = QFixed::fromReal(winDescent * fontDef.pixelSize) / unitsPerEm; m_descent = QFixed::fromReal(winDescent * fontDef.pixelSize) / unitsPerEm;
m_leading = QFixed{};
} }
return true; return true;