var formattedText = new FormattedText(
                    text,
                    CultureInfo.CurrentUICulture,
                    FlowDirection.LeftToRight,
                    typeFace,
                    fontSize,
                    Brushes.Black);

double width = formattedText.WidthIncludingTrailingWhitespace;

double height = formattedText.Height;