多行WPF FormattedText中特定字符的坐标 [英] Coordinates of a specific character in a multi-lined WPF FormattedText

查看:762
本文介绍了多行WPF FormattedText中特定字符的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在多行WPF FormattedText中获取特定字符的位置(xy坐标)?



我的文本可以包含斜体部分,粗体部分,不同的字体,不同的字体大小,不同的路线等,我需要得到第30个字符的坐标,可能在第3行。



有是通过使用我可以从FormattedText(BuildGeometry)构建的几何体的Children(单词)的Children(字母)的某种半工作技巧,但这并不总是奏效,因为某些字形合并成单个(Point,Int32,Int32)的格式化文本.BuildHighlightGeometry,方法(像fi:仅限于一个几何)。

确实如此。


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 30st 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.

这篇关于多行WPF FormattedText中特定字符的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆