-
Notifications
You must be signed in to change notification settings - Fork 88
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
More FontAwesome options #12
Comments
Hello, There are lots of possible customizations that users might desire when it comes to fonts (glyph range, glyph layout options, additional icon fonts other than font awesome, etc). Thus, at the moment, the user is given the possibility to completely override the font loading function (simply by setting For example, in
I think it could be possible to update the available functions inside |
Sure! After taking a quick look, it seems there might already have been an attempt at adding customization to font configurations in Do you think lambda's for font configurations is a good idea? Perhaps something like this could work: LoadFontTTF("fonts/DroidSans.ttf", 12.0f, [](ImFontConfig& config) {
// modify the config here
config.GlyphMinAdvanceX = 18;
config.GlyphMaxAdvanceX = 18;
}); And then probably exposing |
I don't know if a lambda is the most appropriate. The important thing to know is that the ImFontConfig instance has to live during the whole application lifecycle (imgui only takes a pointer to it, which should not be dangling). This is why I added this static container:
|
If you look at the code of https://github.com/ocornut/imgui/blob/5f45047fb67c2147c6a1b1798b98d401e7998b51/imgui_draw.cpp#L2133 So it's safe to just keep it on the stack, which will simplify a lot of this code. I'll do a pull request shortly! |
More options were added in this PR |
The FontAwesome feature could use a couple new features.
A locked glyph size will allow for menu items to align nicely in vertical menus, giving icons all the same width. Here's an example I use in one of my projects:
Also, exposing
MergeFontAwesomeToLastFont
to the public API will allow using a custom font size, which can in some times be beneficial. For example, in my case, having the icon font be 1 pixel smaller fixes an issue in multi-line text fields where icons will blend into each other if they're right underneath other icons on the next line. (And they kinda align better in menu bars if they're 1 pixel smaller than the main font.)The text was updated successfully, but these errors were encountered: