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