AppKit: ContentFit.Cover distorts the image instead of cropping it #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Recorded as a gap when the Apple renderer landed and still open:
Prop.Fit(ContentFit.Cover)distorts on AppKit.Covermeans fill the frame, preserve aspect ratio, crop the overflow — distorting is the one thing it must not do, since it is the fit used for avatars and hero images where the wrong aspect ratio is immediately visible.NSImageView.imageScalinghas no cover mode:.scaleProportionallyUpOrDownisContain,.scaleAxesIndependentlyisFill(and is almost certainly what is wired up now). Cover needs either a layer-backed view withcontentsGravity = .resizeAspectFillandmasksToBounds = true, or a customNSViewthat draws the image into an aspect-fill rect.Check UIKit at the same time:
UIView.ContentMode.scaleAspectFilldoes the right thing, so that side may already be correct — confirm rather than assume, and say which in the report.How to verify. Render a deliberately non-square image (e.g. 400x100) into a square frame under each of
Contain,CoverandFill, and assert the drawn aspect ratio:ContainandCoverpreserve it,Filldoes not. Screenshot the three side by side intodocs/screenshots/— this is a defect that is obvious in a picture and invisible in a log.See
docs/12-component-status.md§12.2.