如何将 FormattedText 字符串转换为基于几何的对象?

发布于 2024-07-27 12:56:57 字数 160 浏览 9 评论 0原文

如何将 FormattedText 字符串转换为基于几何的对象?

我认为这个问题不需要太多解释,而且我想不出我是否可以提供很多其他细节......

我只需要将 FormattedText 转换为我可以在数学上(几何上)使用的东西。

任何建议表示赞赏!

How do I convert a FormattedText string into a geometry-based object?

I don't think this question requires much explanation, and I can't think if very many other details I could give ...

I just need to convert the FormattedText into something I can use mathematically (geometrically).

Any advice is appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

养猫人 2024-08-03 12:56:57

您可能正在寻找 FormattedText.BuildGeometry方法<代码>FormattedText.BuildHighlightGeometry方法; 这两个 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));

You are probably looking for FormattedText.BuildGeometry Method or FormattedText.BuildHighlightGeometry Method; both MSDN links are featuring the usual examples too.

The basic usage pattern is like so:

// 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));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文