ENH:Bold font for preview title

Change-Id: I75c9b1ad0b1b7b07650b2038dbbc101b5a4fb4d7
This commit is contained in:
xiangdong.yang 2022-08-11 11:16:13 +08:00 committed by Lane.Wei
parent afc1395828
commit aa59c93eb5
3 changed files with 38 additions and 5 deletions

View file

@ -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;