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
[widget Audit] toga.Canvas #2029
Conversation
Yes, those changes all look reasonable. |
So I don't forget where I'm up to: the test failures at this point are all due to weird inconsistencies between CI behavior and desktop behavior. Linux: iOS: macOS: The differences on multiline text all seem to be related to line leading. It may also be due to an image dimensions vs image resolution discrepancy. The iOS test images report dimensions of 100x100, but a resolution of 144x144. It's not clear to me how this impacts pixel inspection calculations on Pillow. The transparency differences are due to the alpha calculation on the transparent rectangle. |
fde8665
to
d15ed48
Compare
@mhsmith Ok - after further investigation, I think we're stuck between a rock and a hard place. In the multiline text case, AFAICT the discrepancies are caused by font leading, which is caused by subtle differences in the font itself between OS versions. I'm not sure I see any way to work around this; and in the Linux case, it's going to be hugely dependent on what the local system, GTK theme, and more. In the transparency case, I can reproduce the problem moving between my M1 MacBook and my x86_64 Mac mini. The issue appears to be that recent MacBooks have a different display profile, so they operate in sRGB colourspace; older Macs don't do this by default - although the colourspace is extremely configurable. So - the options I see are:
Any preferences or alternatives that I may have missed? |
Actually - thinking about this some more, there's another option (for macOS and iOS anyway) - we can make the variants dependent on the macOS/iOS version. The same approach might work for GTK; but we'll need more variants. However, it's a moot point at present because GTK font rendering has deeper problems. |
Done.
In this case it's not caused by DPI scaling, but by differences in the definition of a "point". Windows matches the CSS definition of 1.33 logical pixels, while Apple uses exactly 1 logical pixel. Fixed by increasing font sizes on Apple, as mentioned above. Android does have a "point" unit in its API, but it's not generally used, even for font sizes, and doesn't have a clearly documented definition, so I'll use 1.33 logical pixels there as well. |
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.
I can only explain the overlapping stroke on the "a" as being a bug in the font itself. But when we implement font loading support on Cocoa, this file will be replaced anyway.
…ng and logging to Cocoa to try and fix CI
I've changed the default WinForms font to respect the system theme, a change which has already been made in newer versions of .NET (dotnet/winforms#656), though as I understand it, not in the version of .NET which comes with Windows itself. The difference is not dramatic, but readability is definitely improved: see screenshots at dotnet/winforms#656 (comment). Notice that the title bar was already using the system theme, and the menu bar was too. The concerns in that comment don't apply to us because we're not using "hand placed controls with pixel perfect layout". |
88c4cd0
to
8d486b4
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.
Art immitates life... the test case now reflects how we feel about the Canvas widget :-)
Audit of Canvas.
Builds on #1903 as an audit of Font.
This involves a number of backwards incompatible changes:
remove
andclear
, which collide with Widget's child manipulation operations of the same name. Interestingly, the method to add was calledadd_draw_obj
, and was explicitly undocumented. To avoid the collision, Canvas now has acontext
property that returns the root context of the canvas. Simple drawing operations have been retained for backwards compatibility, redirecting to the default context; context generating operations have been retained.Canvas.context
property; the operation on canvas to produce a new sub-context is nowCanvas.Context()
.preserve
option on aFill()
context has been removed. It appears to be an internal optimization for GTK that isn't required, and isn't easy to explain.new_path
simple drawing operation has been renamedbegin_path
for consistency with HTML5.Fixes:
Audit checklist