Why doesn't Maui provide a cross-platform MeasureText method? #15957
Replies: 3 comments 3 replies
-
It have a simple method to measure text, see https://github.com/dotnet/maui/blob/main/src/Graphics/src/Graphics/IStringSizeService.cs |
Beta Was this translation helpful? Give feedback.
-
I found that early on but the only implementation I found was for Skia. Did I miss the Maui coordinate space implementation? |
Beta Was this translation helpful? Give feedback.
-
I have found, in practice, that the IStringSizeService does not return a valid Size.Width, it is always less than the actual width of the text in pixels. I've seen a few discussions about this limitation but no usable solution. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Goal: Given a text string and font attributes, what is rectangle needed to display the text.
I've seen discussions of measuring text with Skia and drawing on a canvas but I cannot find anything that allows me to measure text using Maui coordinates.
One use case I encounter is setting the absolute width of a grid column to ensure it doesn't resize as the contents change. I know the maximum text length as well as the font and attributes but I don't see anywhere I can use this information to calculate the appropriate value for the width.
Does such a method exist?
Beta Was this translation helpful? Give feedback.
All reactions