Description
In iOS canvas.GetStringSize() seems not to handle correctly newlines. It creates a Size wide as the longest row and high as a single row.
You can verify this by running the project in repro and setting NEWLINE_IOS global variable (if not already set) in MyDrawable.cs.
In my opinion this issue could be linked to #8486.
Steps to Reproduce
- Create a
GraphicsView with a Drawable.
- Define a string
StringToVisualize with newlines, like this one: "HELLO, WORLD!\nCiao mondo row 2\n\nGuten tag!?àèìòù@"
- Choose a
FontSize
- Inside the
Draw() method, call canvas.GetStringSize(StringToVisualize, Font.Default, FontSize);
- Draw a rectangle with the size returned by the call at point 4.
Expected Result (Android)

Actual Result (iOS)

Link to public reproduction project repository
https://github.com/Riccardo11/MauiIssues/tree/main/MeasureStringWrongBounds
Version with bug
8.0.0-rc.2.9511
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS16, iOS17. Couldn't test other versions
Did you find any workaround?
Calculating string size by hand.
Relevant log output
No response
Description
In iOS
canvas.GetStringSize()seems not to handle correctly newlines. It creates aSizewide as the longest row and high as a single row.You can verify this by running the project in repro and setting
NEWLINE_IOSglobal variable (if not already set) in MyDrawable.cs.In my opinion this issue could be linked to #8486.
Steps to Reproduce
GraphicsViewwith aDrawable.StringToVisualizewith newlines, like this one:"HELLO, WORLD!\nCiao mondo row 2\n\nGuten tag!?àèìòù@"FontSizeDraw()method, callcanvas.GetStringSize(StringToVisualize, Font.Default, FontSize);Expected Result (Android)

Actual Result (iOS)

Link to public reproduction project repository
https://github.com/Riccardo11/MauiIssues/tree/main/MeasureStringWrongBounds
Version with bug
8.0.0-rc.2.9511
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS16, iOS17. Couldn't test other versions
Did you find any workaround?
Calculating string size by hand.
Relevant log output
No response