我在使用 liveTile 上的自定义字体资源渲染自定义文本块时遇到问题?
我的项目在后台更新动态磁贴。但它应该是个性化的。
我正在使用此代码。但它不能正常工作,当我尝试使用嵌入字体时,文本显示为空白,位图背景工作得很好。但是字体不起作用。
当我在“前台代理”中使用相同的代码时,字体显示完美。
Grid grid = new Grid();
// load your image
StreamResourceInfo info = Application.GetResourceStream(new Uri("tile.jpg", UriKind.Relative));
// create source bitmap for Image control (image is assumed to be alread 173x173)
WriteableBitmap wbmp2 = new WriteableBitmap(1, 1);
wbmp2.SetSource(info.Stream);
Image img = new Image();
img.Source = wbmp2;
// add Image to Grid
grid.Children.Add(img);
TextBlock text = new TextBlock()
{
FontFamily = new FontFamily("/MyTaskAgent;component/Fonts/Fonts.zip#Buxton Sketch"),
Foreground = new SolidColorBrush(Colors.Black) ,
TextWrapping = TextWrapping.Wrap,
};
text.Text = "Test";
// this is our final image containing custom text and image
WriteableBitmap wbmp = new WriteableBitmap(173, 173);
// now render everything - this image can be used as background for tile
wbmp.Render(grid, null);
wbmp.Invalidate();