本文整理汇总了C++中QFontDatabase::pointSizes方法的典型用法代码示例。如果您正苦于以下问题:C++ QFontDatabase::pointSizes方法的具体用法?C++ QFontDatabase::pointSizes怎么用?C++ QFontDatabase::pointSizes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFontDatabase
的用法示例。
在下文中一共展示了QFontDatabase::pointSizes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
QList<int> FontSettingsPage::pointSizesForSelectedFont() const
{
QFontDatabase db;
const QString familyName = d_ptr->m_ui->fontComboBox->currentFont().family();
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;
}
示例2: loadFontSizeComboBox
// Load the list of font sizes
void EditorButtonBar::loadFontSizeComboBox(QString name) {
QFontDatabase fdb;
fontSizes->clear();
QList<int> sizes = fdb.pointSizes(name);
for (int i=0; i<sizes.size(); i++) {
fontSizes->addItem(QString::number(sizes[i]), sizes[i]);
}
}
示例3: updateFontSize
void OptionsDialog::updateFontSize(const QString& fontFamily)
{
QFontDatabase database;
QString oldFontSize = fontSizeBox->currentText();
QList<int> sizes = database.pointSizes( fontFamily, "" );
fontSizeBox->clear();
foreach (int size, sizes) {
fontSizeBox->addItem( QString::number(size) );
}
示例4:
FNTextDialog::FNTextDialog(const QString& fontname, FNColorDialog* dlg, QWidget* parent, const char* name )
:FNTextDialogBase(parent, name, true, 0), _pen(1), _colorSelector(dlg)
{
static QFontDatabase fbase;
QValueList<int> sizes = fbase.pointSizes(fontname);
char buf[10];
for (uint i = 0; i < sizes.count(); ++i) {
sprintf(buf, "%d", sizes[i]);
cboFontSize->insertItem(buf);
}
lines->setFont(QFont(fontname, 20));
}
示例5: __updateFontSize
void PreferenceDialog::__updateFontSize(const QFont& font)
{
QFontDatabase fontdatabase;
QList<int> sizeList = fontdatabase.smoothSizes(font.family(), "");
if (sizeList.empty()) sizeList = fontdatabase.pointSizes(font.family(), "");
if (sizeList.empty()) sizeList = fontdatabase.standardSizes();
if (!sizeList.contains(font.pointSize())) sizeList.append(font.pointSize());
fontSize->clear();
for (int size : sizeList) fontSize->addItem(QString::number(size), size);
fontSize->setCurrentIndex(sizeList.indexOf(fontFamilly->currentFont().pointSize()));
}
示例6: fontPixelSize
void
CQIllustratorCreateTextToolbar::
updateFontWidgets()
{
int nind = fontCombo_->findText(qfont_.family());
if (nind >= 0 && nind != font_ind_) {
font_ind_ = nind;
fontCombo_->setCurrentIndex(nind);
QFontDatabase database;
const QString &family = fontCombo_->itemText(fontCombo_->currentIndex());
QList<int> sizes = database.pointSizes(family);
sizeCombo_->clear();
int font_size = fontPixelSize(qfont_);
int size1 = -1, size2 = -1;
for (int i = 0; i < sizes.size(); ++i) {
size1 = size2;
size2 = sizes[i];
if (font_size > size1 && font_size < size2)
sizeCombo_->addItem(QString("%1").arg(font_size));
sizeCombo_->addItem(QString("%1").arg(size2));
}
if (font_size > size2)
sizeCombo_->addItem(QString("%1").arg(font_size));
}
int font_size = fontPixelSize(qfont_);
if (font_size != font_size_) {
int ind = sizeCombo_->findText(QString("%1").arg(font_size));
if (ind >= 0 && ind != sizeCombo_->currentIndex()) {
sizeCombo_->setCurrentIndex(ind);
font_size_ = font_size;
}
}
boldButton_ ->setChecked(qfont_.bold());
italicButton_->setChecked(qfont_.italic());
}
示例7: metrics
void tst_QFontMetrics::metrics()
{
QFont font;
QFontDatabase fdb;
// Query the QFontDatabase for a specific font, store the
// result in family, style and size.
QStringList families = fdb.families();
if (families.isEmpty())
return;
QStringList::ConstIterator f_it, f_end = families.end();
for (f_it = families.begin(); f_it != f_end; ++f_it) {
const QString &family = *f_it;
QStringList styles = fdb.styles(family);
QStringList::ConstIterator s_it, s_end = styles.end();
for (s_it = styles.begin(); s_it != s_end; ++s_it) {
const QString &style = *s_it;
if (fdb.isSmoothlyScalable(family, style)) {
// smoothly scalable font... don't need to load every pointsize
font = fdb.font(family, style, 12);
QFontMetrics fontmetrics(font);
QCOMPARE(fontmetrics.ascent() + fontmetrics.descent(),
fontmetrics.height());
QCOMPARE(fontmetrics.height() + fontmetrics.leading(),
fontmetrics.lineSpacing());
} else {
QList<int> sizes = fdb.pointSizes(family, style);
QVERIFY(!sizes.isEmpty());
QList<int>::ConstIterator z_it, z_end = sizes.end();
for (z_it = sizes.begin(); z_it != z_end; ++z_it) {
const int size = *z_it;
// Initialize the font, and check if it is an exact match
font = fdb.font(family, style, size);
QFontMetrics fontmetrics(font);
QCOMPARE(fontmetrics.ascent() + fontmetrics.descent(),
fontmetrics.height());
QCOMPARE(fontmetrics.height() + fontmetrics.leading(),
fontmetrics.lineSpacing());
}
}
}
}
}
示例8: loadFontSizes
// Load the list of font sizes
void AppearancePreferences::loadFontSizes(QString name) {
webSettingsChanged =true;
QFontDatabase fdb;
defaultFontSizeChooser->clear();
defaultFontSizeChooser->addItem(tr("System Default"), 0);
QList<int> sizes = fdb.pointSizes(name);
for (int i=0; i<sizes.size(); i++) {
defaultFontSizeChooser->addItem(QString::number(sizes[i]), sizes[i]);
}
int idx = defaultFontSizeChooser->findData(global.defaultFontSize, Qt::UserRole);
if (idx >=0) {
defaultFontSizeChooser->setCurrentIndex(idx);
} else
defaultFontSizeChooser->setCurrentIndex(0);
}
示例9:
void
CQFontChooser::
updateSizes()
{
QFontDatabase database;
const QString &family = ncombo_->itemText(ncombo_->currentIndex());
QList<int> sizes = database.pointSizes(family);
zcombo_->clear();
for (int i = 0; i < sizes.size(); ++i)
zcombo_->addItem(QString("%1").arg(sizes[i]));
}
示例10: loadFontInfo
void DFontChooser::loadFontInfo(const QString &family)
{
QString currentSize = m_fontSize->currentText();
QString currentStyle = m_fontStyle->currentText();
QFontDatabase fdb;
m_fontStyle->clear();
m_fontStyle->addItems(fdb.styles(family));
m_fontSize->clear();
QList<int> points = fdb.pointSizes(family);
foreach(int point, points)
{
m_fontSize->addItem(QString::number(point));
}
示例11: updateFontPointSize
void MainWindow::updateFontPointSize( const QString & strFamily, const QString & strStyleName )
{
QFontDatabase fdb;
QList<int> lsPointSize = fdb.pointSizes( strFamily, strStyleName );
QString strOriginSelected = m_pCmbFontPointSize->currentText();
m_pCmbFontPointSize->blockSignals( true );
m_pCmbFontPointSize->clear();
int iSizeCnt = lsPointSize.count();
for ( int iSizeIndex = 0; iSizeIndex < iSizeCnt; iSizeIndex++ ) {
m_pCmbFontPointSize->addItem( QString::number( lsPointSize.at( iSizeIndex ) ) );
}
m_pCmbFontPointSize->setCurrentIndex( -1 );
m_pCmbFontPointSize->blockSignals( false );
if ( iSizeCnt > 0 ) {
int iCurSelectedIndex = m_pCmbFontPointSize->findText( strOriginSelected );
m_pCmbFontPointSize->setCurrentIndex( iCurSelectedIndex != -1 ? iCurSelectedIndex : 0 );
}
}
示例12: fontChanged
void QQGeneralSettings::fontChanged(const QFont &font)
{
QFontDatabase fDB;
QList<int> listSizes = fDB.pointSizes(font.family());
int fontSize = m_defaultFont.pointSize();
if(! listSizes.contains(fontSize))
fontSize = font.pointSize();
QString fontSizeStr = QString::number(fontSize);
ui->fontSizeComboB->clear();
for(int i = 0; i < listSizes.size(); i++)
ui->fontSizeComboB->addItem(QString::number(listSizes.at(i)));
int index = ui->fontSizeComboB->findText(fontSizeStr);
if(index >= 0)
ui->fontSizeComboB->setCurrentIndex(index);
m_defaultFont = font;
m_defaultFont.setPointSize(fontSize);
}
示例13: exactMatch
//.........这里部分代码省略.........
#ifdef Q_OS_WIN
if (font.family().startsWith("MS ") || fontinfo.family().startsWith("MS ")) {
/* qDebug("Family matching skipped for MS-Alias font: %s, fontinfo: %s",
font.family().latin1(), fontinfo.family().latin1());
*/
} else
#endif
{
if (!(font.family() == fontinfo.family()
|| fontinfo.family().contains(font.family())
|| fontinfo.family().isEmpty())) {
qDebug("Test about to fail for font: %s, fontinfo: %s",
font.family().toLatin1().constData(),
fontinfo.family().toLatin1().constData());
}
QVERIFY(font.family() == fontinfo.family()
|| fontinfo.family().contains(font.family())
|| fontinfo.family().isEmpty());
}
if (font.pointSize() != -1) {
QVERIFY(font.pointSize() == fontinfo.pointSize());
} else {
QVERIFY(font.pixelSize() == fontinfo.pixelSize());
}
QVERIFY(font.italic() == fontinfo.italic());
if (font.weight() != fontinfo.weight()) {
qDebug("font is %s", font.toString().toLatin1().constData());
}
QVERIFY(font.weight() == fontinfo.weight());
} else {
font.setFixedPitch(!fontinfo.fixedPitch());
QFontInfo fontinfo1(font);
QVERIFY( !fontinfo1.exactMatch() );
font.setFixedPitch(fontinfo.fixedPitch());
QFontInfo fontinfo2(font);
QVERIFY( fontinfo2.exactMatch() );
}
}
#if 0
// ############## can only work if we have float point sizes in QFD
else {
QList<int> sizes = fdb.pointSizes(family, style);
QVERIFY(!sizes.isEmpty());
QList<int>::ConstIterator z_it, z_end = sizes.end();
for (z_it = sizes.begin(); z_it != z_end; ++z_it) {
const int size = *z_it;
// Initialize the font, and check if it is an exact match
font = fdb.font(family, style, size);
QFontInfo fontinfo(font, (QFont::Script) script);
if (! fontinfo.exactMatch()) {
// Unfortunately, this can fail, since
// QFontDatabase does not fill in all font
// properties. Check to make sure that the
// test didn't fail for obvious reasons
if (fontinfo.family().isEmpty()
&& fontinfo.pointSize() == 0) {
// this is a box rendering engine... this can happen from
// time to time, especially on X11 with iso10646-1 or
// unknown font encodings
continue;
}
// no need to skip MS-fonts here it seems
if (!(font.family() == fontinfo.family()
|| fontinfo.family().contains(font.family())
|| fontinfo.family().isEmpty())) {
qDebug("Test about to fail for font: %s, fontinfo: %s",
font.family().latin1(), fontinfo.family().latin1());
}
QVERIFY(font.family() == fontinfo.family()
|| fontinfo.family().contains(font.family())
|| fontinfo.family().isEmpty());
if (font.pointSize() != -1) {
QVERIFY(font.pointSize() == fontinfo.pointSize());
} else {
QVERIFY(font.pixelSize() == fontinfo.pixelSize());
}
QVERIFY(font.italic() == fontinfo.italic());
QVERIFY(font.weight() == fontinfo.weight());
} else {
font.setFixedPitch(!fontinfo.fixedPitch());
QFontInfo fontinfo1(font, (QFont::Script) script);
QVERIFY( !fontinfo1.exactMatch() );
font.setFixedPitch(fontinfo.fixedPitch());
QFontInfo fontinfo2(font, (QFont::Script) script);
QVERIFY( fontinfo2.exactMatch() );
}
}
}
#endif
}
}
}
}