diff --git a/resources/fonts/HarmonyOS_Sans_SC_Black.ttf b/resources/fonts/HarmonyOS_Sans_SC_Black.ttf deleted file mode 100644 index 553db8e3a..000000000 Binary files a/resources/fonts/HarmonyOS_Sans_SC_Black.ttf and /dev/null differ diff --git a/resources/fonts/HarmonyOS_Sans_SC_Light.ttf b/resources/fonts/HarmonyOS_Sans_SC_Light.ttf deleted file mode 100644 index 30af673b7..000000000 Binary files a/resources/fonts/HarmonyOS_Sans_SC_Light.ttf and /dev/null differ diff --git a/resources/fonts/HarmonyOS_Sans_SC_Medium.ttf b/resources/fonts/HarmonyOS_Sans_SC_Medium.ttf deleted file mode 100644 index 755348d2d..000000000 Binary files a/resources/fonts/HarmonyOS_Sans_SC_Medium.ttf and /dev/null differ diff --git a/resources/fonts/HarmonyOS_Sans_SC_Thin.ttf b/resources/fonts/HarmonyOS_Sans_SC_Thin.ttf deleted file mode 100644 index d33db2b5b..000000000 Binary files a/resources/fonts/HarmonyOS_Sans_SC_Thin.ttf and /dev/null differ diff --git a/resources/fonts/NotoSansJP-Bold.ttf b/resources/fonts/NotoSansJP-Bold.ttf new file mode 100644 index 000000000..384f8ebb8 Binary files /dev/null and b/resources/fonts/NotoSansJP-Bold.ttf differ diff --git a/resources/fonts/NotoSansJP-Regular.ttf b/resources/fonts/NotoSansJP-Regular.ttf new file mode 100644 index 000000000..1583096a2 Binary files /dev/null and b/resources/fonts/NotoSansJP-Regular.ttf differ diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 0b4c6d957..e27cc9693 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1342,6 +1342,9 @@ GUI_App::GUI_App() { //app config initializes early becasuse it is used in instance checking in BambuStudio.cpp this->init_app_config(); + if (app_config) { + ::Label::initSysFont(app_config->get_language_code(), false); + } this->init_download_path(); reset_to_active(); diff --git a/src/slic3r/GUI/Widgets/Label.cpp b/src/slic3r/GUI/Widgets/Label.cpp index 861b8b1d6..3280b5de2 100644 --- a/src/slic3r/GUI/Widgets/Label.cpp +++ b/src/slic3r/GUI/Widgets/Label.cpp @@ -2,10 +2,13 @@ #include "Label.hpp" #include "StaticBox.hpp" +#include "../GUI_App.hpp" +#include "libslic3r/AppConfig.hpp" + #include #include -wxFont Label::sysFont(int size, bool bold) +wxFont Label::sysFont(int size, bool bold, std::string lang_code) { //#ifdef __linux__ // return wxFont{}; @@ -14,7 +17,13 @@ wxFont Label::sysFont(int size, bool bold) size = size * 4 / 5; #endif - auto face = wxString::FromUTF8("HarmonyOS Sans SC"); + wxString face; + if (lang_code == "ja") { + face = wxString::FromUTF8("Noto Sans JP"); + } else { + face = wxString::FromUTF8("HarmonyOS Sans SC"); + } + wxFont font{size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL, false, face}; font.SetFaceName(face); if (!font.IsOk()) { @@ -22,6 +31,7 @@ wxFont Label::sysFont(int size, bool bold) if (bold) font.MakeBold(); font.SetPointSize(size); } + return font; } wxFont Label::Head_48; @@ -47,41 +57,43 @@ wxFont Label::Body_10; wxFont Label::Body_9; wxFont Label::Body_8; -void Label::initSysFont() +void Label::initSysFont(std::string lang_code, bool load_font_resource) { #ifdef __linux__ - const std::string& resource_path = Slic3r::resources_dir(); - wxString font_path = wxString::FromUTF8(resource_path+"/fonts/HarmonyOS_Sans_SC_Bold.ttf"); - bool result = wxFont::AddPrivateFont(font_path); - //BOOST_LOG_TRIVIAL(info) << boost::format("add font of HarmonyOS_Sans_SC_Bold returns %1%")%result; - printf("add font of HarmonyOS_Sans_SC_Bold returns %d\n", result); - font_path = wxString::FromUTF8(resource_path+"/fonts/HarmonyOS_Sans_SC_Regular.ttf"); - result = wxFont::AddPrivateFont(font_path); - //BOOST_LOG_TRIVIAL(info) << boost::format("add font of HarmonyOS_Sans_SC_Regular returns %1%")%result; - printf("add font of HarmonyOS_Sans_SC_Regular returns %d\n", result); + if (load_font_resource) { + const std::string& resource_path = Slic3r::resources_dir(); + wxString font_path = wxString::FromUTF8(resource_path+"/fonts/HarmonyOS_Sans_SC_Bold.ttf"); + bool result = wxFont::AddPrivateFont(font_path); + //BOOST_LOG_TRIVIAL(info) << boost::format("add font of HarmonyOS_Sans_SC_Bold returns %1%")%result; + printf("add font of HarmonyOS_Sans_SC_Bold returns %d\n", result); + font_path = wxString::FromUTF8(resource_path+"/fonts/HarmonyOS_Sans_SC_Regular.ttf"); + result = wxFont::AddPrivateFont(font_path); + //BOOST_LOG_TRIVIAL(info) << boost::format("add font of HarmonyOS_Sans_SC_Regular returns %1%")%result; + printf("add font of HarmonyOS_Sans_SC_Regular returns %d\n", result); + } #endif - Head_48 = Label::sysFont(48, true); - Head_32 = Label::sysFont(32, true); - Head_24 = Label::sysFont(24, true); - Head_20 = Label::sysFont(20, true); - Head_18 = Label::sysFont(18, true); - Head_16 = Label::sysFont(16, true); - Head_15 = Label::sysFont(15, true); - Head_14 = Label::sysFont(14, true); - Head_13 = Label::sysFont(13, true); - Head_12 = Label::sysFont(12, true); - Head_11 = Label::sysFont(11, true); - Head_10 = Label::sysFont(10, true); + Head_48 = Label::sysFont(48, true, lang_code); + Head_32 = Label::sysFont(32, true, lang_code); + Head_24 = Label::sysFont(24, true, lang_code); + Head_20 = Label::sysFont(20, true, lang_code); + Head_18 = Label::sysFont(18, true, lang_code); + Head_16 = Label::sysFont(16, true, lang_code); + Head_15 = Label::sysFont(15, true, lang_code); + Head_14 = Label::sysFont(14, true, lang_code); + Head_13 = Label::sysFont(13, true, lang_code); + Head_12 = Label::sysFont(12, true, lang_code); + Head_11 = Label::sysFont(11, true, lang_code); + Head_10 = Label::sysFont(10, true, lang_code); - Body_16 = Label::sysFont(16, false); - Body_15 = Label::sysFont(15, false); - Body_14 = Label::sysFont(14, false); - Body_13 = Label::sysFont(13, false); - Body_12 = Label::sysFont(12, false); - Body_11 = Label::sysFont(11, false); - Body_10 = Label::sysFont(10, false); - Body_9 = Label::sysFont(9, false); - Body_8 = Label::sysFont(8, false); + Body_16 = Label::sysFont(16, false, lang_code); + Body_15 = Label::sysFont(15, false, lang_code); + Body_14 = Label::sysFont(14, false, lang_code); + Body_13 = Label::sysFont(13, false, lang_code); + Body_12 = Label::sysFont(12, false, lang_code); + Body_11 = Label::sysFont(11, false, lang_code); + Body_10 = Label::sysFont(10, false, lang_code); + Body_9 = Label::sysFont(9, false, lang_code); + Body_8 = Label::sysFont(8, false, lang_code); } class WXDLLIMPEXP_CORE wxTextWrapper2 diff --git a/src/slic3r/GUI/Widgets/Label.hpp b/src/slic3r/GUI/Widgets/Label.hpp index ea15128ec..b3581406a 100644 --- a/src/slic3r/GUI/Widgets/Label.hpp +++ b/src/slic3r/GUI/Widgets/Label.hpp @@ -54,9 +54,9 @@ public: static wxFont Body_9; static wxFont Body_8; - static void initSysFont(); + static void initSysFont(std::string lang_code = "", bool load_font_resource = true); - static wxFont sysFont(int size, bool bold = false); + static wxFont sysFont(int size, bool bold = false, std::string lang_code = ""); static wxSize split_lines(wxDC &dc, int width, const wxString &text, wxString &multiline_text); };