mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-03 08:05:12 +00:00
Fixed font changing
This commit is contained in:
@@ -161,6 +161,18 @@ Application::~Application() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Application::run() {
|
void Application::run() {
|
||||||
|
if (!cMainFont().isEmpty()) {
|
||||||
|
style::internal::SetMainFont(cMainFont());
|
||||||
|
}
|
||||||
|
if (!cSemiboldFont().isEmpty()) {
|
||||||
|
style::internal::SetSemiboldFont(cSemiboldFont());
|
||||||
|
}
|
||||||
|
if (cSemiboldFontIsBold()) {
|
||||||
|
style::internal::SetSemiboldIsBold(cSemiboldFontIsBold());
|
||||||
|
}
|
||||||
|
if (!cMonospaceFont().isEmpty()) {
|
||||||
|
style::internal::SetMonospaceFont(cMonospaceFont());
|
||||||
|
}
|
||||||
style::internal::StartFonts();
|
style::internal::StartFonts();
|
||||||
|
|
||||||
ThirdParty::start();
|
ThirdParty::start();
|
||||||
|
@@ -30,6 +30,7 @@ auto PaletteChanges = rpl::event_stream<>();
|
|||||||
auto ShortAnimationRunning = rpl::variable<bool>(false);
|
auto ShortAnimationRunning = rpl::variable<bool>(false);
|
||||||
auto RunningShortAnimations = 0;
|
auto RunningShortAnimations = 0;
|
||||||
auto ResolvedMonospaceFont = style::font();
|
auto ResolvedMonospaceFont = style::font();
|
||||||
|
QString CustomMonospaceFont;
|
||||||
|
|
||||||
std::vector<internal::ModuleBase*> &StyleModules() {
|
std::vector<internal::ModuleBase*> &StyleModules() {
|
||||||
static auto result = std::vector<internal::ModuleBase*>();
|
static auto result = std::vector<internal::ModuleBase*>();
|
||||||
@@ -52,8 +53,8 @@ void ResolveMonospaceFont() {
|
|||||||
family = attempt;
|
family = attempt;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!cMonospaceFont().isEmpty()) {
|
if (!CustomMonospaceFont.isEmpty()) {
|
||||||
tryFont(cMonospaceFont());
|
tryFont(CustomMonospaceFont);
|
||||||
}
|
}
|
||||||
tryFont("Consolas");
|
tryFont("Consolas");
|
||||||
tryFont("Liberation Mono");
|
tryFont("Liberation Mono");
|
||||||
@@ -69,6 +70,10 @@ void ResolveMonospaceFont() {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
void SetMonospaceFont(const QString &familyName) {
|
||||||
|
CustomMonospaceFont = familyName;
|
||||||
|
}
|
||||||
|
|
||||||
void registerModule(ModuleBase *module) {
|
void registerModule(ModuleBase *module) {
|
||||||
StyleModules().push_back(module);
|
StyleModules().push_back(module);
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,8 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void SetMonospaceFont(const QString &familyName);
|
||||||
|
|
||||||
void registerModule(ModuleBase *module);
|
void registerModule(ModuleBase *module);
|
||||||
|
|
||||||
[[nodiscard]] QColor EnsureContrast(const QColor &over, const QColor &under);
|
[[nodiscard]] QColor EnsureContrast(const QColor &over, const QColor &under);
|
||||||
|
@@ -76,8 +76,24 @@ bool Started = false;
|
|||||||
QString OpenSansOverride;
|
QString OpenSansOverride;
|
||||||
QString OpenSansSemiboldOverride;
|
QString OpenSansSemiboldOverride;
|
||||||
|
|
||||||
|
QString CustomMainFont;
|
||||||
|
QString CustomSemiboldFont;
|
||||||
|
bool CustomSemiboldIsBold = false;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
void SetMainFont(const QString &familyName) {
|
||||||
|
CustomMainFont = familyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetSemiboldFont(const QString &familyName) {
|
||||||
|
CustomSemiboldFont = familyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetSemiboldIsBold(bool isBold) {
|
||||||
|
CustomSemiboldIsBold = isBold;
|
||||||
|
}
|
||||||
|
|
||||||
void StartFonts() {
|
void StartFonts() {
|
||||||
if (Started) {
|
if (Started) {
|
||||||
return;
|
return;
|
||||||
@@ -119,11 +135,11 @@ void StartFonts() {
|
|||||||
QFont::insertSubstitutions("Open Sans Semibold", list);
|
QFont::insertSubstitutions("Open Sans Semibold", list);
|
||||||
#endif // Q_OS_WIN || Q_OS_MAC
|
#endif // Q_OS_WIN || Q_OS_MAC
|
||||||
|
|
||||||
if (!cMainFont().isEmpty() && ValidateFont(cMainFont())) {
|
if (!CustomMainFont.isEmpty() && ValidateFont(CustomMainFont)) {
|
||||||
OpenSansOverride = cMainFont();
|
OpenSansOverride = CustomMainFont;
|
||||||
}
|
}
|
||||||
if (!cSemiboldFont().isEmpty() && ValidateFont(cSemiboldFont())) {
|
if (!CustomSemiboldFont.isEmpty() && ValidateFont(CustomSemiboldFont)) {
|
||||||
OpenSansSemiboldOverride = cSemiboldFont();
|
OpenSansSemiboldOverride = CustomSemiboldFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +185,7 @@ FontData::FontData(int size, uint32 flags, int family, Font *other)
|
|||||||
f.setPixelSize(size);
|
f.setPixelSize(size);
|
||||||
if (_flags & FontBold) {
|
if (_flags & FontBold) {
|
||||||
f.setBold(true);
|
f.setBold(true);
|
||||||
} else if (fontFamilies[family] == "Open Sans Semibold" && cSemiboldFontIsBold()) {
|
} else if (fontFamilies[family] == "Open Sans Semibold" && CustomSemiboldIsBold) {
|
||||||
f.setBold(true);
|
f.setBold(true);
|
||||||
}
|
}
|
||||||
f.setItalic(_flags & FontItalic);
|
f.setItalic(_flags & FontItalic);
|
||||||
|
@@ -15,6 +15,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
namespace style {
|
namespace style {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
void SetMainFont(const QString &familyName);
|
||||||
|
void SetSemiboldFont(const QString &familyName);
|
||||||
|
void SetSemiboldIsBold(bool isBold);
|
||||||
|
|
||||||
void StartFonts();
|
void StartFonts();
|
||||||
[[nodiscard]] QString GetFontOverride(const QString &familyName);
|
[[nodiscard]] QString GetFontOverride(const QString &familyName);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user