I am writing an application for Windows 10 using Win2D and I'm trying to draw a shape which scales dynamically to fit whatever text happens to be in it.
What I'd like to do is work out how big a particular string would be with a given CanvasTextFormat and then use that to set the size of the shape.
My problem is I can't seem to find a way of working out how big the string will be?
If you create a
CanvasTextLayout
with arequestedWidth
of0
, like in the example ofMichael Vach
, you may want to disable Word Wrap in Win2D 1.23. Like:(I'm not allowed to comment)
See code below to calculate the required size (look for "theRectYouAreLookingFor")