How to convert a FormattedText string to a geometry based object?

How to convert a FormattedText string to a geometry based object?

I donโ€™t think this question needs much explanation, and I canโ€™t think if there were so many other details that I could give ...

I just need to convert FormattedText to what I can use mathematically (geometrically).

Any advice is appreciated!

+4
source share
1 answer

You may be looking for the FormattedText.BuildGeometry Method or FormattedText.BuildHighlightGeometry Method ; both MSDN links also contain common examples.

The basic usage pattern looks like this:

 // Create sample formatted text. FormattedText formattedText = new FormattedText("Sample", CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Verdana"), 16, System.Windows.Media.Brushes.Black); // Build geometry object that represents the text. Geometry normalGeometry = formattedText.BuildGeometry( new System.Windows.Point(0, 0)); // Build geometry object that represents the highlight bounding box of the text. Geometry highLightGeometry = formattedText.BuildHighlightGeometry( new System.Windows.Point(0, 0)); 
+6
source

All Articles