Skip to content

Fix PlatformStringSizeService on iOS/Catalyst to use correct API#18621

Merged
drasticactions merged 2 commits intodotnet:mainfrom
drasticactions:dev/timill/GetStringSize-iOS
Nov 10, 2023
Merged

Fix PlatformStringSizeService on iOS/Catalyst to use correct API#18621
drasticactions merged 2 commits intodotnet:mainfrom
drasticactions:dev/timill/GetStringSize-iOS

Conversation

@drasticactions
Copy link
Copy Markdown
Contributor

Description of Change

There is a wrapper check around PlatformStringSizeService to either use BoundingBox or StringSize to get the size of a given string. The original implementation was intended for iOS apps greater than version 14.0 to use BoundingBox and StringSize for everything else.

A negation in the check meant that it would do the opposite, and only work on iOS versions below 14.0. The check itself should not be needed in any case, as the baseline versions of MAUI are above iOS 7.0, which is the first version where that API was deprecated.

Likewise for Catalyst, this code would also not work correctly.

We should be able to remove the check and run the bounding rect code as is.

スクリーンショット 2023-11-08 19 36 35

Issues Fixed

Fixes #18572

@drasticactions
Copy link
Copy Markdown
Contributor Author

Also Re: the bounding box in the example above. There may be some math issues with how the calculation is done with the NSString Bounding Rect and the actual drawing with Skia. Depending on the font used, the literal bounding box could seem less than what's drawn based on the test code used, but as this is closer to correct than before if nothing else (and using the correct API) it should be good for now, and a new issue could be filed for the actual math should it be wrong.

@Eilon Eilon added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label Nov 8, 2023
@drasticactions
Copy link
Copy Markdown
Contributor Author

I am not sure why the Android test keeps failing, considering my change is only in iOS/Catalyst code and doesn't touch that part of the codebase at all.

@drasticactions drasticactions merged commit bfc76ed into dotnet:main Nov 10, 2023
@drasticactions drasticactions deleted the dev/timill/GetStringSize-iOS branch November 10, 2023 12:52
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2023
@samhouts samhouts added the fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing fixed-in-8.0.6 Look for this fix in 8.0.6 SR1! platform/ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] canvas.GetStringSize() not considering newlines

4 participants