Use extern with custom font variables (#3)
This commit is contained in:
parent
8ce091c159
commit
e6fdff4597
4 changed files with 12 additions and 39 deletions
|
|
@ -20,7 +20,7 @@
|
||||||
namespace style {
|
namespace style {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
bool GetUseSystemFont();
|
extern bool UseSystemFont;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
@ -32,7 +32,6 @@ 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*>();
|
||||||
|
|
@ -58,7 +57,7 @@ void ResolveMonospaceFont() {
|
||||||
if (!CustomMonospaceFont.isEmpty()) {
|
if (!CustomMonospaceFont.isEmpty()) {
|
||||||
tryFont(CustomMonospaceFont);
|
tryFont(CustomMonospaceFont);
|
||||||
}
|
}
|
||||||
if (!GetUseSystemFont()) {
|
if (!UseSystemFont) {
|
||||||
tryFont("Consolas");
|
tryFont("Consolas");
|
||||||
tryFont("Liberation Mono");
|
tryFont("Liberation Mono");
|
||||||
tryFont("Menlo");
|
tryFont("Menlo");
|
||||||
|
|
@ -74,9 +73,7 @@ void ResolveMonospaceFont() {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void SetMonospaceFont(const QString &familyName) {
|
QString CustomMonospaceFont;
|
||||||
CustomMonospaceFont = familyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void registerModule(ModuleBase *module) {
|
void registerModule(ModuleBase *module) {
|
||||||
StyleModules().push_back(module);
|
StyleModules().push_back(module);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@
|
||||||
namespace style {
|
namespace style {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
extern QString CustomMonospaceFont;
|
||||||
|
|
||||||
// Objects of derived classes are created in global scope.
|
// Objects of derived classes are created in global scope.
|
||||||
// They call [un]registerModule() in [de|con]structor.
|
// They call [un]registerModule() in [de|con]structor.
|
||||||
class ModuleBase {
|
class ModuleBase {
|
||||||
|
|
@ -25,8 +27,6 @@ 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);
|
||||||
|
|
|
||||||
|
|
@ -167,38 +167,14 @@ QString FontTypeWindowsFallback[FontTypesCount] = {
|
||||||
bool Started = false;
|
bool Started = false;
|
||||||
QString Overrides[FontTypesCount];
|
QString Overrides[FontTypesCount];
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
QString CustomMainFont;
|
QString CustomMainFont;
|
||||||
QString CustomSemiboldFont;
|
QString CustomSemiboldFont;
|
||||||
bool CustomSemiboldIsBold = false;
|
bool CustomSemiboldIsBold = false;
|
||||||
bool UseSystemFont = false;
|
bool UseSystemFont = false;
|
||||||
bool UseOriginalMetrics = false;
|
bool UseOriginalMetrics = false;
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
bool GetUseSystemFont() {
|
|
||||||
return UseSystemFont;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetMainFont(const QString &familyName) {
|
|
||||||
CustomMainFont = familyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetSemiboldFont(const QString &familyName) {
|
|
||||||
CustomSemiboldFont = familyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetSemiboldIsBold(bool isBold) {
|
|
||||||
CustomSemiboldIsBold = isBold;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetUseSystemFont(bool isSystemFont) {
|
|
||||||
UseSystemFont = isSystemFont;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetUseOriginalMetrics(bool isOriginal) {
|
|
||||||
UseOriginalMetrics = isOriginal;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartFonts() {
|
void StartFonts() {
|
||||||
if (Started) {
|
if (Started) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@
|
||||||
namespace style {
|
namespace style {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
void SetMainFont(const QString &familyName);
|
extern QString CustomMainFont;
|
||||||
void SetSemiboldFont(const QString &familyName);
|
extern QString CustomSemiboldFont;
|
||||||
void SetSemiboldIsBold(bool isBold);
|
extern bool CustomSemiboldIsBold;
|
||||||
void SetUseSystemFont(bool isSystemFont);
|
extern bool UseSystemFont;
|
||||||
void SetUseOriginalMetrics(bool isOriginal);
|
extern bool UseOriginalMetrics;
|
||||||
|
|
||||||
void StartFonts();
|
void StartFonts();
|
||||||
[[nodiscard]] QString GetFontOverride(const QString &familyName, int32 flags = 0);
|
[[nodiscard]] QString GetFontOverride(const QString &familyName, int32 flags = 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue