From be2fd7164ccb2ebfe6d033268734b42b09e5f452 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 19 Mar 2020 13:32:34 +0100 Subject: [PATCH] ImGUI characters for OSX keyboard keyboard modifiers are only contained in the CJK fonts, not in the regular fonts. Load them from CJK fonts even for non CJK languages. --- src/slic3r/GUI/ImGuiWrapper.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 703ed60ad2..49101cf0f8 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -441,6 +441,16 @@ bool ImGuiWrapper::want_any_input() const return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput; } +#ifdef __APPLE__ +static const ImWchar ranges_keyboard_shortcuts[] = +{ + 0x2318, 0x2318, // OSX Command Key symbol + 0x2325, 0x2325, // OSX Option Key symbol + 0x21E7, 0x21E7, // OSX Shift Key symbol + 0, +}; +#endif // __APPLE__ + void ImGuiWrapper::init_font(bool compress) { destroy_font(); @@ -453,9 +463,9 @@ void ImGuiWrapper::init_font(bool compress) ImFontAtlas::GlyphRangesBuilder builder; builder.AddRanges(m_glyph_ranges); #ifdef __APPLE__ - builder.AddChar(0x2318); // OSX Command Key symbol - builder.AddChar(0x2325); // OSX Option Key symbol - builder.AddChar(0x21E7); // OSX Shift Key symbol + if (m_font_cjk) + // Apple keyboard shortcuts are only contained in the CJK fonts. + builder.AddRanges(ranges_keyboard_shortcuts); #endif builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted) @@ -469,6 +479,12 @@ void ImGuiWrapper::init_font(bool compress) } } +#ifdef __APPLE__ + if (! m_font_cjk) + // Apple keyboard shortcuts are only contained in the CJK fonts. + io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSansCJK-Regular.ttf").c_str(), m_font_size, nullptr, ranges_keyboard_shortcuts); +#endif + // Build texture atlas unsigned char* pixels; int width, height;