本文整理汇总了C++中QFontDatabase::writingSystems方法的典型用法代码示例。如果您正苦于以下问题:C++ QFontDatabase::writingSystems方法的具体用法?C++ QFontDatabase::writingSystems怎么用?C++ QFontDatabase::writingSystems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFontDatabase
的用法示例。
在下文中一共展示了QFontDatabase::writingSystems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fontChanged
void MainWindow::fontChanged()
{
QFont f = preview->font();
f.setStyleStrategy(QFont::NoFontMerging);
f.setPixelSize(pixelSize->value());
f.setFamily(fontComboBox->currentFont().family());
f.setItalic(italic->isChecked());
f.setWeight(weightCombo->itemData(weightCombo->currentIndex()).toInt());
if (!preview->isModified()) {
QFontDatabase db;
QFontDatabase::WritingSystem ws = db.writingSystems(f.family()).value(0, QFontDatabase::Any);
QString sample = db.writingSystemSample(ws);
preview->setText(sample);
preview->setModified(false);
}
fileName->setText(QPF::fileNameForFont(f));
preview->setFont(f);
}
示例2: exactMatch
void tst_QFont::exactMatch()
{
QFont font;
// Check if a non-existing font hasn't an exact match
font = QFont( "BogusFont", 33 );
QVERIFY( !font.exactMatch() );
#ifdef Q_OS_WIN
QSKIP("Exact matching on windows misses a lot because of the sample chars");
#endif
if (QGuiApplication::platformName() == QLatin1String("xcb")) {
QVERIFY(QFont("sans").exactMatch());
QVERIFY(QFont("sans-serif").exactMatch());
QVERIFY(QFont("serif").exactMatch());
QVERIFY(QFont("monospace").exactMatch());
}
QSKIP("This test is bogus on Unix with support for font aliases in fontconfig");
QFontDatabase fdb;
QList<QFontDatabase::WritingSystem> systems = fdb.writingSystems();
for (int system = 0; system < systems.count(); ++system) {
QStringList families = fdb.families(systems[system]);
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;
if (family.contains('['))
continue;
QStringList styles = fdb.styles(family);
QVERIFY(!styles.isEmpty());
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);
QFontInfo fontinfo(font);
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;
}
#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() );
}
}
//.........这里部分代码省略.........