Windows Phone 8.1 Runtime Text Outline

被刻印的时光 ゝ 提交于 2020-01-15 07:27:11

问题


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:

Thanks for any tips


回答1:


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.



来源:https://stackoverflow.com/questions/26681319/windows-phone-8-1-runtime-text-outline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!