pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping

Home Page:https://pthom.github.io/hello_imgui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FontAwesome solid vs. regular

wkjarosz opened this issue · comments

As far as I can tell, Hello ImGui uses the regular variant of fontawesome. Is there a built-in way to use the solid variant instead?

It seems that the solid and regular variant don't have all the same icons, and some are missing in regular (even though the ICON_FA_ macros are defined). When missing these render as ? instead.

For instance, ICON_FA_LAYER_GROUP renders as ?, but is available in solid.

As far as I can tell the generated icons_font_awesome.h file includes macros FONT_ICON_FILE_NAME_FAR and FONT_ICON_FILE_NAME_FAS which could presumably be used to select between two different ttf files, but hello imgui doesn't seem to use it.

Thanks for the help.

Hi,

HelloImGui comes with FontAwesome 4 (i.e. an old version of FontAwesome). I cannot update the default font awesome provided in HelloImGui, since this would break too much user code.

I added an example for the use of Font Awesome 6 free, here:

https://github.com/pthom/hello_imgui/tree/master/src/hello_imgui_demos/hello_imgui_demo_fontawesome6

Thanks! I will take a look.

I'm still puzzled why some icon names still exist in hello imgui's #defines (like ICON_FA_LAYER_GROUP), when they lead to ? with the current font awesome 4.

Sorry, forgot to reply when I tested. Your example was great, and I've been able to get FA6 working based off of it. Thanks a lot. This issue can probably be closed.

The following is related to my original issue, but perhaps not helloimgui specific, so please let me know if I should take it elsewhere: is there a way to use both regular and solid variants of the font awesome icons in a single app (or ideally even merge both icon font variants into a single imgui font)? This doesn't seem easy to do with the generated IconsFontAwesome6.h file since it uses the same macro names for both the regular and solid fonts. I could certainly modify their generation script to use different abbreviation prefixes for regular and solid, but figured there must be a better way to go for what seems like a common enough thing.

Sorry, forgot to reply when I tested. Your example was great, and I've been able to get FA6 working based off of it. Thanks a lot. This issue can probably be closed.

Hi, thanks for letting me know.

or ideally even merge both icon font variants into a single imgui font?

I don't think so, since it is likely that variations for the same icon will use the same codepoint. You would be better of writing a variant of ImGui::Text that accepts a collection of pair<ImFont, string>

This doesn't seem easy to do with the generated IconsFontAwesome6.h file since it uses the same macro names for both the regular and solid fonts. I could certainly modify their generation script to use different abbreviation prefixes for regular and solid, but figured there must be a better way to go for what seems like a common enough thing.

I do not know if there is a better way. Changing the generation script so that it generates

namespace IconsFa6
{
    constexpr char* ICON_FA_ACCESSIBLE_ICON  = "\xef\x8d\xa8";   // U+f368
    ...
}

instead of

#define ICON_FA_ACCESSIBLE_ICON "\xef\x8d\xa8"	// U+f368
...

seems a viable way to go. May be this could be suggested at https://github.com/juliettef/IconFontCppHeaders

Note: it could also generate only

constexpr char* ICON_FA_ACCESSIBLE_ICON  = "\xef\x8d\xa8";   // U+f368
...

(and would be enclosed in a namespace at include time)