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

Added config parameters to font loading functions #13

Merged
merged 1 commit into from
Apr 6, 2021

Conversation

codecat
Copy link
Contributor

@codecat codecat commented Apr 6, 2021

This is in response to #12.

There is now an added ImFontConfig config parameters to all font loading functions, which serves as a "template" for the actual config (much like how imgui does it internally too). I've also exposed MergeFontAwesomeToLastFont so that it's easier to use a different configuration (and size) for both icon font & regular font.

Example usage:

auto& io = ImGui::GetIO();

ImFontConfig configIcons;
configIcons.GlyphMinAdvanceX = 18;
configIcons.GlyphMaxAdvanceX = 18;

io.FontDefault = HelloImGui::LoadFontTTF("fonts/DroidSans.ttf", 16);
HelloImGui::MergeFontAwesomeToLastFont(15, configIcons);

I have also removed the lambda's creating the config structures as well as the static variables intended to keep the config structures in memory as it doesn't appear to be necessary.

@pthom
Copy link
Owner

pthom commented Apr 6, 2021

I have also removed the lambda's creating the config structures as well as the static variables intended to keep the config structures in memory as it doesn't appear to be necessary.

You are right, thanks for pointing this out! I now remember I had an issue with the glyph_range param of AddFontFromMemoryTTF, not with the config in itself.

Your PR looks good to me, and brings value!

Are you OK to merge?

@codecat
Copy link
Contributor Author

codecat commented Apr 6, 2021

Ah good point, I didn't see that one! I kept those arrays static however, so the PR should still be correct. If all looks okay to you, I'm ok to merge!

@pthom pthom merged commit 00e29f1 into pthom:master Apr 6, 2021
@pthom pthom mentioned this pull request Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants