Merge remote-tracking branch 'tdesktop/master' into v2.1.2
This commit is contained in:
commit
a76cb8e35e
4 changed files with 40 additions and 24 deletions
Binary file not shown.
Binary file not shown.
|
|
@ -41,6 +41,7 @@ void InitOnTopPanel(not_null<QWidget*> panel) {
|
||||||
Assert([platformWindow isKindOfClass:[NSPanel class]]);
|
Assert([platformWindow isKindOfClass:[NSPanel class]]);
|
||||||
|
|
||||||
auto platformPanel = static_cast<NSPanel*>(platformWindow);
|
auto platformPanel = static_cast<NSPanel*>(platformWindow);
|
||||||
|
[platformPanel setBackgroundColor:[NSColor clearColor]];
|
||||||
[platformPanel setLevel:NSModalPanelWindowLevel];
|
[platformPanel setLevel:NSModalPanelWindowLevel];
|
||||||
[platformPanel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorFullScreenAuxiliary|NSWindowCollectionBehaviorIgnoresCycle];
|
[platformPanel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorFullScreenAuxiliary|NSWindowCollectionBehaviorIgnoresCycle];
|
||||||
[platformPanel setHidesOnDeactivate:NO];
|
[platformPanel setHidesOnDeactivate:NO];
|
||||||
|
|
|
||||||
|
|
@ -125,35 +125,50 @@ bool LoadCustomFont(const QString &filePath, const QString &familyName, int flag
|
||||||
return ValidateFont(familyName, flags);
|
return ValidateFont(familyName, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] QString SystemMonospaceFont() {
|
||||||
|
const auto type = QFontDatabase::FixedFont;
|
||||||
|
return QFontDatabase::systemFont(type).family();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TryFont(const QString &attempt) {
|
||||||
|
const auto resolved = QFontInfo(QFont(attempt)).family();
|
||||||
|
return !resolved.trimmed().compare(attempt, Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] QString ManualMonospaceFont() {
|
||||||
|
const auto kTryFirst = std::initializer_list<QString>{
|
||||||
|
"Consolas",
|
||||||
|
"Liberation Mono",
|
||||||
|
"Menlo",
|
||||||
|
"Courier"
|
||||||
|
};
|
||||||
|
for (const auto &family : kTryFirst) {
|
||||||
|
if (TryFont(family)) {
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
QString MonospaceFont() {
|
QString MonospaceFont() {
|
||||||
static const auto family = [&]() -> QString {
|
static const auto family = [&]() -> QString {
|
||||||
const auto tryFont = [&](const QString &attempt) {
|
if (TryFont(CustomMonospaceFont)) {
|
||||||
const auto resolved = QFontInfo(QFont(attempt)).family();
|
|
||||||
return !resolved.trimmed().compare(attempt, Qt::CaseInsensitive);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (tryFont(CustomMonospaceFont)) {
|
|
||||||
return CustomMonospaceFont;
|
return CustomMonospaceFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Q_OS_LINUX
|
const auto manual = ManualMonospaceFont();
|
||||||
if (!UseSystemFont) {
|
const auto system = SystemMonospaceFont();
|
||||||
const auto kTryFirst = std::initializer_list<QString>{
|
|
||||||
"Consolas",
|
|
||||||
"Liberation Mono",
|
|
||||||
"Menlo",
|
|
||||||
"Courier"
|
|
||||||
};
|
|
||||||
for (const auto &family : kTryFirst) {
|
|
||||||
if (tryFont(family)) {
|
|
||||||
return family;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // !Q_OS_LINUX
|
|
||||||
|
|
||||||
const auto type = QFontDatabase::FixedFont;
|
#if defined Q_OS_WIN || defined Q_OS_MAC
|
||||||
return QFontDatabase::systemFont(type).family();
|
// Prefer our monospace font.
|
||||||
|
const auto useSystem = manual.isEmpty();
|
||||||
|
#else // Q_OS_WIN || Q_OS_MAC
|
||||||
|
// Prefer system monospace font.
|
||||||
|
const auto metrics = QFontMetrics(QFont(system));
|
||||||
|
const auto useSystem = manual.isEmpty()
|
||||||
|
|| (metrics.charWidth("i", 0) == metrics.charWidth("W", 0));
|
||||||
|
#endif // Q_OS_WIN || Q_OS_MAC
|
||||||
|
return (useSystem || UseSystemFont) ? system : manual;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
return family;
|
return family;
|
||||||
|
|
@ -367,7 +382,7 @@ FontData::FontData(int size, uint32 flags, int family, Font *other)
|
||||||
f.setStrikeOut(_flags & FontStrikeOut);
|
f.setStrikeOut(_flags & FontStrikeOut);
|
||||||
|
|
||||||
if (_flags & FontSemibold) {
|
if (_flags & FontSemibold) {
|
||||||
if (CustomSemiboldIsBold) {
|
if (CustomSemiboldIsBold || fontOverride.startsWith("DAOpenSansSemibold")) {
|
||||||
f.setBold(true);
|
f.setBold(true);
|
||||||
#ifdef DESKTOP_APP_USE_PACKAGED_FONTS
|
#ifdef DESKTOP_APP_USE_PACKAGED_FONTS
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue