From 23feba7e5a1396110d543a676e018bcbdfa50d39 Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Sat, 27 Feb 2021 09:23:59 +1100 Subject: Adds emoji toggle preference. --- src/documentstyle.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/documentstyle.cpp') diff --git a/src/documentstyle.cpp b/src/documentstyle.cpp index 5edef73..11d29e7 100644 --- a/src/documentstyle.cpp +++ b/src/documentstyle.cpp @@ -430,6 +430,8 @@ DocumentStyle DocumentStyle::derive(const QUrl &url) const auto const patchup_font = [](QFont & font, bool fixed=false) { // Set the "fallback" font, just to be absolutely sure. + // Note the main purpose of this is to avoid emoji fonts + // from taking precedence over text fonts. // (fixes *nix default font issues) emojiFonts[1] = fixed ? kristall::default_font_family_fixed @@ -438,7 +440,7 @@ DocumentStyle DocumentStyle::derive(const QUrl &url) const // Set the primary font as the preferred font. // We ensure that the font family is available first, // so that we don't get an ugly default font - // (fixes Windows' default font) + // (fixes Windows' default font problem) QFontDatabase db; if (!db.families().contains(font.family())) { @@ -451,12 +453,16 @@ DocumentStyle DocumentStyle::derive(const QUrl &url) const emojiFonts.front() = font.family(); } - // We don't support emoji fonts on lower than Qt 5.13 - #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - font.setFamily(emojiFonts.front()); - #else - font.setFamilies(emojiFonts); - #endif + // Set emoji fonts if supported and enabled. + if (kristall::EMOJIS_SUPPORTED && + kristall::options.emojis_enabled) + { + font.setFamilies(emojiFonts); + } + else + { + font.setFamily(emojiFonts.front()); + } }; patchup_font(themed.h1_font); -- cgit v1.2.3