Windows Phone 8.1 运行时文本大纲 [英] Windows Phone 8.1 Runtime Text Outline

查看:29
本文介绍了Windows Phone 8.1 运行时文本大纲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 TextBlock 上显示文本轮廓?我在地图控件顶部显示一些文本,并希望以黑色和白色轮廓显示文本,以便它始终可读.像这样:

Is there a way to show text outline on a TextBlock? I am showing some text on top of map control and would like to show the text in black with white outline so it's always readable. Something like this:

感谢您的建议

推荐答案

Windows.UI.Xaml 不支持此类字体操作,但您可以与 DirectWrite 互操作以将带有效果的文本绘制到位图中,然后进行合成地图顶部的位图.

This sort of font manipulation isn't supported in Windows.UI.Xaml, but you can interop to DirectWrite to draw text with effects into a bitmap and then composite the bitmap on top of your map.

对于静态文本,您可以像 Chris W 所说的那样预先创建位图或将字体转换为路径.Windows.UI.Xaml.Shapes.Path 的 Data 与 SVG 的基本相同,因此您可以使用许多矢量图形程序进行转换,方法是保存到 SVG,然后将路径数据从 SVG Path 的 d= 属性复制到 Xaml Path 的 Data=属性.

For static text you can either pre-create a bitmap or convert the font to paths as Chris W says. The Windows.UI.Xaml.Shapes.Path's Data is essentially the same as SVG's, so you can use many vector graphics programs for the converstion by saving to SVG and then copying the path data from SVG Path's d= attribute to Xaml Path's Data= attribute.

在没有与 Direct2D 互操作的情况下,Windows.UI.Xaml 中不支持投影,因此在此环境中,伪造的 it 链接不会比 DirectWrite 有任何优势.

Drop shadows aren't supported in Windows.UI.Xaml without interop to Direct2D, so the fake it link won't give any advantage over DirectWrite in this environment.

确保对比度的最简单方法是将文本放在部分透明的框上,但这会产生不同的外观.

The simplest way to ensure contrast would be to place the text on a partially transparent box, but that will give a different look.

这篇关于Windows Phone 8.1 运行时文本大纲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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