freetype/no-fc: Disambiguate fonts with different widths
When using the Freetype font database, we would ignore the typographical width of loaded fonts, which could make it impossible to select certain fonts in a family. [ChangeLog][Freetype] Fixed a bug where fonts of different width within the same family would be unselectable if the Freetype font database (no-fontconfig configuration) was in use. Pick-to: 5.15 6.2 Fixes: QTBUG-89640 Change-Id: Ic9c17a7c3cc14eb7e942b05d6b21b7c1602816cf Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
6f0d7eb92e
commit
e05e3c7762
@ -153,6 +153,7 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q
|
||||
}
|
||||
}
|
||||
|
||||
QFont::Stretch stretch = QFont::Unstretched;
|
||||
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
|
||||
if (os2) {
|
||||
quint32 unicodeRange[4] = {
|
||||
@ -191,6 +192,36 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q
|
||||
else if (w <= 10)
|
||||
weight = QFont::Black;
|
||||
}
|
||||
|
||||
switch (os2->usWidthClass) {
|
||||
case 1:
|
||||
stretch = QFont::UltraCondensed;
|
||||
break;
|
||||
case 2:
|
||||
stretch = QFont::ExtraCondensed;
|
||||
break;
|
||||
case 3:
|
||||
stretch = QFont::Condensed;
|
||||
break;
|
||||
case 4:
|
||||
stretch = QFont::SemiCondensed;
|
||||
break;
|
||||
case 5:
|
||||
stretch = QFont::Unstretched;
|
||||
break;
|
||||
case 6:
|
||||
stretch = QFont::SemiExpanded;
|
||||
break;
|
||||
case 7:
|
||||
stretch = QFont::Expanded;
|
||||
break;
|
||||
case 8:
|
||||
stretch = QFont::ExtraExpanded;
|
||||
break;
|
||||
case 9:
|
||||
stretch = QFont::UltraExpanded;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString family = QString::fromLatin1(face->family_name);
|
||||
@ -198,7 +229,6 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q
|
||||
fontFile->fileName = QFile::decodeName(file);
|
||||
fontFile->indexValue = index;
|
||||
|
||||
QFont::Stretch stretch = QFont::Unstretched;
|
||||
QString styleName = QString::fromLatin1(face->style_name);
|
||||
|
||||
if (applicationFont != nullptr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user