From 6e659c853bf36a94ee35295ad31d8243652ef1d0 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 17 Dec 2020 13:35:40 +0100 Subject: [PATCH] Add special font configuration for flatpak --- CMakeLists.txt | 2 ++ cmake/Flatpak.cmake | 16 ++++++++++++++ cmake/Flatpak/99-noto-mono-color-emoji.conf | 23 +++++++++++++++++++++ src/CMakeLists.txt | 4 ++++ src/main.cpp | 7 +++++++ 5 files changed, 52 insertions(+) create mode 100644 cmake/Flatpak.cmake create mode 100644 cmake/Flatpak/99-noto-mono-color-emoji.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index 36be5312d..fa3f82912 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ include(KDEClangFormat) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) +include(cmake/Flatpak.cmake) + # Fix a crash due to problems with quotient's event system. Can probably be removed once the reworked event system is in cmake_policy(SET CMP0063 OLD) diff --git a/cmake/Flatpak.cmake b/cmake/Flatpak.cmake new file mode 100644 index 000000000..3262a7dbd --- /dev/null +++ b/cmake/Flatpak.cmake @@ -0,0 +1,16 @@ +if(NOT NEOCHAT_FLATPAK) + # Only include this if we build a Flatpak + return() +endif() + +include(GNUInstallDirs) + +# Include FontConfig config which uses the Emoji One font from the +# KDE Flatpak SDK. +install( + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Flatpak/99-noto-mono-color-emoji.conf + DESTINATION + ${CMAKE_INSTALL_SYSCONFDIR}/fonts/conf.d/ +) + diff --git a/cmake/Flatpak/99-noto-mono-color-emoji.conf b/cmake/Flatpak/99-noto-mono-color-emoji.conf new file mode 100644 index 000000000..386b890e3 --- /dev/null +++ b/cmake/Flatpak/99-noto-mono-color-emoji.conf @@ -0,0 +1,23 @@ + + + + + serif + + Emoji One + + + + sans-serif + + Emoji One + + + + monospace + + Emoji One + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 22b75f77f..2e2cd05b4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,6 +28,10 @@ target_include_directories(neochat PRIVATE ${CMAKE_BINARY_DIR}) target_link_libraries(neochat PRIVATE Qt5::Quick Qt5::Qml Qt5::Gui Qt5::Network Qt5::QuickControls2 KF5::I18n KF5::Kirigami2 KF5::Notifications KF5::ConfigCore KF5::ConfigGui KF5::CoreAddons Quotient cmark::cmark) kconfig_add_kcfg_files(neochat GENERATE_MOC neochatconfig.kcfgc) +if(NEOCHAT_FLATPAK) + target_compile_definitions(neochat PRIVATE NEOCHAT_FLATPAK) +endif() + if (KQuickImageEditor_FOUND) target_compile_definitions(neochat PRIVATE HAS_KQUICKIMAGEEDITOR) endif() diff --git a/src/main.cpp b/src/main.cpp index c9d6acdad..1633d8375 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,6 +76,13 @@ int main(int argc, char *argv[]) KDBusService service(KDBusService::Unique); #endif +#ifdef NEOCHAT_FLATPAK + // Copy over the included FontConfig configuration to the + // app's config dir: + QFile::copy("/app/etc/fonts/conf.d/99-noto-mono-color-emoji.conf", + "/var/config/fontconfig/conf.d/99-noto-mono-color-emoji.conf"); +#endif + Clipboard clipboard; auto config = NeoChatConfig::self();