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();
|
oldSize = d_ptr->m_value.fontSize();
|
||||||
d_ptr->ui.sizeComboBox->clear();
|
d_ptr->ui.sizeComboBox->clear();
|
||||||
}
|
}
|
||||||
QFontDatabase db;
|
const QList<int> sizeLst = pointSizesForSelectedFont();
|
||||||
const QList<int> sizeLst = db.pointSizes(d_ptr->ui.familyComboBox->currentText());
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < sizeLst.count(); ++i) {
|
for (; i < sizeLst.count(); ++i) {
|
||||||
@@ -395,6 +394,23 @@ void FontSettingsPage::updatePointSizes()
|
|||||||
d_ptr->ui.sizeComboBox->setCurrentIndex(idx);
|
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)
|
void FontSettingsPage::fontSizeSelected(const QString &sizeString)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include "texteditoroptionspage.h"
|
#include "texteditoroptionspage.h"
|
||||||
|
|
||||||
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -117,6 +118,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void maybeSaveColorScheme();
|
void maybeSaveColorScheme();
|
||||||
void updatePointSizes();
|
void updatePointSizes();
|
||||||
|
QList<int> pointSizesForSelectedFont() const;
|
||||||
void refreshColorSchemeList();
|
void refreshColorSchemeList();
|
||||||
|
|
||||||
Internal::FontSettingsPagePrivate *d_ptr;
|
Internal::FontSettingsPagePrivate *d_ptr;
|
||||||
|
Reference in New Issue
Block a user