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.
This commit is contained in:
bubnikv 2020-03-19 13:32:34 +01:00
parent 966b2ce371
commit be2fd7164c

View File

@ -441,6 +441,16 @@ bool ImGuiWrapper::want_any_input() const
return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput; 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) void ImGuiWrapper::init_font(bool compress)
{ {
destroy_font(); destroy_font();
@ -453,9 +463,9 @@ void ImGuiWrapper::init_font(bool compress)
ImFontAtlas::GlyphRangesBuilder builder; ImFontAtlas::GlyphRangesBuilder builder;
builder.AddRanges(m_glyph_ranges); builder.AddRanges(m_glyph_ranges);
#ifdef __APPLE__ #ifdef __APPLE__
builder.AddChar(0x2318); // OSX Command Key symbol if (m_font_cjk)
builder.AddChar(0x2325); // OSX Option Key symbol // Apple keyboard shortcuts are only contained in the CJK fonts.
builder.AddChar(0x21E7); // OSX Shift Key symbol builder.AddRanges(ranges_keyboard_shortcuts);
#endif #endif
builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted) 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 // Build texture atlas
unsigned char* pixels; unsigned char* pixels;
int width, height; int width, height;