Gif*_*guy 5 .net wpf geometry .net-3.5 formatted-text
如何将FormattedText字符串转换为基于几何的对象?
我认为这个问题不需要太多解释,我想不出是否可以提供很多其他细节......
我只需要将FormattedText转换为我可以在数学上(几何上)使用的东西.
任何建议表示赞赏!
你可能正在寻找FormattedText.BuildGeometry Method或FormattedText.BuildHighlightGeometry Method; 这两个MSDN链接也都是通常的例子.
基本使用模式是这样的:
// Create sample formatted text.
FormattedText formattedText = new FormattedText("Sample",
CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight,
new Typeface("Verdana"), 16, System.Windows.Media.Brushes.Black);
// Build geometry object that represents the text.
Geometry normalGeometry = formattedText.BuildGeometry(
new System.Windows.Point(0, 0));
// Build geometry object that represents the highlight bounding box of the text.
Geometry highLightGeometry = formattedText.BuildHighlightGeometry(
new System.Windows.Point(0, 0));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2322 次 |
| 最近记录: |