Respect font stretch if set together with font style
Fixes: QTBUG-77854 Change-Id: I2bf9cea9d5ecd151a9d96bbe93e9477a9159ca1f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>bb10
parent
c89c145616
commit
ae10084ef9
|
|
@ -783,7 +783,7 @@ QFontEngine *loadSingleEngine(int script,
|
|||
if (style->key.stretch != 0 && request.stretch != 0
|
||||
&& (request.styleName.isEmpty() || request.styleName != style->styleName)) {
|
||||
def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
|
||||
} else {
|
||||
} else if (request.stretch == QFont::AnyStretch) {
|
||||
def.stretch = 100;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ private slots:
|
|||
void registerOpenTypePreferredNamesSystem();
|
||||
void registerOpenTypePreferredNamesApplication();
|
||||
|
||||
void stretchRespected();
|
||||
|
||||
private:
|
||||
QString m_ledFont;
|
||||
QString m_testFont;
|
||||
|
|
@ -349,6 +351,28 @@ static QString testString()
|
|||
return QStringLiteral("foo bar");
|
||||
}
|
||||
|
||||
void tst_QFontDatabase::stretchRespected()
|
||||
{
|
||||
int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
|
||||
QVERIFY(italicId != -1);
|
||||
|
||||
QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
|
||||
|
||||
QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
|
||||
|
||||
QFont italicFont = QFontDatabase::font(italicFontName,
|
||||
QString::fromLatin1("Italic"), 14);
|
||||
QVERIFY(italicFont.italic());
|
||||
|
||||
QFont italicStretchedFont = italicFont;
|
||||
italicStretchedFont.setStretch( 400 );
|
||||
|
||||
QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
|
||||
QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
|
||||
|
||||
QFontDatabase::removeApplicationFont(italicId);
|
||||
}
|
||||
|
||||
void tst_QFontDatabase::condensedFontWidthNoFontMerging()
|
||||
{
|
||||
int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
|
||||
|
|
|
|||
Loading…
Reference in New Issue