FIX: korean font display issue

Jira: STUDIO-3995

Change-Id: If92b05c1a38041f976fc5a5823feb674549c4993
This commit is contained in:
liz.li 2023-08-31 16:48:44 +08:00 committed by Lane.Wei
parent f964842d8f
commit 5927b5f87a
4 changed files with 10 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View file

@ -371,6 +371,7 @@ void ImGuiWrapper::set_language(const std::string &language)
} else if (lang == "ko") { } else if (lang == "ko") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesKorean(); // Default + Korean characters ranges = ImGui::GetIO().Fonts->GetGlyphRangesKorean(); // Default + Korean characters
m_font_cjk = true; m_font_cjk = true;
m_is_korean = true;
} else if (lang == "zh") { } else if (lang == "zh") {
ranges = (language == "zh_TW") ? ranges = (language == "zh_TW") ?
// Traditional Chinese // Traditional Chinese
@ -2090,7 +2091,10 @@ void ImGuiWrapper::init_font(bool compress)
cfg.OversampleH = cfg.OversampleV = 1; cfg.OversampleH = cfg.OversampleV = 1;
//FIXME replace with io.Fonts->AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, m_font_size, nullptr, ranges.Data); //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 //https://github.com/ocornut/imgui/issues/220
default_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Regular.ttf").c_str(), m_font_size, &cfg, m_font_cjk ? ImGui::GetIO().Fonts->GetGlyphRangesChineseFull() : ranges.Data); if (m_is_korean)
default_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "NotoSansKR-Regular.ttf").c_str(), m_font_size, &cfg, ranges.Data);
else
default_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Regular.ttf").c_str(), m_font_size, &cfg, ranges.Data);
if (default_font == nullptr) { if (default_font == nullptr) {
default_font = io.Fonts->AddFontDefault(); default_font = io.Fonts->AddFontDefault();
if (default_font == nullptr) { if (default_font == nullptr) {
@ -2098,7 +2102,10 @@ void ImGuiWrapper::init_font(bool compress)
} }
} }
bold_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Bold.ttf").c_str(), m_font_size, &cfg, ranges.Data); if (m_is_korean)
bold_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "NotoSansKR-Bold.ttf").c_str(), m_font_size, &cfg, ranges.Data);
else
bold_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Bold.ttf").c_str(), m_font_size, &cfg, ranges.Data);
if (bold_font == nullptr) { if (bold_font == nullptr) {
bold_font = io.Fonts->AddFontDefault(); bold_font = io.Fonts->AddFontDefault();
if (bold_font == nullptr) { throw Slic3r::RuntimeError("ImGui: Could not load deafult font"); } if (bold_font == nullptr) { throw Slic3r::RuntimeError("ImGui: Could not load deafult font"); }

View file

@ -48,6 +48,7 @@ class ImGuiWrapper
const ImWchar* m_glyph_basic_ranges { nullptr }; const ImWchar* m_glyph_basic_ranges { nullptr };
// Chinese, Japanese, Korean // Chinese, Japanese, Korean
bool m_font_cjk{ false }; bool m_font_cjk{ false };
bool m_is_korean{ false };
float m_font_size{ 18.0 }; float m_font_size{ 18.0 };
unsigned m_font_texture{ 0 }; unsigned m_font_texture{ 0 };
unsigned m_font_another_texture{ 0 }; unsigned m_font_another_texture{ 0 };