How to get the position (x y coordinates) of a specific character in a multi-lined WPF FormattedText ?
My text could contain italic parts, bold parts, different fonts, different font sizes, different alignments, etc. and I need to get the coordinates of, say, the 30th character, which could be on the 3rd line.
There is some kind of a half working trick by using the Children (letters) of Children (words) of the Geometry that I can get built from the FormattedText (BuildGeometry), but this does not always work, because some Glyphs are merged in a single geometry (like for "fi": one geometry only).
FormattedText.BuildHighlightGeometry, method (Point, Int32, Int32) does exactly that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With