Windows Phone 8.1 Runtime Text Outline

2019-07-15 08:47发布

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:enter image description here

Thanks for any tips

1条回答
冷血范
2楼-- · 2019-07-15 09:39

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.

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.

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.

查看更多
登录 后发表回答