Skip to content

Inner context font rasterizer density ignores the host's display density (blurry text on HiDPI) #79

Description

@r4stered

ContainedContext::setFontDensity() does:

ImGui::SetFontRasterizerDensity(roundf(m_scale * 100.0f) / 100.0f);

i.e. the density is the canvas zoom factor and nothing else. That is only correct on a
1x display.

Dear ImGui derives a window's rasterizer density in SetCurrentWindow():

g.FontRasterizerDensity = (viewport->FramebufferScale.x != 0.0f)
                        ? viewport->FramebufferScale.x
                        : g.IO.DisplayFramebufferScale.x;

The contained context is created without a platform backend, so its viewport's FramebufferScale is 0 and its io.DisplayFramebufferScale is the default 1.0. ImGui can only ever derive 1.0 for it. setFontDensity() then overwrites even that with m_scale. So on a 2x display the host renders text at density 2.0 while every glyph inside the node editor is baked at density m_scale (1.0 at default zoom) and upscaled. Font size is still right, because new_style = orig_style carries FontScaleDpi across.

Repro: any HiDPI display (Retina Mac, 150–200% Windows scaling). Compare text in a node against ImGui text drawn outside the editor.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions