Skip to content

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

@dgm3333

Description

@dgm3333

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();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions