Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material Design Icons & ImGui #16

Closed
BluTree opened this issue Apr 29, 2020 · 5 comments
Closed

Material Design Icons & ImGui #16

BluTree opened this issue Apr 29, 2020 · 5 comments
Assignees
Labels

Comments

@BluTree
Copy link

BluTree commented Apr 29, 2020

Hello,
I tried to load the MDI font with ImGui, using the code passed in the Readme to load it :

        io.Fonts->AddFontDefault();

        ImFontConfig config;
        config.MergeMode = true;
        config.GlyphMinAdvanceX = 13.0f; // Use if you want to make the icon monospaced
        static const ImWchar icon_ranges[] = { ICON_MIN_MDI, ICON_MAX_MDI, 0 };
        _icon = io.Fonts->AddFontFromFileTTF("./resources/Editor/materialdesignicons-webfont.ttf", 13.0f, &config, icon_ranges);

but the text using the icons keeps showing me no icons and incorrect characters.
Using this code ImGui::Button(ICON_MDI_PLAY); show me this : image
I also looked in the Styles editor of imgui, but the font doesn't appear in the default font.
I tried with Font Awesome 5, and everything worked fine.

@juliettef
Copy link
Owner

It looks like you can't use MDI with Dear ImGui. The MDI fonts moved to using 32 bit codepoints and Dear ImGui only supports 16 bit.
Additionally my code only supports 16 bits so it's broken. I'll remove Material Design Icons from this repository.

@soufianekhiat
Copy link

Is this issues fixed by
ocornut/imgui@c8ea0a0
?

@juliettef
Copy link
Owner

juliettef commented May 1, 2020

It might do but you'd have to use the IconsMaterialDesignIcons_c.h file as IconsMaterialDesignIcons.h only supports 16 bits.

I might take a look at this in future. Right now I don't have the time.

@soufianekhiat
Copy link

Thanks

@juliettef juliettef self-assigned this May 28, 2023
@dougbinks
Copy link
Collaborator

Adding some notes for anyone who finds this issue:

IconFontCppHeaders now support both 16bit and 32bit maximum fonts.

For 16bit font ranges use the example code with:

static const ImWchar icons_ranges[] = { ICON_MIN_MDI, ICON_MAX_MDI_FA, 0 };

and for 32bit font ranges use the example code with:

static const ImWchar icons_ranges[] = { ICON_MIN_MDI, ICON_MAX_MDI, 0 };

Since the commit mentioned above Dear ImGui now supports 32bit font codepoints internally, which requires setting the IMGUI_USE_WCHAR32 define in your imconfig.h or compile definitions:

//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
#define IMGUI_USE_WCHAR32

@juliettef juliettef added the bug label Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants