forked from qt-creator/qt-creator
Added logic to handle fonts where QtFontDatabase returns an empty list of point-sizes.
The added logic is that if the font has more than one style, to ask for the point-sizes of the first style. If that's also empty, return the list of standard point-sizes. Task-number: QTCREATORBUG-1153
This commit is contained in:
@@ -382,8 +382,7 @@ void FontSettingsPage::updatePointSizes()
|
||||
oldSize = d_ptr->m_value.fontSize();
|
||||
d_ptr->ui.sizeComboBox->clear();
|
||||
}
|
||||
QFontDatabase db;
|
||||
const QList<int> sizeLst = db.pointSizes(d_ptr->ui.familyComboBox->currentText());
|
||||
const QList<int> sizeLst = pointSizesForSelectedFont();
|
||||
int idx = 0;
|
||||
int i = 0;
|
||||
for (; i < sizeLst.count(); ++i) {
|
||||
@@ -395,6 +394,23 @@ void FontSettingsPage::updatePointSizes()
|
||||
d_ptr->ui.sizeComboBox->setCurrentIndex(idx);
|
||||
}
|
||||
|
||||
QList<int> FontSettingsPage::pointSizesForSelectedFont() const
|
||||
{
|
||||
QFontDatabase db;
|
||||
const QString familyName = d_ptr->ui.familyComboBox->currentText();
|
||||
QList<int> sizeLst = db.pointSizes(familyName);
|
||||
if (!sizeLst.isEmpty())
|
||||
return sizeLst;
|
||||
|
||||
QStringList styles = db.styles(familyName);
|
||||
if (!styles.isEmpty())
|
||||
sizeLst = db.pointSizes(familyName, styles.first());
|
||||
if (sizeLst.isEmpty())
|
||||
sizeLst = QFontDatabase::standardSizes();
|
||||
|
||||
return sizeLst;
|
||||
}
|
||||
|
||||
void FontSettingsPage::fontSizeSelected(const QString &sizeString)
|
||||
{
|
||||
bool ok = true;
|
||||
|
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "texteditoroptionspage.h"
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QString>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -117,6 +118,7 @@ private slots:
|
||||
private:
|
||||
void maybeSaveColorScheme();
|
||||
void updatePointSizes();
|
||||
QList<int> pointSizesForSelectedFont() const;
|
||||
void refreshColorSchemeList();
|
||||
|
||||
Internal::FontSettingsPagePrivate *d_ptr;
|
||||
|
Reference in New Issue
Block a user