If you set a breakpoint at formattedtext.BuildGeometry
and inspect the returned value, you'll realize that it is a GeometryGroup
:
var geometry = formattedText.BuildGeometry(new Point());
var geometryGroup = geometry as GeometryGroup;
if (geometryGroup != null)
{
foreach (var childGeometry in geometryGroup.Children)
{
// do something with the child geometries...
}
}
When I test this with a simple FormattedText, the children of the top-level GeometryGroup are themselves GeometryGroups, with PathGeometries as their children. My assumption is that the second-level GeometryGroups each contain one text row of the FormattedText object, whereas the PathGeometries contain single characters or glyphs.