diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 9530c506b4..aa87ebe6b8 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -4160,10 +4160,10 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv auto append_headers = [&imgui](const std::array& texts, const std::array& offsets) { size_t i = 0; for (; i < offsets.size(); i++) { - imgui.text(texts[i]); + imgui.bold_text(texts[i]); ImGui::SameLine(offsets[i]); } - imgui.text(texts[i]); + imgui.bold_text(texts[i]); ImGui::Separator(); }; @@ -4267,7 +4267,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv ImGui::PopStyleColor(3); ImGui::PopStyleVar(1); ImGui::SameLine(); - ImGui::Text(_u8L("Color Scheme").c_str()); + imgui.bold_text(_u8L("Color Scheme")); push_combo_style(); ImGui::SameLine(); diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index b5e88cd155..f3fe8d7704 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -1526,9 +1526,26 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co // check_box(_L("Search in English"), view_params.english); } +void ImGuiWrapper::bold_text(const std::string& str) +{ + if (bold_font){ + ImGui::PushFont(bold_font); + text(str); + ImGui::PopFont(); + } else { + text(str); + } +} + void ImGuiWrapper::title(const std::string& str) { - text(str); + if (bold_font){ + ImGui::PushFont(bold_font); + text(str); + ImGui::PopFont(); + } else { + text(str); + } ImGui::Separator(); } @@ -1690,6 +1707,7 @@ void ImGuiWrapper::init_font(bool compress) //FIXME replace with io.Fonts->AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, m_font_size, nullptr, ranges.Data); //https://github.com/ocornut/imgui/issues/220 ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Regular.ttf").c_str(), m_font_size, nullptr, ranges.Data); + if (font == nullptr) { font = io.Fonts->AddFontDefault(); if (font == nullptr) { @@ -1697,6 +1715,15 @@ void ImGuiWrapper::init_font(bool compress) } } + ImFontConfig cfg = ImFontConfig(); + cfg.OversampleH = 1; + bold_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Bold.ttf").c_str(), m_font_size, &cfg); + + if (bold_font == nullptr) { + bold_font = io.Fonts->AddFontDefault(); + if (bold_font == nullptr) { throw Slic3r::RuntimeError("ImGui: Could not load deafult font"); } + } + #ifdef __APPLE__ ImFontConfig config; config.MergeMode = true; diff --git a/src/slic3r/GUI/ImGuiWrapper.hpp b/src/slic3r/GUI/ImGuiWrapper.hpp index 8cb579f504..dee1553eb2 100644 --- a/src/slic3r/GUI/ImGuiWrapper.hpp +++ b/src/slic3r/GUI/ImGuiWrapper.hpp @@ -147,7 +147,12 @@ public: bool combo(const wxString& label, const std::vector& options, int& selection); // Use -1 to not mark any option as selected bool undo_redo_list(const ImVec2& size, const bool is_undo, bool (*items_getter)(const bool, int, const char**), int& hovered, int& selected, int& mouse_wheel); void search_list(const ImVec2& size, bool (*items_getter)(int, const char** label, const char** tooltip), char* search_str, - Search::OptionViewParameters& view_params, int& selected, bool& edited, int& mouse_wheel, bool is_localized); + Search::OptionViewParameters &view_params, + int & selected, + bool & edited, + int & mouse_wheel, + bool is_localized); + void bold_text(const std::string &str); void title(const std::string& str); void disabled_begin(bool disabled); @@ -204,6 +209,7 @@ private: static void clipboard_set(void* user_data, const char* text); LastSliderStatus m_last_slider_status; + ImFont* bold_font = nullptr; }; class IMTexture