Escape calculating vertical windows-metrics if they're too big
This amends 073fae097ce40bee1532c252a8c696840b5dfc16 which added an escape before calculating the vertical metrics if they were too big and would overflow. It missed one spot, which was when using the winAscent/winDescent instead of the typo-metrics. Change-Id: Ib6a7705f6676c66bfd04b37efa30fe2d1b99581c Reviewed-by: Robert Löhning <robert.loehning@qt.io> (cherry picked from commit f846754663aae1652e4eec9a441ee222af352319) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit e51d03e334b18cd34fbfb708b9835327658f2075)bb10
parent
86fa37fc3b
commit
ca8ee54544
|
|
@ -469,6 +469,9 @@ bool QFontEngine::processOS2Table() const
|
|||
// Some fonts may have invalid OS/2 data. We detect this and bail out.
|
||||
if (winAscent == 0 && winDescent == 0)
|
||||
return false;
|
||||
const auto limitForQFixed = std::numeric_limits<int>::max() / (fontDef.pixelSize * 64);
|
||||
if (winAscent > limitForQFixed || winDescent > limitForQFixed)
|
||||
return false;
|
||||
m_ascent = QFixed::fromReal(winAscent * fontDef.pixelSize) / unitsPerEm;
|
||||
m_descent = QFixed::fromReal(winDescent * fontDef.pixelSize) / unitsPerEm;
|
||||
m_leading = QFixed{};
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ private slots:
|
|||
void largeText_data();
|
||||
void largeText(); // QTBUG-123339
|
||||
void typoLineMetrics();
|
||||
void hugeFontMetrics();
|
||||
};
|
||||
|
||||
void tst_QFontMetrics::same()
|
||||
|
|
@ -454,5 +455,21 @@ void tst_QFontMetrics::typoLineMetrics()
|
|||
}
|
||||
}
|
||||
|
||||
void tst_QFontMetrics::hugeFontMetrics()
|
||||
{
|
||||
QFont bigFont;
|
||||
bigFont.setPixelSize(10000);
|
||||
|
||||
QFont hugeFont;
|
||||
hugeFont.setPixelSize(32000);
|
||||
|
||||
QFont hugeFontWithTypoLineMetrics;
|
||||
hugeFontWithTypoLineMetrics.setStyleStrategy(QFont::PreferTypoLineMetrics);
|
||||
hugeFontWithTypoLineMetrics.setPixelSize(30000);
|
||||
|
||||
QVERIFY(QFontMetricsF(bigFont).height() < QFontMetricsF(hugeFont).height());
|
||||
QVERIFY(QFontMetricsF(bigFont).height() < QFontMetricsF(hugeFontWithTypoLineMetrics).height());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QFontMetrics)
|
||||
#include "tst_qfontmetrics.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue