-
Notifications
You must be signed in to change notification settings - Fork 569
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
Snap the TextBox cursor to the pixel grid #1794
Conversation
24a5883
to
eb9023e
Compare
This snaps the cursor of the TextBox to the grid to ensure it's always rendered as sharp as possible.
eb9023e
to
22de5f8
Compare
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.
Thank you!
I'd like to take a look at this before it gets merged please. (I can't figure out how to self-request a review from my phone 😕) |
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.
Thanks for this! I do think it's important to get this stuff right, and my main concern is totally unrelated to this patch, and is more about how need some mechanisms for being more consistent about this, across the board. There's a discussion in #1088, and there's been various efforts in the past (linebender/kurbo#93, linebender/kurbo#107, #904).
Anyway, main actual question is whether we should round
to trunc
?
cursor.p0.x = cursor.p0.x.trunc() + 0.5; | ||
cursor.p1.x = cursor.p0.x; |
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 should be correct for coregraphics and skia; i'm not sure if directwrite behaves the same way?
- might
round
make more sense thantrunc
? - I'm actually also not sure if this will work at all scale factors. it should work at 1x and 2x? I'm less sure about other cases.
All that said: I'm not opposed to this at all, it's just exposing some of my general confusion about pixels and scale factor. I would really love to see a sort of 'unified' theory of this stuff; until we have that it's going to feel like our drawing code is an inconsistently applied series of heuristics. :/
I'm going to merge this, it's an improvement on the current code and we can always fix other problems later. |
This snaps the cursor of the TextBox to the grid to ensure it's always rendered as sharp as possible.
Screenshot:
Top is with grid snapping, bottom without.