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

[ImGui] Allow setting of custom font config to enable merging of multiple fonts and other features #2085

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

rh101
Copy link
Contributor

@rh101 rh101 commented Aug 12, 2024

Describe your changes

When adding multiple fonts to ImGui, the only way to merge fonts is to set the ImFontConfig::MergeMode = true, otherwise glyphs from additional fonts do not render correctly.

This change allows custom ImFontConfig to be set on a font that is added via ImGuiPresenter::addFont. This change does not affect existing usage of the ImGuiPresenter::addFont method, because the fontConfig parameter has a default value of ImFontConfig(). The default value is valid, since it is what ImGui does internally if a nullptr is passed to one of the ImGui::AddFontXYZ methods.

For example:

auto* presenter = extension::ImGuiPresenter::getInstance();
presenter->addFont("fonts/arial.ttf", 14.f); // This will use the default ImFontConfig

ImFontConfig fontConfig;
fontConfig.MergeMode = true; // Set to true for any additional fonts if merging is required. This must be false for the first font in.
presenter->addFont("fonts/fa-regular-400.ttf", 14.f, { ICON_MIN_FA, ICON_MAX_FA, 0 } , fontConfig); // example of adding Font Awesome glyphs

Issue ticket number and link

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

@halx99 halx99 added this to the 2.1.6 milestone Aug 12, 2024
@halx99 halx99 merged commit 80a8255 into axmolengine:dev Aug 12, 2024
15 checks passed
@rh101 rh101 deleted the imgui-font-merge-fix branch August 12, 2024 16:16
xfbird pushed a commit to xfbird/axmol that referenced this pull request Sep 18, 2024
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.

2 participants