-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed GetStringSize() is not consistent with actual string size in GraphicsView #30133
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
base: main
Are you sure you want to change the base?
Conversation
Hey there @@Dhivya-SF4094! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
The test GraphicsViewShouldNotWrapText is failing on iOS and could be related with the changes. Could you take a look?
Snapshot different than baseline: GraphicsViewShouldNotWrapText.png (0.80% difference)
@jsuarezruiz I have resaved the image for the failing GraphicsViewShouldNotWrapText test case. Could you please review once. |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
/rebase |
3b4ca01
to
04cfc7c
Compare
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Detail
When drawing text and its bounding rectangle in GraphicsView using canvas.GetStringSize(string), the measured size is insufficient, causing the text to overflow the rectangle.
Root Cause
String size was calculated inaccurately on iOS and Windows, causing text to overflow the measured rectangle in GraphicsView.
Description of Change
iOS: Replaced NSString.GetBoundingRect with CTFramesetter.SuggestFrameSize, which provides a more accurate and layout-aware measurement of the text using CoreText. This results proper frame size of string text.
Windows: Replaced the previous bounding logic with CanvasTextLayout from Win2D to accurately measure text size. Word wrapping is disabled, and proper horizontal and vertical alignments are applied. The size is taken from LayoutBounds, with a fallback to DrawBounds to ensure the full text is enclosed.
Validated the behaviour in the following platforms
Issues Fixed:
Fixes #18679
Screenshots