开发者

Coordinates of a specific character in a multi-lined WPF FormattedText

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 (word开发者_StackOverflow社区s) 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜