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() {
|
QString MonospaceFont() {
|
||||||
static const auto family = [&]() -> QString {
|
static const auto family = [&]() -> QString {
|
||||||
#ifdef Q_OS_WIN
|
#ifndef Q_OS_LINUX
|
||||||
const auto tryFont = [&](const QString &attempt) {
|
const auto kTryFirst = std::initializer_list<QString>{
|
||||||
return !QFontInfo(QFont(attempt)).family().trimmed().compare(
|
"Consolas",
|
||||||
attempt,
|
"Liberation Mono",
|
||||||
Qt::CaseInsensitive);
|
"Menlo",
|
||||||
|
"Courier"
|
||||||
};
|
};
|
||||||
|
for (const auto &family : kTryFirst) {
|
||||||
if (tryFont("Consolas")) {
|
const auto resolved = QFontInfo(QFont(family)).family();
|
||||||
return "Consolas";
|
if (!resolved.trimmed().compare(family, Qt::CaseInsensitive)) {
|
||||||
|
return family;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif // !Q_OS_LINUX
|
||||||
if (tryFont("Liberation Mono")) {
|
|
||||||
return "Liberation Mono";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tryFont("Menlo")) {
|
|
||||||
return "Menlo";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tryFont("Courier")) {
|
|
||||||
return "Courier";
|
|
||||||
}
|
|
||||||
#endif // Q_OS_WIN
|
|
||||||
|
|
||||||
const auto type = QFontDatabase::FixedFont;
|
const auto type = QFontDatabase::FixedFont;
|
||||||
return QFontDatabase::systemFont(type).family();
|
return QFontDatabase::systemFont(type).family();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue