diff --git a/resources/credits.md b/resources/credits.md index e28d50db1..df9da8ce8 100644 --- a/resources/credits.md +++ b/resources/credits.md @@ -74,8 +74,9 @@ First time here? See the reference documents below to get started using SatDump. ### Fonts - [Roboto](https://fonts.google.com/specimen/Roboto), for text -- [3270 Nerd Font](https://www.nerdfonts.com/font-downloads), for icons and symbols -*Both fonts were merged into a single font.ttf* +- [3270 Nerd Font](https://www.nerdfonts.com/font-downloads), for icons and symbols +- [Perfect DOS VGA 437](https://www.dafont.com/perfect-dos-vga-437.font), for Phosphor theme +*3270 Nerd Font and Roboto have been merged into a single font.ttf* # Developers **Lead Developer:** Aang23 (F4LAU) diff --git a/resources/fonts/FreeMono.png b/resources/fonts/FreeMono.png deleted file mode 100644 index a24e8b6e2..000000000 Binary files a/resources/fonts/FreeMono.png and /dev/null differ diff --git a/resources/fonts/Perfect-DOS-VGA-437-Win.ttf b/resources/fonts/Perfect-DOS-VGA-437-Win.ttf new file mode 100644 index 000000000..d03b1c5e5 Binary files /dev/null and b/resources/fonts/Perfect-DOS-VGA-437-Win.ttf differ diff --git a/resources/themes/Phosphor.json b/resources/themes/Phosphor.json index 13e7b7259..d3f02e9a2 100644 --- a/resources/themes/Phosphor.json +++ b/resources/themes/Phosphor.json @@ -1,5 +1,7 @@ { "light": false, + "font": "Perfect-DOS-VGA-437-Win", + "font_size": 14, "ImGuiStyle": { "ScrollbarRounding": 0.0, "TabRounding": 0.0, diff --git a/src-core/common/image/image.h b/src-core/common/image/image.h index 98fc09e6b..7130afc0a 100644 --- a/src-core/common/image/image.h +++ b/src-core/common/image/image.h @@ -145,7 +145,7 @@ namespace image // Others // Font creation - std::vector> make_font(int size, bool text_mode = true); // Generate a font to be used by draw_text. Uses the bundled GNU FreeMono + std::vector> make_font(int size, bool text_mode = true); // Generate a font to be used by draw_text. Uses the bundled Roboto font template Image generate_text_image(std::string text, T color[], int size, int padX, int padY); // return text on a transparent background diff --git a/src-core/core/style.cpp b/src-core/core/style.cpp index f1a6eaf15..41e48d707 100644 --- a/src-core/core/style.cpp +++ b/src-core/core/style.cpp @@ -51,13 +51,23 @@ namespace style try { std::string selected_theme = satdump::config::main_cfg["user_interface"]["theme"]["value"]; + std::string theme_path; + if(resources::resourceExists("themes/" + selected_theme + ".json")) + theme_path = "themes/" + selected_theme + ".json"; + else + { + logger->warn("Failed to load theme \"%s\". Will fall back to Dark", selected_theme.c_str()); + satdump::config::main_cfg["user_interface"]["theme"]["value"] = selected_theme = "Dark"; + satdump::config::saveUserConfig(); + } + std::ifstream file(resources::getResourcePath("themes/" + selected_theme + ".json")); file >> data; file.close(); } catch (std::exception&) { - logger->error("Failed to load theme! There will be visual issues."); + logger->error("Failed to load any theme! Your SatDump installation may be missing critical files."); return; } @@ -68,6 +78,20 @@ namespace style else ImGui::StyleColorsDark(); + // Set font + if (data.contains("font") && data["font"].is_string()) + { + std::string font = data["font"]; + if (resources::resourceExists("fonts/" + font + ".ttf")) + theme.font = font; + else + logger->debug("Specified font \"%s\" not found. Falling back to default", font.c_str()); + } + + // Set font size + if (data.contains("font_size") && data["font_size"].is_number() && data["font_size"].get() > 0) + theme.font_size = data["font_size"]; + // ImGui sizes if (data.contains("ImGuiStyle") && data["ImGuiStyle"].is_object()) { @@ -83,13 +107,16 @@ namespace style {"FrameRounding", &ImGuiStyle::FrameRounding}, {"FrameBorderSize", &ImGuiStyle::FrameBorderSize}, {"IndentSpacing", &ImGuiStyle::IndentSpacing}, + {"LogSliderDeadzone", &ImGuiStyle::LogSliderDeadzone}, + {"ColumnsMinSpacing", &ImGuiStyle::ColumnsMinSpacing}, {"ScrollbarSize", &ImGuiStyle::ScrollbarSize}, {"ScrollbarRounding", &ImGuiStyle::ScrollbarRounding}, {"GrabMinSize", &ImGuiStyle::GrabMinSize}, {"GrabRounding", &ImGuiStyle::GrabRounding}, {"TabRounding", &ImGuiStyle::TabRounding}, {"TabBorderSize", &ImGuiStyle::TabBorderSize}, - {"TabBarBorderSize", &ImGuiStyle::TabBarBorderSize} + {"TabBarBorderSize", &ImGuiStyle::TabBarBorderSize}, + {"SeparatorTextBorderSize", &ImGuiStyle::SeparatorTextBorderSize} }; for (auto& style_item : data["ImGuiStyle"].items()) @@ -254,15 +281,15 @@ namespace style float macos_fbs = macos_framebuffer_scale(); float font_scaling = dpi_scaling * macos_fbs; - baseFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/Roboto-Medium.ttf").c_str(), 16.0f * font_scaling, &config, def); + baseFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/" + theme.font + ".ttf").c_str(), theme.font_size * font_scaling, &config, def); config.MergeMode = true; for (int i = 0; i < 6; i++) - baseFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/font.ttf").c_str(), 16.0f * font_scaling, &config, list[i]); + baseFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/font.ttf").c_str(), theme.font_size * font_scaling, &config, list[i]); config.MergeMode = false; - bigFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/Roboto-Medium.ttf").c_str(), 45.0f * font_scaling); //, &config, ranges); - //hugeFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/Roboto-Medium.ttf").c_str(), 128.0f * font_scaling); //, &config, ranges); + bigFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/" + theme.font + ".ttf").c_str(), 45.0f * font_scaling); //, &config, ranges); + //hugeFont = io.Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/" + theme.font + ".ttf").c_str(), 128.0f * font_scaling); //, &config, ranges); io.Fonts->Build(); io.FontGlobalScale = 1 / macos_fbs; diff --git a/src-core/core/style.h b/src-core/core/style.h index f0cff9bec..7f1f760c4 100644 --- a/src-core/core/style.h +++ b/src-core/core/style.h @@ -8,6 +8,8 @@ namespace style struct Theme { bool light_mode = false; + std::string font = "Roboto-Medium"; + float font_size = 16.0f; ImColor red; ImColor green;