Imgui: Cyrillic symbols in textboxes.

Created on 10 Mar 2017  路  11Comments  路  Source: ocornut/imgui

Hi, thanks for your project, its amazing :)

I'm using ImGui_ImplDX11_WndProcHandler for input handling, and everything is fine, except one thing:
When I'm trying to type with russian keyboard layout, I'm getting bad symbols.

Your demo project also shows bad symbols (questions symbols)

1

Could you point me on right direction? How to resolve?

fontext

Most helpful comment

I have same issue, i can't change project to unicode, and found this solution

    case WM_CHAR:
            wchar_t wch;
            MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (char*)&wParam, 1, &wch, 1);
            io.AddInputCharacter(wch);

All 11 comments

Hello,

Did you read the FAQ and documentation?
Did you load a Cyrillic font with the correct Cyrillic glyphs loaded?

First check if you can display Cyrillic characters (using UTF-8 C++11 literal, such as ImGui::Text(u8"insert text here");). If you can display them not input them, the problem lies in your application not passing the correct Unicode codepoint to io.AddInputCharacter().

-Omar

image

Its ok, I can display russian symbols. Yes, I've loaded correct font with Cyrillic glyphs

``` ImGuiIO& io = ImGui::GetIO();
ImFontConfig font_cfg;
font_cfg.FontDataOwnedByAtlas = false;
font_cfg.MergeMode = false;
font_cfg.MergeGlyphCenterV = true;
io.Fonts->AddFontFromMemoryTTF(Roboto_TTF_Data, RobotoFont_TTF_DataSize, 18.0f, &font_cfg, io.Fonts->GetGlyphRangesCyrillic());
font_cfg.MergeMode = true;
font_cfg.PixelSnapH = true;
font_cfg.MergeGlyphCenterV = true;
static const ImWchar icons_ranges_md[] = { ICON_MIN_MD, ICON_MAX_MD, 0 };
io.Fonts->AddFontFromMemoryTTF(Material_TTF_Data, MaterialFont_TTF_DataSize, 18.0f, &font_cfg, icons_ranges_md);

I'm simply pass everything from
WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
to ImGui_ImplDX11_WndProcHandler(hWnd, message, wParam, lParam)

case WM_CHAR:
        // You can also use ToAscii()+GetKeyboardState() to retrieve characters.
        if (wParam > 0 && wParam < 0x10000)
            io.AddInputCharacter((unsigned short)wParam);
        return true;
    }

do u think something wrong with wParam?

Print the value and see by yourself if they are valid Unicode codepoints (and _not_ legacy local page codepoints in the 0x80...0xFF range). I think with Windows you need to compile your application with Unicode libraries to get valid unicode in the WM_CHAR message.

image

Right now, MultiByte charset is enabled.
I'll try to enable Unicode.

Please try to do your research thoroughly and post collated results instead of making successive posts as they happens. (Some people receive notifications for those messages)

Sorry for that. I'll try to resolve this problem in next few days and let you know about results. If you think its better to close this issue now, please do.

1

It works, changed Character Set to Unicode.
Thanks for help

I have same issue, i can't change project to unicode, and found this solution

    case WM_CHAR:
            wchar_t wch;
            MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (char*)&wParam, 1, &wch, 1);
            io.AddInputCharacter(wch);

Hi is this working for GE europe?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dowit picture dowit  路  3Comments

noche-x picture noche-x  路  3Comments

spaderthomas picture spaderthomas  路  3Comments

KaungZawHtet picture KaungZawHtet  路  3Comments

BlackWatersInc picture BlackWatersInc  路  3Comments