本文整理汇总了C++中QFontDatabase::isFixedPitch方法的典型用法代码示例。如果您正苦于以下问题:C++ QFontDatabase::isFixedPitch方法的具体用法?C++ QFontDatabase::isFixedPitch怎么用?C++ QFontDatabase::isFixedPitch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFontDatabase
的用法示例。
在下文中一共展示了QFontDatabase::isFixedPitch方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _k_fontList
QStringList _k_fontList(const QFontComboBox::FontFilters &fontFilters = QFontComboBox::AllFonts)
{
QFontDatabase dbase;
QStringList families;
if (fontFilters == QFontComboBox::AllFonts) {
families = dbase.families();
} else {
const QFontComboBox::FontFilters scalableMask = (QFontComboBox::ScalableFonts | QFontComboBox::NonScalableFonts);
const QFontComboBox::FontFilters spacingMask = (QFontComboBox::ProportionalFonts | QFontComboBox::MonospacedFonts);
foreach (const QString &family, dbase.families()) {
if ((fontFilters & scalableMask) && (fontFilters & scalableMask) != scalableMask) {
if (bool(fontFilters & QFontComboBox::ScalableFonts) != dbase.isSmoothlyScalable(family))
continue;
}
if ((fontFilters & spacingMask) && (fontFilters & spacingMask) != spacingMask) {
if (bool(fontFilters & QFontComboBox::MonospacedFonts) != dbase.isFixedPitch(family))
continue;
}
families << family;
}
}
families.sort();
return families;
}
示例2: setupFontList
// Populates the 'family' ComboBox
void OptionsDialog::setupFontList()
{
QFontDatabase database;
// We only show the fixed fonts
foreach ( const QString &str, database.families() ) {
if ( database.isFixedPitch( str ) )
fontFamilyBox->addItem( str );
}
}
示例3: _q_updateModel
void QFontComboBoxPrivate::_q_updateModel()
{
Q_Q(QFontComboBox);
const int scalableMask = (QFontComboBox::ScalableFonts | QFontComboBox::NonScalableFonts);
const int spacingMask = (QFontComboBox::ProportionalFonts | QFontComboBox::MonospacedFonts);
QStringListModel *m = qobject_cast<QStringListModel *>(q->model());
if (!m)
return;
QFontFamilyDelegate *delegate = qobject_cast<QFontFamilyDelegate *>(q->view()->itemDelegate());
QFontDatabase::WritingSystem system = delegate ? delegate->writingSystem : QFontDatabase::Any;
QFontDatabase fdb;
QStringList list = fdb.families(system);
QStringList result;
int offset = 0;
QFontInfo fi(currentFont);
for (int i = 0; i < list.size(); ++i) {
if (fdb.isPrivateFamily(list.at(i)))
continue;
if ((filters & scalableMask) && (filters & scalableMask) != scalableMask) {
if (bool(filters & QFontComboBox::ScalableFonts) != fdb.isSmoothlyScalable(list.at(i)))
continue;
}
if ((filters & spacingMask) && (filters & spacingMask) != spacingMask) {
if (bool(filters & QFontComboBox::MonospacedFonts) != fdb.isFixedPitch(list.at(i)))
continue;
}
result += list.at(i);
if (list.at(i) == fi.family() || list.at(i).startsWith(fi.family() + QLatin1String(" [")))
offset = result.count() - 1;
}
list = result;
//we need to block the signals so that the model doesn't emit reset
//this prevents the current index from changing
//it will be updated just after this
///TODO: we should finda way to avoid blocking signals and have a real update of the model
{
const QSignalBlocker blocker(m);
m->setStringList(list);
}
if (list.isEmpty()) {
if (currentFont != QFont()) {
currentFont = QFont();
emit q->currentFontChanged(currentFont);
}
} else {
q->setCurrentIndex(offset);
}
}
示例4: fixedPitch
void tst_QFontDatabase::fixedPitch()
{
QFETCH(QString, font);
QFETCH(bool, fixedPitch);
QFontDatabase fdb;
if (!fdb.families().contains(font))
QSKIP( "Font not installed");
QCOMPARE(fdb.isFixedPitch(font), fixedPitch);
QFont qfont(font);
QFontInfo fi(qfont);
QCOMPARE(fi.fixedPitch(), fixedPitch);
}
示例5: createFontList
void fileviewer::createFontList(void)
{
QFontDatabase fontdb;
QStringList fontlst = fontdb.families(QFontDatabase::Latin);
QStringList fixedpitch;
QStringList::iterator it;
for(it = fontlst.begin(); it != fontlst.end(); it++)
{
if (fontdb.isFixedPitch(*it))
{
fixedpitch << (*it);
}
}
fixedpitch.sort();
m_fontlist = fixedpitch;
}
示例6: fixedPitch
void tst_QFontDatabase::fixedPitch()
{
#ifdef Q_WS_QWS
QSKIP("fixedPitch not implemented for Qtopia Core", SkipAll);
#endif
QFETCH(QString, font);
QFETCH(bool, fixedPitch);
QFontDatabase fdb;
if (!fdb.families().contains(font))
QSKIP( "Font not installed", SkipSingle);
QCOMPARE(fdb.isFixedPitch(font), fixedPitch);
QFont qfont(font);
QFontInfo fi(qfont);
QCOMPARE(fi.fixedPitch(), fixedPitch);
}
示例7: _q_updateModel
void QFontComboBoxPrivate::_q_updateModel()
{
Q_Q(QFontComboBox);
const int scalableMask = (QFontComboBox::ScalableFonts | QFontComboBox::NonScalableFonts);
const int spacingMask = (QFontComboBox::ProportionalFonts | QFontComboBox::MonospacedFonts);
QStringListModel *m = qobject_cast<QStringListModel *>(q->model());
if (!m)
return;
QFontFamilyDelegate *delegate = qobject_cast<QFontFamilyDelegate *>(q->view()->itemDelegate());
QFontDatabase::WritingSystem system = delegate ? delegate->writingSystem : QFontDatabase::Any;
QFontDatabase fdb;
QStringList list = fdb.families(system);
QStringList result;
int offset = 0;
QFontInfo fi(currentFont);
for (int i = 0; i < list.size(); ++i) {
if ((filters & scalableMask) && (filters & scalableMask) != scalableMask) {
if (bool(filters & QFontComboBox::ScalableFonts) != fdb.isSmoothlyScalable(list.at(i)))
continue;
}
if ((filters & spacingMask) && (filters & spacingMask) != spacingMask) {
if (bool(filters & QFontComboBox::MonospacedFonts) != fdb.isFixedPitch(list.at(i)))
continue;
}
result += list.at(i);
if (list.at(i) == fi.family() || list.at(i).startsWith(fi.family() + QLatin1String(" [")))
offset = result.count() - 1;
}
list = result;
m->setStringList(list);
if (list.isEmpty()) {
if (currentFont != QFont()) {
currentFont = QFont();
emit q->currentFontChanged(currentFont);
}
} else {
q->setCurrentIndex(offset);
}
}
示例8: updateFamilies
void QFontDialogPrivate::updateFamilies()
{
Q_Q(QFontDialog);
enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 };
const QFontDialog::FontDialogOptions scalableMask = (QFontDialog::ScalableFonts | QFontDialog::NonScalableFonts);
const QFontDialog::FontDialogOptions spacingMask = (QFontDialog::ProportionalFonts | QFontDialog::MonospacedFonts);
const QFontDialog::FontDialogOptions options = q->options();
QFontDatabase fdb;
QStringList familyNames;
foreach (const QString &family, fdb.families(writingSystem)) {
if (fdb.isPrivateFamily(family))
continue;
if ((options & scalableMask) && (options & scalableMask) != scalableMask) {
if (bool(options & QFontDialog::ScalableFonts) != fdb.isSmoothlyScalable(family))
continue;
}
if ((options & spacingMask) && (options & spacingMask) != spacingMask) {
if (bool(options & QFontDialog::MonospacedFonts) != fdb.isFixedPitch(family))
continue;
}
familyNames << family;
}
familyList->model()->setStringList(familyNames);
QString foundryName1, familyName1, foundryName2, familyName2;
int bestFamilyMatch = -1;
match_t bestFamilyType = MATCH_NONE;
QFont f;
// ##### do the right thing for a list of family names in the font.
QFontDatabase::parseFontName(family, foundryName1, familyName1);
QStringList::const_iterator it = familyNames.constBegin();
int i = 0;
for(; it != familyNames.constEnd(); ++it, ++i) {
QFontDatabase::parseFontName(*it, foundryName2, familyName2);
//try to match...
if (familyName1 == familyName2) {
bestFamilyType = MATCH_FAMILY;
if (foundryName1 == foundryName2) {
bestFamilyMatch = i;
break;
}
if (bestFamilyMatch < MATCH_FAMILY)
bestFamilyMatch = i;
}
//and try some fall backs
match_t type = MATCH_NONE;
if (bestFamilyType <= MATCH_NONE && familyName2 == f.lastResortFamily())
type = MATCH_LAST_RESORT;
if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.family())
type = MATCH_APP;
// ### add fallback for writingSystem
if (type != MATCH_NONE) {
bestFamilyType = type;
bestFamilyMatch = i;
}
}
if (i != -1 && bestFamilyType != MATCH_NONE)
familyList->setCurrentItem(bestFamilyMatch);
else
familyList->setCurrentItem(0);
familyEdit->setText(familyList->currentText());
if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
&& familyList->hasFocus())
familyEdit->selectAll();
updateStyles();
}