Once you have initialized FormattedText, it has the Width and Height elements that are equal to its actual rendering size, given its parameters. In fact, changing the parameters immediately updates them, e, g,:
FormattedText ft = new FormattedText(cellString, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, fontFace, fontSize, fontBrush); ft.Trimming = TextTrimming.CharacterEllipsis; double originalHeight = ft.Height; double width = ft.Width; ft.MaxTextWidth = bCellRect.Width;
Edit for GlyphRun:. When you created your GlyphRun, you already gave it the width of the advance for each character, so you add them for the width. To get the height, use GlyphTypeface.Baseline * FontSize
source share