Use predefined monospace fonts on macOS.
This commit is contained in:
parent
74889b8c21
commit
3090ba7721
1 changed files with 12 additions and 21 deletions
|
|
@ -87,29 +87,20 @@ bool LoadCustomFont(const QString &filePath, const QString &familyName, int flag
|
|||
|
||||
QString MonospaceFont() {
|
||||
static const auto family = [&]() -> QString {
|
||||
#ifdef Q_OS_WIN
|
||||
const auto tryFont = [&](const QString &attempt) {
|
||||
return !QFontInfo(QFont(attempt)).family().trimmed().compare(
|
||||
attempt,
|
||||
Qt::CaseInsensitive);
|
||||
#ifndef Q_OS_LINUX
|
||||
const auto kTryFirst = std::initializer_list<QString>{
|
||||
"Consolas",
|
||||
"Liberation Mono",
|
||||
"Menlo",
|
||||
"Courier"
|
||||
};
|
||||
|
||||
if (tryFont("Consolas")) {
|
||||
return "Consolas";
|
||||
for (const auto &family : kTryFirst) {
|
||||
const auto resolved = QFontInfo(QFont(family)).family();
|
||||
if (!resolved.trimmed().compare(family, Qt::CaseInsensitive)) {
|
||||
return family;
|
||||
}
|
||||
|
||||
if (tryFont("Liberation Mono")) {
|
||||
return "Liberation Mono";
|
||||
}
|
||||
|
||||
if (tryFont("Menlo")) {
|
||||
return "Menlo";
|
||||
}
|
||||
|
||||
if (tryFont("Courier")) {
|
||||
return "Courier";
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
#endif // !Q_OS_LINUX
|
||||
|
||||
const auto type = QFontDatabase::FixedFont;
|
||||
return QFontDatabase::systemFont(type).family();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue