Fix DPI scaling on X11 and Windows #922
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is another attempt to fix the DPI scaling issues seen in #868.
MainWindow::GetFontPrefwas attempting to apply DPI scaling to the font sizes it returns, which was causing double scaling of everything but the default font since ImGui now handles font scaling on its own inImGui::PushFont. The double scaling was inconsistent because we sometimes passed the size fromGetFontPreftoImDrawList::AddText, which does not perform font scaling, so text drawn that way was only scaled once. That's what was causing the weird headers in the filter graph: the height of the header was scaled twice but the header text was rendered throughImDrawListand so only scaled once.This PR fixes the double scaling issue by removing all of the application code which attempts to handle font scaling, leaving that responsibility to ImGui. I also removed everything that attempts to pass fonts explicitly to ImGui calls; now we always use the current font set by
ImGui::PushFontwhen drawing or measuring text. Calls toImDrawList::AddTextnow either use the overload that uses the current font or, when that's not possible because we need to pass a wrap width, pass the font usingImGui::GetFont()andImGui::GetFontSize()to achieve the same result.That seems to have fixed all of the odd scaling, but I'm still seeing the issue where the Stream Browser and Filter Palette panels are too small. It looks like those are set proportional to the window size, so I think the issue there is actually that we're setting the default window size too small (probably not applying DPI scaling at all). I'm still looking into that.