Merge branch 'master' of https://github.com/prusa3d/Slic3r into et_multivolume_models

This commit is contained in:
Enrico Turri 2019-02-19 14:17:08 +01:00
commit 94c529a118
4 changed files with 37 additions and 2 deletions

Binary file not shown.

View File

@ -412,6 +412,7 @@ bool GUI_App::select_language( wxArrayString & names,
//FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
wxSetlocale(LC_NUMERIC, "C");
Preset::update_suffix_modified();
m_imgui->set_language(m_wxLocale->GetCanonicalName().ToUTF8().data());
return true;
}
return false;
@ -440,6 +441,7 @@ bool GUI_App::load_language()
//FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
wxSetlocale(LC_NUMERIC, "C");
Preset::update_suffix_modified();
m_imgui->set_language(m_wxLocale->GetCanonicalName().ToUTF8().data());
return true;
}
}

View File

@ -25,7 +25,8 @@ namespace GUI {
ImGuiWrapper::ImGuiWrapper()
: m_font_texture(0)
: m_glyph_ranges(nullptr)
, m_font_texture(0)
, m_style_scaling(1.0)
, m_mouse_buttons(0)
, m_disabled(false)
@ -49,6 +50,35 @@ bool ImGuiWrapper::init()
return true;
}
void ImGuiWrapper::set_language(const std::string &language)
{
const ImWchar *ranges = nullptr;
size_t idx = language.find('_');
std::string lang = (idx == std::string::npos) ? language : language.substr(0, idx);
static const ImWchar ranges_latin2[] =
{
0x0020, 0x00FF, // Basic Latin + Latin Supplement
0x0100, 0x017F, // Latin Extended-A
0,
};
if (lang == "cs" || lang == "pl") {
ranges = ranges_latin2;
} else if (lang == "ru" || lang == "uk") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesCyrillic();
} else if (lang == "jp") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesJapanese();
} else if (lang == "kr") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesKorean();
} else if (lang == "zh") {
ranges = ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon();
}
if (ranges != m_glyph_ranges) {
m_glyph_ranges = ranges;
init_default_font(m_style_scaling);
}
}
void ImGuiWrapper::set_display_size(float w, float h)
{
ImGuiIO& io = ImGui::GetIO();
@ -210,7 +240,7 @@ void ImGuiWrapper::init_default_font(float scaling)
ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear();
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSans-Regular.ttf").c_str(), font_size * scaling);
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSans-Regular.ttf").c_str(), font_size * scaling, nullptr, m_glyph_ranges);
if (font == nullptr) {
font = io.Fonts->AddFontDefault();
if (font == nullptr) {

View File

@ -20,6 +20,7 @@ class ImGuiWrapper
typedef std::map<std::string, ImFont*> FontsMap;
FontsMap m_fonts;
const ImWchar *m_glyph_ranges;
unsigned m_font_texture;
float m_style_scaling;
unsigned m_mouse_buttons;
@ -32,6 +33,7 @@ public:
bool init();
void read_glsl_version();
void set_language(const std::string &language);
void set_display_size(float w, float h);
void set_style_scaling(float scaling);
bool update_mouse_data(wxMouseEvent &evt);
@ -59,6 +61,7 @@ public:
bool want_keyboard() const;
bool want_text_input() const;
bool want_any_input() const;
private:
void init_default_font(float scaling);
void create_device_objects();