-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Fix accuracy bugs around float/double/int conversions #15098
Conversation
380e36f
to
dc9e1db
Compare
dc9e1db
to
c8865d4
Compare
@@ -853,8 +852,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |||
// concerned with initialization process. Value forwarded to event handler. | |||
void ControlCore::_updateFont(const bool initialUpdate) | |||
{ | |||
const auto newDpi = static_cast<int>(static_cast<double>(USER_DEFAULT_SCREEN_DPI) * | |||
_compositionScale); | |||
const auto newDpi = static_cast<int>(lrint(_compositionScale * USER_DEFAULT_SCREEN_DPI)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this cast seems extraneous or at the very best silly given the auto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise AuditMode complains that long
isn't automatically convertible to int
(the parameter type for SetDPI
).
@lhecker is this safe for 1.17 as well? |
Yeah I think this is safe. I've just checked it again and the only functional change is in |
I noticed this bug while resizing my window on my 150% scale display.
Every 3 "snaps" of the window size, it would fail to resize the text
buffer. I found that this occurs, because we convert the swap chain
size from a float into a double, which converts my 597.333313 height
into 597.33331298828125, which then multiplied by 1.5 results in
895.999969482421875. If you just cast this to an integer, it'll
result in a height of 895px instead of the expected 896px.
This PR addresses the issue in two ways:
lrint
orfloor
, etc.PR Checklist