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>
This commit is contained in:
parent
dbfd84ae4c
commit
e51d03e334
@ -473,6 +473,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{};
|
||||
|
@ -39,6 +39,7 @@ private slots:
|
||||
void typoLineMetrics();
|
||||
void defaultIgnorableHorizontalAdvance_data();
|
||||
void defaultIgnorableHorizontalAdvance();
|
||||
void hugeFontMetrics();
|
||||
};
|
||||
|
||||
void tst_QFontMetrics::same()
|
||||
@ -511,5 +512,21 @@ void tst_QFontMetrics::defaultIgnorableHorizontalAdvance()
|
||||
QCOMPARE_GT(withSupportWithIgnorablesAdvance, withSupportWithoutIgnorablesAdvance);
|
||||
}
|
||||
|
||||
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…
x
Reference in New Issue
Block a user