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

How can you change font for parts of the plot? #235

Open
dgm3333 opened this issue May 24, 2021 · 1 comment
Open

How can you change font for parts of the plot? #235

dgm3333 opened this issue May 24, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@dgm3333
Copy link

dgm3333 commented May 24, 2021

I'm sure there's an obvious answer to this, but how do I change the font for a specific portion of the plot?
Pushing normalFont in the following is completely ignored and the same font is used throughout the plot.
I actually only want to set the header independent of the axes, but I failed before I even got that far...
It seems odd to me that imgui doesn't pass fonts as part of it's style struct, but I guess an alternative question is: How can I access the plot dimensions so I can hide the plot text and use the main imgui code to draw the text (if it's not possible to do from within implot)?

if (ImGui::CollapsingHeader("Multiple Fonts")) {
    ImFont* normalFont = ImGui::GetIO().Fonts->Fonts[0];
    ImFont* headerFont = ImGui::GetIO().Fonts->Fonts[3];

    ImGui::PushFont(headerFont);
    int data[2] = { 0,1 };
    if (ImPlot::BeginPlot("Plot A", "x-label", "y0-label")) {
        ImGui::PushFont(normalFont);
        ImPlot::PlotLine("Line", data, 2);
        ImGui::PopFont();
        ImPlot::EndPlot();
    }
    ImGui::PopFont();
}
@epezent
Copy link
Owner

epezent commented May 24, 2021

All text is rendered inside of BeginPlot (title/axes) or EndPlot (legend). There is currently no way to setup different fonts for different elements of the plot.

If you want to render the header yourself, you can hide the default by prepending ## on the label ID.

@epezent epezent added the enhancement New feature or request label Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants