mirror of
https://git.mirrors.martin98.com/https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-15 00:16:02 +08:00
fix Korean font not be loaded properly (#1681)
* Update Korean Translation - Make overhang printable - Lift Z Enforcement - etc * fix Korean font not be loaded
This commit is contained in:
parent
127ce2b909
commit
580424701b
@ -1,6 +1,7 @@
|
|||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
#include "Label.hpp"
|
#include "Label.hpp"
|
||||||
#include "StaticBox.hpp"
|
#include "StaticBox.hpp"
|
||||||
|
#include <wx/intl.h> // For wxLocale
|
||||||
|
|
||||||
wxFont Label::sysFont(int size, bool bold)
|
wxFont Label::sysFont(int size, bool bold)
|
||||||
{
|
{
|
||||||
@ -11,11 +12,17 @@ wxFont Label::sysFont(int size, bool bold)
|
|||||||
size = size * 4 / 5;
|
size = size * 4 / 5;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto face = wxString::FromUTF8("HarmonyOS Sans SC");
|
wxString face = "HarmonyOS Sans SC";
|
||||||
|
|
||||||
|
// Check if the current locale is Korean
|
||||||
|
if (wxLocale::GetSystemLanguage() == wxLANGUAGE_KOREAN) {
|
||||||
|
face = "Noto Sans KR";
|
||||||
|
}
|
||||||
|
|
||||||
wxFont font{size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL, false, face};
|
wxFont font{size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL, false, face};
|
||||||
font.SetFaceName(face);
|
font.SetFaceName(face);
|
||||||
if (!font.IsOk()) {
|
if (!font.IsOk()) {
|
||||||
BOOST_LOG_TRIVIAL(warning) << boost::format("Cann't find HarmonyOS Sans SC font");
|
BOOST_LOG_TRIVIAL(warning) << boost::format("Can't find %1% font") % face;
|
||||||
font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||||
BOOST_LOG_TRIVIAL(warning) << boost::format("Use system font instead: %1%") % font.GetFaceName();
|
BOOST_LOG_TRIVIAL(warning) << boost::format("Use system font instead: %1%") % font.GetFaceName();
|
||||||
if (bold)
|
if (bold)
|
||||||
@ -49,17 +56,25 @@ wxFont Label::Body_9;
|
|||||||
void Label::initSysFont()
|
void Label::initSysFont()
|
||||||
{
|
{
|
||||||
#if defined(__linux__) || defined(_WIN32)
|
#if defined(__linux__) || defined(_WIN32)
|
||||||
const std::string& resource_path = Slic3r::resources_dir();
|
const std::string &resource_path = Slic3r::resources_dir();
|
||||||
wxString font_path = wxString::FromUTF8(resource_path+"/fonts/HarmonyOS_Sans_SC_Bold.ttf");
|
wxString font_path = wxString::FromUTF8(resource_path + "/fonts/HarmonyOS_Sans_SC_Bold.ttf");
|
||||||
bool result = wxFont::AddPrivateFont(font_path);
|
bool result = wxFont::AddPrivateFont(font_path);
|
||||||
//BOOST_LOG_TRIVIAL(info) << boost::format("add font of HarmonyOS_Sans_SC_Bold returns %1%")%result;
|
// 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);
|
printf("add font of HarmonyOS_Sans_SC_Bold returns %d\n", result);
|
||||||
font_path = wxString::FromUTF8(resource_path+"/fonts/HarmonyOS_Sans_SC_Regular.ttf");
|
font_path = wxString::FromUTF8(resource_path + "/fonts/HarmonyOS_Sans_SC_Regular.ttf");
|
||||||
result = wxFont::AddPrivateFont(font_path);
|
result = wxFont::AddPrivateFont(font_path);
|
||||||
//BOOST_LOG_TRIVIAL(info) << boost::format("add font of HarmonyOS_Sans_SC_Regular returns %1%")%result;
|
// 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);
|
printf("add font of HarmonyOS_Sans_SC_Regular returns %d\n", result);
|
||||||
|
// Adding Noto Sans KR Regular and Bold
|
||||||
|
font_path = wxString::FromUTF8(resource_path + "/fonts/NotoSansKR-Regular.otf");
|
||||||
|
result = wxFont::AddPrivateFont(font_path);
|
||||||
|
// BOOST_LOG_TRIVIAL(info) << boost::format("add font of NotoSansKR-Regular returns %1%")%result;
|
||||||
|
printf("add font of NotoSansKR-Regular returns %d\n", result);
|
||||||
|
font_path = wxString::FromUTF8(resource_path + "/fonts/NotoSansKR-Bold.otf");
|
||||||
|
result = wxFont::AddPrivateFont(font_path);
|
||||||
|
// BOOST_LOG_TRIVIAL(info) << boost::format("add font of NotoSansKR-Bold returns %1%")%result;
|
||||||
|
printf("add font of NotoSansKR-Bold returns %d\n", result);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Head_48 = Label::sysFont(48, true);
|
Head_48 = Label::sysFont(48, true);
|
||||||
Head_32 = Label::sysFont(32, true);
|
Head_32 = Label::sysFont(32, true);
|
||||||
Head_24 = Label::sysFont(24, true);
|
Head_24 = Label::sysFont(24, true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user